def index(request): try: # If there is a page at the path /, render it return CmsPageDispatcher.as_view()(request, path='') except Http404: try: # If there is a page with slug 'home', render it, return CmsPageDispatcher.as_view()(request, path='home/') except Http404: # otherwise render a getting started page context = { 'has_pages': Page.objects.count(), } return TemplateResponse(request, 'fluent_pages/intro_page.html', context)
""" The URLs to serve the CMS. They can be included using: urlpatterns += patterns('', url(r'', include('fluent_pages.urls')) ) The following named URLs are defined: - fluent-page-admin-redirect - An redirect to the admin. - fluent-page - Display of a page. By Appending @admin to an URL, the request will be redirected to the admin URL of the page. """ from fluent_pages.views import CmsPageDispatcher, CmsPageAdminRedirect from fluent_pages.utils.compat import url, patterns # This urlpatterns acts as a catch-all, as there is no terminating slash in the pattern. # This allows the pages to have any name, including file names such as /robots.txt # Sadly, that circumvents the CommonMiddleware check whether a slash needs to be appended to a path. # The APPEND_SLASH behavior is implemented in the CmsPageDispatcher so the standard behavior still works as expected. urlpatterns = patterns('fluent_pages.views', url(r'^(?P<path>.*)@admin$', CmsPageAdminRedirect.as_view(), name='fluent-page-admin-redirect'), url(r'^(?P<path>.*)$', CmsPageDispatcher.as_view(), name='fluent-page-url'), url(r'^$', CmsPageDispatcher.as_view(), name='fluent-page'), )
""" The URLs to serve the CMS. They can be included using: urlpatterns += patterns('', url(r'', include('fluent_pages.urls')) ) The following named URLs are defined: - fluent-page-admin-redirect - An redirect to the admin. - fluent-page - Display of a page. By Appending @admin to an URL, the request will be redirected to the admin URL of the page. """ from django.conf.urls.defaults import * from fluent_pages.views import CmsPageDispatcher, CmsPageAdminRedirect # The URLs of the cmspage are forced to end with a slash, # so django will redirect /admin will redirect to /admin/. # The same trick also needs to be used in the main site # which includes this file. Otherwise a rule matched after all. urlpatterns = patterns( 'fluent_pages.views', url(r'^(?P<path>.*)@admin$', CmsPageAdminRedirect.as_view(), name='fluent-page-admin-redirect'), url(r'^$|^(?P<path>.*)$', CmsPageDispatcher.as_view(), name='fluent-page'))