How to use the pelican.generators function in pelican

To help you get started, we’ve selected a few pelican examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mindcruzer / pelican-encrypt-content / encrypt_content / encrypt_content.py View on Github external
def pelican_all_generators_finalized(content_generators):
    """
    Finds pages and articles/article.drafts marked with a password and processes them.
    """
    for generator in content_generators:
        if isinstance(generator, generators.ArticlesGenerator):
            for article in generator.articles + generator.translations:
                if hasattr(article, 'password'):
                    encrypt_content(article)
            for draft in generator.drafts + generator.drafts_translations:
                if hasattr(draft, 'password'):
                    encrypt_content(draft)
        if isinstance(generator, generators.PagesGenerator):
            for page in generator.pages:
                if 'password' in page.metadata:
                    encrypt_content(page)
github cmacmackin / scribbler / scribbler / render_math / math.py View on Github external
For reStructuredText content, examine both articles and pages.
    If article or page is reStructuredText and there is math present,
    append the mathjax script.

    Also process summaries if present (only applies to articles)
    and user wants summaries processed (via user settings)
    """

    for generator in content_generators:
        if isinstance(generator, generators.ArticlesGenerator):
            for article in generator.articles + generator.translations:
                rst_add_mathjax(article)
                #optionally fix truncated formulae in summaries.
                if process_summary.mathjax_script is not None:
                    process_summary(article)
        elif isinstance(generator, generators.PagesGenerator):
            for page in generator.pages:
                rst_add_mathjax(page)
github AlexJF / pelican-entities / entities.py View on Github external
class Entity(contents.Page):
    pass


def EntityFactory(name, mandatory_properties, default_template, BaseClass=Entity):
    base_mandatory_properties = ['title']
    mandatory_properties = set(base_mandatory_properties + mandatory_properties)
    newclass = type(str(name), (BaseClass,),
                    {'type': name,
                     'mandatory_properties': mandatory_properties,
                     'default_template': default_template})
    return newclass


class EntityGenerator(generators.Generator):
    """ Generate entity pages for each defined entity type."""

    class EntitySubGenerator(generators.CachingGenerator):
        """Generate entity pages for a specific entity type."""

        def __init__(self, entity_type, *args, **kwargs):
            """initialize properties"""
            self.entity_type = entity_type
            self.entities = []  # only entities in default language
            self.translations = []
            self.tags = defaultdict(list)
            self.categories = defaultdict(list)
            self.authors = defaultdict(list)
            self.drafts = [] # only drafts in default language
            self.drafts_translations = []
            self.sort_attrs = []
github barrysteyn / pelican_plugin-render_math / render_math.py View on Github external
For reStructuredText content, examine both articles and pages.
    If article or page is reStructuredText and there is math present,
    append the mathjax script.

    Also process summaries if present (only applies to articles)
    and user wants summaries processed (via user settings)
    """

    for generator in content_generators:
        if isinstance(generator, generators.ArticlesGenerator):
            for article in generator.articles + generator.translations:
                rst_add_mathjax(article)
                #optionally fix truncated formulae in summaries.
                if process_summary.mathjax_script is not None:
                    process_summary(article)
        elif isinstance(generator, generators.PagesGenerator):
            for page in generator.pages:
                rst_add_mathjax(page)
github AlexJF / pelican-entities / entities.py View on Github external
def EntityFactory(name, mandatory_properties, default_template, BaseClass=Entity):
    base_mandatory_properties = ['title']
    mandatory_properties = set(base_mandatory_properties + mandatory_properties)
    newclass = type(str(name), (BaseClass,),
                    {'type': name,
                     'mandatory_properties': mandatory_properties,
                     'default_template': default_template})
    return newclass


class EntityGenerator(generators.Generator):
    """ Generate entity pages for each defined entity type."""

    class EntitySubGenerator(generators.CachingGenerator):
        """Generate entity pages for a specific entity type."""

        def __init__(self, entity_type, *args, **kwargs):
            """initialize properties"""
            self.entity_type = entity_type
            self.entities = []  # only entities in default language
            self.translations = []
            self.tags = defaultdict(list)
            self.categories = defaultdict(list)
            self.authors = defaultdict(list)
            self.drafts = [] # only drafts in default language
            self.drafts_translations = []
            self.sort_attrs = []
            super(EntityGenerator.EntitySubGenerator, self).__init__(*args, cache_name=entity_type, **kwargs)
            entity_subgenerator_init.send(self)