Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def button(*content, **attrs):
tag = attrs.pop('tag', HTML.a if 'href' in attrs else HTML.button)
attrs.setdefault('type', 'button')
class_ = attrs['class'] if 'class' in attrs else attrs.pop('class_', '').split()
if 'btn' not in class_:
class_.append('btn')
attrs['class'] = ' '.join(class_)
return tag(*content, **attrs)
kw['class'] = kw['class_']
del kw['class_']
rsc = None
rsc_name = kw.pop('rsc', None)
for _rsc in RESOURCES:
if _rsc.interface.providedBy(obj) or _rsc.name == rsc_name:
rsc = _rsc
break
assert rsc
href = kw.pop('href', req.resource_url(obj, rsc=rsc, **kw.pop('url_kw', {})))
kw['class'] = ' '.join(
filter(None, kw.get('class', '').split() + [rsc.interface.__name__[1:]]))
label = kw.pop('label', text_type(obj))
kw.setdefault('title', label)
return HTML.a(label, href=href, **kw)
def item(layer):
return HTML.a(
layer.name,
onclick='return %s;' % helpers.JS_CLLD.mapShowGeojson(self.eid, layer.id),
href=layer.data if isinstance(layer.data, str) else '#')
yield Legend(
def format_label_link(href, label, title=None):
return HTML.span(
HTML.a(label, href=href, title=title or label, style='color: white;'),
class_='label')
def render(self):
a_attrs = {
'class': 'dropdown-toggle',
'data-toggle': "dropdown",
'href': "#",
'id': self.format_id('opener')}
ul_class = 'dropdown-menu'
if self.stay_open:
ul_class += ' stay-open'
return HTML.li(
HTML.a(self.label, HTML.b(class_='caret'), **a_attrs),
HTML.ul(
*map(self.render_item, self.items),
**dict(class_=ul_class, id=self.format_id('container'))),
class_='dropdown' + (' pull-right' if self.pull_right else ''),
id=self.format_id(),
)
def dl_link(self, adapter):
return HTML.a(
adapter.name or adapter.extension,
href="#",
id=self._id_prefix + adapter.extension,
onclick="document.location.href = %s; return false;"
% (self.dl_url_tmpl % adapter.extension))
def dl_link(self, adapter):
return HTML.a(
adapter.name or adapter.extension,
href="#",
id=self._id_prefix + adapter.extension,
onclick="document.location.href = %s; return false;"
% (self.dl_url_tmpl % adapter.extension))
def link(href, label, img, alt=None):
return HTML.li(
HTML.a(
HTML.img(
src=req.static_url('glottolog3:static/' + img),
height="20",
width="20",
alt=alt or label),
' ',
label,
href=href,
target = "_blank",
title=label,
)