Esempio n. 1
0
def home(request):
    ctxt = {
        'sample': WikiPage.objects.get(name='home'),
    }
    
    
    return context_response(request, 'homepage.html', ctxt)
Esempio n. 2
0
def show_page(request, page_slug=None, show_src=False):
    """
    Show a WikiPage (or redirect to LUAU_DEFAULT_SLUG)
    """
    
    if not page_slug:
        page_slug = slugify(request.GET.get('new', settings.LUAU_DEFAULT_SLUG))
        title = request.GET.get('title', request.GET.get('new', settings.LUAU_DEFAULT_SLUG))
        try:
            page = WikiPage.objects.get(name=page_slug)
            return redirect('/wiki/%s' % (page_slug))
        except WikiPage.DoesNotExist:
            return redirect('/wiki/%s?title=%s' % (page_slug, title))
        
    try:
        page = WikiPage.objects.get(name=page_slug)
    except WikiPage.DoesNotExist:
        title = request.GET.get('title', page_slug)
        return redirect('/wiki/%s/edit?title=%s' % (page_slug, title))
    
    ctxt = dict(
        page=page,
        pages=WikiPage.objects.all(),
        show_src=show_src,
    )
         
    return context_response(request, 'luau/show.html', ctxt)
Esempio n. 3
0
def edit_page(request, page_slug=None):
    """
    Edit a WikiPage
    """
    try:
        page = WikiPage.objects.get(name=page_slug)
    except WikiPage.DoesNotExist:
        page = WikiPage(name=page_slug, title=request.GET.get('title', page_slug))
    
    if request.POST.get('action', None) == 'edit':
        form = WikiPageForm(request.POST, instance=page)
        if form.is_valid():
            form.instance.save()
            return redirect('luau.views.show_page', page_slug=page_slug)
        else:
            return context_response(request, 'luau/edit.html', {'form':form})
    
    ctxt = dict(
        form=WikiPageForm(instance=page),
        page=page,
        pages=WikiPage.objects.all(),
        )
    
    return context_response(request, 'luau/edit.html', ctxt)
Esempio n. 4
0
def syntax(request):
    ctxt = {}
    return context_response(request, 'tangle/syntax.html', ctxt)