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
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'sMedia Choosers
forAudio
andVideo
- 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
- Making WebStories previewable using the wagtail
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 WebStoriesapiCallbacks
. 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
- Click to show the WebStories dashboard
- Create a new WebStory
- 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 oflive
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file wagtail-webstories-editor-0.1.0.tar.gz
.
File metadata
- Download URL: wagtail-webstories-editor-0.1.0.tar.gz
- Upload date:
- Size: 3.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2395c6101fcfe5f4d5d1c3600594a828f60a2f6da17d9213493a16ee240d2bc6 |
|
MD5 | 101f47c5a579a477674e65a034f11358 |
|
BLAKE2b-256 | b9515889564344a3faec5236c3f4a5784c0ffa6361cddad9a26f8d672c8c95fb |
File details
Details for the file wagtail_webstories_editor-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: wagtail_webstories_editor-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e786753691e9e2a1876a91613418e9cf073071802f971a5f36d3f3e16c33bbb2 |
|
MD5 | 3551681ce80fff6740c6201081191079 |
|
BLAKE2b-256 | c575f8cff2ea2e58e331b7893f99d877cecf1255b95314c384610f863a30dc1a |