This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Developer-friendly, simple CMS for Django, “flatpages on steroids”.

Features

  • edit pages in Admin using syntax highlighting - HTML, CSS, JavaScript, Django template language
  • edit pages as files using your favourite text editor or IDE
  • on demand synchronization of pages between database and file system using Django commands
  • integration with Django’s template system
  • attach custom server-side logic to a page through configurable Page Processors
  • sitemap.xml

Installation

Install package using pip:

pip install django-powerpages

Add 'powerpages' to INSTALLED_APPS in your settings module:

INSTALLED_APPS = (
    ...
    'powerpages',
)

Define POWER_PAGES setting:

POWER_PAGES = {
    # absolute path to directory, where page files are located:
    'SYNC_DIRECTORY': '/path/to/directory/'
}

Include app’s URLs at the end of your urlconf:

urlpatterns = [
    ...
    url(r'', include('powerpages.urls', namespace='powerpages')),
]

Run migrations:

python manage.py migrate

Usage

Admin screenshots:

Edit pages using Admin

Admin interface allows to edit pages using the following fields:

  • URL - unique address of every page
  • Alias - optional code name for page to be used to resolve it’s URL address
  • Title, Description, Keywords - convenience fields to work with meta-tags
  • Template - page’s content as a Django template source
  • Page Processor and Page Processor Config - options to assign and customize server-side logic

URL addresses of pages can be reversed in templates by using {% page_url alias %}. This template tag can also reverse URLs of regular Django views.

Page templates work as regular Django’s templates with few modifications:

  1. {% extends ... %} tag should not be used:
  • by default each template inherits from template of parent page
  • parent template can be overwritten by providing base template option to the page processor config
  1. {% load ... %} tag is not necessary:
  • template tag libraries from settings.POWER_PAGES['TAG_LIBRARIES'] are loaded automatically
  • additional libraries may be provided using tag libraries in page processor config

Page Processor field allows to select a Python class responsible for processing requests for current page. Page processor can be configured using YAML config in Page Processor Config field. Default value, powerpages.DefaultPageProcessor just renders page content and returns the output as 200 OK response. Other predefined options are:

  • powerpages.RedirectProcessor - creates 301 Moved Permanently or 302 Found response depending on boolean permanent parameter. Redirect location is provided by URL (parameter to url), view name (to name) or Page alias (to alias).
  • powerpages.NotFoundProcessor - generates 404 Not Found response.

Example configuration of default page processor:

base template: myapp/base.html
context processors:
- myapp.context_processors.context
tag libraries:
- myapp_tags
headers: {x-magic-id: '42'}
cache: 300
cache for user: true
sitemap: false

To define a custom page processor you may create a subclass of DefaultPageProcessor inside page_processors.py file in your app:

# myapp/page_processors.py
from powerpages.page_processors import DefaultPageProcessor
from powerpages.page_processor_registry import register

class MyPageProcessor(DefaultPageProcessor):

     def process_request(self, request, extra_context=None):
         """Process a request and create HTTP Response."""
         # Put your custom view logic here

register(MyPageProcessor)

Browse website in “edit mode”

Button “Edit mode” in Admin allows to show information about current page while browsing the website. User enables “Edit mode” for current session in Admin using Edit mode button. This mode works only if template tag {% current_page_info %} has been added to the template source.

File-Database Synchronization

Export pages from database to file system is done by website_dump command. All pages are saved as structure of files and directories inside settings.POWER_PAGES['SYNC_DIRECTORY']. Exported pages can be modified using text editor and later loaded again into the database.

python manage.py website_dump

Example structure of output directory:

_index_.page
about-us/_index_.page
about-us/contact.page
download.page
robots.txt

Each of dumped files has the following structure:

{
   ... page fields as JSON
}
## TEMPLATE SOURCE: ##
... template content (plain text)

Import pages from directory into database is done using website_load command.

python manage.py website_load

Both website commands accept a variety of options to tweak their behaviour. For the full list of options, use --help.

XML Sitemaps

django-powerpages comes with a system for defining XML Sitemaps (alternative to django.contrib.sitemaps). By default, all accessible pages are listed as URLs in sitemap.xml. To remove a page from the sitemap user may add the following option to page processor config:

sitemap: false

sitemap option may be used to modify page’s sitemap params:

sitemap: {changefreq: 'daily', priority: 0.9}

Default values for changefreq and priority for all URLs can be set using settings.POWER_PAGES:

POWER_PAGES = {
    # (...)
    'SITEMAP_DEFAULT_CHANGEFREQ': 'weekly',
    'SITEMAP_DEFAULT_PRIORITY': 0.7,
}

To add custom URLs from your app to the sitemap you may define and register a subclass of Sitemap or ModelSitemap class inside sitemap.py file in your app:

# myapp/sitemap.py
from powerpages import sitemap_config
from myapp.models import MyModel

class MyModelSitemap(sitemap_config.ModelSitemap):
    """Sitemap config for Storage Powered by Open-E document files"""
    queryset = MyModel.objects.all()

class MyStaticSitemap(sitemap_config.Sitemap):
    items = (
        {'location': sitemap_config.NamedURL('myview')},
        {'location': sitemap_config.NamedURL('myview2', param='value')}
    )

sitemap_config.sitemaps.add(MyModelSitemap)
sitemap_config.sitemaps.add(MyStaticSitemap)

Requirements

Python: 2.7, 3.4, 3.5

Django: 1.9, 1.10

Release History

Release History

0.0.6

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django_powerpages-0.0.6-py2.py3-none-any.whl (1.3 MB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Oct 26, 2016
django-powerpages-0.0.6.tar.gz (1.2 MB) Copy SHA256 Checksum SHA256 Source Oct 26, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting