def __call__(self, ctx, req): if IValue.providedBy(ctx): #print ctx.jsondata['family']#,ctx,[self],ctx.domainelement.jsondata['icon'] ##return ctx.domainelement.jsondata['icon'] return req.static_url('lsi:static/icons/' + ctx.jsondata['family'] + ctx.domainelement.jsondata['icon'] + '.png') ##return req.static_url('lsi:static/icons/c000000.png') if IValueSet.providedBy(ctx): #print ctx.domainelement ##return ctx.values[0].domainelement.jsondata['icon'] req.static_url('lsi:static/icons/' + ctx.values[0].domainelement.jsondata['icon'] + '.png') if IDomainElement.providedBy(ctx): ##return None print ctx.jsondata return req.static_url('lsi:static/icons/' + 'cr' + ''.join(ctx.jsondata['icon'][:]) + '.png') ##return ctx.jsondata['icon'] #print LanguageByFamilyMapMarker #print LanguageByFamilyMapMarker.get_icon(self, ctx, req) ##return LanguageByFamilyMapMarker.get_icon(self, ctx, req) return req.static_url( 'lsi:static/icons/' + LanguageByFamilyMapMarker.get_icon(self, ctx, req) + '.png')
def __call__(self, ctx, req): if IDomainElement.providedBy(ctx): return url('c' + ctx.jsondata['color']) if IValue.providedBy(ctx): if ctx.domainelement: return url('c' + ctx.domainelement.jsondata['color']) if ctx.valueset.language.jsondata['icon']: return url(ctx.valueset.language.jsondata['icon']) if IValueSet.providedBy(ctx): if ctx.values[0].domainelement: return url('c' + ctx.values[0].domainelement.jsondata['color']) if ctx.language.jsondata['icon']: return url(ctx.language.jsondata['icon']) if ctx.language.family: return url(ctx.language.family.jsondata['icon']) return url( req.registry.settings.get('clld.isolates_icon', ISOLATES_ICON)) if ILanguage.providedBy(ctx): icon_ = ctx.jsondata['icon'] return url(icon_) return super(LanguageByFamilyMapMarker, self).__call__(ctx, req)
def __call__(self, ctx, req): color, shape = None, 'c' if IValue.providedBy(ctx): if ctx.cognates: color = ctx.cognates[0].cognateset.color else: color = '#fff' if IValueSet.providedBy(ctx): v = ctx.values[0] if v.cognates: color = v.cognates[0].cognateset.color else: color = '#fff' if ctx.language.historical: shape = 'd' if ILanguage.providedBy(ctx): color = ctx.color if ctx.historical: shape = 'd' if color: if color.startswith('#'): color = color[1:] return svg.data_url(svg.icon(shape + color)) return super(CoblMapMarker, self).__call__(ctx, req)
def __call__(self, ctx, req): if IDomainElement.providedBy(ctx): return url('c' + ctx.jsondata['color']) if IValue.providedBy(ctx): if ctx.domainelement: return url('c' + ctx.domainelement.jsondata['color']) return url(ctx.valueset.language.family.jsondata['icon']) if IValueSet.providedBy(ctx): # # FIXME: To add genericity, draw a pie chart respecting all values! # if ctx.values[0].domainelement: return url('c' + ctx.values[0].domainelement.jsondata['color']) if ctx.language.family: return url(ctx.language.family.jsondata['icon']) return url( req.registry.settings.get('clld.isolates_icon', ISOLATES_ICON)) if ILanguage.providedBy(ctx): icon_ = super(LanguageByFamilyMapMarker, self).get_icon(ctx, req) if ctx.subgroup: icon_ = ctx.jsondata['shape'] + icon_[1:] return url(icon_) return super(LanguageByFamilyMapMarker, self).__call__(ctx, req)
def get_icon(self, ctx, req): if IValue.providedBy(ctx): return ctx.domainelement.jsondata['icon'] if IValueSet.providedBy(ctx): return ctx.values[0].domainelement.jsondata['icon'] if IDomainElement.providedBy(ctx): return ctx.jsondata['icon'] return LanguageByFamilyMapMarker.get_icon(self, ctx, req)
def __call__(self, ctx, req): if IValueSet.providedBy(ctx): if ctx.language.family: return data_url(icon(ctx.language.family.jsondata['icon'])) return data_url(icon(req.registry.settings.get('clld.isolates_icon', ISOLATES_ICON))) return super(LanguageByFamilyMapMarker, self).__call__(ctx, req)
def __call__(self, ctx, req): spec = None if IValueSet.providedBy(ctx): spec = 'c' + ctx.contribution.color elif IValue.providedBy(ctx): spec = 'c' + ctx.valueset.contribution.color elif ILanguage.providedBy(ctx): spec = 'ddd0000' if ctx.vocabulary else 'c4d6cee' return svg.data_url(svg.icon(spec)) if spec else \ super(WoldMapMarker, self).__call__(ctx, req)
def __call__(self, ctx, req): asset_spec = None if IValueSet.providedBy(ctx): asset_spec = 'wold2:static/%s.png' % ctx.contribution.color elif IValue.providedBy(ctx): asset_spec = 'wold2:static/%s.png' % ctx.valueset.contribution.color elif ILanguage.providedBy(ctx): asset_spec = 'clld:web/static/icons/%s.png' % ( 'ddd0000' if ctx.vocabulary else 'c4d6cee',) return req.static_url(asset_spec) if asset_spec else \ super(WoldMapMarker, self).__call__(ctx, req)
def __call__(self, ctx, req): asset_spec = None if IValueSet.providedBy(ctx): asset_spec = 'wold2:static/%s.png' % ctx.contribution.color elif IValue.providedBy(ctx): asset_spec = 'wold2:static/%s.png' % ctx.valueset.contribution.color elif ILanguage.providedBy(ctx): asset_spec = 'clld:web/static/icons/%s.png' % ( 'ddd0000' if ctx.vocabulary else 'c4d6cee', ) return req.static_url(asset_spec) if asset_spec else \ super(WoldMapMarker, self).__call__(ctx, req)
def __call__(self, ctx, req): if IValue.providedBy(ctx): return data_url(icon('c' + ctx.valueset.language.jsondata['color'])) if IValueSet.providedBy(ctx): return data_url(icon('c' + ctx.language.jsondata['color'])) elif ILanguage.providedBy(ctx): return data_url(icon('c' + ctx.jsondata['color'])) return super(LanguageByCantonMapMarker, self).__call__(ctx, req) # pragma: no cover
def __call__(self, ctx, req): c = None if ILanguage.providedBy(ctx): c = ctx.jsondata.get('color') elif IValueSet.providedBy(ctx): c = ctx.language.jsondata.get('color') if c: return req.static_url('waab:static/%s.png' % c) return super(waabMapMarker, self).__call__(ctx, req) # pragma: no cover
def __call__(self, ctx, req): lang = None if IValueSet.providedBy(ctx): lang = ctx.language elif IValue.providedBy(ctx): lang = ctx.valueset.language elif ILanguage.providedBy(ctx): lang = ctx if lang: return req.static_url('csd:static/icons/%s%s.png' % ( 't' if lang.proto else 'c', lang.color)) return super(CsdMapMarker, self).__call__(ctx, req) # pragma: no cover
def link_attrs(req, obj, **kw): if ILanguage.providedBy(obj): # we are about to link to a language details page: redirect to contribution page! id_ = obj.language.id if obj.language else obj.id kw['href'] = req.route_url('contribution', id=id_, **kw.pop('url_kw', {})) if IValueSet.providedBy(obj) and obj.parameter_pk == 1: # we are about to link to a valueset of the "hidden" feature 0: redirect to # contribution page! kw['href'] = req.route_url( 'contribution', id=obj.language.id, **kw.pop('url_kw', {})) return kw
class LanguageByFamilyMapMarker(util.LanguageByFamilyMapMarker): def __call__(self, ctx, req): {% if cookiecutter.cldf_module.lower() == 'wordlist' %} if IValueSet.providedBy(ctx): if ctx.language.family: return data_url(icon(ctx.language.family.jsondata['icon'])) return data_url(icon(req.registry.settings.get('clld.isolates_icon', util.ISOLATES_ICON))) {% elif cookiecutter.cldf_module.lower() == 'structuredataset' %} if IValueSet.providedBy(ctx): c = collections.Counter([v.domainelement.jsondata['color'] for v in ctx.values]) return data_url(pie(*list(zip(*[(v, k) for k, v in c.most_common()])), **dict(stroke_circle=True))) if IDomainElement.providedBy(ctx): return data_url(icon(ctx.jsondata['color'].replace('#', 'c'))) if IValue.providedBy(ctx): return data_url(icon(ctx.domainelement.jsondata['color'].replace('#', 'c')))
def __call__(self, ctx, req): if IValue.providedBy(ctx): 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))
def __call__(self, ctx, req): if IDomainElement.providedBy(ctx): return self.svg_icon(ctx) if IValue.providedBy(ctx): if ctx.domainelement_pk: return self.svg_icon(ctx.domainelement) return LanguageByFamilyMapMarker.__call__(self, ctx.valueset.language, req) if IValueSet.providedBy(ctx): if ctx.values[0].domainelement_pk: return self.svg_icon(ctx.values[0].domainelement) return LanguageByFamilyMapMarker.__call__(self, ctx.language, req) if ILanguage.providedBy(ctx): if ctx.family: return data_url(icon(ctx.family.jsondata['icon'])) return data_url(icon(req.registry.settings.get('clld.isolates_icon', ISOLATES_ICON))) return LanguageByFamilyMapMarker.__call__(self, ctx, req)
def link_attrs(req, obj, **kw): if ILanguage.providedBy(obj): # we are about to link to a language details page: redirect to contribution page! id_ = obj.language.id if obj.language else obj.id kw['href'] = req.route_url('contribution', id=id_, **kw.pop('url_kw', {})) if IValueSet.providedBy(obj) and obj.parameter_pk == 1: # we are about to link to a valueset of the "hidden" feature 0: redirect to # contribution page! kw['href'] = req.route_url('contribution', id=obj.language.id, **kw.pop('url_kw', {})) return kw
def __call__(self, ctx, req): icon = None if IValueSet.providedBy(ctx): if req.matched_route.name == 'valueset' and not ctx.parameter.multivalued: return '' icon = ctx.jsondata['icon'] if IValue.providedBy(ctx): icon = ctx.domainelement.jsondata['icon'] if IDomainElement.providedBy(ctx): icon = ctx.jsondata['icon'] if icon: return req.static_url('apics:static/icons/%s' % icon) return super(ApicsMapMarker, self).__call__(ctx, req)
def get_color(self, ctx, req): lineage = None if ctx and isinstance(ctx, (tuple, list)): ctx = ctx[0] if ILanguage.providedBy(ctx): lineage = ctx.lineage elif IValueSet.providedBy(ctx): lineage = ctx.language.lineage elif IValue.providedBy(ctx): lineage = ctx.valueset.language.lineage if isinstance(ctx, string_types): lineage = req.db.query(models.Lineage)\ .filter(models.Lineage.name == ctx).one() return lineage.color if lineage else 'ff6600'
def get_color(self, ctx, req): lineage = None if ctx and isinstance(ctx, (tuple, list)): ctx = ctx[0] if ILanguage.providedBy(ctx): lineage = ctx.lineage elif IValueSet.providedBy(ctx): lineage = ctx.language.lineage elif IValue.providedBy(ctx): lineage = ctx.valueset.language.lineage if isinstance(ctx, str): lineage = req.db.query(models.Lineage)\ .filter(models.Lineage.name == ctx).one() return lineage.color if lineage else 'ff6600'
def __call__(self, ctx, req): if IValueSet.providedBy(ctx): if req.matched_route.name == 'valueset' and not ctx.parameter.multivalued: return self.pie((100, ctx.values[0].domainelement.jsondata['color'])) return self.pie_from_filename(ctx.jsondata['icon']) if IValue.providedBy(ctx): freq = ctx.frequency or 100 slices = [(freq, ctx.domainelement.jsondata['color'])] if freq < 100: slices.append((100 - freq, 'ffffff')) return self.pie(*slices) if IDomainElement.providedBy(ctx): return self.pie((100, ctx.jsondata['color'])) return super(ApicsMapMarker, self).__call__(ctx, req)
def __call__(self, ctx, req): if IValueSet.providedBy(ctx): if req.matched_route.name == 'valueset' and not ctx.parameter.multivalued: return self.pie( (100, ctx.values[0].domainelement.jsondata['color'])) return self.pie_from_filename(ctx.jsondata['icon']) if IValue.providedBy(ctx): freq = ctx.frequency or 100 slices = [(freq, ctx.domainelement.jsondata['color'])] if freq < 100: slices.append((100 - freq, 'ffffff')) return self.pie(*slices) if IDomainElement.providedBy(ctx): return self.pie((100, ctx.jsondata['color'])) return super(ApicsMapMarker, self).__call__(ctx, req)
def __call__(self, ctx, req): #if ILanguage.providedBy(ctx) or IValueSet.providedBy(ctx): # return req.registry.getUtility(IIcon, 'c{0}'.format(ctx.jsondata['color'])).url(req) icon = None if ILanguage.providedBy(ctx): icon = ctx.languoid.jsondata['icon'] elif IValue.providedBy(ctx): icon = ctx.jsondata['icon'] elif IValueSet.providedBy(ctx): icon = ctx.jsondata['icon'] if icon: try: return svg.data_url(svg.icon(icon)) except: raise ValueError(icon) return super(GelatoMapMarker, self).__call__(ctx, req) # pragma: no cover
def __call__(self, ctx, req): mapping = {} count = -1 shape = 'c' if IValueSet.providedBy(ctx): c = colors[ctx.language.family] if ctx.language.family in ['MIA', 'OIA'] or 'Old' in ctx.language.name: shape = 'd' return data_url(icon(shape + c)) if ILanguage.providedBy(ctx): c = colors[ctx.family] if ctx.family in ['MIA', 'OIA'] or 'Old' in ctx.name: shape = 'd' return data_url(icon(shape + c)) return super(LanguageByFamilyMapMarker, self).__call__(ctx, req)
def get_icon(self, ctx, req): if IValue.providedBy(ctx): ctx = ctx.valueset if IValueSet.providedBy(ctx): ctx = ctx.language return LanguageByFamilyMapMarker.get_icon(self, ctx, req)
def __call__(self, ctx, req): {% if cookiecutter.cldf_module.lower() == 'wordlist' %} if IValueSet.providedBy(ctx): if ctx.language.family: return data_url(icon(ctx.language.family.jsondata['icon'])) return data_url(icon(req.registry.settings.get('clld.isolates_icon', util.ISOLATES_ICON)))