Commits

mitar committed ecd3d2e

Support also static and downloads files.

  • Participants
  • Parent commits 35911a7

Comments (0)

Files changed (2)

sphinxdoc/urls.py

         'images',
     ),
     url(
+        r'^(?P<slug>[\w-]+)/_static/(?P<path>.*)$',
+        'static',
+    ),
+    url(
+        r'^(?P<slug>[\w-]+)/_downloads/(?P<path>.*)$',
+        'downloads',
+    ),
+    url(
         r'^(?P<slug>[\w-]+)/_source/(?P<path>.*)$',
         'source',
     ),

sphinxdoc/views.py

 
 
 @cache_page(60 * CACHE_MINUTES)
+def static(request, slug, path):
+    """
+    Shows the specified static file.
+
+    """
+    project = get_object_or_404(Project, slug=slug)
+    return serve(
+        request,
+        document_root=os.path.join(project.path, BUILDDIR, '_static'),
+        path=path,
+    )
+
+
+@cache_page(60 * CACHE_MINUTES)
+def downloads(request, slug, path):
+    """
+    Shows the specified downloads file.
+
+    """
+    project = get_object_or_404(Project, slug=slug)
+    return serve(
+        request,
+        document_root=os.path.join(project.path, BUILDDIR, '_downloads'),
+        path=path,
+    )
+
+
+@cache_page(60 * CACHE_MINUTES)
 def source(request, slug, path):
     """
     Shows the ReST source of a document.