diff --git a/grambank/__init__.py b/grambank/__init__.py index afa3bd4..edcc9d9 100644 --- a/grambank/__init__.py +++ b/grambank/__init__.py @@ -3,9 +3,7 @@ from pyramid.config import Configurator from sqlalchemy.orm import joinedload -from clld.interfaces import ( - IValue, IDomainElement, IMapMarker, IValueSet, ILinkAttrs, IContribution, ICtxFactoryQuery, -) +from clld.interfaces import IMapMarker, ILinkAttrs, IContribution, ICtxFactoryQuery from clld.web.app import CtxFactoryQuery, menu_item from clld_glottologfamily_plugin.util import LanguageByFamilyMapMarker from clld.db.models import common @@ -15,6 +13,7 @@ from grambank import models from grambank import views from grambank import datatables +from grambank.util import icon_from_req _ = lambda s: s _('Parameters') @@ -25,21 +24,11 @@ class GrambankMapMarker(LanguageByFamilyMapMarker): def __call__(self, ctx, req): - if IValue.providedBy(ctx): # pragma: no cover - icon = ctx.domainelement.jsondata['icon'] - elif IValueSet.providedBy(ctx): - icon = ctx.values[0].domainelement.jsondata['icon'] - elif IDomainElement.providedBy(ctx): - icon = ctx.jsondata['icon'] - else: - icon = LanguageByFamilyMapMarker.get_icon(self, ctx, req) - icon = { - 'cffffff': 'c0077bb', - 'cff0000': 'ccc3311', - 'c0000ff': 'c009988', - 'cffff00': 'cee7733', - }.get(icon, icon) - return svg.data_url(svg.icon(icon, opacity=0.8)) + icon = icon_from_req(ctx, req) + if icon: + return icon.url(req) + return svg.data_url( + svg.icon(LanguageByFamilyMapMarker.get_icon(self, ctx, req), opacity='0.7')) class GrambankCtxFactoryQuery(CtxFactoryQuery): diff --git a/grambank/maps.py b/grambank/maps.py index 83bde57..c0f0d65 100644 --- a/grambank/maps.py +++ b/grambank/maps.py @@ -21,9 +21,6 @@ def get_layers(self): ), marker=helpers.map_marker_img(self.req, de, marker=self.map_marker)) - #def get_default_options(self): - # return {'hash': True, 'icon_size': 15, 'base_layer': "Esri.WorldPhysical"} - def includeme(config): config.register_map('parameter', FeatureMap) diff --git a/grambank/static/project.css b/grambank/static/project.css index fdf33ab..0e08a3d 100644 --- a/grambank/static/project.css +++ b/grambank/static/project.css @@ -125,4 +125,4 @@ a:hover { background-image: none; } -img.leaflet-marker-icon {opacity: 0.5;} +/*img.leaflet-marker-icon {opacity: 0.5;}*/ diff --git a/grambank/templates/combination/detail_html.mako b/grambank/templates/combination/detail_html.mako index 5fec0b9..289179f 100644 --- a/grambank/templates/combination/detail_html.mako +++ b/grambank/templates/combination/detail_html.mako @@ -1,7 +1,12 @@ <%inherit file="../${context.get('request').registry.settings.get('clld.app_template', 'app.mako')}"/> <%namespace name="util" file="../util.mako"/> <%! active_menu_item = "parameters" %> +<% from clld.web.icon import Icon %> + <%block name="title">F-Dependency ${'→'.join(p.id for p in ctx.parameters)|n} +<%block name="head"> + ${util.head_coloris()|n} +

${_('F-Dependency')} ${' → '.join(h.link(request, p) for p in ctx.parameters)|n}

@@ -30,13 +35,8 @@ % if item[1].languages: - % if iconselect: - <%self:iconselect id="iconselect${str(item[0])}" param="v${str(item[0])}" placement="right" tag="span"> - - - % else: - - % endif + ${util.coloris_icon_picker(Icon.from_req(item[1], req))|n} + ${util.parameter_map_reloader([Icon.from_req(de, req) for de in ctx.domain])|n} % endif diff --git a/grambank/templates/parameter/detail_html.mako b/grambank/templates/parameter/detail_html.mako index 65eee10..332d9d2 100644 --- a/grambank/templates/parameter/detail_html.mako +++ b/grambank/templates/parameter/detail_html.mako @@ -8,6 +8,7 @@ <%block name="head"> + ${util.head_coloris()|n} @@ -79,10 +80,31 @@ ${u.process_markdown(ctx.description, req)|n} + +
+ + Customize map markers: + + + % for de in ctx.domain: + + + + + + % endfor + +
${util.coloris_icon_picker(u.icon_from_req(de, req))|n}${de.name}${de.description}
+ ${util.parameter_map_reloader([u.icon_from_req(de, req) for de in ctx.domain])} +
+

Map

+ +
+ ${request.map.render()}

diff --git a/grambank/util.py b/grambank/util.py index 93bf21f..4019131 100644 --- a/grambank/util.py +++ b/grambank/util.py @@ -21,6 +21,7 @@ ) from clld_glottologfamily_plugin.models import Family from clld.web.util.multiselect import CombinationMultiSelect +from clld.web.icon import Icon from clld.web.util import glottolog # used in templates! from clld_phylogeny_plugin.models import Phylogeny from clldutils.misc import slug @@ -35,6 +36,18 @@ assert markdown +def icon_from_req(ctx, req): + return Icon.from_req( + ctx, + req, + icon_map={ + 'cffffff': 'c0077bb', + 'cff0000': 'ccc3311', + 'c0000ff': 'c009988', + 'cffff00': 'cee7733', + }) + + def process_markdown(text, req, section=None): from markdown import markdown diff --git a/setup.py b/setup.py index 9753a0f..d12198a 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ zip_safe=False, install_requires=[ 'cldfcatalog', - 'clld>=9.2.1', + 'clld>=11.0.1', 'clldmpg>=4.2', 'clld-glottologfamily-plugin>=4', 'clld-phylogeny-plugin>=1.5',