Esempio n. 1
0
def get_markdown_docs() -> Generator[Document, None, None]:
    for path in DOCS_DIR.glob('**/*.md'):
        name, _ = os.path.splitext(str(path.relative_to(DOCS_DIR)))

        # sanity check that the file is under the directory we expect
        assert DOCS_DIR in path.parents

        with path.open() as f:
            text, meta = text_and_meta(f)

        if 'title' not in meta:
            raise ValueError(f'Document {name} lacks required title meta variable.')

        yield Document(
            name='/' + name,
            title=meta['title'],
            render=partial(render_markdown_doc, path, meta, text),
        )
Esempio n. 2
0
from django.conf.urls import url
from django.http import Http404

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()
Esempio n. 3
0
from ocfweb.docs.doc import Document
from ocfweb.docs.markdown_based import get_markdown_docs
from ocfweb.docs.views.account_policies import account_policies
from ocfweb.docs.views.commands import commands
from ocfweb.docs.views.hosting_badges import hosting_badges
from ocfweb.docs.views.index import docs_index
from ocfweb.docs.views.lab import lab
from ocfweb.docs.views.officers import officers
from ocfweb.docs.views.servers import servers
from ocfweb.docs.views.stretch_upgrade import stretch_upgrade

DOCS = {
    doc.name: doc
    for doc in chain(
        [
            Document(name='/about/officers', title='Officers',
                     render=officers),
            Document(name='/staff/backend/servers',
                     title='Servers',
                     render=servers),
            Document(name='/staff/backend/stretch',
                     title='Debian Stretch upgrade',
                     render=stretch_upgrade),
            Document(name='/services/account/account-policies',
                     title='Account policies',
                     render=account_policies),
            Document(name='/services/vhost/badges',
                     title='Hosting badges',
                     render=hosting_badges),
            Document(name='/services/lab', title='Computer lab', render=lab),
            Document(name='/services/shell/commands',
                     title='Command reference',
Esempio n. 4
0
from itertools import chain

from django.conf.urls import url
from django.http import Http404

from ocfweb.docs.doc import Document
from ocfweb.docs.markdown_based import get_markdown_docs
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),
        ],
        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)

Esempio n. 5
0
from ocfweb.docs.markdown_based import get_markdown_docs
from ocfweb.docs.views.account_policies import account_policies
from ocfweb.docs.views.buster_upgrade import buster_upgrade
from ocfweb.docs.views.commands import commands
from ocfweb.docs.views.hosting_badges import hosting_badges
from ocfweb.docs.views.index import docs_index
from ocfweb.docs.views.lab import lab
from ocfweb.docs.views.officers import officers
from ocfweb.docs.views.servers import servers
from ocfweb.docs.views.shorturl import shorturl

DOCS = {
    doc.name: doc
    for doc in chain(
        [
            Document(name='/about/officers', title='Officers',
                     render=officers),
            Document(name='/staff/backend/servers',
                     title='Servers',
                     render=servers),
            Document(name='/staff/backend/buster',
                     title='Debian Buster upgrade',
                     render=buster_upgrade),
            Document(name='/services/account/account-policies',
                     title='Account policies',
                     render=account_policies),
            Document(name='/services/vhost/badges',
                     title='Hosting badges',
                     render=hosting_badges),
            Document(name='/services/lab', title='Computer lab', render=lab),
            Document(name='/services/shell/commands',
                     title='Command reference',
Esempio n. 6
0
from django.http import Http404

from ocfweb.docs.doc import Document
from ocfweb.docs.markdown_based import get_markdown_docs
from ocfweb.docs.views.commands import commands
from ocfweb.docs.views.hosting_badges import hosting_badges
from ocfweb.docs.views.index import docs_index
from ocfweb.docs.views.lab import lab
from ocfweb.docs.views.officers import officers
from ocfweb.docs.views.servers import servers

DOCS = {
    doc.name: doc
    for doc in chain(
        [
            Document(name='/about/officers', title='Officers',
                     render=officers),
            Document(name='/staff/backend/servers',
                     title='Servers',
                     render=servers),
            Document(name='/services/vhost/badges',
                     title='Hosting badges',
                     render=hosting_badges),
            Document(name='/services/lab', title='Computer lab', render=lab),
            Document(name='/services/shell/commands',
                     title='Command reference',
                     render=commands),
        ],
        get_markdown_docs(),
    )
}