How to use the pelican.generators.ArticlesGenerator 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 cmacmackin / scribbler / scribbler / render_math / math.py View on Github external
Ensure mathjax script is applied to RST and summaries are
    corrected if specified in user settings.

    Handles content attached to ArticleGenerator and PageGenerator objects,
    since the plugin doesn't know how to handle other Generator types.

    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 pyvideo / pyvideo / plugins / aggregations.py View on Github external
def _inject_aggregates(generator):
    if isinstance(generator, generators.ArticlesGenerator):
        latest_categories = sorted(_categories.values(), key=lambda x: x.get('latest'), reverse=True)[:5]
        active_speakers = sorted(_speakers.values(), key=lambda x: x.get('count'), reverse=True)
        active_tags = sorted(_tags.values(), key=lambda x: x.get('count'), reverse=True)
        fn = generator.settings['VIDEO_LANGUAGE_NAMES']
        languages = sorted(map(lambda lang: (fn.get(lang.get('name'), lang.get('name')), lang.get('name'), lang.get('count'), lang.get('videos')), _languages.values()), reverse=True)
        active_languages = sorted(map(lambda lang: (lang.get('count'), fn.get(lang.get('name'), lang.get('name')), lang.get('name')), _languages.values()), reverse=True)
        # The actual category URL has to be fetched in the
        # article_generator_finalized hook in order for the event_info plugin to
        # have done its magic.
        for category in latest_categories:
            category['url'] = generator.event_by_name[category['name']].url
        generator.context['latest_categories'] = latest_categories
        generator.context['active_speakers'] = active_speakers
        generator.context['active_tags'] = active_tags
        generator.context['languages'] = languages
        generator.context['active_languages'] = active_languages
github pyvideo / pyvideo / plugins / event_info.py View on Github external
def _collect_event_info(generator):
    events = _load_events()
    if isinstance(generator, generators.ArticlesGenerator):
        event_by_name = {}
        for event in [x[0] for x in generator.categories]:
            meta = events.get(event.name)
            # Update the slug of the event with the one provided
            # by the metadata object.
            if meta and 'slug' in meta:
                event.slug = meta['slug']
            event.meta = meta
            event_by_name[event.name] = event
        generator.event_by_name = event_by_name
github barrysteyn / pelican_plugin-render_math / render_math.py View on Github external
Ensure mathjax script is applied to RST and summaries are
    corrected if specified in user settings.

    Handles content attached to ArticleGenerator and PageGenerator objects,
    since the plugin doesn't know how to handle other Generator types.

    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 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 / clean_summary / clean_summary.py View on Github external
def run_plugin(generators):
    for generator in generators:
        if isinstance(generator, ArticlesGenerator):
            for article in generator.articles:
                clean_summary(article)
github JenkinsDev / pelican-readtime / readtime.py View on Github external
def run_read_time(generators):
    for generator in generators:
        if isinstance(generator, ArticlesGenerator):
            for article in generator.articles:
                READTIME_PARSER.read_time(article)

        elif isinstance(generator, PagesGenerator):
            for page in generator.pages:
                READTIME_PARSER.read_time(page)
github mtgjson / mtgjson-website / plugins / i18n_subsites / i18n_subsites.py View on Github external
article.source_path, article._context)
    draft.status = 'draft'
    return draft


def page2hidden_page(page):
    '''Transform a Page to a hidden Page'''
    page.status = 'hidden'
    return page


class GeneratorInspector(object):
    '''Inspector of generator instances'''

    generators_info = {
        ArticlesGenerator: {
            'translations_lists': ['translations', 'drafts_translations'],
            'contents_lists': [('articles', 'drafts')],
            'hiding_func': article2draft,
            'policy': 'I18N_UNTRANSLATED_ARTICLES',
        },
        PagesGenerator: {
            'translations_lists': ['translations', 'hidden_translations'],
            'contents_lists': [('pages', 'hidden_pages')],
            'hiding_func': page2hidden_page,
            'policy': 'I18N_UNTRANSLATED_PAGES',
        },
    }

    def __init__(self, generator):
        '''Identify the best known class of the generator instance
github cmacmackin / pelican-cite / pelican_cite.py View on Github external
if not pyb_imported:
        logger.warn('`pelican-cite` failed to load dependency `pybtex`')
        return

    if 'PUBLICATIONS_SRC' in generators[0].settings:
        refs_file = generators[0].settings['PUBLICATIONS_SRC']
        try:
            global_bib = Parser().parse_file(refs_file)
        except PybtexError as e:
            logger.warn('`pelican_bibtex` failed to parse file %s: %s' % (
                refs_file,
                str(e)))

    # Process the articles and pages
    for generator in generators:
        if isinstance(generator, ArticlesGenerator):
            for article in (generator.articles +
                            generator.translations +
                            generator.drafts):
                process_content(article)
        elif isinstance(generator, PagesGenerator):
            for page in generator.pages:
                process_content(page)