added view to serve images

--HG--
extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40514
This commit is contained in:
Ismael Carnales 2008-12-16 16:14:15 +00:00
parent aab5a4a7dd
commit 6766a39628
2 changed files with 11 additions and 0 deletions

View File

@ -2,11 +2,13 @@ from django.conf import settings
from django.conf.urls.defaults import *
from scrapyorg.docs.views import document
from scrapyorg.docs.views import images
urlpatterns = patterns('',
url(r'^$', document, {'url': ''}),
url(r'^(?P<url>[\w./-]*)/$', document),
url(r'^_images/(?P<path>.*)$', images),
)
if settings.DEBUG: # devel

View File

@ -1,6 +1,7 @@
import cPickle as pickle
import os
import django.views.static
from django.conf import settings
from django.http import Http404
from django.shortcuts import render_to_response
@ -22,3 +23,11 @@ def document(request, url):
return render_to_response('docs/doc.html', {'doc': doc},
context_instance=RequestContext(request))
def images(request, path):
return django.views.static.serve(
request,
document_root = os.path.join(settings.DOC_PICKLE_ROOT, '_images'),
path = path,
)