blag.blag

blag’s core methods.

Functions

build(args)

Build the site.

environment_factory([template_dir, globals_])

Environment factory.

generate_archive(articles, template, output_dir)

Generate the archive page.

generate_feed(articles, output_dir, ...)

Generate Atom feed.

generate_tags(articles, tags_template, ...)

Generate the tags page.

get_config(configfile)

Load site configuration from configfile.

main([arguments])

Main entrypoint for the CLI.

parse_args([args])

Parse command line arguments.

process_markdown(convertibles, input_dir, ...)

Process markdown files.

blag.blag.build(args: Namespace) None

Build the site.

This is blag’s main method that builds the site, generates the feed etc.

Parameters:

args

blag.blag.environment_factory(template_dir: str | None = None, globals_: dict[str, object] | None = None) Environment

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 – directory containing the templates

  • globals

Return type:

jinja2.Environment

blag.blag.generate_archive(articles: list[tuple[str, dict[str, Any]]], template: Template, output_dir: str) None

Generate the archive page.

Parameters:
  • articles – List of articles. Each article has the destination path and a dictionary with the content.

  • template

  • output_dir

blag.blag.generate_feed(articles: list[tuple[str, dict[str, Any]]], output_dir: str, base_url: str, blog_title: str, blog_description: str, blog_author: str) None

Generate Atom feed.

Parameters:
  • articles – list of relative output path and article dictionary

  • output_dir – where the feed is stored

  • base_url – base url

  • blog_title – blog title

  • blog_description – blog description

  • blog_author – blog author

blag.blag.generate_tags(articles: list[tuple[str, dict[str, Any]]], tags_template: Template, tag_template: Template, output_dir: str) None

Generate the tags page.

Parameters:
  • articles – List of articles. Each article has the destination path and a dictionary with the content.

  • tags_template

  • tag_template

  • output_dir

blag.blag.get_config(configfile: str) SectionProxy

Load site configuration from configfile.

Parameters:

configfile – path to configuration file

Return type:

configparser.SectionProxy

blag.blag.main(arguments: list[str] | None = None) None

Main entrypoint for the CLI.

This method parses the CLI arguments and executes the respective commands.

Parameters:

arguments – optional parameters, used for testing

blag.blag.parse_args(args: list[str] | None = None) argparse.Namespace

Parse command line arguments.

Parameters:

args – optional parameters, used for testing

Return type:

arparse.Namespace

blag.blag.process_markdown(convertibles: list[tuple[str, str]], input_dir: str, output_dir: str, page_template: Template, article_template: Template) tuple[list[tuple[str, dict[str, Any]]], list[tuple[str, dict[str, Any]]]]

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 – relative paths to markdown- (src) html- (dest) files

  • input_dir

  • output_dir

  • page_template – templats for pages and articles

  • archive_template – templats for pages and articles

Returns:

articles and pages

Return type:

list[tuple[str, dict[str, Any]]], list[tuple[str, dict[str, Any]]]