1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
from django import forms, http, template
from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404, render_to_response
from django.http import HttpResponse, Http404, HttpResponseServerError
import os, commands
from models import *
from settings import *
# Create your views here.
def frontpage(request):
t = fromslug('')
t.update()
return render_to_response('git_wiki/frontpage.html', \
dict(shortlog=shortlog(), tree=t))
def tree(request, reqslug, tree=None):
if not tree:
t = fromslug(reqslug)
if not t:
raise Http404
if t.type == 'blob':
return item(request, reqslug, blob=t)
else:
t = tree
t.update()
(heads,tags) = reposcan()
return render_to_response('git_wiki/tree.html',
dict(shortlog=shortlog(tree=t), tree=t,
heads=heads,tags=tags))
def item(request, reqslug, blob=None):
if not blob:
i = fromslug(reqslug)
if not i:
raise Http404
if i.type == 'tree':
return tree(request, reqslug)
else:
i = blob
i.update()
try:
from docutils.core import publish_parts
except ImportError:
if settings.DEBUG:
raise HttpResponseServerError(request)
else:
docutils_settings = getattr(settings, "GITWIKI_REST_SETTINGS", {})
parts = publish_parts(source=i.contents, writer_name="html4css1", settings_overrides=docutils_settings)
return render_to_response('git_wiki/item.html',
dict(item=i,doc=parts))
def olditem(request, hash):
i = get_object_or_404(Item, id=hash)
i.update()
return render_to_response('git_browse/olditem.html',
dict(item=i))
def view_commit(request, hash):
(heads, tags) = reposcan()
c = Commit(id=hash)
c.update()
return render_to_response('git_wiki/commit.html',
dict(heads=heads, tags=tags,
commit=c))
|