Ejemplo n.º 1
0
def wiki_view(page, request):
    # TODO wait what happens if the path is empty

    # If we got here and the URL has no trailing slash, redirect and add it.
    # (Only files and /@@foo are allowed to not have a trailing slash.)
    # TODO any cleaner way to do this, or cleaner place to do it?  i can't use
    # append_slash because core has dibs on the notfound view, and anyway i
    # want a consistent url for pages that /do/ exist too
    if not request.path.endswith('/'):
        new_url = request.path_url + '/'
        if request.query_string:
            new_url += '?'
            new_url += request.query_string
        raise HTTPMovedPermanently(location=new_url)

    if not page.exists:
        # TODO what if it exists, but is a directory, or unreadable, or etc.?
        # TODO should offer spelling suggestions...  eventually
        # TODO should examine the hierarchy to see if the parent exist, or any
        # children exist
        # TODO possibly a URL containing a dot somewhere (or @@, or whatever)
        # should not end up here?
        request.response.status_int = 404
        return render_to_response('spline_wiki:templates/missing.mako',
                                  dict(page=page),
                                  request=request)

    # TODO maybe i should go through git for this too, in case the repo is
    # bare.  bare repo actually sounds like an ok idea.
    content = render_prose(page.read())

    return dict(
        page=page,
        content=content,
    )
Ejemplo n.º 2
0
def wiki_view(page, request):
    # TODO wait what happens if the path is empty

    # If we got here and the URL has no trailing slash, redirect and add it.
    # (Only files and /@@foo are allowed to not have a trailing slash.)
    # TODO any cleaner way to do this, or cleaner place to do it?  i can't use
    # append_slash because core has dibs on the notfound view, and anyway i
    # want a consistent url for pages that /do/ exist too
    if not request.path.endswith('/'):
        new_url = request.path_url + '/'
        if request.query_string:
            new_url += '?'
            new_url += request.query_string
        raise HTTPMovedPermanently(location=new_url)

    if not page.exists:
        # TODO what if it exists, but is a directory, or unreadable, or etc.?
        # TODO should offer spelling suggestions...  eventually
        # TODO should examine the hierarchy to see if the parent exist, or any
        # children exist
        # TODO possibly a URL containing a dot somewhere (or @@, or whatever)
        # should not end up here?
        request.response.status_int = 404
        return render_to_response(
            'spline_wiki:templates/missing.mako',
            dict(page=page),
            request=request)

    # TODO maybe i should go through git for this too, in case the repo is
    # bare.  bare repo actually sounds like an ok idea.
    content = render_prose(page.read())

    return dict(
        page=page,
        content=content,
    )
Ejemplo n.º 3
0
Archivo: core.py Proyecto: eevee/spline
def render_markdown(request):
    markup = render_prose(request.POST['markdown'])
    return dict(markup=markup)
Ejemplo n.º 4
0
def render_markdown(request):
    markup = render_prose(request.POST['markdown'])
    return dict(markup=markup)