Permalink
Browse files

move view docstrings to views/*.rst

  • Loading branch information...
1 parent 61ab088 commit cc69c66101dc591ccac7fcdb092503e708e2fed8 @posativ committed Jun 29, 2013
@@ -72,97 +72,6 @@ def href(self):
class Category(Index):
- """A view to recursively render all posts of a category, sub category and
- so on. Configuration syntax:
-
- .. code-block:: python
-
- '/category/:name/': {
- 'view': 'category',
- 'pagination': '/category/:name/:num/'
- }
-
- Categories are either explicitly set in the metadata section
- (`category: foo/bar`) or derived from the path of the post, e.g.
- `content/projects/python/foo-bar.txt` will set the category to `projects/python`.
-
- .. code-block:: sh
-
- $ tree content/
- content/
- ├── projects
- │ ├── bla.txt
- │ └── python
- │ └── fuu.txt
- └── test
- └── sample-entry.txt
-
- The directory structure above then renders the following:
-
- .. code-block:: sh
-
- $ acrylamid compile
- create [0.00s] output/category/test/index.html
- create [0.00s] output/category/projects/index.html
- create [0.00s] output/category/projects/python/index.html
-
- Both, bla.txt and fuu.txt are shown on the project listing, but only the
- fuu.txt post appears on the projects/python listing.
-
- Categories in the Entry Context
- -------------------------------
-
- To link to the category listing, use the following Jinja2 code instead of
- the tag code in the `entry.html` template:
-
- .. code-block:: html+jinja
-
- {% if 'category' in env.views and entry.category %}
- <p>categorized in
- {% for link in entry.category | categorize %}
- <a href="{{ env.path + link.href }}">{{ link.title }}</a>
- {%- if loop.revindex > 2 -%}
- ,
- {%- elif loop.revindex == 2 %}
- and
- {% endif %}
- {% endfor %}
- </p>
-
- This uses the new `categorize` filter which is available when you have the
- category view enabled. It takes the category list from `entry.category` and
- yields the hierarchical categories, e.g. projects/python yields projects and
- projects/python.
-
- Categories in the Environment Context
- -------------------------------------
-
- Similar to the tag cloud you are able to generate a category listing on
- each page: ``env.categories`` is an iterable object that yields categories
- (which are iterable as well and yield sub categories). The following Jinja2
- code recursively renders all categories and sub categories in a simple list:
-
- .. code-block:: html+jinja
-
- <ul class="categories">
- {% for category in env.categories recursive %}
-
- <li>Category: <a href="{{ category.href }}">{{ category.title }}</a>
- with {{ category.items | count }} articles.
- </li>
-
- {% if category %}
- <ul class="depth-{{ loop.depth }}">{{ loop(category) }}</ul>
- {% endif %}
-
- {% endfor %}
- </ul>
-
-
- .. versionadded:: 0.8
-
- Support for categories was introduced.
- """
export = ['prev', 'curr', 'next', 'items_per_page', 'category', 'entrylist']
template = 'main.html'
@@ -90,24 +90,6 @@ def generate(self, conf, env, data):
class Entry(Base):
- """Creates single full-length entry
- (`Example <http://blog.posativ.org/2012/nginx/>`_).
-
- To enable Entry view, add this to your :doc:`conf.py`:
-
- .. code-block:: python
-
- '/:year/:slug/': {
- 'view': 'entry',
- 'template': 'main.html' # default, includes entry.html
- }
-
- The entry view renders an post to a unique location and should be used as
- permalink URL. The url is user configurable, but may be overwritten by
- setting ``ENTRY_PERMALINK`` explicitly to a URL in your configuration.
-
- This view takes no other arguments and uses *main.html* and *entry.html* as
- template."""
@property
def type(self):
@@ -131,77 +113,13 @@ def prev(self, entrylist, i):
class Page(Base):
- """Creates a static page
-
- To enable Entry view, add this to your :doc:`conf.py`:
-
- .. code-block:: python
-
- '/:year/:slug/': {
- 'view': 'page',
- 'template': 'main.html' # default, includes entry.html
- }
-
- The page view renders an post to a unique location withouth any references
- to other blog entries. The url is user configurable, but may be overwritten by
- setting ``PAGE_PERMALINK`` explicitly to a URL in your configuration.
-
- This view takes no other arguments and uses *main.html* and *entry.html* as
- template."""
@property
def type(self):
return 'pages'
class Translation(Base):
- """Creates translation of a single full-length entry. To enable the
- Translation view, add this to your :doc:`conf.py`:
-
- .. code-block:: python
-
- '/:year/:slug/:lang/': {
- 'view': 'translation',
- 'template': 'main.html', # default, includes entry.html
- }
-
- Translations are posts with the same `identifier` and a different `lang` attribute.
- An example:
-
- The English article::
-
- ---
- title: Foobar is not dead
- identifier: foobar-is-not-dead
- ---
-
- That's true, foobar is still alive!
-
- And the French version::
-
- ---
- title: Foobar n'est pas mort !
- identifier: foobar-is-not-dead
- lang: fr
- ---
-
- Oui oui, foobar est toujours vivant !
-
- If the blog language is ``"en"`` then the english article will be included into
- the default listing but the french version not. You can link to the translated
- versions via:
-
- .. code-block:: html+jinja
-
- {% if 'translation' in env.views and env.translationsfor(entry) %}
- <ul>
- {% for tr in env.translationsfor(entry) %}
- <li><strong>{{ tr.lang }}:</strong>
- <a href="{{ env.path ~ tr.permalink }}">{{ tr.title }}</a>
- </li>
- {% endfor %}
- </ul>
- {% endif %}"""
@property
def type(self):
@@ -50,21 +50,6 @@ def finish(self):
class Sitemap(View):
- """Create an XML-Sitemap where permalinks have the highest priority (1.0) and do never
- change and all other ressources have a changefreq of weekly.
-
- .. code-block:: python
-
- '/sitemap.xml': {
- 'view': 'Sitemap'
- }
-
- The sitemap by default excludes any resources copied over with the entry.
- If you wish to include image resources associated with the entry, the config property
- ``SITEMAP_IMAGE_EXT`` can be use to define file extensions to include.
- ``SITEMAP_RESOURCE_EXT`` can be used for other file types such as text files and PDFs.
- Video resources are not supported, and should not be included in the above properties.
- """
priority = 0.0
scores = {'page': (1.0, 'never'), 'entry': (1.0, 'never')}
View
@@ -22,7 +22,7 @@ https://github.com/posativ/acrylamid/.
commands
idea
filters/index
- views
+ views/index
assets
hooks
static-search
@@ -0,0 +1,3 @@
+Feeds
+=====
+
@@ -14,7 +14,7 @@ later). Currently, Acrylamid ships the following:
- static site search, self-explanatory.
All views have some properties in common such as path, filters and conditionals,
-you've to set in your :doc:`conf.py`. The idea of views is similar to routes in
+you've to set in your :doc:`/conf.py`. The idea of views is similar to routes in
Django or Flask. You can set your URL setup to whatever you like, Acrylamid is
not fixed to a single directory structure. For convenience, Acrylamid appends an
``index.html`` to a URL if it does end with a slash (as shown in the defaults).
@@ -47,36 +47,21 @@ Here's an example of how to use views:
"/path/": {"view": "translation", "if": lambda e: e.lang == 'klingon'}
}
-To see, what variables are available during templating, consult :doc:`templating`.
+To see, what variables are available during templating, consult :doc:`/templating`.
Built-in Views
**************
-.. autoclass:: acrylamid.views.archive.Archive()
-
-.. autoclass:: acrylamid.views.articles.Articles()
-
-.. autoclass:: acrylamid.views.entry.Entry()
-
-.. autoclass:: acrylamid.views.feeds.Feed()
-
-.. autoclass:: acrylamid.views.index.Index()
-
-.. autoclass:: acrylamid.views.entry.Page()
-
-.. autoclass:: acrylamid.views.tag.Tag()
-
-.. autoclass:: acrylamid.views.category.Category()
-
-.. autoclass:: acrylamid.views.entry.Translation()
-
-.. autoclass:: acrylamid.views.sitemap.Sitemap()
-
+* :ref:`views-entry`, :ref:`views-page`, :ref:`views-translation`
+* :ref:`views-archive`, :ref:`views-tag`, :ref:`views-category`
+* :doc:`/views/feeds`,
+* :ref:`views-sitemap`
+* :doc:`/views/search`
Custom Views
************
You can easily extend Acrylamid by writing custom views directly in your blog
-directory. Just add ``VIEWS_DIR += ['views/']`` to your :doc:`conf.py` and write
+directory. Just add ``VIEWS_DIR += ['views/']`` to your :doc:`/conf.py` and write
your own view.
Oops, something went wrong.

0 comments on commit cc69c66

Please sign in to comment.