-
Notifications
You must be signed in to change notification settings - Fork 2k
/
plugin.py
32 lines (22 loc) · 882 Bytes
/
plugin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import logging
import ckan.plugins as p
log = logging.getLogger(__name__)
ignore_empty = p.toolkit.get_validator('ignore_empty')
DEFAULT_IMAGE_FORMATS = ['png', 'jpeg', 'jpg', 'gif']
class ImageView(p.SingletonPlugin):
'''This extenstion makes views of images'''
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')
def info(self):
return {'name': 'image',
'title': 'Image',
'schema': {'image_url': [ignore_empty, unicode]},
'iframed': False}
def can_view(self, data_dict):
return True
def view_template(self, context, data_dict):
return 'image_view.html'
def form_template(self, context, data_dict):
return 'image_form.html'