From f9c703a0bd3617f8537bf767146f8a3180bce480 Mon Sep 17 00:00:00 2001 From: amercader Date: Thu, 16 May 2013 18:41:47 +0100 Subject: [PATCH] [#63] Add missing files :| --- ckanext/geodatagov/controllers.py | 31 ++++++++++++++++++++++++ ckanext/geodatagov/templates/viewer.html | 14 +++++++++++ 2 files changed, 45 insertions(+) create mode 100644 ckanext/geodatagov/controllers.py create mode 100644 ckanext/geodatagov/templates/viewer.html diff --git a/ckanext/geodatagov/controllers.py b/ckanext/geodatagov/controllers.py new file mode 100644 index 00000000..83e17f15 --- /dev/null +++ b/ckanext/geodatagov/controllers.py @@ -0,0 +1,31 @@ +import urllib +import ckan.plugins as p +from pylons import config +import ckan.lib.helpers as h, json +from ckan.lib.base import BaseController, c, \ + request, response, abort, redirect + + +import logging +log = logging.getLogger(__name__) + +class ViewController(BaseController): + + def show(self): + + viewer_url = config.get('ckanext.geodatagov.spatial_preview.url') + if not viewer_url: + abort(500, 'Viewer URL not defined') + + params_to_forward = {} + viewer_params = ['url', 'servicetype', 'srs'] + + for key, value in request.params.iteritems(): + if key.lower() in viewer_params: + params_to_forward[key] = value + + params_to_forward['mode'] = 'advanced' + + c.viewer_url = '{0}?{1}'.format(viewer_url.strip('?'), urllib.urlencode(params_to_forward)) + + return p.toolkit.render('viewer.html') diff --git a/ckanext/geodatagov/templates/viewer.html b/ckanext/geodatagov/templates/viewer.html new file mode 100644 index 00000000..61a9d9ae --- /dev/null +++ b/ckanext/geodatagov/templates/viewer.html @@ -0,0 +1,14 @@ +{% extends "page.html" %} + +{% block breadcrumb_content %} +
  • {{ h.nav_link(_('Map Viewer'), controller='ckanext.geodatagov.controllers:ViewController', action='show') }}
  • +{% endblock %} + +{% block primary %} + + {# TODO: remove sidebar #} + + +{% endblock %}