Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[djangoproject.com] Fixed searching of multiple doc versions.

git-svn-id: http://code.djangoproject.com/svn/djangoproject.com@10068 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 48a9cf0b98683c105d0aba2225c371354d57b6e6 1 parent 00ea784
jacob authored
Showing with 12 additions and 8 deletions.
  1. +12 −8 djangodocs/views.py
View
20 djangodocs/views.py
@@ -25,11 +25,15 @@ def language(request, lang):
})
)
-def document(request, lang, version, url):
+def get_docroot(lang, version):
docroot = Path(settings.DOCS_PICKLE_ROOT).child(lang, version, "_build", "json")
if not docroot.exists():
raise Http404()
+ return docroot
+def document(request, lang, version, url):
+ docroot = get_docroot(lang, version)
+
# First look for <bits>/index.fpickle, then for <bits>.fpickle
bits = url.strip('/').split('/') + ['index.fjson']
doc = docroot.child(*bits)
@@ -57,25 +61,23 @@ def document(request, lang, version, url):
}))
def images(request, lang, version, path):
- if lang != 'en' or version != 'dev': raise Http404()
+ docroot = get_docroot(lang, version)
return django.views.static.serve(
request,
- document_root = Path(settings.DOCS_PICKLE_ROOT).child('_images'),
+ document_root = docroot.child('_images'),
path = path,
)
def source(request, lang, version, path):
- if lang != 'en' or version != 'dev': raise Http404()
+ docroot = get_docroot(lang, version)
return django.views.static.serve(
request,
- document_root = Path(settings.DOCS_PICKLE_ROOT).child('_sources'),
+ document_root = docroot.child('_sources'),
path = path,
)
def search(request, lang, version):
- if lang != 'en' or version != 'dev': raise Http404()
-
- docroot = Path(settings.DOCS_PICKLE_ROOT)
+ docroot = get_docroot(lang, version)
# Remove the 'cof' GET variable from the query string so that the page
# linked to by the Javascript fallback doesn't think its inside an iframe.
@@ -86,6 +88,8 @@ def search(request, lang, version):
return render_to_response('docs/search.html', RequestContext(request, {
'query': request.GET.get('q'),
'query_string': mutable_get.urlencode(),
+ 'lang': lang,
+ 'version': version,
'env': simplejson.load(open(docroot.child('globalcontext.json'), 'rb')),
'home': urlresolvers.reverse('document-index', kwargs={'lang':lang, 'version':version}),
'search': urlresolvers.reverse('document-search', kwargs={'lang':lang, 'version':version}),
Please sign in to comment.
Something went wrong with that request. Please try again.