1 .. _flatpagesfile-chapter:
7 This is the flatpages file plugin. It allows you to add pages to your
8 MediaGoblin instance which are not generated from user content. For
9 example, this is useful for these pages:
14 * How to get an account here
21 Add the following to your MediaGoblin .ini file in the ``[plugins]``
24 [[mediagoblin.plugins.flatpagesfile]]
27 This tells MediaGoblin to load the flatpagesfile plugin. This is the
28 subsection that you'll do all flatpagesfile plugin configuration in.
34 To add a new page to your site, you need to do two things:
36 1. add a route to the MediaGoblin .ini file in the flatpagesfile
39 2. write a template that will get served when that route is requested
45 First, let's talk about the route.
47 A route is a key/value in your configuration file.
49 The key for the route is the route name You can use this with `url()`
50 in templates to have MediaGoblin automatically build the urls for
53 It should be "unique" and it should be alphanumeric characters and
54 hyphens. I wouldn't put spaces in there.
56 Examples: ``flatpages-about``, ``about-view``, ``contact-view``, ...
58 The value has two parts separated by commas:
60 1. **route path**: This is the URL that this route matches.
62 Examples: ``/about``, ``/contact``, ``/pages/about``, ...
64 You can do anything with this that you can do with the routepath
65 parameter of `routes.Route`. For more details, see `the routes
66 documentation <http://routes.readthedocs.org/en/latest/>`_.
68 Example: ``/siteadmin/{adminname:\w+}``
72 If you're doing something fancy, enclose the route in single
75 For example: ``'/siteadmin/{adminname:\w+}'``
77 2. **template**: The template to use for this URL. The template is in
78 the flatpagesfile template directory, so you just need to specify
81 Like with other templates, if it's an HTML file, it's good to use
82 the ``.html`` extensions.
84 Examples: ``index.html``, ``about.html``, ``contact.html``, ...
87 Here's an example configuration that adds two flat pages: one for an
88 "About this site" page and one for a "Terms of service" page::
90 [[mediagoblin.plugins.flatpagesfile]]
91 about-view = '/about', about.html
92 terms-view = '/terms', terms.html
97 The order in which you define the routes in the config file is the
98 order in which they're checked for incoming requests.
104 To add pages, you must edit template files on the file system in your
105 `local_templates` directory.
107 The directory structure looks kind of like this::
116 The ``.html`` file contains the content of your page. It's just a
117 template like all the other templates you have.
119 Here's an example that extends the `flatpagesfile/base.html`
122 {% extends "flatpagesfile/base.html" %}
123 {% block mediagoblin_content %}
124 <h1>About this site</h1>
126 This site is a MediaGoblin instance set up to host media for
127 me, my family and my friends.
134 If you have a bunch of flatpages that kind of look like one
135 another, take advantage of Jinja2 template extending and create a
136 base template that the others extend.
145 You can handle URLs like ``/about/{name}`` and access the name that's
146 passed in in the template.
150 about-page = '/about/{name}', about.html
154 {% extends "flatpagesfile/base.html" %}
155 {% block mediagoblin_content %}
157 <h1>About page for {{ request.matchdict['name'] }}</h1>
161 See the `the routes documentation
162 <http://routes.readthedocs.org/en/latest/>`_ for syntax details for
163 the route. Values will end up in the ``request.matchdict`` dict.