lib – Utility functions
A collection of library routines.
Module contents
-
class pagd.lib.Site[source]
Abstraction object to hold following attributes.
- sitepath,
- Absolute path to where the source files for the site is present.
- siteconfig,
- A python dictionary of configuration settings application to entire
site.
All the above attributes have site-wide scope.
-
class pagd.lib.Page[source]
Abstraction object to hold following attributes.
- site,
- an instance of Site class that contains this page.
- pagename,
- name of the page that will appear in url-path as last path segment.
- relpath,
- relative path from sitepath, where pagename is located.
- urlpath,
- url path relative to script-path. Includes pagename as the last
segment in the path.
- contentfiles,
- List of files, in absolute path, that contains contents for this page.
- articles,
- List of article tuples which each tuple is made up of,
( article's fpath, article-context, html-text ). Article’s
file-path is the absolute path of the content file which was
translated to html-text. Article’s context is page.context
overrided with meta-data from file-content.
- context,
- Dictionary of context attributes for page.
- templatefile,
- Template file name with absolute path-name to be used for translating
this content-page to html page.
All the above attributes are unique for each page.
-
pagd.lib.json2dict(jsonfile)[source]
Convert jsonfile to python dictionary. Return None if jsonfile
is not found.
-
pagd.lib.pagd(path, files)[source]
This function implements the key concept in pagd, that is, to aggregate
content and for target web-page.
- path,
- Absolute directory path pointing a sub-directory under layout’s
content directory.
- files,
- List of files under a sub-directory from layout’s content directory.
Return a tuple of, (pagename, page-contents, remaining-files)
- pagename,
- name of the web-page that will appear in url-path as last path segment.
- page-contents,
- List of files that can be translated to html content for page
pagename.
- remaining-files,
- List of files that remain after gathering contents.
-
pagd.lib.findtemplate(subdir, pagename=None, default=None)[source]
Find a matching template under subdir.
- subdir,
- Directory path that shall contain one or more template files.
- pagename,
- Page-name for which this function shall find a corresponding
template-file.
- default,
- Basename of default-template.