Skip to content

Commit

Permalink
moved previewable types to os.environ
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Nov 27, 2012
1 parent 6d483bb commit 8e48daf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 4 additions & 0 deletions ckan/config/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ def genshi_lookup_attr(cls, obj, key):
if not model.meta.engine:
model.init_model(engine)

# set which data types can be previewed natively
os.environ['DIRECT_EMBEDS'] = 'png, jpg, gif'
os.environ['LOADABLE'] = '''html, htm, rdf+xml, owl+xml, xml,
n3, n-triples, turtle, plain, atom, tsv, rss, txt, json'''

This comment has been minimized.

Copy link
@tobes

tobes Nov 28, 2012

Contributor

I was meaning in the application rather than the os,environ maybe I was not very clear you probably want it to be in the config see what other things do in that file eg template paths

This comment has been minimized.

Copy link
@domoritz

domoritz Nov 30, 2012

Author Contributor

Okay. I reverted the changes and will move the file types to the config file. What do you want to be in the environment.py file then?


for plugin in p.PluginImplementations(p.IConfigurable):
plugin.configure(config)
10 changes: 3 additions & 7 deletions ckan/lib/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import copy
from urllib import urlencode
import urlparse
import os

from paste.deploy.converters import asbool
from webhelpers.html import escape, HTML, literal, url_escape
Expand Down Expand Up @@ -1315,11 +1316,6 @@ def resource_preview(resource, pkg_id):
embeds a web page, recline or a pdf preview.
'''

DIRECT_EMBEDS = ['png', 'jpg', 'gif']
LOADABLE = ['html', 'htm', 'rdf+xml', 'owl+xml', 'xml', 'n3',
'n-triples', 'turtle', 'plain', 'atom', 'tsv', 'rss',
'txt', 'json']

format_lower = resource['format'].lower()
directly = False
url = ''
Expand All @@ -1338,10 +1334,10 @@ def resource_preview(resource, pkg_id):
if _can_be_previewed(data_dict):
url = url_for(controller='package', action='resource_datapreview',
resource_id=resource['id'], id=pkg_id, qualified=True)
elif format_lower in DIRECT_EMBEDS:
elif format_lower in os.environ.get('DIRECT_EMBEDS').split(','):
directly = True
url = resource['url']
elif format_lower in LOADABLE:
elif format_lower in os.environ.get('LOADABLE').split(','):
url = resource['url']
else:
log.info('No preview handler for resource type {0}'.format(format_lower))
Expand Down

0 comments on commit 8e48daf

Please sign in to comment.