Esempio n. 1
0
def _render_static_content(request,
                           version,
                           content_id,
                           additional_context=None):
    """
    This is the primary function that renders all static content (.html) pages.
    It builds the context and passes it to the only documentation template rendering template.
    """
    isRaw = request.GET.get('raw', None)
    static_content_path = sitemap_helper.get_external_file_path(request.path)
    static_content = _get_static_content_from_template(static_content_path)

    if isRaw and isRaw == '1':
        response = HttpResponse(static_content, content_type="text/html")
        return response
    else:
        context = {
            'static_content': static_content,
            'content_id': content_id,
        }

        if additional_context:
            context.update(additional_context)

        template = 'content_panel.html'
        if content_id in [Content.MOBILE, Content.MODELS]:
            template = 'content_doc.html'

        response = render(request, template, context)
        if version:
            portal_helper.set_preferred_version(request, response, version)

        return response
Esempio n. 2
0
def _render_static_content(request,
                           version,
                           content_id,
                           additional_context=None):
    """
    This is the primary function that renders all static content (.html) pages.
    It builds the context and passes it to the only documentation template rendering template.
    """

    static_content_path = sitemap_helper.get_external_file_path(request.path)

    context = {
        'static_content':
        _get_static_content_from_template(static_content_path),
        'content_id': content_id,
    }

    if additional_context:
        context.update(additional_context)

    template = 'visualdl/content_panel.html'

    response = render(request, template, context)
    if version:
        portal_helper.set_preferred_version(response, version)

    return response
Esempio n. 3
0
def blog_sub_path(request, path):
    static_content_path = sitemap_helper.get_external_file_path(request.path)

    return render(request, 'content.html', {
        'static_content': _get_static_content_from_template(static_content_path),
        'content_id': Content.BLOG
    })
Esempio n. 4
0
def blog_root(request):
    path = sitemap_helper.get_external_file_path('blog/index.html')

    return render(request, 'content.html', {
        'static_content': _get_static_content_from_template(path),
        'content_id': Content.BLOG
    })
Esempio n. 5
0
def other_path(request, version, path=None):
    """
    Try to find the template associated with this path.
    """
    try:
        # If the template is found, render it.
        static_content_template = get_template(
            sitemap_helper.get_external_file_path(request.path))

    except TemplateDoesNotExist:
        # Else, fetch the page, and run through a generic stripper.
        fetch_and_transform(url_helper.GITHUB_ROOT + '/' + os.path.splitext(path)[0] + '.md', version)

    return _render_static_content(request, version, Content.OTHER)