Example #1
0
def tr_rel(ctx, name, label=None, dt='name', dd='description', attr=None):
    content = []
    for item in attr:
        content.extend([HTML.dt(getattr(item, dt)), HTML.dd(getattr(item, dd))])
    content = HTML.dl(*content, class_='dl-horizontal')
    if len(attr) > 3:
        content = collapsed('collapsed-' + name, content)
    return HTML.tr(HTML.td((label or name.capitalize()) + ':'), HTML.td(content))
Example #2
0
 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)
Example #3
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)))
Example #4
0
def tr_rel(ctx, name, label=None, dt='name', dd='description', attr=None):
    content = []
    for item in attr:
        content.extend(
            [HTML.dt(getattr(item, dt)),
             HTML.dd(getattr(item, dd))])
    content = HTML.dl(*content, class_='dl-horizontal')
    if len(attr) > 3:
        content = collapsed('collapsed-' + name, content)
    return HTML.tr(HTML.td((label or name.capitalize()) + ':'),
                   HTML.td(content))
Example #5
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))
Example #6
0
File: base.py Project: clld/clld
 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)
Example #7
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)))
Example #8
0
 def __init__(self, dt, name, **kw):
     self.macroareas = DBSession.query(Macroarea).order_by(
         Macroarea.id).all()
     kw['bSortable'] = False
     desc = []
     for area in self.macroareas:
         desc.append(HTML.dt(u'%s' % area))
         desc.append(HTML.dd(area.description))
     kw['sDescription'] = HTML.span(
         'see ',
         HTML.a('glossary',
                href=dt.req.route_url(
                    'home.glossary', _anchor='macroarea')))  #HTML.dl(*desc)
     super(MacroareaCol, self).__init__(dt, name, **kw)
Example #9
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())
Example #10
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())