Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Commit

Permalink
Refs #14106 - Fallback to Simile Exhibit 2.2
Browse files Browse the repository at this point in the history
- Update Simile Exhibit 2.2 Map Extenstion to use Google Maps v3
- Force Simile Exhibit 2.2 if browser is Internet Explorer as
  Simile Exhibit 3.0 is not stable for IE
- Added Simile Exhibit section within Daviz Visualization Control Panel
  and allow Plone admins to select which version of Simile Exhibit
  to use (2.2.0 or 3.0.0. Default 3.0.0)
  • Loading branch information
avoinea committed Mar 12, 2013
1 parent ce7362e commit c4a00e5
Show file tree
Hide file tree
Showing 15 changed files with 2,590 additions and 369 deletions.
9 changes: 9 additions & 0 deletions docs/HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ Changelog

7.1-dev - (unreleased)
----------------------
* Feature: Update Simile Exhibit 2.2 Map Extenstion to use Google Maps v3
[voineali refs #14106]
* Bug fix: Force Simile Exhibit 2.2 if browser is Internet Explorer as
Simile Exhibit 3.0 is not stable for IE
[voineali refs #14106]
* Feature: Added Simile Exhibit section within Daviz Visualization Control Panel
and allow Plone admins to select which version of Simile Exhibit
to use (2.2.0 or 3.0.0. Default 3.0.0)
[voineali refs #14106]
* Change: Moved eea.exhibit specific code from eea.app.visualization to this
package and load exhibit API only if there is at least one Exhibit
Visualization enabled
Expand Down
55 changes: 54 additions & 1 deletion eea/exhibit/browser/app/view.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
""" Browser views
"""
import json
from zope.component import queryAdapter
import logging
from zope.component import queryAdapter, queryUtility
from Products.Five.browser import BrowserView
from eea.app.visualization.interfaces import IVisualizationConfig
from eea.app.visualization.zopera import getToolByName
from eea.app.visualization.zopera import IPropertiesTool
from eea.app.visualization.interfaces import IDavizSettings

logger = logging.getLogger('eea.exhibit')

class View(BrowserView):
""" Custom header
Expand All @@ -14,6 +19,14 @@ def __init__(self, context, request):
self._accessor = None
self._available = None
self._bundle = None
self._exhibit3 = None

@property
def siteProperties(self):
""" Persistent utility for site_properties
"""
ds = queryUtility(IDavizSettings)
return ds.settings if ds else {}

@property
def accessor(self):
Expand Down Expand Up @@ -51,6 +64,46 @@ def bundle(self):
self._bundle = True
return json.dumps(self._bundle)

@property
def exhibit3(self):
""" Browser is Internet Explorer
"""
if self._exhibit3 is not None:
return self._exhibit3

# Force Exhibit 2 for IE as Exhibit 3 is not supported yet
if 'MSIE ' in getattr(self.request, 'HTTP_USER_AGENT', ''):
self._exhibit3 = False
return self._exhibit3

# Get Exhibit version from @@daviz-settings
version = self.siteProperties.get('exhibit.framework', 3)
if int(version) == 3:
self._exhibit3 = True
else:
self._exhibit3 = False
return self._exhibit3

@property
def gmapkey(self):
""" Get Google Maps key from
portal_properties.geographical_properties.google_key
"""
ptool = queryUtility(IPropertiesTool)
props = getattr(ptool, 'geographical_properties', None)
if callable(props):
try:
props = props(context=self.context, request=self.request)
except Exception, err:
logger.debug(err)

if getattr(props, 'getProperty', None):
key = props.getProperty('google_key', '')
else:
key = getattr(props, 'google_key', '')

return key

@property
def sources(self):
""" External sources
Expand Down
30 changes: 21 additions & 9 deletions eea/exhibit/browser/zpt/head.pt
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<tal:exhibit tal:condition="view/available" tal:define="bundle view/bundle">
<tal:exhibit tal:condition="view/available"
tal:define="bundle view/bundle">

<!-- Custom babel-translators -->
<link rel="exhibit/babel-translator"
tal:attributes="href string:${here/absolute_url}/babel-translator" />

<!-- Related items merged JSON with own JSON -->
<link rel="exhibit-data" type="application/json"
tal:attributes="href string:${here/absolute_url}/daviz.json" />
<link type="application/json" tal:attributes="
rel python:'exhibit-data' if view.exhibit3 else 'exhibit/data';
href string:${here/absolute_url}/daviz.json" />

<!-- External sources JSONs -->
<tal:additional repeat="source python:view.sources">
<link rel="exhibit-data"
tal:attributes="
<link tal:attributes="
rel python:'exhibit-data' if view.exhibit3 else 'exhibit/data';
type string:application/${source/type};
href string:${source/name};
data-ex-converter python:source.get('converter', None) or None;" />
Expand All @@ -25,13 +27,23 @@
//-->
</script>

<!-- XXX Dynamically insert these scripts from pluggable visualization library -->
<script type="text/javascript"
<!-- Exhibit API -->
<script type="text/javascript" tal:condition="view/exhibit3"
tal:attributes="src string:++resource++eea.simile.exhibit/exhibit-api.js?bundle=$bundle"></script>
<link rel="exhibit-extension" type="text/javascript"
<script type="text/javascript" tal:condition="not:view/exhibit3"
tal:attributes="src string:++resource++eea.simile.exhibit2/exhibit-api.js?bundle=$bundle"></script>

<!-- Exhibit Timeline Extension -->
<link rel="exhibit-extension" type="text/javascript" tal:condition="view/exhibit3"
tal:attributes="href string:++resource++eea.simile.exhibit/extensions/time/time-extension.js?bundle=$bundle" />
<link rel="exhibit-extension" type="text/javscript"
<script type="text/javascript" tal:condition="not:view/exhibit3"
tal:attributes="src string:++resource++eea.simile.exhibit2/extensions/time/time-extension.js?bundle=$bundle"></script>

<!-- Exhibit Map Extension -->
<link rel="exhibit-extension" type="text/javascript" tal:condition="view/exhibit3"
tal:attributes="href string:++resource++eea.simile.exhibit/extensions/map/map-extension.js?service=google&bundle=$bundle" />
<script type="text/javascript" tal:condition="not:view/exhibit3"
tal:attributes="src string:++resource++eea.simile.exhibit2/extensions/map/map-extension.js?service=google&bundle=$bundle"></script>

<script type="text/javascript">
<!--
Expand Down
1 change: 1 addition & 0 deletions eea/exhibit/common.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<include package=".babel" />
<include package=".browser" />
<include package=".controlpanel" />
<include package=".facets" />
<include package=".simile" />
<include package=".views" />
Expand Down
2 changes: 2 additions & 0 deletions eea/exhibit/controlpanel/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
""" Controlpanel
"""
7 changes: 7 additions & 0 deletions eea/exhibit/controlpanel/configure.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<configure xmlns="http://namespaces.zope.org/zope">

<utility
name="eea.exhibit.controlpanel.ExhibitSection"
factory=".controlpanel.ExhibitSection" />

</configure>
30 changes: 30 additions & 0 deletions eea/exhibit/controlpanel/controlpanel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
""" Googlecharts Control Panel Section
"""
from zope.interface import implements
from eea.app.visualization.controlpanel.interfaces import IDavizSection
from zope.formlib.form import FormFields
from zope import schema
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
from eea.googlecharts.config import EEAMessageFactory as _

class ExhibitSection(object):
""" Simile Exhibit Settings Section
"""
implements(IDavizSection)

prefix = 'exhibit'
title = 'Simile Exhibit Settings'
form_fields = FormFields(
schema.Choice(
__name__='exhibit.framework',
title=_(u'Version'),
description=_(u"use the following version of Simile Exhibit "
"Framework"),
required=True,
default=3,
vocabulary=SimpleVocabulary([
SimpleTerm(2, 2, u"2.2.0"),
SimpleTerm(3, 3, u"3.0.0"),
])
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
div.exhibit-mapView-map {
border: 1px solid #738699;
}
.olPopupCloseBox {
background: transparent url(http://api.simile-widgets.org/ajax/2.2.1/images/close-button.png) no-repeat scroll 0 0 ! important;
}
Loading

0 comments on commit c4a00e5

Please sign in to comment.