gresiblos

API

API

gresiblos - greyrat's simple blog system.

Entry

Represents a blog entry with metadata and content.

Attributes:

Name Type Description
_fields Dict[str, str]

A dictionary to store entry fields.

__init__(fields={})

Initializes an Entry object with default values.

Parameters:

Name Type Description Default
fields Dict[str, str]

The entry's meta data and content.

{}

get(key)

Returns the value of a field by key.

Parameters:

Name Type Description Default
key str

The key of the field to retrieve.

required

Returns:

Type Description
str

The value of the field.

has_key(key)

Returns whether the key is known.

Parameters:

Name Type Description Default
key str

The key of the field to check for.

required

Returns:

Type Description
bool

Whether the named field is stored.

get_isodate(date_format)

Returns the date in isoformat, if given. Otherwise return None.

Parameters:

Name Type Description Default
date_format str

The date format if it differs from ISO

required

Returns:

Type Description
str

The date in isoformat.

load(filename)

Loads entry data from a filename.

Parameters:

Name Type Description Default
filename str

The path to the filename containing entry data.

required

embed(template, topics_format, apply_markdown=False, prettifier=None)

Embeds entry data into a template.

Parameters:

Name Type Description Default
template str

The HTML template to embed data into.

required
topics_format str

The format for topics in the template.

required
apply_markdown bool

Whether the content/title/abstract shall be parsed as markdown.

False
prettifier Any

The degrotesque instance to prettify the content/title/abstract.

None

Returns:

Type Description
str

The template with embedded entry data.

PlainStorage

Stores metadata of blog entries.

Attributes:

Name Type Description
_meta Dict[str, Dict[str, str]]

A dictionary to store metadata of entries.

__init__()

Initializes a PlainStorage object.

add(filename, entry, date_format)

Adds an entry's metadata to the storage.

Parameters:

Name Type Description Default
filename str

The filename of the entry.

required
entry Entry

The Entry object containing metadata.

required
date_format str

The date format if it differs from ISO

required

get_meta()

Returns all stored metadata.

Returns:

Type Description
Dict[str, Dict[str, str]]

A dictionary of all stored metadata.

_get_entries()

Returns all stored entries' metadata as a list.

Returns:

Type Description
List[Dict[str, str]]

A list of entry metadata

get_entries_chronological()

Returns all stored entries' metadata as a list, sorted by date.

Returns:

Type Description
List[Dict[str, str]]

A list of entry metadata

get_entries_alphabetical()

Returns all stored entries' metadata as a list, sorted by title (alphabetic).

Returns:

Type Description
List[Dict[str, str]]

A list of entry metadata

write_list(title, dest_path, template, entries, topic_format, apply_markdown, prettifier)

Generates an unordered list from the given list of entry metadata, embeds it into the given template, and saves the result under the given path.

Parameters:

Name Type Description Default
title str

The title to apply.

required
dest_path str

The filename of the entry.

required
template str

The template to fill.

required
entries List[Dict[str, str]]

A list of entry metadata.

required
topic_format str

The format of topics to use.

required
apply_markdown bool

Whether markdown shall be applied.

required
prettifier Any

The prettyfier to use.

required

main(arguments=None)

The main method using parameters from the command line.

Parameters:

Name Type Description Default
arguments List[str]

A list of command line arguments.

None

Returns:

Type Description
int

The exit code (0 for success).

script_run()

Execute from command line.