Easier sharing of Wagtail drafts
Easier sharing of Wagtail drafts.
Wagtail Sharing makes it easier to share Wagtail draft content for review by users who don’t have access to the Wagtail admin site. It allows you to define an alternate hostname and/or port on which to expose the latest revision of all of your Wagtail pages.
For example, let’s say your Wagtail site is running on http://mysite.com. You’ve created a draft page at slug /path/to/draft, but haven’t yet published it. Wagtail Sharing lets you expose that draft page at some other domain, for example http://sharing.mysite.com/path/to/draft.
In another use case, you might have a published page at http://mysite.com/already/published/page, and you’ve made some draft changes. Wagtail Sharing lets you expose those draft changes at http://sharing.mysite.com/already/published/page while still keeping the same published content at your regular domain.
These examples obviously work best when you have some method of restricting access to http://sharing.mysite.com, for example by only exposing that subdomain on a private network.
Wagtail Sharing lets you create separate sharing sites for each Wagtail Site you have defined. It also supports a configurable visual banner on shared pages to remind reviewers that content may differ from your published site.
This new logic only applies to GET requests. Other HTTP methods like POST defer to standard Wagtail handling.
Install the package using pip:
$ pip install wagtail-sharing
Add wagtailsharing as an installed app in your Django settings:
# in settings.py INSTALLED_APPS = ( ... 'wagtailsharing', ... )
wagtail.contrib.modeladmin is also required and must be included in your list of installed apps.
Run migrations to create required database tables:
$ manage.py migrate wagtailsharing
Replace use of Wagtail’s catch-all URL pattern:
# in urls.py -from wagtail.core import urls as wagtail_urls +from wagtailsharing import urls as wagtailsharing_urls ... -urlpatterns.append(url(r'', include(wagtail_urls))) +urlpatterns.append(url(r'', include(wagtailsharing_urls)))
Creating a new sharing site
After following the setup steps above, you should be able to create a new sharing site to use this functionality in a local Django development server. Let’s assume that you are running your local development server on the default port 8000, and that pages there are being served at http://localhost:8000. We want to create a new sharing site at http://sharing.localhost:8000 at which latest page revisions will be exposed.
To simulate accessing your site on a different hostname, you’ll need to loosen Django’s default security settings that only allow access on localhost. Edit your settings file (e.g. myproject/settings/local.py) to add the following:
ALLOWED_HOSTS = ['*']
Verify that you can access your local server at http://sharing.localhost:8000. You should see the same content there as on http://localhost:8000, as you haven’t enabled wagtail-sharing for the default site yet.
To do so, in the Wagtail admin, under Settings, Sharing Sites, create a new sharing site for the default site, with hostname sharing.localhost and port 8000.
Your latest page revisions (including drafts) should now be available at http://sharing.localhost:8000.
As with normal page serving, the serving of shared pages continues to respect Wagtail’s built-in before_serve_page hook.
This project adds these additional hooks:
This project has been tested for compatibility with:
- Python 3.6, 3.8
- Django 1.11, 2.0, 2.2
- Wagtail 1.13, 2.3, 2.8
It should be compatible with all intermediate versions, as well. If you find that it is not, please file an issue.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size wagtail_sharing-1.0-py3-none-any.whl (21.5 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size wagtail-sharing-1.0.tar.gz (17.9 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for wagtail_sharing-1.0-py3-none-any.whl