How to use the clld.web.util.htmllib.HTML.a function in clld

To help you get started, we’ve selected a few clld examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github clld / clld / src / clld / web / util / helpers.py View on Github external
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)
github clld / clld / clld / web / util / helpers.py View on Github external
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)
github clld / clld / src / clld / web / maps / __init__.py View on Github external
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(
github clld / glottolog3 / glottolog3 / util.py View on Github external
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')
github clld / clld / src / clld / web / maps / __init__.py View on Github external
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(),
        )
github clld / clld / clld / web / util / downloadwidget.py View on Github external
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))
github clld / clld / src / clld / web / util / downloadwidget.py View on Github external
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))
github clld / glottolog3 / glottolog3 / util.py View on Github external
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,
            )