blag.blag¶
blag’s core methods.
Functions
|
Build the site. |
|
Environment factory. |
|
Generate the archive page. |
|
Generate Atom feed. |
|
Generate the tags page. |
|
Load site configuration from configfile. |
|
Main entrypoint for the CLI. |
|
Parse command line arguments. |
|
Process markdown files. |
|
Quickstart. |
- blag.blag.build(args)¶
Build the site.
This is blag’s main method that builds the site, generates the feed etc.
- Parameters
args (argparse.Namespace) –
- blag.blag.environment_factory(template_dir=None, globals_=None)¶
Environment factory.
Creates a Jinja2 Environment with the default templates and additional templates from template_dir loaded. If globals are provided, they are attached to the environment and thus available to all contexts.
- Parameters
template_dir (str) –
globals (dict) –
- Returns
- Return type
jinja2.Environment
- blag.blag.generate_archive(articles, template, output_dir)¶
Generate the archive page.
- Parameters
articles (list[list[str, dict]]) – List of articles. Each article has the destination path and a dictionary with the content.
template (jinja2.Template instance) –
output_dir (str) –
- blag.blag.generate_feed(articles, output_dir, base_url, blog_title, blog_description, blog_author)¶
Generate Atom feed.
- Parameters
articles (list[list[str, dict]]) – list of relative output path and article dictionary
output_dir (str) – where the feed is stored
base_url (str) – base url
blog_title (str) – blog title
blog_description (str) – blog description
blog_author (str) – blog author
- blag.blag.generate_tags(articles, tags_template, tag_template, output_dir)¶
Generate the tags page.
- Parameters
articles (list[list[str, dict]]) – List of articles. Each article has the destination path and a dictionary with the content.
tags_template (jinja2.Template instance) –
tag_template (jinja2.Template instance) –
output_dir (str) –
- blag.blag.get_config(configfile)¶
Load site configuration from configfile.
- Parameters
configfile (str) – path to configuration file
- Returns
- Return type
dict
- blag.blag.main(args=None)¶
Main entrypoint for the CLI.
This method parses the CLI arguments and executes the respective commands.
- Parameters
args (list[str]) – optional parameters, used for testing
- blag.blag.parse_args(args=None)¶
Parse command line arguments.
- Parameters
args (List[str]) – optional parameters, used for testing
- Returns
- Return type
arparse.Namespace
- blag.blag.process_markdown(convertibles, input_dir, output_dir, page_template, article_template)¶
Process markdown files.
This method processes the convertibles, converts them to html and saves them to the respective destination paths.
If a markdown file has a date metadata field it will be recognized as article otherwise as page.
- Parameters
convertibles (List[Tuple[str, str]]) – relative paths to markdown- (src) html- (dest) files
input_dir (str) –
output_dir (str) –
page_template (jinja2 template) – templats for pages and articles
archive_template (jinja2 template) – templats for pages and articles
- Returns
articles, pages
- Return type
List[Tuple[str, Dict]]
- blag.blag.quickstart(args)¶
Quickstart.
This method asks the user some questions and generates a configuration file that is needed in order to run blag.
- Parameters
args (argparse.Namespace) –