Skip to content

Commit

Permalink
[#63] Add missing files :|
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed May 16, 2013
1 parent 0af26cd commit f9c703a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
31 changes: 31 additions & 0 deletions ckanext/geodatagov/controllers.py
Original file line number Diff line number Diff line change
@@ -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')
14 changes: 14 additions & 0 deletions ckanext/geodatagov/templates/viewer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% extends "page.html" %}

{% block breadcrumb_content %}
<li class="active">{{ h.nav_link(_('Map Viewer'), controller='ckanext.geodatagov.controllers:ViewController', action='show') }}</li>
{% endblock %}

{% block primary %}

{# TODO: remove sidebar #}
<iframe src="{{ c.viewer_url }}" frameborder="0" width="100%" data-module="data-viewer">
<p>{{ _('Your browser does not support iframes.') }}</p>
</iframe>

{% endblock %}

0 comments on commit f9c703a

Please sign in to comment.