Ejemplo n.º 1
0
    def href_button(self, url, text, title=None, icon_name=None, **kw):
        """Returns an etree object of a ``<a href>`` tag to the given URL
        `url`. 

        `url` is what goes into the `href` part. If `url` is `None`,
        then we return just a ``<b>`` tag.

        `text` is what goes between the ``<a>`` and the ``</a>``. This
        can be either a string or a tuple (or list) of strings (or
        etree elements).

        """
        # logger.info('20121002 href_button %s', unicode(text))
        if title:
            # Remember that Python 2.6 doesn't like if title is a Promise
            kw.update(title=str(title))
            #~ return xghtml.E.a(text,href=url,title=title)
        if not isinstance(text, (tuple, list)):
            text = (text,)
        if url is None:
            return E.b(*text)

        kw.update(href=url)
        if icon_name is not None:
            src = settings.SITE.build_static_url(
                'images', 'mjames', icon_name + '.png')
            img = E.img(src=src, alt=icon_name)
            return E.a(img, **kw)
        else:
            return E.a(*text, **kw)
Ejemplo n.º 2
0
    def href_button(
            self, url, text, title=None, target=None, icon_name=None, **kw):
        """
        Returns an etree object of a "button-like" ``<a href>`` tag.
        """
        # logger.info('20121002 href_button %s', unicode(text))
        if target:
            kw.update(target=target)
        if title:
            # Remember that Python 2.6 doesn't like if title is a Promise
            kw.update(title=unicode(title))
            #~ return xghtml.E.a(text,href=url,title=title)
        if not isinstance(text, (tuple, list)):
            text = (text,)
        if url is None:
            return E.b(*text)

        kw.update(href=url)
        if icon_name is not None:
            src = settings.SITE.build_media_url(
                'lino', 'extjs', 'images', 'mjames', icon_name + '.png')
            img = E.img(src=src, alt=icon_name)
            return E.a(img, **kw)
        else:
            return E.a(*text, **kw)
Ejemplo n.º 3
0
    def href_button(self,
                    url,
                    text,
                    title=None,
                    target=None,
                    icon_name=None,
                    **kw):
        """
        Returns an etree object of a "button-like" ``<a href>`` tag.
        """
        # logger.info('20121002 href_button %s', unicode(text))
        if target:
            kw.update(target=target)
        if title:
            # Remember that Python 2.6 doesn't like if title is a Promise
            kw.update(title=unicode(title))
            #~ return xghtml.E.a(text,href=url,title=title)
        if not isinstance(text, (tuple, list)):
            text = (text, )
        if url is None:
            return E.b(*text)

        kw.update(href=url)
        if icon_name is not None:
            src = settings.SITE.build_static_url('images', 'mjames',
                                                 icon_name + '.png')
            img = E.img(src=src, alt=icon_name)
            return E.a(img, **kw)
        else:
            return E.a(*text, **kw)
Ejemplo n.º 4
0
 def href_button(self, url, text, title=None, target=None, icon_name=None, **kw):
     """
     Returns an etree object of a "button-like" ``<a href>`` tag.
     """
     #~ logger.info('20121002 href_button %r',unicode(text))
     if target:
         kw.update(target=target)
     if title:
         # Remember that Python 2.6 doesn't like if title is a Promise
         kw.update(title=unicode(title))
         #~ return xghtml.E.a(text,href=url,title=title)
     kw.update(href=url)
     #~ if icon_name:
     if icon_name is not None:
         #~ btn = xghtml.E.button(type='button',class_='x-btn-text '+icon_name)
         #~ btn = xghtml.E.button(
             #~ type='button',
             #~ class_='x-btn-text '+icon_name,
             #~ onclick='function() {console.log(20121024)}')
         #~ return btn
         #~ return xghtml.E.a(btn,**kw)
         #~ kw.update(class_='x-btn-text '+icon_name)
         img = E.img(src=settings.SITE.build_media_url(
             'lino', 'extjs', 'images', 'mjames', icon_name + '.png'))
         return E.a(img, **kw)
     else:
         #~ return E.span('[',xghtml.E.a(text,**kw),']')
         #~ kw.update(style='border-width:1px; border-color:black; border-style:solid;')
         return E.a(text, **kw)
Ejemplo n.º 5
0
 def image(self, ar):
     url = self.get_image_url(ar)
     return E.a(E.img(src=url, width="100%"), href=url, target="_blank")
Ejemplo n.º 6
0
 def image(self, ar):
     url = self.get_image_url(ar)
     return E.a(E.img(src=url, width="100%"), href=url, target="_blank")