~widelands-dev/widelands-website/django_staticfiles

« back to all changes in this revision

Viewing changes to sphinxdoc/views.py

  • Committer: franku
  • Date: 2016-12-13 18:28:51 UTC
  • mto: This revision was merged to the branch mainline in revision 443.
  • Revision ID: somal@arcor.de-20161213182851-bo5ebf8pdvw5beua
run the script

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    app = get_object_or_404(App, slug=slug)
24
24
    url = url.strip('/')
25
25
    page_name = os.path.basename(url)
26
 
    
 
26
 
27
27
    path = os.path.join(app.path, url, 'index.fjson')
28
28
    if not os.path.exists(path):
29
29
        path = os.path.dirname(path) + '.fjson'
34
34
        'sphinxdoc/%s.html' % page_name,
35
35
        'sphinxdoc/documentation.html',
36
36
    )
37
 
    
 
37
 
38
38
    data = {
39
39
        'app': app,
40
40
        'doc': json.load(open(path, 'rb')),
41
41
        'env': json.load(open(
42
 
                os.path.join(app.path, 'globalcontext.json'), 'rb')),
 
42
            os.path.join(app.path, 'globalcontext.json'), 'rb')),
43
43
        'version': app.name,
44
44
        'docurl': url,
45
45
        'update_date':  datetime.datetime.fromtimestamp(
46
 
                os.path.getmtime(os.path.join(app.path, 'last_build'))),
 
46
            os.path.getmtime(os.path.join(app.path, 'last_build'))),
47
47
        'home': app.get_absolute_url(),
48
48
        # 'search': urlresolvers.reverse('document-search', kwargs={'lang':lang, 'version':version}),
49
49
        'redirect_from': request.GET.get('from', None),
50
 
    
 
50
 
51
51
    }
52
52
    if 'title' not in data['doc']:
53
53
        data['doc']['title'] = SPECIAL_TITLES[page_name]
54
54
 
55
55
    return render_to_response(templates, data,
56
 
            context_instance=RequestContext(request))
 
56
                              context_instance=RequestContext(request))
 
57
 
57
58
 
58
59
def search(request, slug):
59
60
    from django.http import HttpResponse
60
61
    return HttpResponse('Not yet implemented.')
61
 
    
 
62
 
 
63
 
62
64
def objects_inventory(request, slug):
63
65
    app = get_object_or_404(App, slug=slug)
64
66
    response = static.serve(
65
 
        request, 
66
 
        document_root = app.path,
67
 
        path = "objects.inv",
 
67
        request,
 
68
        document_root=app.path,
 
69
        path='objects.inv',
68
70
    )
69
 
    response['Content-Type'] = "text/plain"
 
71
    response['Content-Type'] = 'text/plain'
70
72
    return response
71
73
 
 
74
 
72
75
def images(request, slug, path):
73
76
    app = get_object_or_404(App, slug=slug)
74
77
    return static.serve(
75
 
        request, 
76
 
        document_root = os.path.join(app.path, '_images'),
77
 
        path = path,
 
78
        request,
 
79
        document_root=os.path.join(app.path, '_images'),
 
80
        path=path,
78
81
    )
79
 
    
 
82
 
 
83
 
80
84
def source(request, slug, path):
81
85
    app = get_object_or_404(App, slug=slug)
82
86
    return static.serve(
83
87
        request,
84
 
        document_root = os.path.join(app.path, '_sources'),
85
 
        path = path,
 
88
        document_root=os.path.join(app.path, '_sources'),
 
89
        path=path,
86
90
    )