Example #1
0
from ocfweb.docs.views.hosting_badges import hosting_badges
from ocfweb.docs.views.index import docs_index
from ocfweb.docs.views.servers import servers

DOCS = {
    doc.name: doc
    for doc in chain(
        [
            Document(name='/staff/backend/servers',
                     title='Servers',
                     render=servers),
            Document(name='/services/vhost/badges',
                     title='Hosting badges',
                     render=hosting_badges),
        ],
        get_markdown_docs(),
    )
}


def render_doc(request, doc_name):
    """Render a document given a request."""
    doc = DOCS['/' + doc_name]
    if not doc:
        raise Http404()
    return doc.render(doc, request)


def doc_name(doc_name):
    # we can't actually deal with escaping into a regex, so we just use a whitelist
    assert re.match('^/[a-zA-Z\-/]+$',
Example #2
0
from ocfweb.docs.doc import Document
from ocfweb.docs.markdown_based import get_markdown_docs
from ocfweb.docs.views.hosting_badges import hosting_badges
from ocfweb.docs.views.index import docs_index
from ocfweb.docs.views.servers import servers


DOCS = {
    doc.name: doc
    for doc in chain(
        [
            Document(name='/staff/backend/servers', title='Servers', render=servers),
            Document(name='/services/vhost/badges', title='Hosting badges', render=hosting_badges),
        ],
        get_markdown_docs(),
    )
}


def render_doc(request, doc_name):
    """Render a document given a request."""
    doc = DOCS['/' + doc_name]
    if not doc:
        raise Http404()
    return doc.render(doc, request)


def doc_name(doc_name):
    # we can't actually deal with escaping into a regex, so we just use a whitelist
    assert re.match('^/[a-zA-Z\-/]+$', doc_name), 'Bad document name: ' + doc_name