Skip to content

Commit

Permalink
recline datapreview moved to extension
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Oct 19, 2012
1 parent ca8a274 commit 437ed46
Show file tree
Hide file tree
Showing 61 changed files with 40 additions and 4 deletions.
Empty file.
36 changes: 36 additions & 0 deletions ckanext/reclinepreview/plugin.py
@@ -0,0 +1,36 @@
from logging import getLogger

import ckan.plugins as p
import ckan.plugins.toolkit as toolkit

log = getLogger(__name__)


class ReclinePreview(p.SingletonPlugin):
"""This extension previews resources using recline
This extension implements two interfaces
- ``IConfigurer`` allows to modify the configuration
- ``IResourcePreview`` allows to add previews
"""
p.implements(p.IConfigurer, inherit=True)
p.implements(p.IResourcePreview, inherit=True)

def update_config(self, config):
''' Set up the resource library, public directory and
template directory for the preview
'''
toolkit.add_public_directory(config, 'theme/public')
toolkit.add_template_directory(config, 'theme/templates')
toolkit.add_resource('theme/public', 'ckanext-reclinepreview')

def requires_same_orign(self, resource):
return False

def can_preview(self, resource):
format_lower = resource['format'].lower()
return format_lower in ['csv', 'xls', 'tsv']

def preview_template(self, context):
return 'recline.html'
Expand Up @@ -7,12 +7,11 @@ lte IE 8 =

[depends]

datapreview-frame = base/ckan
recline = base/main
main = base/main

[groups]

recline =
main =
vendor/underscore/underscore.js
vendor/backbone/backbone.js
vendor/mustache/mustache.js
Expand Down
Expand Up @@ -11,5 +11,5 @@ <h4 class="loading-dialog">

{% block scripts %}
{{ super() }}
{% resource 'datapreview/recline' %}
{% resource 'ckanext-reclinepreview/main' %}
{% endblock %}
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -121,6 +121,7 @@
test_tag_vocab_plugin=ckanext.test_tag_vocab_plugin:MockVocabTagsPlugin
jsonpreview=ckanext.jsonpreview.plugin:JsonPreview
pdfpreview=ckanext.pdfpreview.plugin:PdfPreview
reclinepreview=ckanext.reclinepreview.plugin:ReclinePreview
[ckan.system_plugins]
domain_object_mods = ckan.model.modification:DomainObjectModificationExtension
Expand Down

0 comments on commit 437ed46

Please sign in to comment.