-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support for subpages #29
Comments
Thanks for your suggestions @jorenham . First thought will be override the You can use this already to make your custom page render multiple static html files. However we want to provide people with off-the-shelf solutions to make it much easier as you suggest. Could you let me know if this works (for now) for you? |
@robmoorman The |
I solved it. Just add the attribute import logging
import os
from django.test.client import RequestFactory
from wagtailbakery.views import AllPagesView, AllPublishedPagesView
logger = logging.getLogger(__name__)
class AllSubpagesView(AllPagesView):
def build_subpages(self, obj):
site = obj.get_site()
base_url = self.get_url(obj)
for subpage_url in obj.subpage_urls:
url = base_url + subpage_url
logger.debug("Building %s" % url)
self.request = RequestFactory(SERVER_NAME=site.hostname).get(url)
self.set_kwargs(obj)
build_path = self.get_subpage_build_path(obj, subpage_url)
self.build_file(build_path, self.get_content(obj))
def get_subpage_build_path(self, obj, subpage_url):
base_path = os.path.dirname(self.get_build_path(obj))
path = os.path.join(base_path, subpage_url)
os.path.exists(path) or os.makedirs(path)
return os.path.join(path, 'index.html')
def build_queryset(self):
super(AllSubpagesView, self).build_queryset()
for item in self.get_queryset().all():
specific_item = item.specific
if hasattr(specific_item, 'subpage_urls'):
self.build_subpages(specific_item)
class AllPublishedSubpagesView(AllSubpagesView, AllPublishedPagesView):
pass |
That's awesome @jorenham . I'll keep your implementation as an example till we have supported this. |
This or something like it would be great to add to wagtail-bakery itself. Any blockers? |
http://docs.wagtail.io/en/stable/reference/contrib/routablepage.html
Perhaps using a setting to enable this.
The text was updated successfully, but these errors were encountered: