Exemplo n.º 1
0
 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')
Exemplo n.º 2
0
Arquivo: base.py Projeto: FieldDB/clld
 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')
Exemplo n.º 3
0
Arquivo: util.py Projeto: moriwx/wals3
def comment_button(req, feature, language, class_=''):
    return HTML.form(
        button(icon('comment'), type='submit', class_=class_, title='comment'),
        class_='inline',
        method='POST',
        action=req.route_url('datapoint', fid=feature.id, lid=language.id),
    )
Exemplo n.º 4
0
def comment_button(req, feature, language, class_=''):
    return HTML.form(
        button(icon('comment'), type='submit', class_=class_, title='comment'),
        class_='inline',
        method='POST',
        action=req.route_url('datapoint', fid=feature.id, lid=language.id),
    )
Exemplo n.º 5
0
def format_ca_icon(req, ref, type_):
    trigger = getattr(ref, 'ca_' + type_ + '_trigger')
    if not trigger:
        return ''
    return icon(
        'warning-sign',
        title='computerized assignment of %ss from "%s"' % (type_, trigger))
Exemplo n.º 6
0
def languoid_link(req, languoid, active=True, classification=False):
    link_attrs = {}
    content = [link(req, languoid, **link_attrs) if active else languoid.name]
    if classification:
        if languoid.fc or languoid.sc:
            content.append(
                icon("icon-info-sign", title="classification comment available"))
    return HTML.span(*content, **dict(class_="level-" + languoid.level.value))
Exemplo n.º 7
0
def languoid_link(req, languoid, active=True, classification=False):
    content = [link(req, languoid) if active else languoid.name]
    if classification:
        if languoid.fc or languoid.sc:
            content.append(
                icon("icon-info-sign",
                     title="classification comment available"))
    return HTML.span(*content, **dict(class_="level-" + languoid.level.value))
Exemplo n.º 8
0
def comment_button(req, valueset, class_=''):
    return HTML.form(button(icon('comment'),
                            type='submit',
                            class_=class_,
                            title='comment'),
                     class_='inline',
                     method='POST',
                     action=req.resource_url(valueset))
Exemplo n.º 9
0
 def format(self, item):
     icon_ = MIMETYPE_TO_ICON.get(self.maintype)
     if icon_:
         item = self.get_obj(item)
         for f in item._files:
             mtype = maintype(f)
             if mtype == self.maintype:
                 return icon(icon_)
     return ''
Exemplo n.º 10
0
 def format(self, item):
     icon_ = MIMETYPE_TO_ICON.get(self.maintype)
     if icon_:
         item = self.get_obj(item)
         for f in item._files:
             mtype = maintype(f)
             if mtype == self.maintype:
                 return icon(icon_)
     return ''
Exemplo n.º 11
0
def format_file(f, with_mime_type=True):
    icon_ = {
        'image': 'camera',
        'video': 'facetime-video',
    }.get(f.mime_type.split('/')[0], 'file')
    if with_mime_type:
        label = f.mime_type + '; '
    else:
        label = ''
    label = ' [%s%s]' % (label, misc.format_size(f.jsondata['size']))
    return HTML.span(icon(icon_, inverted=True), label, class_='badge')
Exemplo n.º 12
0
 def format(self, item):
     obj = self.get_obj(item)
     if not obj or getattr(obj, 'latitude', None) is None:
         return ''
     return HTML.a(
         icon('icon-globe'),
         title='show %s on map' % getattr(obj, 'name', ''),
         href="#" + self.map_id,
         onclick=JS_CLLD.mapShowInfoWindow(self.map_id, obj.id),
         class_='btn',
     )
Exemplo n.º 13
0
Arquivo: base.py Projeto: FieldDB/clld
 def format(self, item):
     obj = self.get_obj(item)
     if not obj or getattr(obj, 'latitude', None) is None:
         return ''
     return HTML.a(
         icon('icon-globe'),
         title='show %s on map' % getattr(obj, 'name', ''),
         href="#" + self.map_id,
         onclick=JS_CLLD.mapShowInfoWindow(self.map_id, obj.id),
         class_='btn',
     )
Exemplo n.º 14
0
Arquivo: util.py Projeto: clld/wold2
def infobutton(desc, content_type='text', placement='right'):
    if not desc:
        return ''
    if content_type == 'text':
        desc = text2html(escape(desc, quote=True), mode='p')
    return button(
        icon('info-sign', inverted=True),
        **{
            'data-toggle': 'popover',
            'data-placement': placement,
            'data-content': desc,
            'class': ['btn-info', 'btn-mini', 'fieldinfo']})
Exemplo n.º 15
0
def infobutton(desc, content_type='text', placement='right'):
    if not desc:
        return ''
    if content_type == 'text':
        desc = text2html(escape(desc, quote=True), mode='p')
    return button(
        icon('info-sign', inverted=True), **{
            'data-toggle': 'popover',
            'data-placement': placement,
            'data-content': desc,
            'class': ['btn-info', 'btn-mini', 'fieldinfo']
        })
Exemplo n.º 16
0
def languoid_link(req, languoid, active=True, classification=False):
    link_attrs = {}
    if languoid.status and languoid.status.value:
        link_attrs['class'] = 'Language ' + languoid.status.value
    if languoid.status and languoid.status != LanguoidStatus.established:
        link_attrs['title'] = '%s - %s' % (languoid.name, languoid.status.description)
    content = [link(req, languoid, **link_attrs) if active else languoid.name]
    if classification:
        if languoid.fc or languoid.sc:
            content.append(
                icon("icon-info-sign", title="classification comment available"))
    return HTML.span(*content, **dict(class_="level-" + languoid.level.value))
Exemplo n.º 17
0
Arquivo: util.py Projeto: clld/ldh
def file_link(file):
    url = file.jsondata.get('url', 'http://hdl.handle.net/' + file.id.replace('__', '/'))
    suffix = pathlib.Path(url.split('/')[-1]).suffix
    content = [
        HTML.a(
            icon('file'),
            '{} ({})'.format(
                suffix[1:].upper() if suffix else 'PDF', format_size(file.jsondata['size'])),
            href=url,
        )]
    license = file.jsondata['license']
    if license:
        content.append(' licensed under ')
        content.append(external_link(
            license['url'], label=license['id'].upper(), title=license['name']))
    return HTML.span(*content)
Exemplo n.º 18
0
def link(obj, label=None, with_mime_type=True, badge=False):
    label = label or 'View file'
    mtype = mimetype(obj)
    icon_ = MIMETYPE_TO_ICON.get(
        mtype, MIMETYPE_TO_ICON.get(maintype(obj, mimetype_=mtype), 'download-alt'))
    md = ''
    if obj.jsondata.get('size'):
        md = format_size(obj.jsondata['size'])
    if with_mime_type:
        if md:
            md += ', '
        md += mtype
    if md:
        label += ' (%s)' % md
    return HTML.a(
        HTML.span(
            icon(icon_, inverted=badge),
            ' ' + label,
            class_='badge' if badge else 'cdstar_link'),
        href=bitstream_url(obj))
Exemplo n.º 19
0
def link(obj, label=None, with_mime_type=True, badge=False):
    label = label or 'View file'
    mtype = mimetype(obj)
    icon_ = MIMETYPE_TO_ICON.get(
        mtype, MIMETYPE_TO_ICON.get(maintype(obj, mimetype_=mtype), 'download-alt'))
    md = ''
    if obj.jsondata.get('size'):
        md = format_size(obj.jsondata['size'])
    if with_mime_type:
        if md:
            md += ', '
        md += mtype
    if md:
        label += ' (%s)' % md
    return HTML.a(
        HTML.span(
            icon(icon_, inverted=badge),
            ' ' + label,
            class_='badge' if badge else 'cdstar_link'),
        href=bitstream_url(obj))
Exemplo n.º 20
0
    def test_icon(self):
        from clld.web.util.helpers import icon

        self.assertIn('white', icon('download', inverted=True))
Exemplo n.º 21
0
 def format(self, item):
     item = self.get_obj(item)
     if item.count_videos:
         return HTML.span(
             '%s' % item.count_videos, icon('film', inverted=True), class_='badge')
     return ''
Exemplo n.º 22
0
 def format(self, item):
     item = self.get_obj(item)
     if item.count_images:
         return HTML.span(
             '%s' % item.count_images, icon('camera', inverted=True), class_='badge')
     return ''
Exemplo n.º 23
0
 def format(self, item):
     if item.pk in self.dt.language_sources:
         return icon('tag')
     return ''
Exemplo n.º 24
0
 def format(self, item):
     return button(
         icon('globe'),
         href="#map",
         onclick='TSAMMALEX.highlightEcoregion(CLLD.Maps.map.marker_map.'
                 + item.id + ')')
Exemplo n.º 25
0
 def format(self, item):
     if item.audio:
         return icon('volume-up')
Exemplo n.º 26
0
 def format(self, item):
     if item.pk in self.dt.language_sources:
         return icon('tag')
     return ''
Exemplo n.º 27
0
 def format(self, item):
     return HTML.a(
         icon('eye-open'),
         href=util.cdstar_url(item),
         title='view',
         class_="btn")
Exemplo n.º 28
0
def test_icon(env):
    from clld.web.util.helpers import icon

    assert 'white' in icon('download', inverted=True)
Exemplo n.º 29
0
 def format(self, item):
     if item.audio:
         return icon('volume-up')
Exemplo n.º 30
0
 def format(self, item):
     if item._files:
         return HTML.span('%s' % len(item._files), icon('file', inverted=True), class_='badge')
     return ''
Exemplo n.º 31
0
def github_link(ctx):
    return button(icon('pencil'),
                  title="see on GitHub",
                  href=ctx.github_url,
                  class_='btn-mini')
Exemplo n.º 32
0
 def format(self, item):
     return button(
         icon('globe'),
         href="#map",
         onclick='TSAMMALEX.highlightEcoregion(CLLD.Maps.map.marker_map.' +
         item.id + ')')
Exemplo n.º 33
0
    def test_icon(self):
        from clld.web.util.helpers import icon

        self.assertIn('white', icon('download', inverted=True))
Exemplo n.º 34
0
 def format(self, item):
     return icon('ok')
Exemplo n.º 35
0
def github_link(ctx):
    return button(
        icon('pencil'), title="see on GitHub", href=ctx.github_url, class_='btn-mini')