Repository: OCHA-DAP/hdx-ckan

Issue:
Add background image and default text below main nav. 
Luis to provide "water color map" static image and the text to be included.  For now, just put some nonsense text.

See wireframe: https://plus.google.com/hangouts/_/76cpjic772m9aumdm8eaooo3n0

![image](https://cloud.githubusercontent.com/assets/1654485/2667303/3796a35a-c0ac-11e3-9d40-cb9470a47fa9.png)

Intelligent button for "Download", "Visit Page"
The buttons for accessing a resource appear to switch depending on the type of resource.  
- Download - for files, even if linking to a file on a different site
- Visit Page - for links to external websites that are not downloadable files

We still would want the _Preview_ button to be available for files that support it. 

See http://catalog.data.gov/dataset/e3-economyenergyenvironment-introductory-video-revitalizing-american-manufacturing for an example.



Discussion:
@luiscape Luis when you will get the background image, can you please insure that it will have the part below the map included (the grayish part where we can read the number of datasets/countries/etc). 
Also can you please tell me what font was used?

I'm also tagging this with UX for the purposes of a discussion I am having with the current (Shawna + me) and the upcoming (frog) UX team. 

Dev team: see templates/package/snippets/resource_item.html, templates/package/resource_read.html, and templates/dataviewer/snippets/data_preview.html


Resolving patch:
diff --git a/ckanext-hdx_theme/ckanext/hdx_theme/count.py b/ckanext-hdx_theme/ckanext/hdx_theme/count.py
new file mode 100644
--- /dev/null
+++ b/ckanext-hdx_theme/ckanext/hdx_theme/count.py
@@ -0,0 +1,20 @@
+import json
+from ckan import model
+from ckan.lib import base
+import sqlalchemy
+
+class CountController(base.BaseController):
+
+    def _get_count(self, table, type):
+        q = sqlalchemy.text(''' select count(*) from {name} where state='active' and type='{type}';'''.format(name=table, type=type))
+        result = model.Session.connection().execute(q, entity_id=id).scalar()
+        return result
+
+    def dataset(self):
+        return json.dumps({'count': self._get_count('package', 'dataset')})
+
+    def country(self):
+        return json.dumps({'count': self._get_count('"group"', 'group')})
+
+    def source(self):
+        return json.dumps({'count': 0})
\ No newline at end of file
diff --git a/ckanext-hdx_theme/ckanext/hdx_theme/helpers.py b/ckanext-hdx_theme/ckanext/hdx_theme/helpers.py
new file mode 100644
--- /dev/null
+++ b/ckanext-hdx_theme/ckanext/hdx_theme/helpers.py
@@ -0,0 +1,11 @@
+
+
+downloadable_formats = {
+    'csv', 'xls', 'txt', 'jpg', 'jpeg', 'png', 'gif', 'zip', 'xml'
+}
+
+def is_downloadable(resource):
+    format = resource.get('format', 'data').lower()
+    if format in downloadable_formats:
+        return True
+    return False
diff --git a/ckanext-hdx_theme/ckanext/hdx_theme/plugin.py b/ckanext-hdx_theme/ckanext/hdx_theme/plugin.py
--- a/ckanext-hdx_theme/ckanext/hdx_theme/plugin.py
+++ b/ckanext-hdx_theme/ckanext/hdx_theme/plugin.py
@@ -4,13 +4,25 @@
 
 
 class HDXThemePlugin(plugins.SingletonPlugin):
-	plugins.implements(plugins.IConfigurer)
-	plugins.implements(plugins.IRoutes, inherit=True)
+    plugins.implements(plugins.IConfigurer)
+    plugins.implements(plugins.IRoutes, inherit=True)
+    plugins.implements(plugins.ITemplateHelpers)
 
-	def update_config(self, config):
-		toolkit.add_template_directory(config, 'templates')
-		toolkit.add_public_directory(config, 'public')
+    def update_config(self, config):
+        toolkit.add_template_directory(config, 'templates')
+        toolkit.add_public_directory(config, 'public')
+        toolkit.add_resource('fanstatic', 'hdx_theme')
+
+    def before_map(self, map):
+        map.connect('home', '/', controller='ckanext.hdx_theme.splash_page:SplashPageController', action='index')
+        map.connect('/count/dataset', controller='ckanext.hdx_theme.count:CountController', action='dataset')
+        map.connect('/count/country', controller='ckanext.hdx_theme.count:CountController', action='country')
+        map.connect('/count/source', controller='ckanext.hdx_theme.count:CountController', action='source')
+        return map
+
+    def get_helpers(self):
+        from ckanext.hdx_theme import helpers as hdx_helpers
+        return {
+            'is_downloadable': hdx_helpers.is_downloadable
+        }
 
-	def before_map(self, map):
-		map.connect('home', '/', controller='ckanext.hdx_theme.splash_page:SplashPageController', action='index')
-		return map
\ No newline at end of file


Test patch: