Skip to main content

Integrate Google Web Stories Editor in Wagtail Projects.

Project description

wagtail-webstories-editor

Integrate Google Web Stories Editor in Wagtail Projects.

This is an effort to integrate the standalone version of Web Stories for WordPress plugin into wagtail.

Table of Contents

Overview

This package brings Web Stories for WordPress plugin to Wagtail by providing integrations with the Wagtail Admin, mainly by use of custom snippet viewsets

Sample Story

Features

  • Editor for creating webstories. The editor brings most features provided by the Web Stories for WordPress
  • Dashboard for listing and managing stories
  • Settings interface for configuring web stories settings including:
    • Google Analytics Integration
    • Setting publisher logos
    • Opt-in to use Google Cache for videos
  • Integration with Wagtail Images to use the Wagtail image chooser and Wagtail Media to use it's Media Choosers for Audio and Video
  • On top of the features provided by the Editor and Dashboard, the package uses most of the Snippets Optional Features to enable the following features:
    • Making WebStories previewable using the wagtail PreviewableMixin
    • Saving revisions for WebStories using RevisionMixin
    • Saving draft changes for WebStories using DraftStateMixin
    • Locking WebStories using LockableMixin
    • Enabling workflows for WebStories using WorkflowMixin

Installation

pip install wagtail-webstories-editor

The following dependencies will be installed as well if not yet installed:

  • django-filter
  • wagtailmedia

Usage

Add the following to your INSTALLED_APPS if not yet added:

INSTALLED_APPS = [
    ...
    "wagtail_webstories_editor",
    "wagtail.api.v2",
    "wagtailmedia",
    "django_filters",
    "wagtail.contrib.settings",
    "django.contrib.sitemaps",

    ...
]

Run migrations

python manage.py migrate wagtail_webstories_editor

You also need to enable Wagtail's API for images, documents, and media. To do, you can follow the steps below:

  • Make sure wagtail.api.v2 is added to your installed apps
  • Create an api.py where you will configure your endpoints to expose .The package adds a few custom functions to the default provided Images, Documents, and Media ViewSet classes to build compatibility with WebStories apiCallbacks. You can import them and use them as below:
# api.py
from wagtail.api.v2.router import WagtailAPIRouter

from wagtail_webstories_editor.api_viewsets import (CustomImagesAPIViewSet,
                                                    CustomMediaAPIViewSet,
                                                    CustomDocumentAPIViewSet)

api_router = WagtailAPIRouter('wagtailapi')

api_router.register_endpoint('images', CustomImagesAPIViewSet)
api_router.register_endpoint("media", CustomMediaAPIViewSet)
api_router.register_endpoint('documents', CustomDocumentAPIViewSet)

Next, register the URLs so Django can route requests into the API:

# urls.py

from .api import api_router

urlpatterns = [
    ...

    path('api/v2/', api_router.urls),

    ...

    # Ensure that the api_router line appears above the default Wagtail page serving route
    re_path(r'^', include(wagtail_urls)),
]

If everything went ok, a new Web Stories menu item will be to your Wagtail Admin Menu

Admin Menu

  1. Click to show the WebStories dashboard
  2. Create a new WebStory
  3. Access WebStories Settings

Settings

  • WAGTAIL_WEBSTORIES_EDITOR_LISTING_PAGE_MODEL : Model for your WebStories listing Page. This will be used to generate urls for individual stories, since stories are saved as snippets and not Wagtail Pages. See below for details

Integrating with Wagtail pages for story links and SEO

WebStories uses Wagtail Snippets to integrate the Editor and Dashboard. The settings component uses Wagtail Site Settings.

To get links for individual WebStories on publishing, you can create a listing page and tell the WebStories package about it. The package provides an abstract page that you could inherit from:

# app/models.py
from wagtail_webstories_editor.models import AbstractWebStoryListPage


class WebStoryListPage(AbstractWebStoryListPage):
    pass

and then in your settings.py, tell webstories about the page class:

# settings.py

WAGTAIL_WEBSTORIES_EDITOR_LISTING_PAGE_MODEL = "app.WebStoryListPage"

Ideally you should create only one instance of this WebStoryListPage in your Wagtail Project. If you create multiple, the first one to be queried will be used

The AbstractWebStoryListPage adds a few functionalities to help working with WebStories:

  • By using Wagtail's RoutablePageMixin, Web Stories will be served to users using sub-urls from the listing page
  • By extending get_sitemap_urls method of the Wagtail's Page model, we are able to add all the urls of live WebStories to Wagtail's autogenerated sitemap, and thus making sure your Web Stories are well indexed for SEO

Example Project

You can find a complete example project showing how to use this package in the sandbox folder

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wagtail_webstories_editor-0.3.0.tar.gz (3.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wagtail_webstories_editor-0.3.0-py3-none-any.whl (3.2 MB view details)

Uploaded Python 3

File details

Details for the file wagtail_webstories_editor-0.3.0.tar.gz.

File metadata

File hashes

Hashes for wagtail_webstories_editor-0.3.0.tar.gz
Algorithm Hash digest
SHA256 c2d836b93e45dd34ee205c1468438ca9538ecfa71b28e27efd85279b0632698e
MD5 d873769ebb82ac4093a5cb77fc1d9b06
BLAKE2b-256 18e16be2f2a9ca58c12bccd8e3ce0fa8d540f040c6d200fbe8621a2bd2c8db30

See more details on using hashes here.

Provenance

The following attestation bundles were made for wagtail_webstories_editor-0.3.0.tar.gz:

Publisher: publish.yml on erick-otenyo/wagtail-webstories-editor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wagtail_webstories_editor-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for wagtail_webstories_editor-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ef6177e060f59d0163f99d6b4f2b4e2d141df1eabb2c003cb1f77a401e24a4d0
MD5 08ca653e8c20d07e5f50f8dc2f8b1641
BLAKE2b-256 944ed9839c485e600318e6d3241456d1c970a6985fac507e9fe18dc20e51c4ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for wagtail_webstories_editor-0.3.0-py3-none-any.whl:

Publisher: publish.yml on erick-otenyo/wagtail-webstories-editor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page