当前位置: 首页>>代码示例>>Python>>正文


Python E.a方法代码示例

本文整理汇总了Python中etgen.html.E.a方法的典型用法代码示例。如果您正苦于以下问题:Python E.a方法的具体用法?Python E.a怎么用?Python E.a使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在etgen.html.E的用法示例。


在下文中一共展示了E.a方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: href_button

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import a [as 别名]
    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,)
        text = forcetext(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)
开发者ID:lino-framework,项目名称:lino,代码行数:33,代码来源:renderer.py

示例2: get_file_button

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import a [as 别名]
 def get_file_button(self, text=None):
     if text is None:
         text = str(self)
     if self.file.name:
         url = settings.SITE.build_media_url(self.file.name)
         return E.a(text, href=url, target="_blank")
     return text
开发者ID:lino-framework,项目名称:lino,代码行数:9,代码来源:uploadable.py

示例3: get_comment_header

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import a [as 别名]
    def get_comment_header(cls, comment, ar):
        ch = []
        if (comment.modified - comment.created).total_seconds() < 1:
            t = _("Created " + comment.created.strftime('%Y-%m-%d %H:%M'))
        else:
            t = _("Modified " + comment.modified.strftime('%Y-%m-%d %H:%M'))
        ch.append(ar.obj2html(
            comment, naturaltime(comment.created), title=t))
        ch += [" ", _("by"), " ",
               ar.obj2html(comment.user, str(comment.user))]

        sar = cls.insert_action.request_from(ar)
        # print(20170217, sar)
        sar.known_values = dict(
            reply_to=comment, **gfk2lookup(
                comment.__class__.owner, comment.owner))
        if ar.get_user().authenticated:
            btn = sar.ar2button(None, _(" Reply "), icon_name=None)
            # btn.set("style", "padding-left:10px")
            ch += [" [", btn, "]"]

        ch.append(' ')
        ch.append(
            E.a(u"⁜", onclick="toggle_visibility('comment-{}');".format(
                comment.id), title=str(_("Hide")), href="#")
        )
        return tostring(ch)
开发者ID:lino-framework,项目名称:lino,代码行数:29,代码来源:ui.py

示例4: when

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import a [as 别名]
 def when(self, obj, ar):
     #~ rv = dbutils.dtosl(obj.date)
     rv = dd.fdf(obj.date)
     if obj.url:
         # replaces spaces by newline to avoid large column
         rv = '\n'.join(rv.split())
         rv = E.a(rv, href=obj.url)
     return rv
开发者ID:lino-framework,项目名称:xl,代码行数:10,代码来源:models.py

示例5: get_sidebar_item

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import a [as 别名]
 def get_sidebar_item(self, request, other):
     kw = dict()
     add_user_language(kw, request)
     url = self.get_absolute_url(**kw)
     a = E.a(self.get_sidebar_caption(), href=url)
     if self == other:
         return E.li(a, **{'class':'active'})
     return E.li(a)
开发者ID:khchine5,项目名称:xl,代码行数:10,代码来源:models.py

示例6: show_menu

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import a [as 别名]
    def show_menu(self, ar, mnu, level=1):
        """
        Render the given menu as an HTML element.
        Used for writing test cases.
        """
        if not isinstance(mnu, Menu):
            assert isinstance(mnu, MenuItem)
            if mnu.bound_action:
                sar = mnu.bound_action.actor.request(
                    action=mnu.bound_action,
                    user=ar.user, subst_user=ar.subst_user,
                    requesting_panel=ar.requesting_panel,
                    renderer=self, **mnu.params)
                # print("20170113", sar)
                url = sar.get_request_url()
            else:
                url = mnu.href
            assert mnu.label is not None
            if url is None:
                return E.p()  # spacer
            return E.li(E.a(str(mnu.label), href=url, tabindex="-1"))

        items = [self.show_menu(ar, mi, level + 1) for mi in mnu.items]
        #~ print 20120901, items
        if level == 1:
            return E.ul(*items, **{'class':'nav navbar-nav'})
        if mnu.label is None:
            raise Exception("%s has no label" % mnu)
        if level == 2:
            cl = 'dropdown'
            menu_title = E.a(
                str(mnu.label), E.b(' ', **{'class': "caret"}), href="#",
                data_toggle="dropdown", **{'class':'dropdown-toggle'})
        elif level == 3:
            menu_title = E.a(str(mnu.label), href="#")
            cl = 'dropdown-submenu'
        else:
            raise Exception("Menu with more than three levels")
        return E.li(
            menu_title,
            E.ul(*items, **{'class':'dropdown-menu'}),
            **{'class':cl})
开发者ID:lino-framework,项目名称:lino,代码行数:44,代码来源:renderer.py

示例7: buttons2pager

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import a [as 别名]
def buttons2pager(buttons, title=None):
    items = []
    if title:
        items.append(E.li(E.span(title)))
    for symbol, label, url in buttons:
        if url is None:
            items.append(E.li(E.span(symbol), **{'class':"disabled"}))
        else:
            items.append(E.li(E.a(symbol, href=url)))
    # Bootstrap version 2.x
    # return E.div(E.ul(*items), class_='pagination')
    return E.ul(*items, **{'class':'pagination pagination-sm'})
开发者ID:lino-framework,项目名称:lino,代码行数:14,代码来源:views.py

示例8: get_table_summary

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import a [as 别名]
 def get_table_summary(self, obj, ar):
     sar = self.request_from(ar, master_instance=obj)
     items = []
     for c in sar:
         # todo have another js button that will expand the summary
         # into the complete description.
         items.append(E.li(
             E.a(c.sha[:6], href=c.url, target="_BLANK"),
             ":" if c.user else "",
             ar.obj2html(c.user) if c.user else "",
             ":",
             ar.obj2html(
                 c, naturaltime(c.created),
                 title=c.created.strftime('%Y-%m-%d %H:%M')),
             E.br(), c.summary))
     return E.ul(*items)
开发者ID:lino-framework,项目名称:xl,代码行数:18,代码来源:desktop.py

示例9: getter

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import a [as 别名]
 def getter(obj, ar):
     if ar is None:
         return ''
     qs = SiteSummary.objects.filter(master=obj)
     d = qs.aggregate(**{k:models.Sum(k)})
     n = d[k]
     if n == 0:
         return ''
     sar = rt.models.tickets.TicketsBySite.request(
         obj, param_values=dict(
             state=ts, show_active=None))
     # n = sar.get_total_count()
     url = ar.renderer.request_handler(sar)
     if url is None:
         return str(n)
     return E.a(str(n), href='javascript:'+url)
开发者ID:lino-framework,项目名称:xl,代码行数:18,代码来源:models.py

示例10: get_help_url

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import a [as 别名]
    def get_help_url(self, docname=None, text=None, **kw):
        """
        Generate a link to the help section of the documentation (whose
        base is defined by :attr:`lino.core.site.Site.help_url`)

        Usage example::

            help = ar.get_help_url("foo", target='_blank')
            msg = _("You have a problem with foo."
                    "Please consult %(help)s "
                    "or ask your system administrator.")
            msg %= dict(help=tostring(help))
            kw.update(message=msg, alert=True)
        """
        if text is None:
            text = six.text_type(_("the documentation"))
        url = settings.SITE.help_url
        if docname is not None:
            url = "%s/help/%s.html" % (url, docname)
        return E.a(text, href=url, **kw)
开发者ID:lino-framework,项目名称:lino,代码行数:22,代码来源:requests.py

示例11: notify_done

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import a [as 别名]
 def notify_done(self, ar, bm, leaf, url, **kw):
     # help_url = ar.get_help_url("print", target='_blank')
     # if bm.use_webdav:
     #     url = ar.build_webdav_uri(url)
     msg = _("Your printable document ({}) "
             "should now open in a new browser window. "
             # "If it doesn't, please consult %(help)s "
             "If it doesn't, please "
             "ask your system administrator.")
     msg = msg.format(
         etree.tostring(E.a(leaf, href=url), encoding="unicode"))
     # msg %= dict(doc=leaf, help=etree.tostring(
     #     help_url, encoding="unicode"))
     kw.update(message=msg, alert=True)
     if has_davlink and bm.use_webdav and ar.request is not None:
         kw.update(
             open_webdav_url=ar.request.build_absolute_uri(url))
     else:
         kw.update(open_url=url)
     ar.success(**kw)
     return
开发者ID:lino-framework,项目名称:lino,代码行数:23,代码来源:actions.py

示例12: href

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import a [as 别名]
 def href(self, url, text):
     return E.a(text, href=url)
开发者ID:lino-framework,项目名称:lino,代码行数:4,代码来源:renderer.py

示例13: fmt

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import a [as 别名]
 def fmt(tbl):
     url = tbl.__module__ + '.' + tbl.__name__
     return E.a(tbl.__name__, href=url)
开发者ID:khchine5,项目名称:xl,代码行数:5,代码来源:desktop.py

示例14: as_html

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import a [as 别名]
 def as_html(self, obj, ar):
     txt = obj.remark or obj.value
     return E.a(txt, href=obj.value)
开发者ID:lino-framework,项目名称:xl,代码行数:5,代码来源:choicelists.py

示例15: table2html

# 需要导入模块: from etgen.html import E [as 别名]
# 或者: from etgen.html.E import a [as 别名]
def table2html(ar, as_main=True):
    """Represent the given table request as an HTML table.

    `ar` is the request to be rendered, an instance of
    :class:`lino.core.tablerequest.TableRequest`.

    The returned HTML enclosed in a ``<div>`` tag and generated using
    :mod:`etgen.html`.

    If `as_main` is True, include additional elements such as a paging
    toolbar. (This argument is currently being ignored.)

    """
    # as_main = True
    t = xghtml.Table()
    t.attrib.update(**{'class':"table table-striped table-hover"})
    if ar.limit is None:
        ar.limit = PLAIN_PAGE_LENGTH
    pglen = ar.limit
    if ar.offset is None:
        page = 1
    else:
        """
        (assuming pglen is 5)
        offset page
        0      1
        5      2
        """
        page = int(old_div(ar.offset, pglen)) + 1

    ar.dump2html(t, ar.sliced_data_iterator, header_links=as_main)
    if not as_main:
        url = ar.get_request_url()  # open in own window
        return E.div(
            E.div(
                E.div(
                    E.a(
                        E.span(**{'class':"glyphicon glyphicon-folder-open"}),
                        href=url, style="margin-left: 4px;",
                        **{'class':"btn btn-default pull-right"}),
                    E.h5(ar.get_title(), style="display: inline-block;"),
                    **{'class': "panel-title"}),
                **{'class':"panel-heading"}),
                t.as_element(),
            style="display: inline-block;",
            **{'class':"panel panel-default"})

    buttons = []
    kw = dict()
    kw = {}
    if pglen != PLAIN_PAGE_LENGTH:
        kw[constants.URL_PARAM_LIMIT] = pglen

    if page > 1:
        kw[constants.URL_PARAM_START] = pglen * (page - 2)
        prev_url = ar.get_request_url(**kw)
        kw[constants.URL_PARAM_START] = 0
        first_url = ar.get_request_url(**kw)
    else:
        prev_url = None
        first_url = None
    buttons.append(('<<', _("First page"), first_url))
    buttons.append(('<', _("Previous page"), prev_url))

    next_start = pglen * page
    if next_start < ar.get_total_count():
        kw[constants.URL_PARAM_START] = next_start
        next_url = ar.get_request_url(**kw)
        last_page = int(old_div((ar.get_total_count() - 1), pglen))
        kw[constants.URL_PARAM_START] = pglen * last_page
        last_url = ar.get_request_url(**kw)
    else:
        next_url = None
        last_url = None
    buttons.append(('>', _("Next page"), next_url))
    buttons.append(('>>', _("Last page"), last_url))

    return E.div(buttons2pager(buttons), t.as_element())
开发者ID:lino-framework,项目名称:lino,代码行数:80,代码来源:views.py


注:本文中的etgen.html.E.a方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。