Node of the site tree.
Name.
List of child nodes.
Path of the directory reflected by this node.
Parent node.
First tries to find and return immediate child called name. Then continues search by calling get_child on every immediate child PageNode. If nothing found, returns None.
Returns descendant node identified by path. If nothing found, returns None.
Represents pages created during automatic pagination (see paginate_tree()). Subclasses Node.
1-based index.
Creates tree that reflects the structure of page_dir.
Recursively sorts the tree according to the ordering_dict – a dictionary where keys are node paths and values are the following:
Recursively paginates tree according to the pagination_dict – a dictionary where keys are node paths and values are the numbers of the items per page (let’s denote it n).
If node path is in pagination_dict, it’s children detached from it, split into the chunks of size n and then each chunk attached back to the node through intermediate PageNode.
Recursively walks the tree and annotates each node with context.
Calls utils.read_context() and combines it’s result with the following data:
Given the site tree, builds the site. The main steps are the following:
If page at path exists, returns it’s root-relative URL; otherwise throws an exception.
Watches all files except those that are hidden or are in the hidden directory.
Parameters: |
|
---|
Daemon thread that waits for the changes and then shuts down the server.
Parameters: |
|
---|
Provides the facility to return the first matched value from the list of (regexp, value) pairs.
Parameters: | items – List of tuples (compiled regexp, value) |
---|
Helper to create RegexResolver. Example:
LAYOUTS = patterns(
(r'^content$', 'content.html'),
(r'^content/.*$', 'speech.html'),
(r'^.*$', 'page.html'),
)
Sorts list_ by explicitly specified order.
>>> sort(['a', 'b', 'c'],
... ['c', 'b', 'xxx', 'a', 'yyy'])
['c', 'b', 'a']
>>> sort(['a', 'b', 'c', 'd'],
... ['c', 'b', 'a'])
['c', 'b', 'a', 'd']
>>> sort([('a', 1), ('b', 2)],
... ['b', 'a'],
... key=lambda el: el[0]) # Sort tuples by first element
[('b', 2), ('a', 1)]
Splits items list into lists of size items_per_page.
>>> paginate([1, 2, 3], 1)
[[1], [2], [3]]
>>> paginate([1, 2, 3, 4, 5, 6, 7], 3)
[[1, 2, 3], [4, 5, 6], [7]]
>>> paginate([], 3)
[]
Searches dir_ for markdown- and yaml-files and returns context dictionary with parsed data.
Markdown and YAML files are files which names matched to <name>.(md|yaml) or <name>.<language>.(md|yaml) pattern if language specified.
First parses each Markdown file and puts result into context under the <name> key. Then parses each YAML file and updates context with resulting dictionary (note: update will override markdown data if there are duplicate keys).