Exemplo n.º 1
0
 def prepare_html(self):
     yield build_html_tag(u"dt", class_=self.class_, style=self.style, id=self.id)
     yield escape(self.term)
     yield u"</dt>"
     yield build_html_tag(u"dd", class_=self.class_)
     for item in Element.prepare_html(self):
         yield item
     yield u"</dd>"
Exemplo n.º 2
0
 def prepare_html(self):
     yield build_html_tag(u'dt',
                          class_=self.class_,
                          style=self.style,
                          id=self.id)
     yield escape(self.term)
     yield u'</dt>'
     yield build_html_tag(u'dd', class_=self.class_)
     for item in Element.prepare_html(self):
         yield item
     yield u'</dd>'
Exemplo n.º 3
0
 def test_build_html_tag(self):
     self.assertEqual(build_html_tag('a'), u'<a>')
     self.assertEqual(build_html_tag('a', href='http://example.com'),
                      u'<a href="http://example.com">')
     self.assertEqual(build_html_tag('a', class_='stunning', href='http://abc.xy'),
                            u'<a href="http://abc.xy" class="stunning">')
     self.assertEqual(build_html_tag('a', classes=('stunning', 'awesome'),
                                     href='http://abc.xy'),
                      u'<a href="http://abc.xy" class="stunning awesome">')
     # test for empty tags
     self.assertEqual(build_html_tag('br'), u'<br>')
Exemplo n.º 4
0
 def prepare_html(self):
     style = self.style and self.style + "; " or ""
     style += u"font-size: %.2f%%" % self.size
     yield build_html_tag(u"span", id=self.id, style=style, class_=self.class_)
     for item in Element.prepare_html(self):
         yield item
     yield u"</span>"
Exemplo n.º 5
0
 def prepare_html(self):
     style = self.style and self.style + "; " or ""
     style += u"color: %s" % self.value
     yield build_html_tag(u"span", id=self.id, style=style, class_=self.class_)
     for item in Element.prepare_html(self):
         yield item
     yield u"</span>"
Exemplo n.º 6
0
 def prepare_html(self):
     yield build_html_tag(u'dl',
                          id=self.id,
                          style=self.style,
                          class_=self.class_)
     for item in Element.prepare_html(self):
         yield item
     yield u'</dl>'
Exemplo n.º 7
0
 def prepare_html(self):
     yield build_html_tag(u'tbody',
                          style=self.style,
                          id=self.id,
                          class_=self.class_)
     for item in Element.prepare_html(self):
         yield item
     yield u'</tbody>'
Exemplo n.º 8
0
 def prepare_html(self):
     yield build_html_tag(u'span',
                          id=self.id,
                          style=self.style,
                          classes=(u'underline', self.class_))
     for item in Element.prepare_html(self):
         yield item
     yield u'</span>'
Exemplo n.º 9
0
 def prepare_html(self):
     classes = ["highlighted"]
     if self.class_:
         classes.append(self._class)
     yield build_html_tag(u"strong", id=self.id, style=self.style, classes=classes)
     for item in Element.prepare_html(self):
         yield item
     yield u"</strong>"
Exemplo n.º 10
0
 def prepare_html(self):
     style = []
     if self.align:
         style.append(u"text-align: " + self.align)
     if self.valign:
         style.append(u"vertical-align: " + self.valign)
     if self.style:
         style.append(self.style)
     yield build_html_tag(u"div", id=self.id, style=style and u" ".join(style) or None, classes=(self.class_,))
     if self.title is not None:
         yield build_html_tag(u"h3", class_=self.class_)
         yield escape(self.title)
         yield u"</h3>"
     yield build_html_tag(u"div", classes=(u"contents",))
     for item in Element.prepare_html(self):
         yield item
     yield u"</div></div>"
Exemplo n.º 11
0
 def prepare_html(self):
     yield build_html_tag(u'div',
                          id=self.id,
                          style=self.style,
                          classes=(u'error', self.class_))
     for item in Element.prepare_html(self):
         yield item
     yield u'</div>'
Exemplo n.º 12
0
 def prepare_html(self):
     class_ = u"section_%d" % self.level
     if self.class_:
         class_ += u" " + self.class_
     yield build_html_tag(u"div", id=self.id, style=self.style, class_=class_)
     for item in Element.prepare_html(self):
         yield item
     yield u"</div>"
Exemplo n.º 13
0
 def prepare_html(self):
     yield build_html_tag(u'tr',
                          id=self.id,
                          class_=self.class_,
                          style=self.style)
     for item in Element.prepare_html(self):
         yield item
     yield u'</tr>'
Exemplo n.º 14
0
 def prepare_html(self):
     yield build_html_tag(u'sup',
                          id=self.id,
                          style=self.style,
                          class_=self.class_)
     yield u'<a href="#source-%d">' % self.target
     for item in Element.prepare_html(self):
         yield item
     yield u'</a></sup>'
Exemplo n.º 15
0
 def prepare_html(self):
     style = self.style and self.style + "; " or ""
     style += u"font-family: %s" % u", ".join(
         x in ("serif", "sans-serif", "fantasy") and x or u"'%s'" % x for x in self.faces
     )
     yield build_html_tag(u"span", id=self.id, style=style, class_=self.class_)
     for item in Element.prepare_html(self):
         yield item
     yield u"</span>"
Exemplo n.º 16
0
 def prepare_html(self):
     yield build_html_tag(u'h%d' % (self.level + 1),
                          id=self.id,
                          style=self.style,
                          class_=self.class_)
     for item in Element.prepare_html(self):
         yield item
     yield u'<a href="#%s" class="headerlink">¶</a>' % self.id
     yield u'</h%d>' % (self.level + 1)
Exemplo n.º 17
0
 def prepare_docbook(self):
     yield build_html_tag(
         u'entry',
         morerows=(self.rowspan and self.rowspan - 1) or None,
         align=self.align,
     )
     for item in Element.prepare_docbook(self):
         yield item
     yield u'</entry>'
Exemplo n.º 18
0
 def prepare_html(self):
     style = self.style and self.style + '; ' or ''
     style += u'font-size: %.2f%%' % self.size
     yield build_html_tag(u'span',
                          id=self.id,
                          style=style,
                          class_=self.class_)
     for item in Element.prepare_html(self):
         yield item
     yield u'</span>'
Exemplo n.º 19
0
 def prepare_html(self):
     style = self.style and self.style + '; ' or ''
     style += u'color: %s' % self.value
     yield build_html_tag(u'span',
                          id=self.id,
                          style=style,
                          class_=self.class_)
     for item in Element.prepare_html(self):
         yield item
     yield u'</span>'
Exemplo n.º 20
0
 def prepare_html(self):
     style = []
     if self.align:
         style.append(u'text-align: ' + self.align)
     if self.valign:
         style.append(u'vertical-align: ' + self.valign)
     if self.style:
         style.append(self.style)
     yield build_html_tag(u'div',
                          id=self.id,
                          style=style and u' '.join(style) or None,
                          classes=(self.class_, ))
     if self.title is not None:
         yield build_html_tag(u'h3', class_=self.class_)
         yield escape(self.title)
         yield u'</h3>'
     yield build_html_tag(u'div', classes=(u'contents', ))
     for item in Element.prepare_html(self):
         yield item
     yield u'</div></div>'
Exemplo n.º 21
0
 def prepare_html(self):
     class_ = u'section_%d' % self.level
     if self.class_:
         class_ += u' ' + self.class_
     yield build_html_tag(u'div',
                          id=self.id,
                          style=self.style,
                          class_=class_)
     for item in Element.prepare_html(self):
         yield item
     yield u'</div>'
Exemplo n.º 22
0
 def prepare_html(self):
     if self.type == "unordered":
         tag = u"ul"
         cls = None
     else:
         tag = u"ol"
         cls = self.type
     yield build_html_tag(tag, id=self.id, style=self.style, classes=(self.class_, cls))
     for item in Element.prepare_html(self):
         yield item
     yield u"</%s>" % tag
Exemplo n.º 23
0
 def prepare_html(self):
     classes = ['highlighted']
     if self.class_:
         classes.append(self._class)
     yield build_html_tag(u'strong',
                          id=self.id,
                          style=self.style,
                          classes=classes)
     for item in Element.prepare_html(self):
         yield item
     yield u'</strong>'
Exemplo n.º 24
0
 def prepare_html(self):
     style = self.style and self.style + '; ' or ''
     style += u"font-family: %s" % u', '.join(
         x in ('serif', 'sans-serif', 'fantasy') and x or u"'%s'" % x
         for x in self.faces)
     yield build_html_tag(u'span',
                          id=self.id,
                          style=style,
                          class_=self.class_)
     for item in Element.prepare_html(self):
         yield item
     yield u'</span>'
Exemplo n.º 25
0
 def prepare_html(self):
     if self.id is None:
         yield build_html_tag(u"small", id=self.id, style=self.style, classes=(u"note", self.class_))
         for item in Element.prepare_html(self):
             yield item
         yield u"</small>"
     else:
         yield u'<a href="#fn-%d" id="bfn-%d" class="footnote">' u'<span class="paren">[</span>%d<span class="paren">]' u"</span></a>" % (
             self.id,
             self.id,
             self.id,
         )
Exemplo n.º 26
0
 def prepare_html(self):
     if self.id is None:
         yield build_html_tag(u'small',
                              id=self.id,
                              style=self.style,
                              classes=(u'note', self.class_))
         for item in Element.prepare_html(self):
             yield item
         yield u'</small>'
     else:
         yield u'<a href="#fn-%d" id="bfn-%d" class="footnote">' \
               u'<span class="paren">[</span>%d<span class="paren">]' \
               u'</span></a>' % (self.id, self.id, self.id)
Exemplo n.º 27
0
 def prepare_html(self):
     if self.type == 'unordered':
         tag = u'ul'
         cls = None
     else:
         tag = u'ol'
         cls = self.type
     yield build_html_tag(tag,
                          id=self.id,
                          style=self.style,
                          classes=(self.class_, cls))
     for item in Element.prepare_html(self):
         yield item
     yield u'</%s>' % tag
Exemplo n.º 28
0
    def prepare_html(self):
        style = []
        if self.align:
            style.append(u'text-align: ' + self.align)
        if self.valign:
            style.append(u'vertical-align: ' + self.valign)
        if self.style:
            style.append(self.style)

        yield build_html_tag(self._html_tag,
                             colspan=self.colspan or None,
                             rowspan=self.rowspan or None,
                             style=style and u'; '.join(style) or None,
                             id=self.id,
                             class_=self.class_)

        for item in Element.prepare_html(self):
            yield item
        yield u'</%s>' % self._html_tag
Exemplo n.º 29
0
    def get_html(self, key, value, nolink=False):
        """
        Returns a HTML link for sorting the table.
        This function is usually called inside the template.

        Usage example in the template file:

        .. sourcecode:: html+jinja

            <tr>
              <th>
                {{ table.get_html('id', '#') }}
              </th>
              <th>
                {{ table.get_html('username', 'Username') }}
              </th>
            </tr>
            {% for user in users %}
              (...)
            {% endfor %}

        :parameter key: The name of the database column that should be used
                        for sorting.
        :param value: The name that is displayed for the link.
        :param nolink: Don't make this column sortable but display a cool link.
        """
        ocol = self.order_by.lstrip('-')
        order = self.order_by.startswith('-')
        if key == ocol:
            new_order = '%s%s' % (('-', '')[order], ocol)
            button = ('down', 'up')[order]
            src = href('static', file='img/%s.png' % button)
            img = build_html_tag('img', src=src)
        else:
            new_order = key
            img = ''

        if nolink:
            return value
        return Markup(u'<a href="?order=%s">%s</a>%s' %
                      (new_order, value, img))
Exemplo n.º 30
0
    def prepare_html(self):
        if self.scheme == "javascript":
            yield escape(self.caption)
            return
        rel = None
        if (
            not self.netloc
            or self.netloc == ctx.cfg["base_domain_name"]
            or self.netloc.endswith("." + ctx.cfg["base_domain_name"])
        ):
            class_ = u"crosslink"
        else:
            class_ = u"external"
            rel = u"nofollow"

        yield build_html_tag(
            u"a", rel=rel, id=self.id, style=self.style, title=self.title, classes=(class_, self.class_), href=self.href
        )
        for item in Element.prepare_html(self):
            yield item
        yield u"</a>"
Exemplo n.º 31
0
    def prepare_html(self):
        style = []
        if self.align:
            style.append(u"text-align: " + self.align)
        if self.valign:
            style.append(u"vertical-align: " + self.valign)
        if self.style:
            style.append(self.style)

        yield build_html_tag(
            self._html_tag,
            colspan=self.colspan or None,
            rowspan=self.rowspan or None,
            style=style and u"; ".join(style) or None,
            id=self.id,
            class_=self.class_,
        )

        for item in Element.prepare_html(self):
            yield item
        yield u"</%s>" % self._html_tag
Exemplo n.º 32
0
    def get_html(self, key, value, nolink=False):
        """
        Returns a HTML link for sorting the table.
        This function is usually called inside the template.

        Usage example in the template file:

        .. sourcecode:: html+jinja

            <tr>
              <th>
                {{ table.get_html('id', '#') }}
              </th>
              <th>
                {{ table.get_html('username', 'Username') }}
              </th>
            </tr>
            {% for user in users %}
              (...)
            {% endfor %}

        :parameter key: The name of the database column that should be used
                        for sorting.
        :param value: The name that is displayed for the link.
        :param nolink: Don't make this column sortable but display a cool link.
        """
        ocol = self.order_by.lstrip('-')
        order = self.order_by.startswith('-')
        if key == ocol:
            new_order = '%s%s' % (('-', '')[order], ocol)
            button = ('down', 'up')[order]
            src = href('static', file='img/%s.png' % button)
            img = build_html_tag('img', src=src)
        else:
            new_order = key
            img = ''

        if nolink:
            return value
        return Markup(u'<a href="?order=%s">%s</a>%s' % (new_order, value, img))
Exemplo n.º 33
0
    def prepare_html(self):
        if self.scheme == 'javascript':
            yield escape(self.caption)
            return
        rel = None
        if not self.netloc or self.netloc == ctx.cfg['base_domain_name'] or \
           self.netloc.endswith('.' + ctx.cfg['base_domain_name']):
            class_ = u'crosslink'
        else:
            class_ = u'external'
            rel = u'nofollow'

        yield build_html_tag(u'a',
                             rel=rel,
                             id=self.id,
                             style=self.style,
                             title=self.title,
                             classes=(class_, self.class_),
                             href=self.href)
        for item in Element.prepare_html(self):
            yield item
        yield u'</a>'
Exemplo n.º 34
0
 def prepare_html(self):
     yield build_html_tag(u"div", id=self.id, style=self.style, classes=(u"error", self.class_))
     for item in Element.prepare_html(self):
         yield item
     yield u"</div>"
Exemplo n.º 35
0
 def prepare_html(self):
     yield build_html_tag(u"h%d" % (self.level + 1), id=self.id, style=self.style, class_=self.class_)
     for item in Element.prepare_html(self):
         yield item
     yield u'<a href="#%s" class="headerlink">¶</a>' % self.id
     yield u"</h%d>" % (self.level + 1)
Exemplo n.º 36
0
 def prepare_html(self):
     yield build_html_tag(u"sup", id=self.id, style=self.style, class_=self.class_)
     yield u'<a href="#source-%d">' % self.target
     for item in Element.prepare_html(self):
         yield item
     yield u"</a></sup>"
Exemplo n.º 37
0
 def prepare_html(self):
     yield build_html_tag(u"span", id=self.id, style=self.style, classes=(u"underline", self.class_))
     for item in Element.prepare_html(self):
         yield item
     yield u"</span>"
Exemplo n.º 38
0
 def prepare_html(self):
     yield build_html_tag(u"tbody", style=self.style, id=self.id, class_=self.class_)
     for item in Element.prepare_html(self):
         yield item
     yield u"</tbody>"
Exemplo n.º 39
0
 def prepare_docbook(self):
     yield build_html_tag(u"entry", morerows=(self.rowspan and self.rowspan - 1) or None, align=self.align)
     for item in Element.prepare_docbook(self):
         yield item
     yield u"</entry>"
Exemplo n.º 40
0
 def prepare_html(self):
     yield build_html_tag(u"dl", id=self.id, style=self.style, class_=self.class_)
     for item in Element.prepare_html(self):
         yield item
     yield u"</dl>"
Exemplo n.º 41
0
 def prepare_html(self):
     yield build_html_tag(u"tr", id=self.id, class_=self.class_, style=self.style)
     for item in Element.prepare_html(self):
         yield item
     yield u"</tr>"