diff --git a/CHANGELOG.txt b/CHANGELOG.txt index a0024b6a0..bcb58c15b 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -5,6 +5,7 @@ Changelog ~~~~~~~~~~~~~~~~ * Added toolbar to allow logged-in users to add and edit pages from the site front-end * Support for alternative image processing backends such as Wand, via the WAGTAILIMAGES_BACKENDS setting + * Added support for generating static sites using django-medusa * Added custom Query set for Pages with some handy methods for querying pages * Editor's guide documentation * Editor interface now outputs form media CSS / JS, to support custom widgets with assets @@ -24,6 +25,7 @@ Changelog * Fix: Page slugs are now validated on page edit * Fix: Filter objects are cached to avoid a database hit every time an {% image %} tag is compiled * Fix: Moving or changing a site root page no longer causes URLs for subpages to change to 'None' + * Fix: Eliminated raw SQL queries from wagtailcore / wagtailadmin, to ensure cross-database compatibility 0.2 (11.03.2014) ~~~~~~~~~~~~~~~~ diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 38e89a8e1..3549e8407 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -25,6 +25,7 @@ Contributors * Miguel Vieira * Ben Emery * David Smith +* Ben Margolis Translators =========== diff --git a/docs/gettingstarted.rst b/docs/gettingstarted.rst index e4d2d6484..626aa42c0 100644 --- a/docs/gettingstarted.rst +++ b/docs/gettingstarted.rst @@ -102,12 +102,17 @@ Required dependencies ===================== - `pip `_ +- `libjpeg `_ +- `libxml2 `_ +- `libxslt `_ +- `zlib `_ Optional dependencies ===================== - `PostgreSQL`_ - `Elasticsearch`_ +- `Redis`_ Installation ============ @@ -137,6 +142,7 @@ with a regular Django project. .. _the Wagtail codebase: https://github.com/torchbox/wagtail .. _PostgreSQL: http://www.postgresql.org .. _Elasticsearch: http://www.elasticsearch.org +.. _Redis: http://redis.io/ _`Remove the demo app` ~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/index.rst b/docs/index.rst index dbfe91f33..5b2b62bc4 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -13,6 +13,7 @@ It supports Django 1.6.2+ on Python 2.6 and 2.7. Django 1.7 and Python 3 support wagtail_search deploying performance + static_site_generation contributing support roadmap diff --git a/docs/static_site_generation.rst b/docs/static_site_generation.rst new file mode 100644 index 000000000..fe4b504ea --- /dev/null +++ b/docs/static_site_generation.rst @@ -0,0 +1,83 @@ +Generating a static site +======================== + +This document describes how to render your Wagtail site into static HTML files using `django medusa`_ and the 'wagtail.contrib.wagtailmedusa' module. + + +Installing django-medusa +~~~~~~~~~~~~~~~~~~~~~~~~ + +Firstly, install django medusa from pip: + +.. code:: + + pip install django-medusa + + +Then add 'django_medusa' and 'wagtail.contrib.wagtailmedusa' to INSTALLED_APPS: + +.. code:: python + + INSTALLED_APPS = [ + ... + 'django_medusa', + 'wagtail.contrib.wagtailmedusa', + ] + + +Replacing GET parameters with custom routing +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Pages which require GET parameters (eg, pagination) don't generate suitable filenames for generated HTML files so they need to be changed to use custom routing instead. + +For example, lets say we have a Blog Index which uses pagination. We can override the 'route' method to make it respond on urls like '/page/1' and pass the page number through to the serve method: + +.. code:: python + + class BlogIndex(Page): + ... + + def serve(self, request, page=1): + ... + + def route(self, request, path_components): + if self.live and len(path_components) == 2 and path_components[0] == 'page': + try: + return self.serve(request, page=int(path_components[1])) + except (TypeError, ValueError): + pass + + return super(BlogIndex, self).route(request, path_components) + + +Rendering pages which use custom routing +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +For page types that override the route method, we need to let django medusa know which URLs it responds on. This is done by overriding the 'get_static_site_paths' method to make it yield one string per URL path. + +For example, the BlogIndex above would need to yield one URL for each page of results: + +.. code:: python + + def get_static_site_paths(self): + # Get page count + page_count = ... + + # Yield a path for each page + for page in range(page_count): + yield '/%d/' % (page + 1) + + # Yield from superclass + for path in super(BlogIndex, self).get_static_site_paths(): + yield path + + +Rendering +~~~~~~~~~ + +To render a site, just run ``./manage.py staticsitegen``. This will render the entire website and place the HTML in a folder called 'medusa_output'. The static and media folders need to be copied into this folder manually after the rendering is complete. + +To test, open the 'medusa_output' folder in a terminal and run ``python -m SimpleHTTPServer``. + + +.. _django medusa: https://github.com/mtigas/django-medusa diff --git a/scripts/install/debian.sh b/scripts/install/debian.sh index 93f513d16..d29d5acdc 100644 --- a/scripts/install/debian.sh +++ b/scripts/install/debian.sh @@ -1,5 +1,5 @@ -# Production-configured Wagtail installation -# (secure services/account for full production use). +# Production-configured Wagtail installation. +# BUT, SECURE SERVICES/ACCOUNT FOR FULL PRODUCTION USE! # Tested on Debian 7.0. # Tom Dyson and Neal Todd @@ -42,6 +42,7 @@ aptitude -y install openjdk-7-jre-headless curl -O https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.0.0.deb dpkg -i elasticsearch-1.0.0.deb rm elasticsearch-1.0.0.deb +perl -pi -e"s/# network.host: 192.168.0.1/network.host: 127.0.0.1/" /etc/elasticsearch/elasticsearch.yml update-rc.d elasticsearch defaults 95 10 service elasticsearch start diff --git a/scripts/install/ubuntu.sh b/scripts/install/ubuntu.sh index 9f60e2e8e..c713cefa9 100644 --- a/scripts/install/ubuntu.sh +++ b/scripts/install/ubuntu.sh @@ -1,5 +1,5 @@ -# Production-configured Wagtail installation -# (secure services/account for full production use). +# Production-configured Wagtail installation. +# BUT, SECURE SERVICES/ACCOUNT FOR FULL PRODUCTION USE! # Tested on Ubuntu 13.04 and 13.10. # Tom Dyson and Neal Todd @@ -40,6 +40,7 @@ aptitude -y install openjdk-7-jre-headless curl -O https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.0.0.deb dpkg -i elasticsearch-1.0.0.deb rm elasticsearch-1.0.0.deb +perl -pi -e"s/# network.host: 192.168.0.1/network.host: 127.0.0.1/" /etc/elasticsearch/elasticsearch.yml update-rc.d elasticsearch defaults 95 10 service elasticsearch start diff --git a/tox.ini b/tox.ini index 329c1c407..11b8bb3a2 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,6 @@ dj16= Django>=1.6,<1.7 pyelasticsearch==0.6.1 elasticutils==0.8.2 - unittest2 [tox] envlist = diff --git a/wagtail/contrib/__init__.py b/wagtail/contrib/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/wagtail/contrib/wagtailmedusa/__init__.py b/wagtail/contrib/wagtailmedusa/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/wagtail/contrib/wagtailmedusa/models.py b/wagtail/contrib/wagtailmedusa/models.py new file mode 100644 index 000000000..e69de29bb diff --git a/wagtail/contrib/wagtailmedusa/renderers.py b/wagtail/contrib/wagtailmedusa/renderers.py new file mode 100644 index 000000000..950e13a14 --- /dev/null +++ b/wagtail/contrib/wagtailmedusa/renderers.py @@ -0,0 +1,24 @@ +from django_medusa.renderers import StaticSiteRenderer +from wagtail.wagtailcore.models import Site +from wagtail.wagtaildocs.models import Document + + +class PageRenderer(StaticSiteRenderer): + def get_paths(self): + # Get site + # TODO: Find way to get this to work with other sites + site = Site.objects.filter(is_default_site=True).first() + if site is None: + return [] + + # Return list of paths + return site.root_page.get_static_site_paths() + + +class DocumentRenderer(StaticSiteRenderer): + def get_paths(self): + # Return list of paths to documents + return (doc.url for doc in Document.objects.all()) + + +renderers = [PageRenderer, DocumentRenderer] diff --git a/wagtail/tests/models.py b/wagtail/tests/models.py index 9124cb253..97858df4d 100644 --- a/wagtail/tests/models.py +++ b/wagtail/tests/models.py @@ -1,4 +1,5 @@ from django.db import models +from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from modelcluster.fields import ParentalKey from wagtail.wagtailcore.models import Page, Orderable from wagtail.wagtailcore.fields import RichTextField @@ -187,11 +188,48 @@ class EventIndex(Page): intro = RichTextField(blank=True) ajax_template = 'tests/includes/event_listing.html' - def get_context(self, request): + def get_events(self): + return self.get_children().live().type(EventPage) + + def get_paginator(self): + return Paginator(self.get_events(), 4) + + def get_context(self, request, page=1): + # Pagination + paginator = self.get_paginator() + try: + events = paginator.page(page) + except PageNotAnInteger: + events = paginator.page(1) + except EmptyPage: + events = paginator.page(paginator.num_pages) + + # Update context context = super(EventIndex, self).get_context(request) - context['events'] = EventPage.objects.filter(live=True) + context['events'] = events return context + def route(self, request, path_components): + if self.live and len(path_components) == 1: + try: + return self.serve(request, page=int(path_components[0])) + except (TypeError, ValueError): + pass + + return super(EventIndex, self).route(request, path_components) + + def get_static_site_paths(self): + # Get page count + page_count = self.get_paginator().num_pages + + # Yield a path for each page + for page in range(page_count): + yield '/%d/' % (page + 1) + + # Yield from superclass + for path in super(EventIndex, self).get_static_site_paths(): + yield path + EventIndex.content_panels = [ FieldPanel('title', classname="full title"), FieldPanel('intro', classname="full"), diff --git a/wagtail/tests/utils.py b/wagtail/tests/utils.py index 11cdb369d..7b6557a78 100644 --- a/wagtail/tests/utils.py +++ b/wagtail/tests/utils.py @@ -1,9 +1,20 @@ from django.contrib.auth.models import User +# We need to make sure that we're using the same unittest library that Django uses internally +# Otherwise, we get issues with the "SkipTest" and "ExpectedFailure" exceptions being recognised as errors +try: + # Firstly, try to import unittest from Django + from django.utils import unittest +except ImportError: + # Django doesn't include unittest + # We must be running on Django 1.7+ which doesn't support Python 2.6 so + # the standard unittest library should be unittest2 + import unittest + def login(client): # Create a user User.objects.create_superuser(username='test', email='test@email.com', password='password') # Login - client.login(username='test', password='password') \ No newline at end of file + client.login(username='test', password='password') diff --git a/wagtail/wagtailadmin/static/wagtailadmin/scss/core.scss b/wagtail/wagtailadmin/static/wagtailadmin/scss/core.scss index 8ffaa450a..2c1232091 100644 --- a/wagtail/wagtailadmin/static/wagtailadmin/scss/core.scss +++ b/wagtail/wagtailadmin/static/wagtailadmin/scss/core.scss @@ -115,7 +115,7 @@ img{ } .nav-wrapper{ - @include box-shadow(inset -2px 0px 10px 0px rgba(0, 0, 0, 0.5)); + @include box-shadow(inset -5px 0px 5px -3px rgba(0, 0, 0, 0.3)); position:relative; background: $color-grey-1; margin-left: -100%; @@ -404,7 +404,7 @@ header{ width:1em; display:none; margin-right:0.4em; - font-size:1.5em; + font-size:1.3em; } } @@ -904,13 +904,8 @@ footer, .logo{ .wrapper{ max-width:$breakpoint-desktop-larger; } - .nav-wrapper{ - @include box-shadow(inset -6px 0px 4px 0px rgba(0, 0, 0, 0.2)); - - .inner{ - background:$color-grey-1; - @include box-shadow(inset -6px 0px 4px 0px rgba(0, 0, 0, 0.2)); - } + .nav-wrapper .inner{ + background:$color-grey-1; } footer{ diff --git a/wagtail/wagtailadmin/static/wagtailadmin/scss/layouts/login.scss b/wagtail/wagtailadmin/static/wagtailadmin/scss/layouts/login.scss index a8164272d..4abf3ae20 100644 --- a/wagtail/wagtailadmin/static/wagtailadmin/scss/layouts/login.scss +++ b/wagtail/wagtailadmin/static/wagtailadmin/scss/layouts/login.scss @@ -179,6 +179,7 @@ form{ left: $desktop-nice-padding; margin-top: -1em; top: 50%; + font-size:1.5em; } .full{ diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/pages/select_location.html b/wagtail/wagtailadmin/templates/wagtailadmin/pages/select_location.html deleted file mode 100644 index f5470158a..000000000 --- a/wagtail/wagtailadmin/templates/wagtailadmin/pages/select_location.html +++ /dev/null @@ -1,13 +0,0 @@ -{% extends "wagtailadmin/base.html" %} -{% load i18n %} -{% block titletag %}{% blocktrans with page_type=content_type.model_class.get_verbose_name %}Where do you want to create a {{ page_type }}{% endblocktrans %}{% endblock %} -{% block content %} - {% trans "Where do you want to create this" as where_str %} - {% include "wagtailadmin/shared/header.html" with title=where_str subtitle=content_type.model_class.get_verbose_name icon="doc-empty-inverse" %} - - -{% endblock %} diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/pages/select_type.html b/wagtail/wagtailadmin/templates/wagtailadmin/pages/select_type.html deleted file mode 100644 index ada1e5027..000000000 --- a/wagtail/wagtailadmin/templates/wagtailadmin/pages/select_type.html +++ /dev/null @@ -1,20 +0,0 @@ -{% extends "wagtailadmin/base.html" %} -{% load i18n %} -{% block titletag %}{% trans "Create a new page" %}{% endblock %} -{% block bodyclass %}menu-explorer{% endblock %} -{% block content %} - {% trans "Create a new page" as create_str %} - {% include "wagtailadmin/shared/header.html" with title=create_str icon="doc-empty-inverse" %} - -
-

{% trans "Your new page will be saved in the top level of your website. You can move it after saving." %}

- - {% if all_page_types %} - - {% endif %} -
-{% endblock %} diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/shared/main_nav.html b/wagtail/wagtailadmin/templates/wagtailadmin/shared/main_nav.html index b282afe3c..f7eb6528a 100644 --- a/wagtail/wagtailadmin/templates/wagtailadmin/shared/main_nav.html +++ b/wagtail/wagtailadmin/templates/wagtailadmin/shared/main_nav.html @@ -6,10 +6,6 @@ {{ menu_item.render_html }} {% endfor %} - {% comment %} - {# TODO: make this work #} -
  • {% trans 'New page' %}
  • - {% endcomment %}