def linked_image(obj, check=True): if check and maintype(obj) != 'image': raise ValueError('type mismatch: {0} and image'.format(maintype(obj))) return HTML.a( HTML.img(src=bitstream_url(obj, 'web'), class_='image'), href=bitstream_url(obj), title="View image ({0})".format(format_size(obj.jsondata.get('size', 0))))
def get_legends(self): def img(spec): return HTML.img( src=self.icon_map[spec], height='20', width='20', style='margin-left: 0.5em;') def desc(text): return HTML.span(text, style='margin-left: 0.5em; margin-right: 0.5em;') values = [desc('Most extensive description is a ...')] for sdt in SIMPLIFIED_DOCTYPES: values.append( HTML.label( HTML.input( type='checkbox', checked='checked', id='marker-toggle-sdt-' + str(sdt.ord), onclick='GLOTTOLOG3.LangdocStatus.toggleMarkers()'), img(sdt.shape + 'ffffff' if self.focus == 'ed' else 'c' + sdt.color), desc(sdt.name))) values.append(desc('Language is ...')) for ed in ENDANGERMENTS: values.append(( HTML.label( HTML.input( type='checkbox', checked='checked', id='marker-toggle-ed-' + str(ed.ord), onclick='GLOTTOLOG3.LangdocStatus.toggleMarkers()'), img('c' + ed.color if self.focus == 'ed' else ed.shape + 'ffffff'), desc(ed.name.lower())))) yield Legend(self, 'values', values, label='Legend')
def format_languages(req, ref): ldict = {l.hid: l for l in ref.languages} in_note = {} lnotes = map(normalize_language_explanation, (ref.language_note or '').split(',')) for lnote in lnotes: note = [] start = 0 m = None for m in LANG_PATTERN.finditer(lnote): note.append(lnote[start:m.start()]) note.append('[') if m.group('id') in ldict: in_note[m.group('id')] = 1 lang = ldict[m.group('id')] note.append(link(req, lang, label=lang.id, title=lang.name)) else: note.append(m.group('id')) note.append(']') start = m.end() if m: note.append(lnote[m.end():]) yield HTML.li(*note) for lang in ldict.values(): if lang.hid not in in_note: yield HTML.li( lang.name + ' [', link(req, lang, label=lang.id, title=lang.name), ']')
def get_legends(self): def img(spec): return HTML.img(src=svg.data_url(svg.icon(spec)), height='20', width='20', style='margin-left: 0.5em;') def desc(text): return HTML.span(text, style='margin-left: 0.5em; margin-right: 0.5em;') values = [desc('Most extensive description is a ...')] for sdt in get_parameter('med').domain: icon = self.de_to_icon['med'][sdt.id.split('-')[1]] values.append( HTML.label( HTML.input( type='checkbox', checked='checked', id='marker-toggle-sdt-' + str(sdt.number), onclick='GLOTTOLOG3.LangdocStatus.toggleMarkers()'), img(icon.shape + 'ffffff' if self.focus == 'ed' else 'c' + icon.color), desc(sdt.name))) values.append(desc('Language is ...')) for ed in get_parameter('aes').domain: icon = self.de_to_icon['aes'][ed.id.split('-')[1]] values.append((HTML.label( HTML.input(type='checkbox', checked='checked', id='marker-toggle-ed-' + str(ed.number), onclick='GLOTTOLOG3.LangdocStatus.toggleMarkers()'), img('c' + icon.color if self.focus == 'ed' else icon.shape + 'ffffff'), desc(ed.name.lower())))) yield Legend(self, 'values', values, label='Legend')
def gloss_with_tooltip(gloss): person_map = {"1": "first person", "2": "second person", "3": "third person"} res = [] end = 0 for match in GLOSS_ABBR_PATTERN.finditer(gloss): if match.start() > end: res.append(gloss[end : match.start()]) abbr = match.group("abbr") if abbr in abbrs: explanation = abbrs[abbr] if match.group("personprefix"): explanation = "%s %s" % (person_map[match.group("personprefix")], explanation) if match.group("personsuffix"): explanation = "%s %s" % (explanation, person_map[match.group("personsuffix")]) res.append( HTML.span( HTML.span(gloss[match.start() : match.end()].lower(), class_="sc"), **{"data-hint": explanation, "class": "hint--bottom"} ) ) else: res.append(abbr) end = match.end() res.append(gloss[end:]) return filter(None, res)
def format_external_link_in_label(url, label=None): label = label or URL(url).domain() return HTML.span(HTML.a(HTML.i('', class_="icon-share icon-white"), label, href=url, style="color: white"), class_="label label-info")
def format(self, item): if not item.gbif_url: return '' return HTML.a(HTML.img( width='20', src=self.dt.req.static_url('acc:static/gbif.png')), item.gbif_name, href=item.gbif_url)
def image_detail_html(context=None, request=None, **kw): referents = get_sticks(context) if context.mime_type == 'application/pdf': return { 'referents': referents, 'image': HTML.div( HTML.iframe( class_='pdf_iframe', src='%sbitstreams/%s/%s' % (cdstar.SERVICE_URL, context.jsondata.get('refobjid'), context.jsondata.get('original')), frameborder='0', ), class_='div_pdf_iframe', ) } else: return { 'referents': referents, 'image': HTML.img( class_='image_single', src=cdstar.bitstream_url(context), ), }
def text2html(text, mode='br', sep='\n\n'): """ >>> assert 'div' in unicode(text2html('chunk', mode='p')) """ if mode == 'p': return HTML.div(*[HTML.p(literal(newline2br(line))) for line in text.split(sep)]) return HTML.p(literal(newline2br(text)))
def toolbar(self): """ """ return HTML.div( button(icon('info-sign', inverted=True), class_='btn-info %s-cdOpener' % self.eid), HTML.a( icon('download-alt'), HTML.span(class_="caret"), **{ 'class_': "btn dropdown-toggle", 'data-toggle': "dropdown", 'href': "#", 'id': "dt-dl-opener", }), HTML.ul( #HTML.li(HTML.a('csv', href="#")), *[ HTML.li( HTML. a(fmt, href="#", onclick= "document.location.href = CLLD.DataTable.current_url" "('%s', '%s'); return false;" % (self.eid, fmt), id='dt-dl-%s' % fmt)) for fmt in [ a.extension for n, a in self.req.registry.getAdapters( [self.model()], IIndex) ] if fmt != 'html' ], **dict(class_="dropdown-menu")), class_='btn-group right')
def gloss_with_tooltip(gloss): person_map = { '1': 'first person', '2': 'second person', '3': 'third person', } res = [] end = 0 for match in GLOSS_ABBR_PATTERN.finditer(gloss): if match.start() > end: res.append(gloss[end:match.start()]) abbr = match.group('abbr') if abbr in abbrs: explanation = abbrs[abbr] if match.group('personprefix'): explanation = '%s %s' % ( person_map[match.group('personprefix')], explanation) if match.group('personsuffix'): explanation = '%s %s' % ( explanation, person_map[match.group('personsuffix')]) res.append(HTML.span( HTML.span(gloss[match.start():match.end()].lower(), class_='sc'), **{'data-hint': explanation, 'class': 'hint--bottom'})) else: res.append(abbr) end = match.end() res.append(gloss[end:]) return filter(None, res)
def cc_link(req, license_url, button='regular'): if license_url == 'https://en.wikipedia.org/wiki/Public_domain': license_url = 'https://creativecommons.org/publicdomain/zero/1.0/' license_url = URL(license_url) if license_url.host() != 'creativecommons.org': return comps = license_url.path().split('/') if len(comps) < 3: return # pragma: no cover known = { 'zero': 'Public Domain', 'by': 'Creative Commons Attribution License', 'by-nc': 'Creative Commons Attribution-NonCommercial License', 'by-nc-nd': 'Creative Commons Attribution-NonCommercial-NoDerivatives License', 'by-nc-sa': 'Creative Commons Attribution-NonCommercial-ShareAlike License', 'by-nd': 'Creative Commons Attribution-NoDerivatives License', 'by-sa': 'Creative Commons Attribution-ShareAlike License'} if comps[2] not in known: return icon = 'cc-' + comps[2] + ('-small' if button == 'small' else '') + '.png' img_attrs = dict( alt=known[comps[2]], src=req.static_url('clld:web/static/images/' + icon)) height, width = (15, 80) if button == 'small' else (30, 86) img_attrs.update(height=height, width=width) return HTML.a(HTML.img(**img_attrs), href=license_url, rel='license')
def format(self, item): return HTML.ul( *[HTML.li( link(self.dt.req, c.contribution), style="background-color: #%s;" % c.contribution.color, class_='dt-full-cell') for c in item.contribution_assocs], class_='nav nav-pills nav-stacked')
def cc_link(req, license_url, button='regular'): if license_url == 'https://en.wikipedia.org/wiki/Public_domain': license_url = 'https://creativecommons.org/publicdomain/zero/1.0/' # pragma: no cover license_url = URL(license_url) if license_url.host() != 'creativecommons.org': return comps = license_url.path().split('/') if len(comps) < 3: return # pragma: no cover known = { 'zero': 'Public Domain', 'by': 'Creative Commons Attribution License', 'by-nc': 'Creative Commons Attribution-NonCommercial License', 'by-nc-nd': 'Creative Commons Attribution-NonCommercial-NoDerivatives License', 'by-nc-sa': 'Creative Commons Attribution-NonCommercial-ShareAlike License', 'by-nd': 'Creative Commons Attribution-NoDerivatives License', 'by-sa': 'Creative Commons Attribution-ShareAlike License'} if comps[2] not in known: return icon = 'cc-' + comps[2] + ('-small' if button == 'small' else '') + '.png' img_attrs = dict( alt=known[comps[2]], src=req.static_url('clld:web/static/images/' + icon)) height, width = (15, 80) if button == 'small' else (30, 86) img_attrs.update(height=height, width=width) return HTML.a(HTML.img(**img_attrs), href=license_url, rel='license')
def cc_link(req, license_url, button="regular"): if license_url == "http://en.wikipedia.org/wiki/Public_domain": license_url = "http://creativecommons.org/publicdomain/zero/1.0/" license_url = URL(license_url) if license_url.host() != "creativecommons.org": return comps = license_url.path().split("/") if len(comps) < 3: return # pragma: no cover known = { "zero": "Public Domain", "by": "Creative Commons Attribution License", "by-nc": "Creative Commons Attribution-NonCommercial License", "by-nc-nd": "Creative Commons Attribution-NonCommercial-NoDerivatives License", "by-nc-sa": "Creative Commons Attribution-NonCommercial-ShareAlike License", "by-nd": "Creative Commons Attribution-NoDerivatives License", "by-sa": "Creative Commons Attribution-ShareAlike License", } if comps[2] not in known: return icon = "cc-" + comps[2] + ("-small" if button == "small" else "") + ".png" img_attrs = dict(alt=known[comps[2]], src=req.static_url("clld:web/static/images/" + icon)) height, width = (15, 80) if button == "small" else (30, 86) img_attrs.update(height=height, width=width) return HTML.a(HTML.img(**img_attrs), href=license_url, rel="license")
def concepticon_link(request, concept): return HTML.a(HTML.img( src=request.static_url('lexibank:static/concepticon_logo.png'), height=20, width=30), title='corresponding concept set at Concepticon', href=concept.concepticon_url)
def __init__(self, dt, name, **kw): self.macroareas = DBSession.query(Macroarea).order_by(Macroarea.id).all() kw['bSortable'] = False kw['sDescription'] = HTML.span( 'see ', HTML.a('glossary', href=dt.req.route_url('home.glossary', _anchor='macroarea'))) super(MacroareaCol, self).__init__(dt, name, **kw)
def format(self, item): return HTML.ul( *[ HTML.li('Min: {0.min:.2f}'.format(item.unitparameter)), HTML.li('Max: {0.max:.2f}'.format(item.unitparameter)), HTML.li('Mean: {0.mean:.2f}'.format(item.unitparameter)), HTML.li('Median: {0.median:.2f}'.format(item.unitparameter)), ], **{'class': 'inline'})
def legend_items(req): for type, label in [('recipient', 'recipient language'), ('donor', 'donor languoid')]: yield HTML.label(HTML.img(src=icon_url(req, type), height='20', width='20'), literal(' ' + label), style='margin-left: 1em; margin-right: 1em;')
def format_justifications(req, refs): r = [] for ref in refs: label = ref.source.name if ref.description: label += '[%s]' % ref.description r.append(HTML.li(link(req, ref.source, label=label))) return HTML.ul(*r)
def concepticon_link(request, meaning): return HTML.a( HTML.img( src=request.static_url('dictionaria:static/concepticon_logo.png'), height=20, width=30), title='corresponding concept set at Concepticon', href=meaning.concepticon_url)
def infobox(*content): return HTML.div( HTML.button( '\xd7', **{ 'type': "button", 'class': "close", 'data-dismiss': "alert" }), *content, **{'class': "alert alert-success"})
def make_item(label, icon): return HTML.span( HTML.img( width=16, height=16, src=self.req.static_url('clld:web/static/icons/%s.png' % icon)), HTML.span(label, style='padding-left:5px'), style='padding-left:5px')
def text2html(text, mode="br", sep="\n\n"): """Turn plain text into simple HTML. >>> assert 'div' in text_type(text2html('chunk', mode='p')) """ if mode == "p": return HTML.div(*[HTML.p(literal(newline2br(line))) for line in text.split(sep)]) return HTML.p(literal(newline2br(text)))
def format_classification(species, with_species=False, with_rank=False): names = [(r, getattr(species, r)) for r in 'order family genus'.split()] if with_species: names.append(('species', species.name)) return HTML.ul( *[HTML.li(('{0} {1}: {2}' if with_rank else '{0} {2}').format('-' * i, *n)) for i, n in enumerate(n for n in names if n[1])], class_="unstyled")
def thead(*cols): return HTML.thead( HTML.tr( HTML.th("", style="height:26px; font-weight:"), *[HTML.th(col) for col in cols], **dict(style="background: #F2F2F2") ) )
def text2html(text, mode='br', sep='\n\n'): """ >>> assert 'div' in unicode(text2html('chunk', mode='p')) """ if mode == 'p': return HTML.div( *[HTML.p(literal(newline2br(line))) for line in text.split(sep)]) return HTML.p(literal(newline2br(text)))
def format(self, item): return HTML.ul( *[HTML.li(HTML.span( link(self.dt.req, c.valueset.parameter), ' ', concepticon_link(self.dt.req, c.valueset.parameter) )) for c in item.counterparts], class_='unstyled' )
def format_external_link_in_label(url, label=None): label = label or URL(url).domain() return HTML.span( HTML.a( HTML.i('', class_="icon-share icon-white"), label, href=url, style="color: white"), class_="label label-info")
def format(self, item): return HTML.ul(*[ HTML.li(link(self.dt.req, c.contribution), style="background-color: #%s;" % c.contribution.color, class_='dt-full-cell') for c in item.contribution_assocs ], class_='nav nav-pills nav-stacked')
def language_detail_html(context=None, request=None, **kw): # makes sure all display elements have a value param_word = {p.id: '#' for p in DBSession.query(Parameter)} # override the param_word dict with values from the DB for word in DBSession.query(Value)\ .join(ValueSet)\ .filter(ValueSet.language_pk == context.pk)\ .options(joinedload_all(Value.valueset, ValueSet.parameter)): param_word[word.valueset.parameter.id] = word.name def thead(*cols): return HTML.thead( HTML.tr( HTML.th("", style="height:26px; font-weight:"), *[HTML.th(col) for col in cols], **dict(style="background: #F2F2F2") ) ) def td(p): return HTML.td(param_word.get(p, '') if p else '') def tr(name, *params): return HTML.tr( HTML.td( name, style="height:26px; font-weight: bold; background: #F2F2F2; padding: 5px"), *[td(p) for p in params]) def table(*cols, **kw): male_cols = kw.get('male', ['m' + col for col in cols]) female_cols = kw.get('female', ['f' + col for col in cols]) return HTML.table( thead(*cols), HTML.tbody(tr('male', *male_cols), tr('female', *female_cols))) # create a paradigm_tables dict for the HTML rendering paradigm_tables = { 'pronouns': HTML.table( thead("A", "S", "O", "P"), HTML.tbody( tr('1st (excl) Person Singular', '1sg_a', '1sg_s', '1sg_o', '1sg_p'), tr('1st (excl) Person Dual', '1du_a', '1du_s', '1du_o', '1du_p'), tr('1st (excl) Person Plural', '1pl_a', '1pl_s', '1pl_o', '1pl_p'), tr('1st (incl) Person Dual', '12du_a', '12du_s', '12du_o', '12du_p'), tr('1st (incl) Person Plural', '12pl_a', '12pl_s', '12pl_o', '12pl_p'), tr('2nd Person Singular', '2sg_a', '2sg_s', '2sg_o', '2sg_p'), tr('2nd Person Dual', '2du_a', '2du_s', '2du_o', '2du_p'), tr('2nd Person Plural', '2pl_a', '2pl_s', '2pl_o', '2pl_p'), tr('3rd Person Singular Gender 1', '3sg_gen1_a', '3sg_gen1_s', '3sg_gen1_o', '3sg_gen1_p'), tr('3rd Person Singular Gender 2', '3sg_gen2_a', '3sg_gen2_s', '3sg_gen2_o', '3sg_gen2_p'), tr('3rd Person Dual', '3du_gen1_a', '3du_gen1_s', '3du_gen1_o', '3du_gen1_p'), tr('3rd Person Plural', '3pl_gen1_a', '3pl_gen1_s', '3pl_gen1_o', '3pl_gen1_p'), ) ), } return paradigm_tables
def collapsed(id_, content, button_content=None): return HTML.div( HTML.p( HTML.a( button_content or icon('plus-sign'), **{ 'class': 'btn', 'data-toggle': 'collapse', 'data-target': '#%s' % id_ })), HTML.div(content, id=id_, class_='collapse'))
def alt_translation(sentence): res = "" if sentence.jsondata.get("alt_translation"): text = sentence.jsondata["alt_translation"] name = "" if ALT_TRANSLATION_LANGUAGE_PATTERN.match(text): name, text = [t.strip() for t in text.split(":", 1)] name = HTML.span(name + ": ") res = HTML.div(name, HTML.span(text, class_="translation")) return res
def alt_translation(sentence): res = '' if sentence.jsondatadict.get('alt_translation'): text = sentence.jsondatadict['alt_translation'] name = '' if ALT_TRANSLATION_LANGUAGE_PATTERN.match(text): name, text = [t.strip() for t in text.split(':', 1)] name = HTML.span(name + ': ') res = HTML.div(name, HTML.span(text, class_='translation')) return res
def concepticon_link(request, concept): if not concept.concepticon_id: return '' return HTML.a( HTML.img( src=request.static_url('dogonlanguages:static/concepticon_logo.png'), height=20, width=30), title='corresponding concept set at Concepticon', href=concept.concepticon_url)
def format(self, item): item = self.get_obj(item) return HTML.span( HTML.img(width='20', src=svg.data_url(svg.icon(item.jsondata['icon']))), ' ', HTML.a(item.family_name, href="http://glottolog.org/resource/languoid/id/" + item.family_id), style="white-space: nowrap;")
def alt_translation(sentence): res = '' if sentence.jsondata.get('alt_translation'): text = sentence.jsondata['alt_translation'] name = '' if ALT_TRANSLATION_LANGUAGE_PATTERN.match(text): name, text = [t.strip() for t in text.split(':', 1)] name = HTML.span(name + ': ') res = HTML.div(name, HTML.span(text, class_='translation')) return res
def collapsed(id_, content, button_content=None): return HTML.div( HTML.p( HTML.a( button_content or icon("plus-sign"), **{"class": "btn", "data-toggle": "collapse", "data-target": "#%s" % id_} ) ), HTML.div(content, id=id_, class_="collapse"), )
def format(self, item): parts = [] for i, cogid in enumerate((item.partial_cognate or '').split()): if i > 0: parts.append('+') parts.append( HTML.a(cogid, href=self.dt.req.route_url('cognateset', id=cogid))) return HTML.span(*parts)
def amsd_linked_references(req, obj): chunks = [] for ref in sorted(getattr(obj, 'references', []), key=lambda x: x.source.note or ''): if ref.source: chunks.append( HTML.li(HTML.span(link(req, ref.source), class_='citation'))) if chunks: return HTML.span(*chunks) return '' # pragma: no cover
def format_classification(taxon, with_species=False, with_rank=False): names = OrderedDict() for r in 'kingdom phylum class_ order family'.split(): names[r.replace('_', '')] = getattr(taxon, r) if with_species: names[taxon.rank] = taxon.name return HTML.ul( *[HTML.li(('{0} {1}: {2}' if with_rank else '{0}{2}').format('-' * i, *n)) for i, n in enumerate(n for n in names.items() if n[1])], class_="unstyled")
def tsammalex_link(request, concept): if not concept.tsammalex_taxon: return '' return HTML.a( HTML.img( src=request.static_url('dogonlanguages:static/tsamma.png'), height=20, width=30), title='corresponding taxon at Tsammalex', href=concept.tsammalex_url)
def get_legends(self): if len(self.layers) > 1: items = [] total = 0 repr_attrs = dict(class_='pull-right stay-open', style="padding-right: 10px;") for layer in self.layers: representation = '' if hasattr(layer, 'representation'): total += layer.representation representation = HTML.span(str(layer.representation), **repr_attrs) items.append([ HTML.label( HTML.input( class_="stay-open", type="checkbox", checked="checked", onclick=helpers.JS_CLLD.mapToggleLayer( self.eid, layer.id, helpers.JS("this"))), getattr(layer, 'marker', ''), layer.name, class_="checkbox inline stay-open", style="margin-left: 5px; margin-right: 5px;", ), representation, ]) if total: items.append(HTML.span(HTML.b(str(total)), **repr_attrs)) yield Legend( self, 'layers', items, label='Legend', stay_open=True, item_attrs=dict(style='clear: right')) items = [] for size in [15, 20, 30, 40]: attrs = dict(name="iconsize", value=str(size), type="radio") if size == self.options.get('icon_size', 30): attrs['checked'] = 'checked' items.append(HTML.label( HTML.input(onclick=helpers.JS_CLLD.mapResizeIcons(self.eid), **attrs), HTML.img( height=str(size), width=str(size), src=self.req.registry.getUtility(IIcon, 'cff6600').url(self.req)), class_="radio", style="margin-left: 5px; margin-right: 5px;")) yield Legend( self, 'iconsize', items, label='Icon size') item = lambda layer: HTML.a( layer.name, onclick='return %s;' % helpers.JS_CLLD.mapShowGeojson(self.eid, layer.id), href=layer.data if isinstance(layer.data, basestring) else '#') yield Legend( self, 'geojson', map(item, self.layers), label='GeoJSON', pull_right=True)
def format_iso_retirement(req, lang): ir = lang.iso_retirement _md, comment = [], '' if ir.description: comment = HTML.div( HTML.p(HTML.strong("Excerpt from change request document:")), HTML.blockquote(md(req, ir.description, small=True))) if ir.change_request: _md.append(( 'Change request:', link( req, Refprovider.get('iso6393:{0}'.format(ir.change_request)).ref, label=ir.change_request))) _md.append(('ISO 639-3:', ir.id)) _md.append(('Name:', ir.name)) if ir.reason: _md.append(('Reason:', ir.reason)) _md.append(('Effective:', ir.effective)) return infobox( HTML.p( HTML.strong("Retired in ISO 639-3: "), linkify_iso_codes(req, ir.remedy, class_='iso639-3')), HTML.ul(*[HTML.li(HTML.strong(dt), Markup(' '), dd) for dt, dd in _md], **{'class': 'inline'}), comment)
def get_legends(self): if len(self.layers) > 1: items = [] total = 0 repr_attrs = dict(class_='pull-right stay-open', style="padding-right: 10px;") for layer in self.layers: representation = '' if hasattr(layer, 'representation'): total += layer.representation representation = HTML.span(str(layer.representation), **repr_attrs) items.append([ HTML.label( HTML.input( class_="stay-open", type="checkbox", checked="checked", onclick=helpers.JS_CLLD.mapToggleLayer( self.eid, layer.id, helpers.JS("this"))), getattr(layer, 'marker', ''), layer.name, class_="checkbox inline stay-open", style="margin-left: 5px; margin-right: 5px;", ), representation, ]) if total: items.append(HTML.span(HTML.b(str(total)), **repr_attrs)) yield Legend( self, 'layers', items, label='Legend', stay_open=True, item_attrs=dict(style='clear: right')) items = [] for size in [15, 20, 30, 40]: attrs = dict(name="iconsize", value=str(size), type="radio") if size == self.options.get('icon_size', 30): attrs['checked'] = 'checked' items.append(HTML.label( HTML.input(onclick=helpers.JS_CLLD.mapResizeIcons(self.eid), **attrs), HTML.img( height=str(size), width=str(size), src=self.req.registry.getUtility(IIcon, 'cff6600').url(self.req)), class_="radio", style="margin-left: 5px; margin-right: 5px;")) yield Legend( self, 'iconsize', items, label='Icon size') item = lambda layer: HTML.a( layer.name, onclick='return %s;' % helpers.JS_CLLD.mapShowGeojson(self.eid, layer.id), href=layer.data if isinstance(layer.data, string_types) else '#') yield Legend( self, 'geojson', map(item, self.layers), label='GeoJSON', pull_right=True)
def format_iso_retirement(req, lang): ir = lang.jsondata['iso_retirement'] _md, comment = [], '' if ir['comment']: comment = HTML.div( HTML.p(HTML.strong("Excerpt from change request document:")), HTML.blockquote(md(req, ir['comment'], small=True))) if ir['change_request']: _md.append(('Change request:', link(req, Refprovider.get('iso6393:{0}'.format( ir['change_request'])).ref, label=ir['change_request']))) _md.append(('ISO 639-3:', ir['code'])) _md.append(('Name:', ir['name'])) if ir['reason']: _md.append(('Reason:', ir['reason'])) _md.append(('Effective:', ir['effective'])) return infobox( HTML.p(HTML.strong("Retired in ISO 639-3: "), linkify_iso_codes(req, ir['remedy'], class_='iso639-3')), HTML.ul( *[ HTML.li(HTML.strong(dt), Markup(' '), dd) for dt, dd in _md ], **{'class': 'inline'}), comment)
def doc(self): items = [] for col in self.ctx.cols: dsc = col.js_args.get('sDescription') if dsc: items.extend([HTML.dt(col.js_args['sTitle']), HTML.dd(dsc)]) return HTML.dl( HTML. p('Columns containing numeric data may be filtered giving upper or lower ' 'bounds in the form "<5" or ranges in the form "-2..20".'), self.ctx.options.get('sDescription', ''), *items)
def __init__(self, dt, name, **kw): ma = DBSession.query(Parameter).filter( Parameter.id == 'macroarea').one() kw['choices'] = [de.name for de in ma.domain] kw['bSortable'] = False kw['sDescription'] = HTML.span( 'see ', HTML.a('glossary', href=dt.req.route_url('home.glossary', _anchor='macroarea'))) super(MacroareaCol, self).__init__(dt, name, **kw)
def html_table(lol, caption): return str( HTML.table( HTML.caption(caption), *[ HTML.tr( *[HTML.td(col, class_='td paradigm-td') for col in row]) for row in lol ], **{'class': 'table paradigm-table'}, ))
def add_unit_links(req, contrib, text): res, pos = [], 0 for m in MARKDOWN_LINK_PATTERN.finditer(text): if m.start() > pos: res.append(escape(text[pos:m.start()])) res.append(HTML.a( m.group('label'), href=req.route_url('unit', id='{0}-{1}'.format(contrib.id, m.group('uid'))))) pos = m.end() if pos < len(text): res.append(escape(text[pos:])) return HTML.span(*res)
def doc(self): items = [] for col in self.ctx.cols: dsc = col.js_args.get('sDescription') if dsc: items.extend([HTML.dt(col.js_args['sTitle']), HTML.dd(dsc)]) return HTML.dl( HTML.p( 'Columns containing numeric data may be filtered giving upper or lower ' 'bounds in the form "<5" or ranges in the form "-2..20".'), self.ctx.options.get('sDescription', ''), *items)
def format_justifications(req, refs): seen = {} r = [] for ref in refs: key = (ref.source.pk, ref.description) if key in seen: continue seen[key] = 1 label = ref.source.name if ref.description: label += '[%s]' % ref.description r.append(HTML.li(link(req, ref.source, label=label))) return HTML.ul(*r)
def ipa_custom(req, segments): rows = [] for i, data in segments.items(): title, symbol, class_, param, exists, vs = data if exists and param and (not param.jsondata['core_list'] or i in [15, 74, 77, 84]): rows.append(HTML.tr( HTML.td( parameter_link(req, literal(symbol), vs or p), title=title, class_=class_), HTML.th( title.split('-')[1].strip(), style="padding-left: 10px; text-align: left;"), )) return HTML.table(HTML.tbody(*rows)) if rows else ''