view pages/documentation/page_meta.py @ 22:5fd933e238bb

massive refactoring from camelCase -> snake_case. See backend commit log for more details
author Goffi <goffi@goffi.org>
date Mon, 22 May 2023 09:11:54 +0200
parents f47d6ba74a26
children e7c7327f9f25
line wrap: on
line source

#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-

from sat.core.log import getLogger
from sat.core.i18n import _

log = getLogger(__name__)

name = "documentation"
template = "doc/doc.html"

allowed_docs = None


def parse_url(self, request):
    """URL is /[DOC_NAME]"""
    global allowed_docs
    template_data = request.template_data

    if allowed_docs is None:
        allowed_docs = sorted(self.config_get("sub_docs_dict", {}).keys())
        try:
            allowed_docs.remove('backend')
        except KeyError:
            log.error("backend doc not available")
        else:
            allowed_docs.insert(0, "backend")
    try:
        doc_name = self.next_path(request)
    except IndexError:
        doc_name = 'backend'
    else:
        if doc_name not in allowed_docs:
            log.warning(_("unknown doc name: {doc_name}").format(doc_name=doc_name))
            doc_name = 'backend'
    template_data['doc_name'] = doc_name
    template_data['all_docs'] = allowed_docs