From: Tom Rees Date: Fri, 29 Mar 2013 15:27:55 +0000 Subject: [304] most_popular_datasets can render a preview image X-Git-Url: http://maxious.lambdacomplex.org/git/?p=ckanext-ga-report.git&a=commitdiff&h=dad5ea149da26fbd35e6dec1563a22a929d43e81 --- [304] most_popular_datasets can render a preview image --- --- a/ckanext/ga_report/helpers.py +++ b/ckanext/ga_report/helpers.py @@ -80,7 +80,7 @@ return base.render_snippet('ga_report/ga_popular_single.html', **context) -def most_popular_datasets(publisher, count=20): +def most_popular_datasets(publisher, count=20, preview_image=None): if not publisher: _log.error("No valid publisher passed to 'most_popular_datasets'") @@ -92,7 +92,8 @@ 'dataset_count': len(results), 'datasets': results, - 'publisher': publisher + 'publisher': publisher, + 'preview_image': preview_image } return base.render_snippet('ga_report/publisher/popular.html', **ctx) --- a/ckanext/ga_report/public/css/ga_report.css +++ b/ckanext/ga_report/public/css/ga_report.css @@ -2,6 +2,11 @@ padding: 1px 0 0 0; width: 108px; text-align: center; + /* Hack to hide the momentary flash of text + * before sparklines are fully rendered */ + font-size: 1px; + color: transparent; + overflow: hidden; } .rickshaw_chart_container { position: relative; --- a/ckanext/ga_report/public/scripts/ckanext_ga_reports.js +++ b/ckanext/ga_report/public/scripts/ckanext_ga_reports.js @@ -69,9 +69,9 @@ spotColor: '', maxSpotColor: '', minSpotColor: '', - highlightSpotColor: '000000', - lineColor: '3F8E6D', - fillColor: 'B7E66B' + highlightSpotColor: '#000000', + lineColor: '#3F8E6D', + fillColor: '#B7E66B' }; $('.sparkline').sparkline('html',sparkOptions); created = true; @@ -87,7 +87,7 @@ * Show the correct rickshaw graph in the sidebar. * Not to be called before all graphs load. */ - $('a[data-toggle="hashchange"]').on( + $('a[data-toggle="hashtab"]').on( 'shown', function(e) { var href = $(e.target).attr('href'); @@ -104,6 +104,8 @@ $(legend_name).show(); } ); + /* The first tab might already have been shown */ + $('li.active > a[data-toggle="hashtab"]').trigger('shown'); }; CKAN.GA_Reports.bind_month_selector = function() { @@ -118,22 +120,3 @@ selectors.bind('change', handler); }; -/* - * Custom bootstrap plugin for handling data-toggle="hashchange". - * Behaves like data-toggle="tab" but I respond to the hashchange. - * Page state is memo-ized in the URL this way. Why doesn't Bootstrap do this? - */ -$(function() { - var mapping = {}; - $('a[data-toggle="hashchange"]').each( - function(i,link) { - link = $(link); - mapping[link.attr('href')] = link; - } - ); - $(window).hashchange(function() { - var link = mapping[window.location.hash]; - if (link) { link.tab('show'); } - }); -}); - --- a/ckanext/ga_report/templates/ga_report/ga_util.html +++ b/ckanext/ga_report/templates/ga_report/ga_util.html @@ -59,21 +59,41 @@ -
-
-
-
--- a/ckanext/ga_report/templates/ga_report/notes.html +++ /dev/null @@ -1,16 +1,1 @@ - -
  • -

    Notes

    -
      -
    • "Views" is the number of times a page was loaded in users' browsers.
    • -
    • "Downloads" is the number of times a user has clicked to download either an original or cached resource for a particular dataset. Download information is only available from 2nd December 2012; 'No data' is shown for records before that date.
    • -
    • These usage statistics are confined to users with javascript enabled, which excludes web crawlers and API calls.
    • -
    • The results are not shown when the number of views/visits is tiny. Where these relate to site pages, results are available in full in the CSV download. Where these relate to users' web browser information, results are not disclosed, for privacy reasons.
    • -
    -
  • - - --- a/ckanext/ga_report/templates/ga_report/publisher/index.html +++ b/ckanext/ga_report/templates/ga_report/publisher/index.html @@ -7,19 +7,9 @@ Usage by Publisher + -
  • -

    Download

    -

    - Download as CSV
    -

    -
  • -
  • -

    Graph Legend

    -
    -
    -
  • - + ${ga_sidebar(download_link=h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='publisher_csv',month=c.month or 'all'))}
    @@ -35,13 +25,12 @@
    -

    Site Usage

    +

    Site Usage ${usage_nav('Publishers')}

    - ${usage_nav('Publishers')} - +
    ${rickshaw_graph(c.top_publishers_graph,'publishers')} -
    +
    ${month_selector(c.month, c.months, c.day)} @@ -49,22 +38,21 @@ - - - - + + + + - - - - + + + +
    PublisherDataset Views
    PublisherDataset Views
    - ${h.link_to(publisher.title, h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport', action='read_publisher', id=publisher.name) + (("?month=" + c.month) if c.month else ''))} - ${views}
    + ${h.link_to(publisher.title, h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport', action='read_publisher', id=publisher.name) + (("?month=" + c.month) if c.month else ''))} + ${views}
    - - -
    +
    +