mkdocs_rss_plugin.util module¶
-
class
mkdocs_rss_plugin.util.
Util
(path='.')[source]¶ Bases:
object
-
build_url
(base_url, path, args_dict=None)[source]¶ Build URL using base URL, cumulating existing and passed path, then adding URL arguments.
-
static
filter_pages
(pages, attribute, length)[source]¶ Filter and return pages into a friendly RSS structure.
Returns authors from page meta. It handles ‘author’ and ‘authors’ for keys, str and iterable as values types.
- Args:
in_page (Page): page to look at
- Returns:
Tuple[str]: tuple of authors names
-
get_date_from_meta
(date_metatag_value, meta_datetime_format)[source]¶ Get date from page.meta handling str with associated datetime format and date already transformed by MkDocs.
-
get_description_or_abstract
(in_page, chars_count=150)[source]¶ Returns description from page meta. If it doesn’t exist, use the {chars_count} first characters from page content (in markdown).
-
get_file_dates
(in_page, source_date_creation='git', source_date_update='git', meta_datetime_format='%Y-%m-%d %H:%M')[source]¶ Extract creation and update dates from page metadata (yaml frontmatter) or git log for given file.
- Parameters
in_page (Page) – input page to work with
source_date_creation (str, optional) – which source to use (git or meta tag) for creation date, defaults to “git”
source_date_update (str, optional) – which source to use (git or meta tag) for update date, defaults to “git”
meta_datetime_format (str, optional) – datetime string format, defaults to “%Y-%m-%d %H:%M”
- Returns
tuple of timestamps (creation date, last commit date)
- Return type
-
get_local_image_length
(page_path, path_to_append)[source]¶ Build URL using base URL, cumulating existing and passed path, then adding URL arguments.
-
get_remote_image_length
(image_url, http_method='HEAD', attempt=0, ssl_context=None)[source]¶ Retrieve length for remote images (starting with ‘http’ in meta.image or meta.illustration). It tries to perform a HEAD request and get the length from the headers. If it fails, it tries again with a GET and disabling SSL verification.
- Parameters
image_url (str) – remote image URL
http_method (str, optional) – HTTP method used to perform request, defaults to “HEAD”
attempt (int, optional) – request tries counter, defaults to 0
ssl_context (ssl.SSLContext, optional) – SSL context, defaults to None
- Returns
image length
- Return type
-