示例#1
0
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), ']')
示例#2
0
 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'})
示例#3
0
    def get_label_properties(self, label, pindex=None):
        def vname(v):
            try:
                return domain[v.domainelement_pk].name
            except KeyError:
                return v.name

        res = {
            'eid': 'tlpk{0}-{1}'.format(label, pindex),
            'shape': 'c',
            'color': '#ff6600',
            'conflict': False,
            'tooltip_title': 'Related ' + self.req.translate('Languages'),
        }
        if pindex is not None:
            parameter = self.parameters[pindex]
            domain = self.domains[pindex]
            values = []
            color = '#ff6600'
            for lpk in self.glottolog2language_ids[label.name]:
                try:
                    vs = self.language2valueset[lpk][pindex]
                    values.extend(vs.values)
                    color = get_color(vs)
                except (KeyError, AttributeError):
                    continue
            if not values:
                res['tooltip_title'] = 'Missing data'
                res['tooltip'] = None
                res['shape'] = 's'
                res['color'] = '#fff'
            else:
                res['conflict'] = not self.all_equal(values,
                                                     bool(parameter.domain))
                res['tooltip_title'] = 'Parameter ' + parameter.id
                lis = []
                for v in values:
                    lis.append(
                        HTML.li(
                            vname(v) + ': ',
                            self._lg_link(self.req, v.valueset.language)))
                res['tooltip'] = HTML.ul(*lis, class_='unstyled')
                res['shape'] = 'c'
                res['color'] = color

        else:
            lis = []
            for lpk in self.glottolog2language_ids[label.name]:
                lis.append(
                    HTML.li(self._lg_link(self.req,
                                          self.langpk2language[lpk])))
            res['tooltip'] = HTML.ul(*lis)
        return res
示例#4
0
def toc(s):
    if not s:
        return '', ''

    def link(id_, label):
        return HTML.a(label, href='#{0}'.format(id_))

    def toplink(html):
        a = html.new_tag(
            'a',
            href='#top',
            title='go to top of the page',
            style="vertical-align: bottom")
        a.string = '⇫'
        return a

    def permalink(html, id_):
        a = html.new_tag(
            'a',
            **{
                'href': '#{0}'.format(id_),
                'title': 'Permalink to this headline',
                'class': "headerlink"})
        a.string = '¶'
        return a

    toc_, count = [], 0
    text = BeautifulSoup(s, 'html5lib')
    for d in text.descendants:
        if d.name in ['h1', 'h2', 'h3', 'h4', 'h5']:
            count += 1
            id_ = 'section{0}'.format(count)
            toc_.append((id_, int(d.name[1:]), d.get_text()))
            d.insert(0, text.new_tag('a', id=id_))
            d.append(toplink(text))
            d.append(permalink(text, id_))

    if toc_:
        top_level = min(t[1] for t in toc_)
        nt = OrderedDict()
        curr = []
        for id_, level, label in toc_:
            if level == top_level:
                curr = nt[(id_, label)] = []
            elif level == top_level + 1:
                curr.append((id_, label))
        toc_ = HTML.ul(*[HTML.li(link(*t), HTML.ul(*[HTML.li(link(*tt)) for tt in ns]))
                         for t, ns in nt.items()])
    else:
        toc_ = ''
    return '{0}'.format(text), toc_
示例#5
0
 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')
示例#6
0
文件: util.py 项目: clld/glottolog3
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)
示例#7
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')
示例#8
0
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)
示例#9
0
文件: base.py 项目: 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')
示例#10
0
文件: util.py 项目: clld/dictionaria
def toc(soup):
    def link(id_, label):
        return HTML.a(label, href='#{0}'.format(id_))

    def toplink(html):
        a = html.new_tag(
            'a',
            href='#top',
            title='go to top of the page',
            style="vertical-align: bottom")
        a.string = '⇫'
        return a

    def permalink(html, id_):
        a = html.new_tag(
            'a',
            **{
                'href': '#{0}'.format(id_),
                'title': 'Permalink to this headline',
                'class': "headerlink"})
        a.string = '¶'
        return a

    toc_, count = [], 0
    for d in soup.descendants:
        if d.name in ['h1', 'h2', 'h3', 'h4', 'h5']:
            count += 1
            id_ = 'section{0}'.format(count)
            toc_.append((id_, int(d.name[1:]), d.get_text()))
            d.insert(0, soup.new_tag('a', id=id_))
            d.append(toplink(soup))
            d.append(permalink(soup, id_))

    if toc_:
        top_level = min(t[1] for t in toc_)
        nt = OrderedDict()
        curr = []
        for id_, level, label in toc_:
            if level == top_level:
                curr = nt[(id_, label)] = []
            elif level == top_level + 1:
                curr.append((id_, label))
        toc_ = HTML.ul(*[HTML.li(link(*t), HTML.ul(*[HTML.li(link(*tt)) for tt in ns]))
                         for t, ns in nt.items()])
    else:
        toc_ = ''
    return '{0}'.format(soup), toc_
示例#11
0
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")
示例#12
0
文件: __init__.py 项目: mitcho/clld
 def render_item(self, item):
     if not isinstance(item, (tuple, list)):
         item = [item]
     attrs = self.item_attrs
     if self.stay_open:
         class_ = attrs.get('class', attrs.get('class_', ''))
         attrs['class'] = class_ + ' stay-open'
     return HTML.li(*item, **attrs)
示例#13
0
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)
示例#14
0
 def render_item(self, item):
     if not isinstance(item, (tuple, list)):
         item = [item]
     attrs = self.item_attrs
     if self.stay_open:
         class_ = attrs.get('class', attrs.get('class_', ''))
         attrs['class'] = class_ + ' stay-open'
     return HTML.li(*item, **attrs)
示例#15
0
 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'
     )
示例#16
0
 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')
示例#17
0
 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'
     )
示例#18
0
文件: util.py 项目: afehn/tsammalex
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")
示例#19
0
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
示例#20
0
def alt_representations(req, rsc, doc_position='right', exclude=None):
    exclude = exclude or []
    exclude.extend(['html', 'snippet.html'])
    adapters = [
        a
        for n, a in req.registry.getAdapters([rsc], interfaces.IRepresentation)
        if a.extension not in set(exclude)
    ]
    doc = []
    for adapter in adapters:
        if adapter.__doc__:
            doc.append(HTML.dt(adapter.name or adapter.extension))
            doc.append(HTML.dd(adapter.__doc__))
    doc = HTML.div(
        HTML.p(
            """You may download alternative representations of the data on
"%s" by clicking the button """ % rsc.name, icon('download-alt')),
        HTML.dl(*doc))
    return HTML.div(
        HTML.div(
            button(
                icon('info-sign', inverted=True), **{
                    'class': ['btn-info'],
                    'id': 'rsc-dl',
                    'data-content': unicode(doc)
                }),
            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(a.name or a.extension,
                          href="#",
                          onclick="document.location.href = '%s'; return false;"
                          % req.resource_url(rsc, ext=a.extension),
                          id='dt-dl-%s' % a.extension)) for a in adapters
                ], **dict(class_="dropdown-menu")),
            class_='btn-group'),
        HTML.script(
            literal("""\
    $(document).ready(function() {
        $('#rsc-dl').clickover({
            html: true,
            title: 'Alternative representations',
            placement: '%s',
            trigger: 'click'
        });
    });""" % doc_position)))
示例#21
0
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")
示例#22
0
 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,
         ))
示例#23
0
文件: util.py 项目: kublaj/glottolog3
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)
示例#24
0
文件: helpers.py 项目: FieldDB/clld
def alt_representations(req, rsc, doc_position='right', exclude=None):
    exclude = exclude or []
    exclude.extend(['html', 'snippet.html'])
    adapters = [a for n, a in req.registry.getAdapters([rsc], interfaces.IRepresentation)
                if a.extension not in set(exclude)]
    doc = []
    for adapter in adapters:
        if adapter.__doc__:
            doc.append(HTML.dt(adapter.name or adapter.extension))
            doc.append(HTML.dd(adapter.__doc__))
    doc = HTML.div(
        HTML.p(
            """You may download alternative representations of the data on
"%s" by clicking the button """ % rsc.name,
            icon('download-alt')),
        HTML.dl(*doc))
    return HTML.div(HTML.div(
        button(
            icon('info-sign', inverted=True),
            **{'class': ['btn-info'],
               'id': 'rsc-dl',
               'data-content': unicode(doc)}),
        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(
                a.name or a.extension,
                href="#",
                onclick="document.location.href = '%s'; return false;"
                        % req.resource_url(rsc, ext=a.extension),
                id='dt-dl-%s' % a.extension))
              for a in adapters],
            **dict(class_="dropdown-menu")),
        class_='btn-group'),
        HTML.script(literal("""\
    $(document).ready(function() {
        $('#rsc-dl').clickover({
            html: true,
            title: 'Alternative representations',
            placement: '%s',
            trigger: 'click'
        });
    });""" % doc_position)))
示例#25
0
def format_justifications(req, refs):
    seen = set()
    r = []
    for ref in refs:
        if ref.source:
            key = (ref.source.pk, ref.description)
            if key in seen:
                continue
            seen.add(key)
            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)
示例#26
0
def get_variety_links(request=None, context=None, **kw):
    if context.glottocode:
        q = DBSession.query(Language.id, Language.name)\
            .join(LanguageIdentifier, Identifier)\
            .filter(Identifier.name == context.glottocode,
                Identifier.type == IdentifierType.glottolog.value,
                Language.id != context.id).all()
        if len(q) == 0:
            return ("", "")
        res = ""
        title_string = "Further variet"
        title_string += "ies " if len(q) > 1 else "y "
        title_string += "linked to Glottocode “{0}”".format(context.glottocode)
        for l in q:
            res += HTML.li(HTML.a(l[1], href=l[0]))
        return (HTML.ul(res), title_string)
    return ("", "")
示例#27
0
 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(),
     )
示例#28
0
文件: __init__.py 项目: mitcho/clld
 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',
         id=self.format_id(),
     )
示例#29
0
文件: util.py 项目: clld/wold2
def source_words(req, ctx):
    def _format(loan):
        if loan.source_word.name == 'Unidentifiable' \
                and not loan.source_word.language and not loan.source_word.description:
            yield 'unidentifiable'
        else:
            yield link(req, loan.source_word)
            if loan.source_word.description and loan.source_word.description != '?':
                yield " '%s'" % loan.source_word.description
            if loan.source_word.language:
                yield ' '
                yield link(req, loan.source_word.language)
            if not loan.certain:
                yield ' (uncertain)'

    return HTML.ul(
        *[HTML.li(*list(_format(loan))) for loan in ctx.source_word_assocs],
        class_="unstyled")
示例#30
0
def source_words(req, ctx):
    def _format(loan):
        if loan.source_word.name == 'Unidentifiable' \
                and not loan.source_word.language and not loan.source_word.description:
            yield 'unidentifiable'
        else:
            yield link(req, loan.source_word)
            if loan.source_word.description and loan.source_word.description != '?':
                yield " '%s'" % loan.source_word.description
            if loan.source_word.language:
                yield ' '
                yield link(req, loan.source_word.language)
            if not loan.certain:
                yield ' (uncertain)'

    return HTML.ul(
        *[HTML.li(*list(_format(loan))) for loan in ctx.source_word_assocs],
        class_="unstyled")
示例#31
0
def video_detail(*objs, **kw):
    def video(mp4):
        return cdstar.video(mp4, width='100%', preload='none', **kw)

    mp4s, name, dl = [], None, []
    if isinstance(objs[0], Movie):
        dl.extend([HTML.dt('Description'), HTML.dd(objs[0].name)])
        dl.extend([HTML.dt('Duration'), HTML.dd(format_duration(objs[0]))])
        if objs[0].get_file('mp4'):
            mp4s = [objs[0].get_file('mp4')]
        files = objs[0].files
    else:
        for obj in objs:
            if obj.mime_type == 'video/mp4':
                mp4s.append(obj)
        files = objs
    dl.extend([HTML.dt('Formats'), HTML.dd(format_videos(files))])
    return HTML.div(
        HTML.ul(*[HTML.li(video(mp4)) for mp4 in mp4s], **dict(class_='unstyled')),
        HTML.dl(*dl))
示例#32
0
def cobl_linked_references(req, obj, comments=False):
    chunks = []
    if comments:
        for i, ref in enumerate(
                sorted(getattr(obj, 'references', []),
                       key=lambda x: x.source.name or '')):
            if ref.source:
                r = ''
                r += HTML.span(link(req, ref.source), class_='citation')
                d = None
                if ref.description:
                    d = ref.description.split('{')
                    if len(d) == 1:
                        r += HTML.span(": {}".format(d[0] if d[0] else ''),
                                       class_='pages')
                    else:
                        r += HTML.span(": {}".format(d[0] if d[0] else ''),
                                       class_='pages')
                        if d[1]:
                            r += HTML.blockquote(d[1][:-1])
                chunks.append(HTML.li(r))
        if chunks:
            return HTML.span(*chunks)
    else:
        for i, ref in enumerate(
                sorted(getattr(obj, 'references', []),
                       key=lambda x: x.source.name or '')):
            if ref.source:
                if i > 0:
                    chunks.append('; ')
                d = ref.description.split('{')[0] if ref.description else None
                chunks.append(
                    HTML.span(
                        link(req, ref.source),
                        HTML.span(': {}'.format(d) if d else '',
                                  class_='pages'),
                        class_='citation',
                    ))
        if chunks:
            return HTML.span(*chunks)
    return ''
示例#33
0
    def render(self, no_js=False):
        adapters = [
            a for n, a in self.req.registry.getAdapters([self.obj],
                                                        self.interface)
            if a.extension not in set(self.options['exclude'])
        ]
        adoc = []
        for adapter in adapters:
            if adapter.__doc__:
                adoc.append(HTML.dt(adapter.name or adapter.extension))
                adoc.append(HTML.dd(adapter.__doc__))
        doc = HTML.div(
            HTML.p(
                """You may download alternative representations of the data on
"%s" by clicking the button """ % self.ctx,
                HTML.i(class_='icon-download-alt')), self.doc(),
            HTML.dl(*adoc))
        res = HTML.div(
            HTML.button(HTML.i(class_='icon-info-sign icon-white'),
                        class_='btn btn-info %s' % self._opener_class,
                        **{
                            'data-content': text_type(doc),
                            'type': 'button'
                        }),
            HTML.a(
                HTML.i(class_='icon-download-alt'), HTML.span(class_="caret"),
                **{
                    'class_': "btn dropdown-toggle",
                    'data-toggle': "dropdown",
                    'href': "#",
                    'id': self._id_prefix + "opener"
                }),
            HTML.ul(*[HTML.li(self.dl_link(adapter)) for adapter in adapters],
                    **dict(class_="dropdown-menu")),
            class_='btn-group right')
        if no_js:
            return res
        return HTML.div(res, self.js())
示例#34
0
 def format(self, item):
     return HTML.div(HTML.div(
         HTML.div(HTML.a(
             '{0} Languages'.format(len(item.contribution_assocs)), **{
                 'class': 'accordion-toggle',
                 'data-toggle': 'collapse',
                 'data-parent': '#acc-{0}'.format(item.pk),
                 'href': '#coll-{0}'.format(item.pk)
             }),
                  class_='accordion-heading'),
         HTML.div(
             HTML.div(HTML.ul(*[
                 HTML.li(link(self.dt.req, c.contribution))
                 for c in item.contribution_assocs
             ]),
                      class_='accordion-inner'), **{
                          'class': 'accordion-body collapse',
                          'id': 'coll-{0}'.format(item.pk)
                      }),
         class_='accordion-group',
     ),
                     class_='accordion',
                     id='acc-{0}'.format(item.pk))
示例#35
0
    def render(self, no_js=False):
        adapters = [a for n, a in
                    self.req.registry.getAdapters([self.obj], self.interface)
                    if a.extension not in set(self.options['exclude'])]
        adapters = sorted(adapters, key=lambda x: x.extension)
        adoc = []
        for adapter in adapters:
            if adapter.__doc__:
                adoc.append(HTML.dt(adapter.name or adapter.extension))
                adoc.append(HTML.dd(adapter.__doc__))
        doc = HTML.div(
            HTML.p(
                """You may download alternative representations of the data on
"%s" by clicking the button """ % self.ctx,
                HTML.i(class_='icon-download-alt')),
            self.doc(),
            HTML.dl(*adoc))
        res = HTML.div(
            HTML.button(
                HTML.i(class_='icon-info-sign icon-white'),
                class_='btn btn-info %s' % self._opener_class,
                **{'data-content': text_type(doc), 'type': 'button'}),
            HTML.a(
                HTML.i(class_='icon-download-alt'),
                HTML.span(class_="caret"),
                **{
                    'class_': "btn dropdown-toggle",
                    'data-toggle': "dropdown",
                    'href': "#",
                    'id': self._id_prefix + "opener"}),
            HTML.ul(
                *[HTML.li(self.dl_link(adapter)) for adapter in adapters],
                **dict(class_="dropdown-menu")),
            class_='btn-group right')
        if no_js:
            return res
        return HTML.div(res, self.js())
示例#36
0
文件: datatables.py 项目: clld/cdk
 def format(self, item):
     return HTML.ul(*[HTML.li(link(self.dt.req, ref.source), ': ', ref.description) for ref in item.references], class_='unstyled')
示例#37
0
 def format(self, item):
     return HTML.ul(*[
         HTML.li(link(self.dt.req, c.contribution))
         for c in item.contribution_assocs
     ])
示例#38
0
文件: datatables.py 项目: clld/ids
 def format(self, item):
     return HTML.ul(
         *[HTML.li(link(self.dt.req, ca.contributor))
           for ca in item.contributor_assocs if ca.ord == self.roleid])
示例#39
0
 def format(self, item):
     return HTML.ul(*[HTML.li(l) for l in item.source_languages.split()],
                    **{'class': 'unstyled'})
示例#40
0
 def format(self, item):
     return HTML.ul(
         *[HTML.li(HTML.span(sd, class_='vocabulary'))
           for sd in item.semantic_domain_list], **{'class': 'unstyled'})
示例#41
0
文件: datatables.py 项目: clld/waab
 def format(self, item):
     return HTML.ul(
         *[HTML.li(link(self.dt.req, pair)) for pair in item.pairs],
         class_="unstyled")
示例#42
0
 def format(self, item):
     return HTML.ul(
         *[HTML.li(link(self.dt.req, lang)) for lang in item.languages],
         class_='unstyled')
示例#43
0
 def format(self, item):
     return HTML.ul(
         *[HTML.li(link(self.dt.req, r.source)) for r in item.references])
示例#44
0
 def format(self, item):
     return HTML.ul(
         *[
             HTML.li('{}: {}'.format(k, ', '.join(v)))
             for k, v in item.jsondata['reconstructions'].items()
         ], **{'class': 'unstyled'})
示例#45
0
 def format(self, item):
     return HTML.ul(
         *[HTML.li(link(self.dt.req, l.contribution, label=l.id)) for l in item.languages],
         **dict(class_='inline'))
示例#46
0
文件: datatables.py 项目: clld/cdk
 def format(self, item):
     return HTML.ul(*[HTML.li(ex.location) for ex in item.examples], class_='unstyled')
示例#47
0
 def format(self, item):
     return HTML.ul(
         *[HTML.li(link(self.dt.req, c)) for c in item.countries], class_='unstyled')
示例#48
0
 def format(self, item):
     return HTML.ul(
         *[HTML.li(link(self.dt.req, c)) for c in item.countries],
         class_='unstyled')
示例#49
0
 def format(self, item):
     return HTML.ul(
         *[HTML.li(l) for l in item.source_languages.split()],
         **{'class': 'unstyled'})
示例#50
0
 def format(self, item):
     return HTML.ul(
         *[HTML.li(HTML.a(c.contribution.name,
                          href=self.dt.req.resource_url(c.contribution)))
           for c in item.contribution_assocs]
     )
示例#51
0
 def format(self, item):
     return HTML.ul(
         *[HTML.li(link(
             self.dt.req, c.contribution)) for c in item.contribution_assocs])
示例#52
0
 def format(self, item):
     return HTML.ul(
         *[HTML.li(link(
             self.dt.req, c.survey)) for c in item.survey_assocs])
示例#53
0
 def format(self, item):
     return HTML.ul(
         *[HTML.li(link(
             self.dt.req, c.contribution, label="%s [%s]" % (c.contribution.desc, c.contribution.id))) for c in item.contribution_assocs])
示例#54
0
def format_videos(fs):
    return HTML.ul(
        *[HTML.li(HTML.a(' ' + format_file(f), href=cdstar_url(f))) for f in fs],
        **dict(class_='unstyled'))