Permalink
Browse files

Add more filetypes.

  • Loading branch information...
1 parent 9cdbc36 commit df86c7c6f7f860499e9d4421b184d9ff61c9049f Chris McDonough committed Jul 9, 2008
Showing with 31 additions and 7 deletions.
  1. +1 −1 repoze/virginia/__init__.py
  2. +7 −4 repoze/virginia/browser.py
  3. +22 −1 repoze/virginia/configure.zcml
  4. +1 −1 setup.cfg
@@ -14,5 +14,5 @@ def make_app(global_config, root=None):
def get_root(environ):
return Directory(fs, root)
import repoze.virginia
- return make_app(get_root, repoze.virginia)
+ return make_app(get_root, repoze.virginia, default_redirects=False)
View
@@ -2,6 +2,7 @@
import mimetypes
mimetypes.add_type('text/html', '.stx')
+mimetypes.add_type('application/pdf', '.pdf')
from zope.component import getMultiAdapter
from zope.structuredtext import stx2html
@@ -25,7 +26,7 @@ def __call__(self, *arg, **kw):
response = Response(result)
mt, encoding = mimetypes.guess_type(filename)
response.content_type = mt or 'text/plain'
- return Response(result)
+ return response
class DirectoryView(BrowserView):
defaults = ('index.html', 'index.stx')
@@ -38,9 +39,11 @@ def __call__(self, *arg, **kw):
pass
if index is None:
response = Response('No default view for %s' % self.context.path)
+ response.content_type = 'text/plain'
else:
fileview = FileView(index, self.request)
- return fileview()
+ response = fileview()
+ return response
class StructuredTextView(BrowserView):
""" Filesystem-based STX view
@@ -50,8 +53,8 @@ def __call__(self, *arg, **kw):
"""
return stx2html(self.context.source)
-class HTMLView(BrowserView):
- """ Filesystem-based HTML view
+class RawView(BrowserView):
+ """ Just return the source raw.
"""
def __call__(self, *arg, **kw):
""" Render html.
@@ -30,9 +30,30 @@
<browser:page
for=".interfaces.IFile"
- class=".browser.HTMLView"
+ class=".browser.RawView"
name=".html"
permission="repoze.view"
/>
+ <browser:page
+ for=".interfaces.IFile"
+ class=".browser.RawView"
+ name=".pdf"
+ permission="repoze.view"
+ />
+
+ <browser:page
+ for=".interfaces.IFile"
+ class=".browser.RawView"
+ name=".txt"
+ permission="repoze.view"
+ />
+
+ <browser:page
+ for=".interfaces.IFile"
+ class=".browser.RawView"
+ name=".jpg"
+ permission="repoze.view"
+ />
+
</configure>
View
@@ -1,3 +1,3 @@
[easy_install]
index_url = http://dist.repoze.org/bfg/dev/simple
-
+zip_ok = 0

0 comments on commit df86c7c

Please sign in to comment.