firmant.writers.j2

Writers that inherit from other writers and render html.

Functions

firmant.writers.j2._setup(self)
Setup the test cases.
firmant.writers.j2._teardown(test)
Cleanup the Jinja2 test cases.

Classes

class firmant.writers.j2.Jinja2Base

Bases: object

Base class used for functionality common to all J2 writers.

static render_to_file(environment, path, template, context)
Render template with context and save to path.
class firmant.writers.j2.Jinja2PostArchiveAll(environment, objects, action=None)

Bases: firmant.writers.j2.Jinja2PostArchiveBase, firmant.writers.posts.PostArchiveAll

Render paginated post lists with Jinja2 templates.

key(obj)

Return the set of attributes suitable as input for url mapping.

Attributes that identify a archived year page:

type
This is always post.
page
The 1-indexed page number of the page.
>>> obj = spaa.obj_list({'settings': settings},
...                     {'post': objects.posts})[0]
>>> pprint(obj) 
([Post(2010-02-02-newday2), Post(2010-02-02-newday)], Paginated(None, 1, 2))

>>> pprint(spaa.key(obj))
{'page': 1, 'type': u'post'}
obj_list(environment, objects)

Return 3-tuples with the list of objects and prev/next information.

The prev/next information is stored in firmant.paginate.Paginated objects and is returned for both the groupings by year, and for the groupings into pages.

>>> spaa.obj_list({'settings': settings}, {})
[]
>>> spaa.obj_list({'settings': settings}, {'post': []})
[]
>>> pprint(spaa.obj_list({'settings': settings},
...                      {'post': objects.posts})) 
[([Post(2010-02-02-newday2), Post(2010-02-02-newday)], Paginated(None, 1, 2)),
 ([Post(2010-02-01-newmonth), Post(2010-01-01-newyear)], Paginated(1, 2, 3)),
 ([Post(2009-12-31-party)], Paginated(2, 3, None))]
render(environment, path, obj)
Render the archive view.
static render_to_file(environment, path, template, context)
Render template with context and save to path.
scheduling_order

The following scheduling orders apply to writers:

10
At timestep 10, the writer will create the chunks for forward declaration and rendering.
500
At timestep 500, the writer will forward-declare urls.
900
At timestep 900, the writer will render the objects.
writername

The string displayed when interacting with the user.

This should be the name of the class they must specify in the configuration. The default value should not be changed.

class firmant.writers.j2.Jinja2PostArchiveBase

Bases: firmant.writers.j2.Jinja2Base

Common functionality for rendering Jinja2 archive views.

render(environment, path, obj)
Render the archive view.
static render_to_file(environment, path, template, context)
Render template with context and save to path.
template
The template to use for rendering.
class firmant.writers.j2.Jinja2PostArchiveDaily(environment, objects, action=None)

Bases: firmant.writers.j2.Jinja2PostArchiveBase, firmant.writers.posts.PostArchiveDaily

Render paginated post lists (grouped by day) with Jinja2 templates.

key(obj)

Return the set of attributes suitable as input for url mapping.

Attributes that identify an archived day page:

type
This is always post.
year
The year of publication.
month
The month of publication.
day
The day of publication.
page
The 1-indexed page number of the page.
>>> obj = spad.obj_list({'settings': settings},
...                     {'post': objects.posts})[0]
>>> pprint(obj) 
([Post(2010-02-02-newday2), Post(2010-02-02-newday)],
 Paginated(None, (2010, 2, 2), (2010, 2, 1)),
 Paginated(None, 1, None))
>>> pprint(spad.key(obj))
{'day': 2, 'month': 2, 'page': 1, 'type': u'post', 'year': 2010}
obj_list(environment, objects)

Return 3-tuples with the list of objects and prev/next information.

The prev/next information is stored in firmant.paginate.Paginated objects and is returned for both the groupings by day, and for the groupings into pages.

>>> spad.obj_list({'settings': settings}, {})
[]
>>> spad.obj_list({'settings': settings}, {'post': []})
[]
>>> pprint(spad.obj_list({'settings': settings},
...                      {'post': objects.posts})) 
[([Post(2010-02-02-newday2), Post(2010-02-02-newday)],
  Paginated(None, (2010, 2, 2), (2010, 2, 1)),
  Paginated(None, 1, None)),
 ([Post(2010-02-01-newmonth)],
  Paginated((2010, 2, 2), (2010, 2, 1), (2010, 1, 1)),
  Paginated(None, 1, None)),
 ([Post(2010-01-01-newyear)],
  Paginated((2010, 2, 1), (2010, 1, 1), (2009, 12, 31)),
  Paginated(None, 1, None)),
 ([Post(2009-12-31-party)],
  Paginated((2010, 1, 1), (2009, 12, 31), None),
  Paginated(None, 1, None))]
render(environment, path, obj)
Render the archive view.
static render_to_file(environment, path, template, context)
Render template with context and save to path.
scheduling_order

The following scheduling orders apply to writers:

10
At timestep 10, the writer will create the chunks for forward declaration and rendering.
500
At timestep 500, the writer will forward-declare urls.
900
At timestep 900, the writer will render the objects.
writername

The string displayed when interacting with the user.

This should be the name of the class they must specify in the configuration. The default value should not be changed.

class firmant.writers.j2.Jinja2PostArchiveMonthly(environment, objects, action=None)

Bases: firmant.writers.j2.Jinja2PostArchiveBase, firmant.writers.posts.PostArchiveMonthly

Render paginated post lists (grouped by month) with Jinja2 templates.

key(obj)

Return the set of attributes suitable as input for url mapping.

Attributes that identify a archived month page:

type
This is always post.
year
The year of publication.
month
The month of publication.
page
The 1-indexed page number of the page.
>>> obj = spam.obj_list({'settings': settings},
...                     {'post': objects.posts})[0]
>>> pprint(obj)
([Post(2010-02-02-newday2), Post(2010-02-02-newday)],
 Paginated(None, (2010, 2), (2010, 1)),
 Paginated(None, 1, 2))
>>> pprint(spam.key(obj))
{'month': 2, 'page': 1, 'type': u'post', 'year': 2010}
obj_list(environment, objects)

Return 3-tuples with the list of objects and prev/next information.

The prev/next information is stored in firmant.paginate.Paginated objects and is returned for both the groupings by month, and for the groupings into pages.

>>> spam.obj_list({'settings': settings}, {})
[]
>>> spam.obj_list({'settings': settings}, {'post': []})
[]
>>> pprint(spam.obj_list({'settings': settings},
...                      {'post': objects.posts})) 
[([Post(2010-02-02-newday2), Post(2010-02-02-newday)],
  Paginated(None, (2010, 2), (2010, 1)),
  Paginated(None, 1, 2)),
 ([Post(2010-02-01-newmonth)],
  Paginated(None, (2010, 2), (2010, 1)),
  Paginated(1, 2, None)),
 ([Post(2010-01-01-newyear)],
  Paginated((2010, 2), (2010, 1), (2009, 12)),
  Paginated(None, 1, None)),
 ([Post(2009-12-31-party)],
  Paginated((2010, 1), (2009, 12), None),
  Paginated(None, 1, None))]
render(environment, path, obj)
Render the archive view.
static render_to_file(environment, path, template, context)
Render template with context and save to path.
scheduling_order

The following scheduling orders apply to writers:

10
At timestep 10, the writer will create the chunks for forward declaration and rendering.
500
At timestep 500, the writer will forward-declare urls.
900
At timestep 900, the writer will render the objects.
writername

The string displayed when interacting with the user.

This should be the name of the class they must specify in the configuration. The default value should not be changed.

class firmant.writers.j2.Jinja2PostArchiveYearly(environment, objects, action=None)

Bases: firmant.writers.j2.Jinja2PostArchiveBase, firmant.writers.posts.PostArchiveYearly

Render paginated post lists (grouped by year) with Jinja2 templates.

key(obj)

Return the set of attributes suitable as input for url mapping.

Attributes that identify a archived year page:

type
This is always post.
year
The year of publication.
page
The 1-indexed page number of the page.
>>> obj = spay.obj_list({'settings': settings},
...                     {'post': objects.posts})[0]
>>> pprint(obj) 
([Post(2010-02-02-newday2), Post(2010-02-02-newday)],
 Paginated(None, (2010,), (2009,)),
 Paginated(None, 1, 2))
>>> pprint(spay.key(obj))
{'page': 1, 'type': u'post', 'year': 2010}
obj_list(environment, objects)

Return 3-tuples with the list of objects and prev/next information.

The prev/next information is stored in firmant.paginate.Paginated objects and is returned for both the groupings by year, and for the groupings into pages.

>>> spay.obj_list({'settings': settings}, {})
[]
>>> spay.obj_list({'settings': settings}, {'post': []})
[]
>>> pprint(spay.obj_list({'settings': settings},
...                      {'post': objects.posts}))
[([Post(2010-02-02-newday2), Post(2010-02-02-newday)],
  Paginated(None, (2010,), (2009,)),
  Paginated(None, 1, 2)),
 ([Post(2010-02-01-newmonth), Post(2010-01-01-newyear)],
  Paginated(None, (2010,), (2009,)),
  Paginated(1, 2, None)),
 ([Post(2009-12-31-party)],
  Paginated((2010,), (2009,), None),
  Paginated(None, 1, None))]
render(environment, path, obj)
Render the archive view.
static render_to_file(environment, path, template, context)
Render template with context and save to path.
scheduling_order

The following scheduling orders apply to writers:

10
At timestep 10, the writer will create the chunks for forward declaration and rendering.
500
At timestep 500, the writer will forward-declare urls.
900
At timestep 900, the writer will render the objects.
writername

The string displayed when interacting with the user.

This should be the name of the class they must specify in the configuration. The default value should not be changed.

class firmant.writers.j2.Jinja2PostWriter(environment, objects, action=None)

Bases: firmant.writers.j2.Jinja2Base, firmant.writers.posts.PostWriter

Render each post individually using Jinja2 templates.

key(post)

Return the set of attributes suitable as input for url mapping.

Attributes that identify a post object:

type
This is always post.
year
The year of publication.
month
The month of publication.
day
The day of publication.
slug
The slug that is unique to the feed object.
>>> print objects.posts[0].published.date(), objects.posts[0].slug
2009-12-31 party
>>> pprint(sp.key(objects.posts[0]))
{'day': 31, 'month': 12, 'slug': u'party', 'type': u'post', 'year': 2009}
obj_list(environment, objects)

Return all objects stored under the key post.

>>> sp.obj_list(None, {})
[]
>>> sp.obj_list(None, {'post': []})
[]
>>> sp.obj_list(None, {'post': ['postobj']})
['postobj']
render(environment, path, post)

Render the data in a Jinja2 template.

>>> j2pw = Jinja2PostWriter(environment, objects)
>>> obj = j2pw.obj_list(environment, objects)[0]
>>> j2pw.render(environment, path, obj)
>>> cat(path)
2009-12-31 | party by John Doe
static render_to_file(environment, path, template, context)
Render template with context and save to path.
scheduling_order

The following scheduling orders apply to writers:

10
At timestep 10, the writer will create the chunks for forward declaration and rendering.
500
At timestep 500, the writer will forward-declare urls.
900
At timestep 900, the writer will render the objects.
writername

The string displayed when interacting with the user.

This should be the name of the class they must specify in the configuration. The default value should not be changed.

class firmant.writers.j2.Jinja2StaticRst(environment, objects, action=None)

Bases: firmant.writers.j2.Jinja2Base, firmant.writers.staticrst.StaticRstWriter

Render staticrst objects using the StaticRstWriter base.

key(staticrst)

Return the set of attributes suitable as input for url mapping.

Attributes that identify a static-rest object:

type
This is always staticrst.
path
A path that describes the object relative to the input/output directories.
>>> print objects.staticrst[0].path
about
>>> pprint(ssrw.key(objects.staticrst[0]))
{'path': u'about', 'type': u'staticrst'}
obj_list(environment, objects)

Return all objects stored under the key staticrst.

>>> ssrw.obj_list(None, {})
[]
>>> ssrw.obj_list(None, {'staticrst': []})
[]
>>> ssrw.obj_list(None, {'staticrst': ['staticobj']})
['staticobj']
render(environment, path, obj)

Render the data in a Jinja2 template.

>>> j2sr = Jinja2StaticRst(environment, objects)
>>> obj = j2sr.obj_list(environment, objects)[0]
>>> j2sr.render(environment, path, obj)
>>> cat(path)
About at about
static render_to_file(environment, path, template, context)
Render template with context and save to path.
scheduling_order

The following scheduling orders apply to writers:

10
At timestep 10, the writer will create the chunks for forward declaration and rendering.
500
At timestep 500, the writer will forward-declare urls.
900
At timestep 900, the writer will render the objects.
writername

The string displayed when interacting with the user.

This should be the name of the class they must specify in the configuration. The default value should not be changed.

Table Of Contents

Previous topic

firmant.writers.feeds

Next topic

firmant.writers.posts

This Page