def footer_html(request):
    """Render and return footer markup."""
    # TODO refactor this function
    # pylint: disable=too-many-locals
    project_slug = request.GET.get('project', None)
    version_slug = request.GET.get('version', None)
    page_slug = request.GET.get('page', '')
    theme = request.GET.get('theme', False)
    docroot = request.GET.get('docroot', '')
    subproject = request.GET.get('subproject', False)
    source_suffix = request.GET.get('source_suffix', '.rst')

    # Hack in a fix for missing version slug deploy that went out a while back
    if version_slug == '':
        version_slug = LATEST

    new_theme = (theme == 'sphinx_rtd_theme')
    using_theme = (theme == 'default')
    project = get_object_or_404(Project, slug=project_slug)
    version = get_object_or_404(
        Version.objects.public(
            request.user,
            project=project,
            only_active=False,
        ),
        slug__iexact=version_slug,
    )
    main_project = project.main_language_project or project

    if page_slug and page_slug != 'index':
        if main_project.documentation_type == 'sphinx_htmldir':
            path = page_slug + '/'
        else:
            path = page_slug + '.html'
    else:
        path = ''

    version_compare_data = get_version_compare_data(project, version)

    context = {
        'project': project,
        'version': version,
        'path': path,
        'downloads': version.get_downloads(pretty=True),
        'current_version': version.verbose_name,
        'versions': project.ordered_active_versions(user=request.user),
        'main_project': main_project,
        'translations': main_project.translations.all(),
        'current_language': project.language,
        'using_theme': using_theme,
        'new_theme': new_theme,
        'settings': settings,
        'subproject': subproject,
        'github_edit_url': version.get_github_url(
            docroot,
            page_slug,
            source_suffix,
            'edit',
        ),
        'github_view_url': version.get_github_url(
            docroot,
            page_slug,
            source_suffix,
            'view',
        ),
        'gitlab_edit_url': version.get_gitlab_url(
            docroot,
            page_slug,
            source_suffix,
            'edit',
        ),
        'gitlab_view_url': version.get_gitlab_url(
            docroot,
            page_slug,
            source_suffix,
            'view',
        ),
        'bitbucket_url': version.get_bitbucket_url(
            docroot,
            page_slug,
            source_suffix,
        ),
        'theme': theme,
    }

    html = template_loader.get_template('restapi/footer.html').render(
        context,
        request,
    )
    resp_data = {
        'html': html,
        'show_version_warning': project.show_version_warning,
        'version_active': version.active,
        'version_compare': version_compare_data,
        'version_supported': version.supported,
    }

    # Allow folks to hook onto the footer response for various information
    # collection, or to modify the resp_data.
    footer_response.send(
        sender=None,
        request=request,
        context=context,
        resp_data=resp_data,
    )

    return Response(resp_data)
示例#2
0
def footer_html(request):
    """Render and return footer markup."""
    # TODO refactor this function
    # pylint: disable=too-many-locals
    project_slug = request.GET.get('project', None)
    version_slug = request.GET.get('version', None)
    page_slug = request.GET.get('page', '')
    theme = request.GET.get('theme', False)
    docroot = request.GET.get('docroot', '')
    subproject = request.GET.get('subproject', False)
    source_suffix = request.GET.get('source_suffix', '.rst')

    # Hack in a fix for missing version slug deploy that went out a while back
    if version_slug == '':
        version_slug = LATEST

    new_theme = (theme == 'sphinx_rtd_theme')
    using_theme = (theme == 'default')
    project = get_object_or_404(Project, slug=project_slug)
    version = get_object_or_404(
        Version.objects.public(
            request.user,
            project=project,
            only_active=False,
        ),
        slug__iexact=version_slug,
    )
    main_project = project.main_language_project or project

    if page_slug and page_slug != 'index':
        if main_project.documentation_type == 'sphinx_htmldir':
            path = page_slug + '/'
        else:
            path = page_slug + '.html'
    else:
        path = ''

    version_compare_data = get_version_compare_data(project, version)

    context = {
        'project':
        project,
        'version':
        version,
        'path':
        path,
        'downloads':
        version.get_downloads(pretty=True),
        'current_version':
        version.verbose_name,
        'versions':
        project.ordered_active_versions(user=request.user),
        'main_project':
        main_project,
        'translations':
        main_project.translations.all(),
        'current_language':
        project.language,
        'using_theme':
        using_theme,
        'new_theme':
        new_theme,
        'settings':
        settings,
        'subproject':
        subproject,
        'github_edit_url':
        version.get_github_url(
            docroot,
            page_slug,
            source_suffix,
            'edit',
        ),
        'github_view_url':
        version.get_github_url(
            docroot,
            page_slug,
            source_suffix,
            'view',
        ),
        'gitlab_edit_url':
        version.get_gitlab_url(
            docroot,
            page_slug,
            source_suffix,
            'edit',
        ),
        'gitlab_view_url':
        version.get_gitlab_url(
            docroot,
            page_slug,
            source_suffix,
            'view',
        ),
        'bitbucket_url':
        version.get_bitbucket_url(
            docroot,
            page_slug,
            source_suffix,
        ),
        'theme':
        theme,
    }

    html = template_loader.get_template('restapi/footer.html').render(
        context,
        request,
    )
    resp_data = {
        'html': html,
        'show_version_warning': project.show_version_warning,
        'version_active': version.active,
        'version_compare': version_compare_data,
        'version_supported': version.supported,
    }

    # Allow folks to hook onto the footer response for various information
    # collection, or to modify the resp_data.
    footer_response.send(
        sender=None,
        request=request,
        context=context,
        resp_data=resp_data,
    )

    return Response(resp_data)
示例#3
0
def footer_html(request):
    """Render and return footer markup."""
    # TODO refactor this function
    # pylint: disable=too-many-locals
    project_slug = request.GET.get('project', None)
    version_slug = request.GET.get('version', None)
    page_slug = request.GET.get('page', None)
    theme = request.GET.get('theme', False)
    docroot = request.GET.get('docroot', '')
    subproject = request.GET.get('subproject', False)
    source_suffix = request.GET.get('source_suffix', '.rst')

    new_theme = (theme == 'sphinx_rtd_theme')
    using_theme = (theme == 'default')
    project = get_object_or_404(Project, slug=project_slug)
    version = get_object_or_404(
        Version.objects.public(
            request.user, project=project, only_active=False),
        slug=version_slug)
    main_project = project.main_language_project or project

    if page_slug and page_slug != 'index':
        if (main_project.documentation_type == 'sphinx_htmldir' or
                main_project.documentation_type == 'mkdocs'):
            path = page_slug + '/'
        elif main_project.documentation_type == 'sphinx_singlehtml':
            path = 'index.html#document-' + page_slug
        else:
            path = page_slug + '.html'
    else:
        path = ''

    if version.type == TAG and version.project.has_pdf(version.slug):
        print_url = (
            'https://keminglabs.com/print-the-docs/quote?project={project}&version={version}'  # noqa
            .format(project=project.slug, version=version.slug))
    else:
        print_url = None

    version_compare_data = get_version_compare_data(project, version)

    context = {
        'project': project,
        'version': version,
        'path': path,
        'downloads': version.get_downloads(pretty=True),
        'current_version': version.verbose_name,
        'versions': project.ordered_active_versions(user=request.user),
        'main_project': main_project,
        'translations': main_project.translations.all(),
        'current_language': project.language,
        'using_theme': using_theme,
        'new_theme': new_theme,
        'settings': settings,
        'subproject': subproject,
        'print_url': print_url,
        'github_edit_url': version.get_github_url(
            docroot,
            page_slug,
            source_suffix,
            'edit',
        ),
        'github_view_url': version.get_github_url(
            docroot,
            page_slug,
            source_suffix,
            'view',
        ),
        'gitlab_edit_url': version.get_gitlab_url(
            docroot,
            page_slug,
            source_suffix,
            'edit',
        ),
        'gitlab_view_url': version.get_gitlab_url(
            docroot,
            page_slug,
            source_suffix,
            'view',
        ),
        'bitbucket_url': version.get_bitbucket_url(
            docroot,
            page_slug,
            source_suffix,
        ),
        'theme': theme,
    }

    html = template_loader.get_template('restapi/footer.html').render(
        context,
        request,
    )
    resp_data = {
        'html': html,
        'version_active': version.active,
        'version_compare': version_compare_data,
        'version_supported': version.supported,
    }

    # Allow folks to hook onto the footer response for various information
    # collection, or to modify the resp_data.
    footer_response.send(
        sender=None,
        request=request,
        context=context,
        resp_data=resp_data,
    )

    return Response(resp_data)
示例#4
0
def footer_html(request):
    project_slug = request.GET.get('project', None)
    version_slug = request.GET.get('version', None)
    page_slug = request.GET.get('page', None)
    theme = request.GET.get('theme', False)
    docroot = request.GET.get('docroot', '')
    subproject = request.GET.get('subproject', False)
    source_suffix = request.GET.get('source_suffix', '.rst')

    new_theme = (theme == "sphinx_rtd_theme")
    using_theme = (theme == "default")
    project = get_object_or_404(Project, slug=project_slug)
    version = get_object_or_404(Version.objects.public(request.user,
                                                       project=project,
                                                       only_active=False),
                                slug=version_slug)
    main_project = project.main_language_project or project

    if page_slug and page_slug != "index":
        if (main_project.documentation_type == "sphinx_htmldir"
                or main_project.documentation_type == "mkdocs"):
            path = page_slug + "/"
        elif main_project.documentation_type == "sphinx_singlehtml":
            path = "index.html#document-" + page_slug
        else:
            path = page_slug + ".html"
    else:
        path = ""

    if version.type == TAG and version.project.has_pdf(version.slug):
        print_url = (
            'https://keminglabs.com/print-the-docs/quote?project={project}&version={version}'
            .format(project=project.slug, version=version.slug))
    else:
        print_url = None

    version_compare_data = get_version_compare_data(project, version)

    context = {
        'project':
        project,
        'version':
        version,
        'path':
        path,
        'downloads':
        version.get_downloads(pretty=True),
        'current_version':
        version.verbose_name,
        'versions':
        project.ordered_active_versions(user=request.user),
        'main_project':
        main_project,
        'translations':
        main_project.translations.all(),
        'current_language':
        project.language,
        'using_theme':
        using_theme,
        'new_theme':
        new_theme,
        'settings':
        settings,
        'subproject':
        subproject,
        'print_url':
        print_url,
        'github_edit_url':
        version.get_github_url(docroot, page_slug, source_suffix, 'edit'),
        'github_view_url':
        version.get_github_url(docroot, page_slug, source_suffix, 'view'),
        'bitbucket_url':
        version.get_bitbucket_url(docroot, page_slug, source_suffix),
        'theme':
        theme,
    }

    request_context = RequestContext(request, context)
    html = template_loader.get_template('restapi/footer.html').render(
        request_context)
    resp_data = {
        'html': html,
        'version_active': version.active,
        'version_compare': version_compare_data,
        'version_supported': version.supported,
    }

    # Allow folks to hook onto the footer response for various information collection,
    # or to modify the resp_data.
    footer_response.send(sender=None,
                         request=request,
                         context=context,
                         resp_data=resp_data)

    return Response(resp_data)
def footer_html(request):
    """Render and return footer markup."""
    # TODO refactor this function
    # pylint: disable=too-many-locals
    project_slug = request.GET.get('project', None)
    version_slug = request.GET.get('version', None)
    page_slug = request.GET.get('page', None)
    theme = request.GET.get('theme', False)
    docroot = request.GET.get('docroot', '')
    subproject = request.GET.get('subproject', False)
    source_suffix = request.GET.get('source_suffix', '.rst')

    new_theme = (theme == "sphinx_rtd_theme")
    using_theme = (theme == "default")
    project = get_object_or_404(Project, slug=project_slug)
    version = get_object_or_404(
        Version.objects.public(request.user, project=project, only_active=False),
        slug=version_slug)
    main_project = project.main_language_project or project

    if page_slug and page_slug != "index":
        if (
                main_project.documentation_type == "sphinx_htmldir" or
                main_project.documentation_type == "mkdocs"):
            path = page_slug + "/"
        elif main_project.documentation_type == "sphinx_singlehtml":
            path = "index.html#document-" + page_slug
        else:
            path = page_slug + ".html"
    else:
        path = ""

    if version.type == TAG and version.project.has_pdf(version.slug):
        print_url = (
            'https://keminglabs.com/print-the-docs/quote?project={project}&version={version}'
            .format(
                project=project.slug,
                version=version.slug))
    else:
        print_url = None

    version_compare_data = get_version_compare_data(project, version)

    context = {
        'project': project,
        'version': version,
        'path': path,
        'downloads': version.get_downloads(pretty=True),
        'current_version': version.verbose_name,
        'versions': project.ordered_active_versions(user=request.user),
        'main_project': main_project,
        'translations': main_project.translations.all(),
        'current_language': project.language,
        'using_theme': using_theme,
        'new_theme': new_theme,
        'settings': settings,
        'subproject': subproject,
        'print_url': print_url,
        'github_edit_url': version.get_github_url(docroot, page_slug, source_suffix, 'edit'),
        'github_view_url': version.get_github_url(docroot, page_slug, source_suffix, 'view'),
        'bitbucket_url': version.get_bitbucket_url(docroot, page_slug, source_suffix),
        'theme': theme,
    }

    request_context = RequestContext(request, context)
    html = template_loader.get_template('restapi/footer.html').render(request_context)
    resp_data = {
        'html': html,
        'version_active': version.active,
        'version_compare': version_compare_data,
        'version_supported': version.supported,
    }

    # Allow folks to hook onto the footer response for various information collection,
    # or to modify the resp_data.
    footer_response.send(sender=None, request=request, context=context, resp_data=resp_data)

    return Response(resp_data)