Skip to content

Commit

Permalink
Fix broken IResourcePreview docstring
Browse files Browse the repository at this point in the history
Not spell-checked, not following CKAN's docstring guidelines, contained
Sphinx errors. I also rewrote it for clarity.
  • Loading branch information
Sean Hammond committed Aug 26, 2013
1 parent 2787a73 commit 3f4db25
Showing 1 changed file with 29 additions and 22 deletions.
51 changes: 29 additions & 22 deletions ckan/plugins/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,33 +196,40 @@ def notify(self, resource):


class IResourcePreview(Interface):
"""
Hook into the resource previews in helpers.py. This lets you
create custom previews for example for xml files.
"""
'''Add custom data previews for resource file-types.
'''
def can_preview(self, data_dict):
'''
Returns info on whether the plugin can preview the resource.
'''Return info on whether the plugin can preview the resource.
This can be done in two ways.
The old way is to just return True or False.
The new way is to return a dict with the following
{
'can_preview': bool - if the extension can preview the resource
'fixable': string - if the extension cannot preview but could for
example if the resource_proxy was enabled.
'quality': int - how good the preview is 1-poor, 2-average, 3-good
used if multiple extensions can preview
}
This can be done in two ways:
The ``data_dict`` contains the resource and the package.
1. The old way is to just return ``True`` or ``False``.
2. The new way is to return a dict with three keys:
``'can_preview'`` (``boolean``)
``True`` if the extension can preview the resource.
``'fixable'`` (``string``)
A string explaining how preview for the resource could be enabled,
for example if the ``resource_proxy`` plugin was enabled.
``'quality'`` (``int``)
How good the preview is: ``1`` (poor), ``2`` (average) or
``3`` (good). When multiple preview extensions can preview the
same resource, this is used to determine which extension will
be used.
:param data_dict: the resource to be previewed and the dataset that it
belongs to.
:type data_dict: dictionary
Make sure to check the ``on_same_domain`` value of the resource or the
url if your preview requires the resource to be on the same domain
because of the same-origin policy. To find out how to preview
resources that are on a different domain, read :ref:`resource-proxy`.
Make sure to ckeck the ``on_same_domain`` value of the
resource or the url if your preview requires the resource to be on
the same domain because of the same origin policy.
To find out how to preview resources that are on a
different domain, read :ref:`resource-proxy`.
'''

def setup_template_variables(self, context, data_dict):
Expand Down

0 comments on commit 3f4db25

Please sign in to comment.