-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from pdelboca/2.10-support
Add support for 2.10
- Loading branch information
Showing
3 changed files
with
38 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,38 @@ | ||
# encoding: utf-8 | ||
|
||
import logging | ||
from six import text_type | ||
import ckan.plugins as p | ||
|
||
log = logging.getLogger(__name__) | ||
ignore_empty = p.toolkit.get_validator('ignore_empty') | ||
ignore_empty = p.toolkit.get_validator("ignore_empty") | ||
url_validator = p.toolkit.get_validator("url_validator") | ||
|
||
|
||
class PDFView(p.SingletonPlugin): | ||
'''This plugin makes views of PDF resources, using an <object> tag''' | ||
"""This plugin makes views of PDF resources, using an <object> tag""" | ||
|
||
p.implements(p.IConfigurer, inherit=True) | ||
p.implements(p.IResourceView, inherit=True) | ||
|
||
def update_config(self, config): | ||
p.toolkit.add_template_directory(config, 'theme/templates') | ||
p.toolkit.add_template_directory(config, "theme/templates") | ||
|
||
def info(self): | ||
return {'name': 'pdf_view', | ||
'title': p.toolkit._('PDF'), | ||
'icon': 'file-pdf-o', | ||
'schema': {'pdf_url': [ignore_empty, text_type]}, | ||
'iframed': False, | ||
'always_available': False, | ||
'default_title': p.toolkit._('PDF'), | ||
} | ||
return { | ||
"name": "pdf_view", | ||
"title": p.toolkit._("PDF"), | ||
"icon": "file-pdf-o", | ||
"schema": {"pdf_url": [ignore_empty, url_validator]}, | ||
"iframed": False, | ||
"always_available": False, | ||
"default_title": p.toolkit._("PDF"), | ||
} | ||
|
||
def can_view(self, data_dict): | ||
return (data_dict['resource'].get('format', '').lower() == 'pdf') | ||
return data_dict["resource"].get("format", "").lower() == "pdf" | ||
|
||
def view_template(self, context, data_dict): | ||
return 'pdf_view.html' | ||
return "pdf_view.html" | ||
|
||
def form_template(self, context, data_dict): | ||
return 'pdf_form.html' | ||
return "pdf_form.html" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters