Fixes to make this work on not-data.gov.uk
Fixes to make this work on not-data.gov.uk

--- a/ckanext/ga_report/command.py
+++ b/ckanext/ga_report/command.py
@@ -52,9 +52,7 @@
         assuming it is correct.
         """
         from ga_auth import init_service
-        init_service('token.dat',
-                      self.args[0] if self.args
-                                   else 'credentials.json')
+        init_service('token.dat', 'credentials.json')
 
 class FixTimePeriods(CkanCommand):
     """

--- a/ckanext/ga_report/download_analytics.py
+++ b/ckanext/ga_report/download_analytics.py
@@ -121,13 +121,13 @@
                 accountName = config.get('googleanalytics.account')
 
                 log.info('Downloading analytics for dataset views')
-                data = self.download(start_date, end_date, '~/%s/dataset/[a-z0-9-_]+' % accountName)
+                data = self.download(start_date, end_date, '~^/dataset/[a-z0-9-_]+')
 
                 log.info('Storing dataset views (%i rows)', len(data.get('url')))
                 self.store(period_name, period_complete_day, data, )
 
                 log.info('Downloading analytics for publisher views')
-                data = self.download(start_date, end_date, '~/%s/publisher/[a-z0-9-_]+' % accountName)
+                data = self.download(start_date, end_date, '~^/organization/[a-z0-9-_]+')
 
                 log.info('Storing publisher views (%i rows)', len(data.get('url')))
                 self.store(period_name, period_complete_day, data,)
@@ -177,7 +177,7 @@
         data = collections.defaultdict(list)
         rows = results.get('rows',[])
         for row in rows:
-            url = _normalize_url('http:/' + row[0])
+            url = row[0]
             data[url].append( (row[1], int(row[2]),) )
         ga_model.update_social(period_name, data)
 
@@ -192,11 +192,8 @@
 
         # Supported query params at
         # https://developers.google.com/analytics/devguides/reporting/core/v3/reference
-        try:
-            # Because of issues of invalid responses, we are going to make these requests
-            # ourselves.
-            headers = {'authorization': 'Bearer ' + self.token}
-
+	# https://ga-dev-tools.appspot.com/explorer/
+        try:
             args = {}
             args["sort"] = "-ga:pageviews"
             args["max-results"] = 100000
@@ -207,25 +204,22 @@
             args["ids"] = "ga:" + self.profile_id
             args["filters"] = query
             args["alt"] = "json"
-
-            r = requests.get("https://www.googleapis.com/analytics/v3/data/ga", params=args, headers=headers)
-            if r.status_code != 200:
-              raise Exception("Request with params: %s failed" % args)
-
-            results = json.loads(r.content)
-            print len(results.keys())
-        except Exception, e:
-            log.exception(e)
-            #return dict(url=[])
-            raise e
+            print args
+            results = self._get_json(args)
+
+        except Exception, e:
+            log.exception(e)
+            return dict(url=[])
 
         packages = []
         log.info("There are %d results" % results['totalResults'])
-        for entry in results.get('rows'):
+	if results['totalResults'] > 0:
+          for entry in results.get('rows'):
             (loc,pageviews,visits) = entry
-            url = _normalize_url('http:/' + loc) # strips off domain e.g. www.data.gov.uk or data.gov.uk
-
-            if not url.startswith('/dataset/') and not url.startswith('/publisher/'):
+            #url = _normalize_url('http:/' + loc) # strips off domain e.g. www.data.gov.uk or data.gov.uk
+            url = loc
+	    #print url
+            if not url.startswith('/dataset/') and not url.startswith('/organization/'):
                 # filter out strays like:
                 # /data/user/login?came_from=http://data.gov.uk/dataset/os-code-point-open
                 # /403.html?page=/about&from=http://data.gov.uk/publisher/planning-inspectorate
@@ -258,37 +252,32 @@
         return data
 
     def _get_json(self, params, prev_fail=False):
-        if prev_fail:
-          import os
-          ga_token_filepath = os.path.expanduser(config.get('googleanalytics.token.filepath', ''))
-          if not ga_token_filepath:
-              print 'ERROR: In the CKAN config you need to specify the filepath of the ' \
-                    'Google Analytics token file under key: googleanalytics.token.filepath'
-              return
-
-          try:
-              self.token, svc = init_service(ga_token_filepath, None)
-          except TypeError:
-              print ('Have you correctly run the getauthtoken task and '
-                     'specified the correct token file in the CKAN config under '
-                     '"googleanalytics.token.filepath"?')
-
-        try:
-            # Because of issues of invalid responses, we are going to make these requests
-            # ourselves.
+        ga_token_filepath = os.path.expanduser(config.get('googleanalytics.token.filepath', ''))
+        if not ga_token_filepath:
+            print 'ERROR: In the CKAN config you need to specify the filepath of the ' \
+                'Google Analytics token file under key: googleanalytics.token.filepath'
+            return
+
+        log.info("Trying to refresh our OAuth token")
+        try:
+            from ga_auth import init_service
+            self.token, svc = init_service(ga_token_filepath, None)
+            log.info("OAuth token refreshed")
+        except Exception, auth_exception:
+            log.error("Oauth refresh failed")
+            log.exception(auth_exception)
+            return
+
+        try:
             headers = {'authorization': 'Bearer ' + self.token}
             r = requests.get("https://www.googleapis.com/analytics/v3/data/ga", params=params, headers=headers)
             if r.status_code != 200:
-              log.info("STATUS: %s" % (r.status_code,))
-              log.info("CONTENT: %s" % (r.content,))
-              raise Exception("Request with params: %s failed" % params)
+                log.info("STATUS: %s" % (r.status_code,))
+                log.info("CONTENT: %s" % (r.content,))
+                raise Exception("Request with params: %s failed" % params)
 
             return json.loads(r.content)
         except Exception, e:
-            if not prev_fail:
-              print e
-              results = self._get_json(self, params, prev_fail=True)
-            else:
               log.exception(e)
 
         return dict(url=[])
@@ -344,8 +333,7 @@
         ga_model.update_sitewide_stats(period_name, "Totals", data, period_complete_day)
 
         # Bounces from / or another configurable page.
-        path = '/%s%s' % (config.get('googleanalytics.account'),
-                          config.get('ga-report.bounce_url', '/'))
+        path = '/' #% (config.get('googleanalytics.account'),                          config.get('ga-report.bounce_url', '/'))
 
         try:
             # Because of issues of invalid responses, we are going to make these requests

--- a/ckanext/ga_report/ga_model.py
+++ b/ckanext/ga_report/ga_model.py
@@ -114,7 +114,7 @@
     >>> normalize_url('http://data.gov.uk/dataset/weekly_fuel_prices')
     '/dataset/weekly_fuel_prices'
     '''
-    return '/' + '/'.join(url.split('/')[3:])
+    return url #'/' + '/'.join(url.split('/')[3:])
 
 
 def _get_package_and_publisher(url):
@@ -130,7 +130,7 @@
                 return dataset_ref,publisher_groups[0].name
         return dataset_ref, None
     else:
-        publisher_match = re.match('/publisher/([^/]+)(/.*)?', url)
+        publisher_match = re.match('/organization/([^/]+)(/.*)?', url)
         if publisher_match:
             return None, publisher_match.groups()[0]
     return None, None
@@ -327,7 +327,7 @@
         filter(model.Group.state=='active').all()
     for publisher in publishers:
         views, visits, subpub = update_publisher(period_name, publisher, publisher.name)
-        parent, parents = '', publisher.get_groups('organization')
+        parent, parents = '', publisher.get_parent_groups(type='organization')
         if parents:
             parent = parents[0].name
         item = model.Session.query(GA_Publisher).\

--- a/ckanext/ga_report/plugin.py
+++ b/ckanext/ga_report/plugin.py
@@ -35,49 +35,49 @@
     def after_map(self, map):
         # GaReport
         map.connect(
-            '/data/site-usage',
+            '/site-usage',
             controller='ckanext.ga_report.controller:GaReport',
             action='index'
         )
         map.connect(
-            '/data/site-usage/data_{month}.csv',
+            '/site-usage_{month}.csv',
             controller='ckanext.ga_report.controller:GaReport',
             action='csv'
         )
         map.connect(
-            '/data/site-usage/downloads',
+            '/site-usage/downloads',
             controller='ckanext.ga_report.controller:GaReport',
             action='downloads'
         )
         map.connect(
-            '/data/site-usage/downloads_{month}.csv',
+            '/site-usage/downloads_{month}.csv',
             controller='ckanext.ga_report.controller:GaReport',
             action='csv_downloads'
         )
 
         # GaDatasetReport
         map.connect(
-            '/data/site-usage/publisher',
+            '/site-usage/publisher',
             controller='ckanext.ga_report.controller:GaDatasetReport',
             action='publishers'
         )
         map.connect(
-            '/data/site-usage/publishers_{month}.csv',
+            '/site-usage/publishers_{month}.csv',
             controller='ckanext.ga_report.controller:GaDatasetReport',
             action='publisher_csv'
         )
         map.connect(
-            '/data/site-usage/dataset/datasets_{id}_{month}.csv',
+            '/site-usagesetsets_{id}_{month}.csv',
             controller='ckanext.ga_report.controller:GaDatasetReport',
             action='dataset_csv'
         )
         map.connect(
-            '/data/site-usage/dataset',
+            '/site-usageset',
             controller='ckanext.ga_report.controller:GaDatasetReport',
             action='read'
         )
         map.connect(
-            '/data/site-usage/dataset/{id}',
+            '/site-usageset/{id}',
             controller='ckanext.ga_report.controller:GaDatasetReport',
             action='read_publisher'
         )

--- a/ckanext/ga_report/public/css/ga_report.css
+++ b/ckanext/ga_report/public/css/ga_report.css
@@ -66,4 +66,7 @@
   margin-top: 4px;
   float: left;
 }
+.tab-content {
+  padding-top: 12px;
+}
 

--- a/ckanext/ga_report/public/scripts/ckanext_ga_reports.js
+++ b/ckanext/ga_report/public/scripts/ckanext_ga_reports.js
@@ -97,7 +97,7 @@
    * Show the correct rickshaw graph in the sidebar. 
    * Not to be called before all graphs load.
    */
-  $('a[data-toggle="hashtab"]').on(
+  $('a[data-toggle="tab"]').on(
     'shown',
     function(e) {
       var href = $(e.target).attr('href');
@@ -115,7 +115,7 @@
     }
   );
   /* The first tab might already have been shown */
-  $('li.active > a[data-toggle="hashtab"]').trigger('shown');
+  $('li.active > a[data-toggle="tab"]').trigger('shown');
 };
 
 CKAN.GA_Reports.bind_month_selector = function() {
@@ -126,7 +126,6 @@
     window.location = url;
   };
   var selectors = $('select[name="month"]');
-  assert(selectors.length>0);
   selectors.bind('change', handler);
 };
 

--- a/ckanext/ga_report/templates/ga_report/ga_util.html
+++ b/ckanext/ga_report/templates/ga_report/ga_util.html
@@ -57,43 +57,19 @@
     </py:for>
  </table>
 
-
-<div py:def="usage_nav(active_name)">
-  <span class="subheading">
-    <img src="/images/arrow-down-right.png" />
-    <a class="${if_(active_name=='Site-wide','active')}" href="${h.url_for(controller='ckanext.ga_report.controller:GaReport',action='index')}${if_(c.month,'?month='+c.month)}">Site-wide</a>
-    <span class="divider">|</span>
-    <a class="${if_(active_name=='Publishers','active')}" href="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='publishers')}${if_(c.month,'?month='+c.month)}">Publishers</a>
-    <span class="divider">|</span>
-    <a class="${if_(active_name=='Datasets','active')}" href="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='read')}${if_(c.month,'?month='+c.month)}">Datasets</a>
-  </span>
-</div>
-
-<div py:def="ga_sidebar(download_link)">
-  <div class="boxed">
-    <div class="widget-container widget_text">
-      <h4>Download</h4>
-      <p><center>
-        <a class="btn button btn-primary" href="${download_link}">Download as CSV</a></center>
-      </p>
-    </div>
-    <div class="widget-container widget_text">
-      <h4>Graph Legend</h4>
-      <div id="graph-legend-container">
-        <div style="display: none;" id="legend_none">(No graph is loaded)</div>
-      </div>
-    </div>
-    <div class="widget-container widget_text">
-      <h4>Notes</h4>
+<py:def function="ga_footer()">
+  <div class="panel panel-default">
+    <div class="panel-heading"><strong>Notes</strong></div>
+    <div class="panel-body">
       <ul>
-          <li>"Views" is the number of times a page was loaded in users' browsers.</li>
-          <li>"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.</li>
-          <li>These usage statistics are confined to users with javascript enabled, which excludes web crawlers and API calls.</li>
-          <li>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.</li>
+        <li>"Views" is the number of times a page was loaded in users' browsers.</li>
+        <li>"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.</li>
+        <li>These usage statistics are confined to users with javascript enabled, which excludes web crawlers and API calls.</li>
+        <li>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.</li>
       </ul>
     </div>
   </div>
-</div>
+</py:def>
 
 
 </html>

--- a/ckanext/ga_report/templates/ga_report/publisher/index.html
+++ b/ckanext/ga_report/templates/ga_report/publisher/index.html
@@ -6,13 +6,6 @@
   <xi:include href="../ga_util.html" />
 
   <py:def function="page_title">Usage by Publisher</py:def>
-
-
-
-  <py:match path="primarysidebar">
-    ${ga_sidebar(download_link=h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='publisher_csv',month=c.month or 'all'))}
-  </py:match>
-
 
   <py:def function="optional_head">
     <link rel="stylesheet" type="text/css" href="/scripts/vendor/rickshaw.min.css"/>
@@ -25,38 +18,49 @@
     <script type="text/javascript" src="/scripts/vendor/d3.layout.min.js"></script>
     <script type="text/javascript" src="/scripts/vendor/rickshaw.min.js"></script>
   </py:def>
-  <py:def function="page_heading">Site Usage ${usage_nav('Publishers')}</py:def>
+
+ <py:match path="breadcrumbs">
+    <li><a href="/site-usage">Site Analytics</a></li>
+    <li><a href="/site-usage/publisher">Publishers</a></li>
+  </py:match>
 
   <div py:match="content">
+    <py:with vars="download_link=h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='publisher_csv',month=c.month or 'all')">
+      <a class="btn button btn-primary btn-sm pull-right" href="${download_link}"><i class="icon-download"></i>&nbsp; Download as CSV</a>
+    </py:with>
+    <h1>Site Usage</h1>
 
-
-    <div class="boxed">
-
-       ${rickshaw_graph(c.top_publishers_graph,'publishers')}
+    <div class="row" style="background: #fff;">
+      <div class="col-md-8">
+        <div class="whitebox">
+          <strong>Publishers</strong>
+           ${rickshaw_graph(c.top_publishers_graph,'publishers')}
+       </div>
+      </div>
+    </div>
 
        <hr/>
        <form class="form-inline" action="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='publishers')}" method="get">
           <div class="controls">
-            <h4 class="ga-reports-heading">Statistics for</h4>
+            <h2 class="ga-reports-heading">Statistics for</h2>
               ${month_selector(c.month, c.months, c.day)}
           </div>
        </form>
 
-       <table class="ga-reports-table table table-condensed table-bordered table-striped">
-         <tr>
-           <th>Publisher</th>
-           <th class="td-numeric">Dataset Views</th>
-         </tr>
-        <py:for each="publisher, views, visits in c.top_publishers">
-          <tr>
-            <td>
-                ${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 ''))}
-            </td>
-            <td class="td-numeric">${views}</td>
-          </tr>
-        </py:for>
-       </table>
-    </div><!--/boxed-->
+     <table class="ga-reports-table table table-condensed table-bordered table-striped">
+       <tr>
+         <th>Publisher</th>
+         <th class="td-numeric">Dataset Views</th>
+       </tr>
+      <py:for each="publisher, views, visits in c.top_publishers">
+        <tr>
+          <td>
+              ${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 ''))}
+          </td>
+          <td class="td-numeric">${views}</td>
+        </tr>
+      </py:for>
+     </table>
   </div><!--/content-->
 
   <py:def function="optional_footer">
@@ -66,7 +70,7 @@
       });
     </script>
   </py:def>
-  <xi:include href="../../layout.html" />
+  <xi:include href="../site/layout.html" />
 
 </html>
 

--- a/ckanext/ga_report/templates/ga_report/publisher/read.html
+++ b/ckanext/ga_report/templates/ga_report/publisher/read.html
@@ -19,64 +19,83 @@
     <script type="text/javascript" src="/scripts/vendor/rickshaw.min.js"></script>
   </py:def>
 
-  <py:def function="sidebar">
-    ${ga_sidebar(download_link=h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='dataset_csv',id=c.publisher_name or 'all',month=c.month or 'all'))}
-  </py:def>
-  <py:def function="page_heading">Site Usage ${usage_nav('Datasets')}</py:def>
+
+ <py:match path="breadcrumbs">
+    <li><a href="/site-usage">Site Analytics</a></li>
+    <py:if test="c.publisher">
+      <li><a href="/site-usage/publisher">Publishers</a></li>
+      <li py:if="c.publisher"><a href="/site-usage/publisher/${c.publisher.name}">${c.publisher.title}</a></li>
+    </py:if>
+    <py:if test="not c.publisher">
+      <li><a href="${request.url}">Usage By Dataset</a></li>
+    </py:if>
+  </py:match>
 
   <div py:match="content">
 
-    <div class="boxed">
-     <h3 py:if="c.publisher"><a href="${h.url_for(controller='ckanext.dgu.controllers.publisher:PublisherController',action='read',id=c.publisher.name)}">${c.publisher.title}</a></h3>
+    <py:with vars="download_link=h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='dataset_csv',id=c.publisher_name or 'all',month=c.month or 'all')">
+      <a class="btn button btn-primary btn-sm pull-right" href="${download_link}"><i class="icon-download"></i>&nbsp; Download as CSV</a>
+    </py:with>
+    <h1>Site Usage
+        <small py:if="c.publisher">${c.publisher.title}</small>
+        <small py:if="not c.publisher">All datasets</small>
+    </h1>
 
-     <py:if test="c.graph_data">
-       ${rickshaw_graph(c.graph_data,'dataset-downloads',debug=True)}
-     </py:if>
-     <form class="form-inline" action="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='read')}" method="get">
-        <div class="controls">
+    <div class="row" style="background: #fff;">
+      <div class="col-md-8">
+        <div class="whitebox">
+          <py:if test="c.graph_data">
+            ${rickshaw_graph(c.graph_data,'dataset-downloads',debug=True)}
+          </py:if>
+       </div>
+      </div>
+    </div>
+    <hr/>
+   <py:if test="c.month">
+     <h4>Statistics for ${h.month_option_title(c.month,c.months,c.day)}:</h4>
+   </py:if>
+   <py:if test="not c.month">
+     <h2>Statistics for all months</h2>
+   </py:if>
+   <form style="margin-bottom:10px;" class="form-inline" action="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='read')}" method="get">
+      <div class="controls">
 
-          ${month_selector(c.month, c.months, c.day)}
+        ${month_selector(c.month, c.months, c.day)}
 
-          <select name="publisher">
-                <option value='' py:attrs="{'selected': 'selected' if not c.publisher else None}">All publishers</option>
-              <py:for each="val,desc in c.publishers">
-                <option value='${val}' py:attrs="{'selected': 'selected' if c.publisher_name == val else None}">${desc}</option>
-              </py:for>
-          </select>
-          <input class="btn button btn-primary" type='submit' value="Update"/>
-        </div>
-     </form>
-     <py:if test="c.month">
-       <h4>Statistics for ${h.month_option_title(c.month,c.months,c.day)}:</h4>
-     </py:if>
-     <py:if test="not c.month">
-       <h4>Statistics for all months:</h4>
-     </py:if>
-     <div class="alert alert-info" py:if="not c.top_packages">No page views in this period.</div>
-     <py:if test="c.top_packages">
-       <table class="ga-reports-table table table-condensed table-bordered table-striped">
+        <select name="publisher">
+              <option value='' py:attrs="{'selected': 'selected' if not c.publisher else None}">All publishers</option>
+            <py:for each="val,desc in c.publishers">
+              <option value='${val}' py:attrs="{'selected': 'selected' if c.publisher_name == val else None}">${desc}</option>
+            </py:for>
+        </select>
+        <input class="btn button btn-primary btn-xs" type='submit' value="Update"/>
+      </div>
+   </form>
+   <div class="alert alert-info" py:if="not c.top_packages">No page views in this period.</div>
+   <py:if test="c.top_packages">
+     <table class="ga-reports-table table table-condensed table-bordered">
+       <tr>
+         <th>Dataset</th>
+         <th>Views</th>
+         <th>Downloads</th>
+       </tr>
+       <py:for each="package, views, visits,downloads in c.top_packages">
          <tr>
-           <th>Dataset</th>
-           <th>Views</th>
-           <th>Downloads</th>
-         </tr>
-         <py:for each="package, views, visits,downloads in c.top_packages">
-           <tr>
-             <td>
-               ${h.link_to(package.title or package.name, h.url_for(controller='package', action='read', id=package.name))}
-             </td>
-             <td class="td-numeric">${views}</td>
-             <td class="td-numeric">${downloads}</td>
-          </tr>
-        </py:for>
-      </table>
-    </py:if>
+           <td>
+             ${h.link_to(package.title or package.name, h.url_for(controller='package', action='read', id=package.name))}
+           </td>
+           <td class="td-numeric">${views}</td>
+           <td class="td-numeric">${downloads}</td>
+        </tr>
+      </py:for>
+    </table>
+  </py:if>
+
+  ${ga_footer()}
 
   </div>
 
-  </div>
-
-  <xi:include href="../../layout.html" />
+  <xi:include href="../site/layout.html" />
 </html>
 
 

--- a/ckanext/ga_report/templates/ga_report/site/downloads.html
+++ b/ckanext/ga_report/templates/ga_report/site/downloads.html
@@ -7,9 +7,9 @@
 
   <py:def function="page_title">Downloads</py:def>
 
-  <py:match path="primarysidebar">
+  <py:def path="sidebar">
     ${ga_sidebar(download_link=h.url_for(controller='ckanext.ga_report.controller:GaReport',action='csv_downloads',month=c.month or 'all'))}
-  </py:match>
+  </py:def>
 
   <py:def function="page_heading">Downloads ${usage_nav('Downloads')}</py:def>
   <div py:match="content">

--- a/ckanext/ga_report/templates/ga_report/site/index.html
+++ b/ckanext/ga_report/templates/ga_report/site/index.html
@@ -8,157 +8,178 @@
   <py:def function="page_title">Site usage</py:def>
 
   <py:def function="optional_head">
-    <link rel="stylesheet" type="text/css" href="/scripts/vendor/rickshaw.min.css"/>
-    <link rel="stylesheet" type="text/css" href="/css/ga_report.css?1"/>
-    <script type="text/javascript" src="/scripts/modernizr-2.6.2.custom.js"></script>
-    <script type="text/javascript" src="/scripts/ckanext_ga_reports.js?1"></script>
-    <script type="text/javascript" src="/scripts/vendor/jquery.sparkline.modified.js"></script>
-    <script type="text/javascript" src="/scripts/rickshaw_ie7_shim.js"></script>
-    <script type="text/javascript" src="/scripts/vendor/d3.v2.js"></script>
-    <script type="text/javascript" src="/scripts/vendor/d3.layout.min.js"></script>
-    <script type="text/javascript" src="/scripts/vendor/rickshaw.min.js"></script>
   </py:def>
 
-  <py:def function="sidebar">
-    ${ga_sidebar(download_link=h.url_for(controller='ckanext.ga_report.controller:GaReport',action='csv',month=c.month or 'all'))}
-  </py:def>
-
-  <py:def function="page_heading">Site Usage ${usage_nav('Site-wide')}</py:def>
+ <py:match path="breadcrumbs">
+    <li><a href="/site-usage">Site Analytics</a></li>
+    <li><a href="/site-usage">Site-wide</a></li>
+  </py:match>
 
   <div py:match="content">
-
-    <div class="boxed">
-    <div class="tabbable">
-      <ul class="nav nav-tabs">
-        <li class="active"><a href="#totals" data-toggle="hashtab">Totals</a></li>
-        <li class="dropdown">
-            <a href="#" class="dropdown-toggle" data-toggle="dropdown">Browsers
-                <b class="caret"></b></a>
-            <ul class="dropdown-menu">
-                <li><a href="#browsers_names" data-toggle="hashtab">Browsers</a></li>
-                <li><a href="#browsers_versions" data-toggle="hashtab">Versions</a></li>
+    <div class="row">
+      <div class="col-sm-7 col-md-8 col-lg-9">
+        <py:with vars="download_link=h.url_for(controller='ckanext.ga_report.controller:GaReport',action='csv',month=c.month or 'all')">
+          <a class="btn button btn-primary btn-sm pull-right" href="${download_link}"><i class="icon-download"></i>&nbsp; Download as CSV</a>
+        </py:with>
+        <h1>Site Usage</h1>
+      </div>
+      <div class="col-sm-5 col-md-4 col-lg-3">
+        <div class="panel panel-default">
+          <div class="panel-heading"><strong>Jump To...</strong></div>
+          <div class="panel-body">
+            <ul>
+              <li><a href="/site-usage/publisher">Publisher Usage Statistics</a></li>
+              <li><a href="/site-usageset">Dataset Usage Statistics</a></li>
             </ul>
-        </li>
-        <li class="dropdown">
-            <a href="#" class="dropdown-toggle" data-toggle="dropdown">Operating Systems
-                <b class="caret"></b></a>
-            <ul class="dropdown-menu">
-                <li><a href="#os" data-toggle="hashtab">Operating Systems</a></li>
-                <li><a href="#os_versions" data-toggle="hashtab">Versions</a></li>
+          </div>
+        </div>