Пример #1
0
def get_page_context(page, content, toc, meta, config):
    """
    Generate the page context by extending the global context and adding page
    specific variables.
    """

    if page.is_homepage or page.title is None:
        page_title = None
    else:
        page_title = page.title

    if page.is_homepage:
        page_description = config['site_description']
    else:
        page_description = None

    if config['site_url']:
        base = config['site_url']
        if not base.endswith('/'):
            base += '/'
        canonical_url = urljoin(base, page.abs_url.lstrip('/'))
    else:
        canonical_url = None

    return {
        'page_title': page_title,
        'page_description': page_description,
        'content': content,
        'toc': toc,
        'meta': meta,
        'canonical_url': canonical_url,
        'current_page': page,
        'previous_page': page.previous_page,
        'next_page': page.next_page,
    }
Пример #2
0
def get_page_context(page, content, nav, toc, meta, config):
    """
    Generate the page context by extending the global context and adding page
    specific variables.
    """

    if page.is_homepage or page.title is None:
        page_title = config["site_name"]
    else:
        page_title = page.title + " - " + config["site_name"]

    if page.is_homepage:
        page_description = config["site_description"]
    else:
        page_description = None

    if config["site_url"]:
        base = config["site_url"]
        if not base.endswith("/"):
            base += "/"
        canonical_url = urljoin(base, page.abs_url.lstrip("/"))
    else:
        canonical_url = None

    return {
        "page_title": page_title,
        "page_description": page_description,
        "content": content,
        "toc": toc,
        "meta": meta,
        "canonical_url": canonical_url,
        "current_page": page,
        "previous_page": page.previous_page,
        "next_page": page.next_page,
    }
Пример #3
0
def get_context(page, content, nav, toc, meta, config):
    site_name = config['site_name']

    if page.is_homepage or page.title is None:
        page_title = site_name
    else:
        page_title = page.title + ' - ' + site_name

    if page.is_homepage:
        page_description = config['site_description']
    else:
        page_description = None

    if config['site_url']:
        base = config['site_url']
        if not base.endswith('/'):
            base += '/'
        canonical_url = urljoin(base, page.abs_url.lstrip('/'))
    else:
        canonical_url = None

    if config['site_favicon']:
        site_favicon = nav.url_context.make_relative('/' +
                                                     config['site_favicon'])
    else:
        site_favicon = None

    return {
        'site_name': site_name,
        'site_author': config['site_author'],
        'favicon': site_favicon,
        'page_title': page_title,
        'page_description': page_description,
        'content': content,
        'toc': toc,
        'nav': nav,
        'meta': meta,
        'base_url': nav.url_context.make_relative('/'),
        'homepage_url': nav.homepage.url,
        'canonical_url': canonical_url,
        'current_page': page,
        'previous_page': page.previous_page,
        'next_page': page.next_page,

        # Note that there's intentionally repetition here. Rather than simply
        # provide the config dictionary we instead pass everything explicitly.
        #
        # This helps ensure that we can throughly document the context that
        # gets passed to themes.
        'repo_url': config['repo_url'],
        'repo_name': config['repo_name'],
        'extra_css': config['extra_css'],
        'extra_javascript': config['extra_javascript'],
        'include_nav': config['include_nav'],
        'include_next_prev': config['include_next_prev'],
        'include_search': config['include_search'],
        'copyright': config['copyright'],
        'google-analytics': config['google-analytics']
    }
Пример #4
0
def get_page_context(page, content, nav, toc, meta, config):
    """
    Generate the page context by extending the global context and adding page
    specific variables.
    """

    if page.is_homepage or page.title is None:
        page_title = config['site_name']
    else:
        page_title = page.title + ' - ' + config['site_name']

    if page.is_homepage:
        page_description = config['site_description']
    else:
        page_description = None

    if config['site_url']:
        base = config['site_url']
        if not base.endswith('/'):
            base += '/'
        canonical_url = urljoin(base, page.abs_url.lstrip('/'))
    else:
        canonical_url = None

    return {
        'page_title': page_title,
        'page_description': page_description,

        'content': content,
        'toc': toc,
        'meta': meta,


        'canonical_url': canonical_url,

        'current_page': page,
        'previous_page': page.previous_page,
        'next_page': page.next_page,
        'include_nav': config['include_nav'],
        'include_next_prev': config['include_next_prev'],
    }
Пример #5
0
def get_context(page, content, nav, toc, meta, config):
    site_name = config['site_name']

    if page.is_homepage or page.title is None:
        page_title = site_name
    else:
        page_title = page.title + ' - ' + site_name

    if page.is_homepage:
        page_description = config['site_description']
    else:
        page_description = None

    if config['site_url']:
        base = config['site_url']
        if not base.endswith('/'):
            base += '/'
        canonical_url = urljoin(base, page.abs_url.lstrip('/'))
    else:
        canonical_url = None

    if config['site_favicon']:
        site_favicon = nav.url_context.make_relative('/' + config['site_favicon'])
    else:
        site_favicon = None

    if config['extra_javascript']:
        config['extra_javascript'] = utils.create_media_urls(nav=nav, url_list=config['extra_javascript'])

    if config['extra_css']:
        config['extra_css'] = utils.create_media_urls(nav=nav, url_list=config['extra_css'])

    return {
        'site_name': site_name,
        'site_author': config['site_author'],
        'favicon': site_favicon,

        'page_title': page_title,
        'page_description': page_description,

        'content': content,
        'toc': toc,
        'nav': nav,
        'meta': meta,

        'base_url': nav.url_context.make_relative('/'),
        'homepage_url': nav.homepage.url,
        'canonical_url': canonical_url,

        'current_page': page,
        'previous_page': page.previous_page,
        'next_page': page.next_page,

        # Note that there's intentionally repetition here. Rather than simply
        # provide the config dictionary we instead pass everything explicitly.
        #
        # This helps ensure that we can throughly document the context that
        # gets passed to themes.
        'repo_url': config['repo_url'],
        'repo_name': config['repo_name'],

        'extra_css': config['extra_css'],
        'extra_javascript': config['extra_javascript'],

        'include_nav': config['include_nav'],
        'include_next_prev': config['include_next_prev'],
        'include_search': config['include_search'],

        'copyright': config['copyright'],
        'google-analytics': config['google-analytics']
    }