format :html do def pdf? card.respond_to?(:file) && card.file.content_type == "application/pdf" end def default_pdfjs_iframe_args args args[:pdf_url] ||= card.file.url if card.respond_to?(:file) args[:viewer_path] ||= "/mod/pdfjs/web/viewer.html" args[:viewer_path] << "?file=#{args[:pdf_url]}" if args[:pdf_url] end def pdfjs_iframe args default_pdfjs_iframe_args args <<-HTML HTML end view :pdf_preview do wrap_with :div, id: "pdf-preview" do pdfjs_iframe pdf_url: card.file_url end end view :pdfjs_viewer do # TODO: show pdfjs viewer directly without iframe # Pdfjs.viewer end end