Skip to content

In Panel Preview Update

Compare
Choose a tag to compare
@donhauser donhauser released this 09 Oct 12:15
· 23 commits to main since this release

To support the in panel previews introduced in wagtail 4.0, this module now employs pdf.js as server hosted PDF viewer.

Support

This version supports wagtail 4 and wagtail 5.

Upgrading from 0.2.1

Check whether wagtail_pdf_view is inside INSTALLED_APPS:

# settings.py

INSTALLED_APPS = [
    ...
    # this is now required!
    'wagtail_pdf_view',
    'wagtail.contrib.routable_page',
    ...
]

It is now required to hook in wagtail_pdf_urls.urls into your projects urls.py:

# urls.py

from wagtail_pdf_view import urls as wagtail_pdf_urls

# this is now required!
urlpatterns = urlpatterns + [
    # hook in the 'live'-view PDFs under "pdf/"
    path("pdf/", include(wagtail_pdf_urls)),
    ...
    # IMPORTANT: This must be below the "pdf/" include
    path("", include(wagtail_urls)),
    ...
]

Bugfixes and changes

  • Fixed the displaying of PDFs inside <iframe>, by hosting the PDF viewer on the server, such that container's properties (like scroll) can be accessed without CORS issues
  • Updated imports to support wagtail 4 and wagtail 5
  • Implemented PDF viewer registry register_pdf_view(), register_pdf_admin_view(), get_pdf_viewer_url() and get_pdf_admin_view to replace DEFAULT_PDF_VIEW_PROVIDER and DEFAULT_PDF_ADMIN_VIEW_PROVIDER
  • Renamed PdfViewPageMixin.PDF_VIEW_PROVIDER to PdfViewPageMixin.pdf_view_class
  • get_preview_name() now just outputs the upper case name (e.g. PDF instead of pdf preview)
  • Added settings WAGTAIL_PDF_VIEW and WAGTAIL_PDF_ADMIN_VIEW to hook in custom view classes
  • Added WAGTAIL_DEFAULT_PDF_OPTIONS and WAGTAIL_PREVIEW_PANEL_PDF_OPTIONS to set global options for weasyprint
  • WAGTAIL_PDF_VIEWER to configure a different pdf viewer (instead of pdf.js) in the panel preview
  • Added PdfViewPageMixin.pdf_options, ModelAdminPdfViewMixin.pdf_options, and ModelAdminPdfAdminViewMixin.pdf_options to set local options for weasyprint
  • Added pdf.js as server hosted PDF viewer
  • Added serve_sameorigin to serve the pdf viewer without CORS problems
  • Added redirect_request_to_pdf_viewer()
  • Added get_pdf_viewer_url()
  • Implemented PdfViewPageMixin.serve_preview_pdf() to handle in panel previews
  • Hook in the server side pdf viewer using PdfViewPageMixin.make_preview_request()
  • Fixed WagtailCoreExtensionLatex._include_block()
  • Added a modified CheckboxSelectMultiple for correct checkbox interaction within PDFs
  • Added some logging if a wrong configuration is detected