[ckan-dev] Datapreview
Toby Dacre
toby.okfn at gmail.com
Mon Sep 24 08:44:07 UTC 2012
Dominik,
As discussed briefly on irc on friday we need to make the datapreviewer
code tidier now that it is expanding in complexity to stop it becoming
spagetti. My suggestions are
a) move all the templates into their own directory.
/templates/package/dataviewer seems good enough for me. This includes the
data_preview snippet.
b) create a new data_preview_base.html template something like this to use
as the base for any preview pages to keep them simpler
{% extends "base.html" %}
{% block subtitle %}{{ h.dataset_display_name(c.package) }} - {{
h.resource_display_name(c.resource }}{% endblock %}
{# remove any scripts #}
{% block scripts %}
{% endblock %}
{# remove any ckan styles #}
{% block styles %}
{% endblock %}
{% block custom_styles %}
{% endblock %}
c) move to using a single route say
/dataset/{pkg_id}/resource/{res_id}/preview{style} where style could be
things like .recline, .json, .pdf etc we could use a regex in the route but
that seems overkill. This means that we just have a single controller
action.
d) merge the separate actions into a single one so they share logic and we
don't end up with situations like caring that a resource is in a package if
viewed by recline but not is json data etc
Once that is achieved then I would next look at
e) cleaning the templates formatting etc {{ _('...') }} not {{_('...')}}
etc minor but important and removing things like
{% resource 'base/main' %}
{% resource 'vendor/vendor' %}
f) consolidating the javascript we could probably just have a single
datapreview bundle
g) look at the _parse_recline_state() stuff first to get a requirements for
it and decide if some of these are not recline specific - also make a bit
more robust
h) look at stuff like do we need javascript to show the json? can we not
just <code>{{ c.resource_json }}</code> maybe some js for syntax
highlighting
What do you think of this as a plan going forward
Toby
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20120924/f2eb7244/attachment.html>
More information about the ckan-dev
mailing list