Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated docs site to work with the new setup.
- Loading branch information
Showing
11 changed files
with
156 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,50 @@ | ||
import djangodocs.views | ||
from django.conf import settings | ||
from django.conf.urls.defaults import * | ||
from . import views | ||
|
||
urlpatterns = patterns('', | ||
url( | ||
r'^$', | ||
djangodocs.views.index, | ||
views.index, | ||
), | ||
url( | ||
r'^(?P<lang>[a-z-]+)/$', | ||
djangodocs.views.language, | ||
views.language, | ||
), | ||
url( | ||
r'^(?P<lang>[a-z-]+)/(?P<version>[\w.-]+)/$', | ||
djangodocs.views.document, | ||
views.document, | ||
{'url': ''}, | ||
name = 'document-index', | ||
), | ||
url( | ||
r'^(?P<lang>[a-z-]+)/(?P<version>[\w.-]+)/search/$', | ||
djangodocs.views.search, | ||
views.search, | ||
name = 'document-search', | ||
), | ||
url( | ||
r'^(?P<lang>[a-z-]+)/(?P<version>[\w.-]+)/_objects/$', | ||
djangodocs.views.objects_inventory, | ||
views.objects_inventory, | ||
name = 'objects-inv', | ||
), | ||
url( | ||
r'^(?P<lang>[a-z-]+)/(?P<version>[\w.-]+)/_images/(?P<path>.*)$', | ||
djangodocs.views.images, | ||
views.images, | ||
), | ||
url( | ||
r'^(?P<lang>[a-z-]+)/(?P<version>[\w.-]+)/_source/(?P<path>.*)$', | ||
djangodocs.views.source, | ||
views.source, | ||
), | ||
url( | ||
r'^(?P<lang>[a-z-]+)/(?P<version>[\w.-]+)/(?P<url>[\w./-]*)/$', | ||
djangodocs.views.document, | ||
views.document, | ||
name = 'document-detail', | ||
), | ||
) | ||
|
||
if settings.DEBUG: | ||
urlpatterns += patterns('', | ||
url(r'^media/(?P<path>.*)$', | ||
'django.views.static.serve', | ||
{'document_root': settings.MEDIA_ROOT}), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from django.conf import settings | ||
from django.http import Http404 | ||
from unipath import FSPath as Path | ||
|
||
def get_doc_root(lang, version): | ||
return Path(settings.DOCS_BUILD_ROOT).child(lang, version, "_build", "json") | ||
|
||
def get_doc_root_or_404(lang, version): | ||
docroot = get_doc_root(lang, version) | ||
if not docroot.exists(): | ||
raise Http404(docroot) | ||
return docroot | ||
|
||
def get_doc_path(docroot, subpath): | ||
# First look for <bits>/index.fpickle, then for <bits>.fpickle | ||
bits = subpath.strip('/').split('/') + ['index.fjson'] | ||
doc = docroot.child(*bits) | ||
if doc.exists(): | ||
return doc | ||
|
||
bits = bits[:-2] + ['%s.fjson' % bits[-2]] | ||
doc = docroot.child(*bits) | ||
if doc.exists(): | ||
return doc | ||
|
||
return None | ||
|
||
def get_doc_path_or_404(docroot, subpath): | ||
doc = get_doc_path(docroot, subpath) | ||
if doc is None: | ||
raise Http404(doc) | ||
return doc |
Oops, something went wrong.