[ckan-changes] commit/ckan: 2 new changesets
Bitbucket
commits-noreply at bitbucket.org
Fri Sep 30 23:19:38 UTC 2011
2 new changesets in ckan:
http://bitbucket.org/okfn/ckan/changeset/586455cc7eeb/
changeset: 586455cc7eeb
branch: feature-1357-datapreview
user: rgrp
date: 2011-09-28 03:27:29
summary: [package/read_core][s]: refactor to old layout with name/description as text in first column linking to resource and add a column named 'Actions'.
affected #: 1 file (-1 bytes)
--- a/ckan/templates/package/read_core.html Tue Sep 27 01:05:03 2011 +0100
+++ b/ckan/templates/package/read_core.html Wed Sep 28 02:27:29 2011 +0100
@@ -15,30 +15,25 @@
<h3>Resources</h3><table><thead>
- <th>Url</th>
- <th>Name/Description</th>
+ <th>Resource</th><th>Format</th>
+ <th>Actions</th></thead><py:for each="res in c.pkg_dict.get('resources', [])"><tr rel="dcat:distribution" resource="_:res${res.id}"
typeof="dcat:Distribution">
- <td>
- <a href="${res.get('url', '')}" target="_blank">${res.get('url', '')}</a>
- </td>
- <td>
- <py:choose test="">
- <py:when test="res.get('name')">
- <span property="rdfs:label">${res.name}</span>
- </py:when>
- <py:when test="res.get('description')">
- <span property="rdfs:label">${res.description}</span>
- </py:when>
- <py:otherwise test="">
- <em>(none)</em>
- </py:otherwise>
- </py:choose>
- </td>
- <td property="dc:format">${res.get('format', '')}</td>
+ <td>
+ <a href="${res.get('url', '')}" rel="dcat:accessURL" target="_blank">
+ <py:if test="res.get('name') or res.get('description')">
+ <span property="rdfs:label">${res.get('name') or res.get('description')}</span>
+ </py:if>
+ <py:if test="not(res.get('name') or res.get('description'))">
+ <em>(none)</em>
+ </py:if>
+ </a>
+ </td>
+ <td property="dc:format">${res.get('format', '')}</td>
+ <td></td></tr></py:for><py:if test="not len(c.pkg_dict.get('resources', []))">
http://bitbucket.org/okfn/ckan/changeset/22e728ecffee/
changeset: 22e728ecffee
branch: feature-1357-datapreview
user: rgrp
date: 2011-10-01 01:19:21
summary: [datapreview,js][s]: have preview buttons showing on dataset page (but do not do anything yet).
affected #: 1 file (-1 bytes)
--- a/ckan/public/scripts/application.js Wed Sep 28 02:27:29 2011 +0100
+++ b/ckan/public/scripts/application.js Sat Oct 01 00:19:21 2011 +0100
@@ -18,6 +18,11 @@
client: client
};
+ var isDatasetView = $('body.package.read').length > 0;
+ if (isDatasetView) {
+ CKAN.Utils.setupDataPreview();
+ }
+
var isDatasetNew = $('body.package.new').length > 0;
if (isDatasetNew) {
$('#save').val(CKAN.Strings.addDataset);
@@ -269,6 +274,92 @@
});
};
+ my.setupDataPreview = function() {
+ var dialogId = 'ckanext-datapreview-dialog';
+ my.createPreviewButtons($('.resources'));
+ };
+
+ /* Public: Creates the base UI for the plugin.
+ *
+ * Adds an additonal preview column to the resources table in the CKAN
+ * UI. Also requests the package from the api to see if there is any chart
+ * data stored and updates the preview icons accordingly.
+ *
+ * resources - The resources table wrapped in jQuery.
+ *
+ * Returns nothing.
+ */
+ my.createPreviewButtons = function(resources) {
+ resources.find('tr td:last-child').each(function(idx, element) {
+ var element = $(element);
+ var _format = $.trim(element.prev().text());
+
+ // do not create previews for some items
+ var _tformat = _format.toLowerCase();
+ if (
+ _tformat.indexOf('zip') != -1
+ ||
+ _tformat.indexOf('tgz') != -1
+ ||
+ _tformat.indexOf('targz') != -1
+ ||
+ _tformat.indexOf('gzip') != -1
+ ||
+ _tformat.indexOf('gz:') != -1
+ ||
+ _tformat.indexOf('word') != -1
+ ||
+ _tformat.indexOf('pdf') != -1
+ ||
+ _tformat === 'other'
+ )
+ {
+ return;
+ }
+
+ // TODO: get this from resource
+ var _url = "/resource.jsonp?_limit=30";
+
+ // An object that holds information about the currently previewed data.
+ var _preview = {
+ 'source': element.find('a').attr('href'),
+ 'format': _format
+ };
+
+ var _previewSpan = $('<a />', {
+ text: 'Preview',
+ href: _url,
+ click: function(e) {
+ e.preventDefault();
+ alert('Loading preview');
+ // dp.loadPreviewDialog(e.target);
+ },
+ 'class': 'resource-preview-button'
+ }).data('preview', _preview).appendTo(element);
+
+ // TODO: get dataset info
+ var dataset = null;
+ var resource = null; // dp.getResourceFromDataset(_preview.hash, dataset),
+ var chartString, charts = {};
+
+ if (resource) {
+ chartString = resource[dp.resourceChartKey];
+ if (chartString) {
+ try {
+ charts = $.parseJSON(chartString);
+
+ // If parsing succeeds add a class to the preview button.
+ _previewSpan.addClass('resource-preview-chart');
+ } catch (e) {}
+ }
+ }
+
+ _preview.dataset = dataset;
+ _preview.resource = resource;
+ _preview.charts = charts;
+ });
+ };
+
// Name slug generator for $name element using $title element
//
// Also does nice things like show errors if name not available etc
Repository URL: https://bitbucket.org/okfn/ckan/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list