• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python tags.link_to函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中webhelpers.html.tags.link_to函数的典型用法代码示例。如果您正苦于以下问题:Python link_to函数的具体用法?Python link_to怎么用?Python link_to使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: _link

        def _link(pagenr, text):
            """
            Create a URL that links to another page
            """
            # Let the url_for() from webhelpers create a new link and set
            # the variable called 'link_var'. Example:
            # You are in '/foo/bar' (controller='foo', action='bar')
            # and you want to add a parameter 'pagenr'. Then you
            # call the navigator method with link_var='pagenr' and
            # the url_for() call will create a link '/foo/bar?pagenr=...'
            # with the respective page number added.
            # Further kwargs that are passed to the navigator will
            # also be added as URL parameters.
            arg_dict = {link_var:pagenr}
            arg_dict.update(kwargs)
            link_url = routes.url_for(**arg_dict)
            if ajax_id:
                # Return an AJAX link that will update the HTML element
                # named by ajax_id.
                if framework == 'jquery':
                    return tags.link_to(text,
                        onclick="""$('#%s').load('%s'); return false""" % \
                        (ajax_id, link_url))
                else:
                    raise Exception, "Unsupported Javascript framework: %s" % \
                            framework

            else:
                # Return a normal a-href link that will call the same
                # controller/action with the link_var set to the new
                # page number.
                return tags.link_to(text, link_url)
开发者ID:pawelniewie,项目名称:5groszy.pl,代码行数:32,代码来源:__init__.py


示例2: lnk

 def lnk(rev, repo_name):
     lazy_cs = False
     title_ = None
     url_ = '#'
     if isinstance(rev, BaseChangeset) or isinstance(rev, AttributeDict):
         if rev.op and rev.ref_name:
             if rev.op == 'delete_branch':
                 lbl = _('Deleted branch: %s') % rev.ref_name
             elif rev.op == 'tag':
                 lbl = _('Created tag: %s') % rev.ref_name
             else:
                 lbl = 'Unknown operation %s' % rev.op
         else:
             lazy_cs = True
             lbl = rev.short_id[:8]
             url_ = url('changeset_home', repo_name=repo_name,
                        revision=rev.raw_id)
     else:
         # changeset cannot be found - it might have been stripped or removed
         lbl = rev[:12]
         title_ = _('Changeset %s not found') % lbl
     if parse_cs:
         return link_to(lbl, url_, title=title_, **{'data-toggle': 'tooltip'})
     return link_to(lbl, url_, class_='lazy-cs' if lazy_cs else '',
                    **{'data-raw_id':rev.raw_id, 'data-repo_name':repo_name})
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:25,代码来源:helpers.py


示例3: lnk

        def lnk(rev, repo_name):
            if isinstance(rev, BaseChangeset) or isinstance(rev, AttributeDict):
                lazy_cs = True
                if getattr(rev, 'op', None) and getattr(rev, 'ref_name', None):
                    lazy_cs = False
                    lbl = '?'
                    if rev.op == 'delete_branch':
                        lbl = '%s' % _('Deleted branch: %s') % rev.ref_name
                        title = ''
                    elif rev.op == 'tag':
                        lbl = '%s' % _('Created tag: %s') % rev.ref_name
                        title = ''
                    _url = '#'

                else:
                    lbl = '%s' % (rev.short_id[:8])
                    _url = url('changeset_home', repo_name=repo_name,
                               revision=rev.raw_id)
                    title = tooltip(rev.message)
            else:
                ## changeset cannot be found/striped/removed etc.
                lbl = ('%s' % rev)[:12]
                _url = '#'
                title = _('Changeset not found')
            if parse_cs:
                return link_to(lbl, _url, title=title, class_='tooltip')
            return link_to(lbl, _url, raw_id=rev.raw_id, repo_name=repo_name,
                           class_='lazy-cs' if lazy_cs else '')
开发者ID:greenboxindonesia,项目名称:rhodecode,代码行数:28,代码来源:helpers.py


示例4: _pagerlink

        def _pagerlink(pagenr, text):
            """
            Create a URL that links to another page using url_for()

            Parameters:
                
            pagenr
                Number of the page that the link points to

            text
                Text to be printed in the A-HREF tag
            """
            # Let the url_for() from webhelpers create a new link and set
            # the variable called 'link_var'. Example:
            # You are in '/foo/bar' (controller='foo', action='bar')
            # and you want to add a parameter 'pagenr'. Then you
            # call the navigator method with link_var='pagenr' and
            # the url_for() call will create a link '/foo/bar?pagenr=...'
            # with the respective page number added.
            link_params = {}
            # Use the instance kwargs from Page.__init__ as URL parameters
            link_params.update(self.kwargs)
            # Add keyword arguments from pager() to the link as parameters
            link_params.update(kwargs)
            link_params[link_var] = pagenr
            # Create the URL to load a certain page
            link_url = routes.url_for(**link_params)
            log.debug("link_url(**%r) => %r", link_params, link_url)
            # Create the URL to load the page area part of a certain page (AJAX updates)
            link_params[partial_var] = 1
            partial_url = routes.url_for(**link_params)
            log.debug("partial_url(**%r) => %r", link_params, partial_url)
            if ajax_id:
                # Return an AJAX link that will update the HTML element
                # named by ajax_id.
                # Degrade gracefully if Javascript is not available by using
                # 'partial_url' in the onclick URLs while using 'link_url'
                # in the A-HREF URL.
                if framework == 'jquery':
                    return tags.link_to(text, url=link_url,
                        onclick="""%s$('#%s').load('%s'); return false""" % \
                                (javascript_before, ajax_id, partial_url), **link_attr)
                elif framework == 'yui':
                    js = """%sYAHOO.util.Connect.asyncRequest('GET','%s',{
                        success:function(o){YAHOO.util.Dom.get('%s').innerHTML=o.responseText;}
                        },null); return false;""" % (javascript_before, partial_url, ajax_id)
                    return tags.link_to(text, url=link_url, onclick=js, **link_attr)
                elif framework == 'extjs':
                    js = """%sExt.get('%s').load({url:'%s'}); return false;""" % (javascript_before, ajax_id, partial_url)
                    return tags.link_to(text, url=link_url, onclick=js, **link_attr)
                else:
                    raise Exception, "Unsupported Javascript framework: %s" % framework

            else:
                # Return a normal a-href link that will call the same
                # controller/action with the link_var set to the new
                # page number.
                return tags.link_to(text, link_url, **link_attr)
开发者ID:pawelniewie,项目名称:5groszy.pl,代码行数:58,代码来源:__init__.py


示例5: bugs_page_link

def bugs_page_link(package):
    """Return the URL to the bug reports page depending on the origin.

    For Ubuntu packages it points to edge.launchpad.net while for all other packages it
    points to bugs.debian.org."""
    if package.origin is not None and package.origin.lower() == "ubuntu":
        return tags.link_to("Bug reports", "https://launchpad.net/distros/ubuntu/+source/%s/+bugs" % package.name)
    else:
        return tags.link_to("Bug reports", "http://bugs.debian.org/%s" % package.name)
开发者ID:rhlee-canonical,项目名称:ubuntushots,代码行数:9,代码来源:helpers.py


示例6: package_page_link

def package_page_link(package):
    """Return the URL to the package page depending on the origin.

    For Ubuntu packages it points to packages.ubuntu.com while for all other packages it
    points to packages.debian.org."""
    if package.origin is not None and package.origin.lower() == "ubuntu":
        return tags.link_to("Package page on ubuntu.com", "http://packages.ubuntu.com/%s" % package.name)
    else:
        return tags.link_to("Package page on debian.org", "http://packages.debian.org/%s" % package.name)
开发者ID:rhlee-canonical,项目名称:ubuntushots,代码行数:9,代码来源:helpers.py


示例7: get_cs_links

    def get_cs_links():
        revs_limit = 3 #display this amount always
        revs_top_limit = 50 #show upto this amount of changesets hidden
        revs = action_params.split(',')
        repo_name = user_log.repository.repo_name

        from rhodecode.model.scm import ScmModel
        repo = user_log.repository.scm_instance

        message = lambda rev: get_changeset_safe(repo, rev).message
        cs_links = []
        cs_links.append(" " + ', '.join ([link_to(rev,
                url('changeset_home',
                repo_name=repo_name,
                revision=rev), title=tooltip(message(rev)),
                class_='tooltip') for rev in revs[:revs_limit] ]))

        compare_view = (' <div class="compare_view tooltip" title="%s">'
                        '<a href="%s">%s</a> '
                        '</div>' % (_('Show all combined changesets %s->%s' \
                                      % (revs[0], revs[-1])),
                                    url('changeset_home', repo_name=repo_name,
                                        revision='%s...%s' % (revs[0], revs[-1])
                                    ),
                                    _('compare view'))
                        )

        if len(revs) > revs_limit:
            uniq_id = revs[0]
            html_tmpl = ('<span> %s '
            '<a class="show_more" id="_%s" href="#more">%s</a> '
            '%s</span>')
            if not feed:
                cs_links.append(html_tmpl % (_('and'), uniq_id, _('%s more') \
                                        % (len(revs) - revs_limit),
                                        _('revisions')))

            if not feed:
                html_tmpl = '<span id="%s" style="display:none"> %s </span>'
            else:
                html_tmpl = '<span id="%s"> %s </span>'

            cs_links.append(html_tmpl % (uniq_id, ', '.join([link_to(rev,
                url('changeset_home',
                repo_name=repo_name, revision=rev),
                title=message(rev), class_='tooltip')
                for rev in revs[revs_limit:revs_top_limit]])))
        if len(revs) > 1:
            cs_links.append(compare_view)
        return ''.join(cs_links)
开发者ID:lmamsen,项目名称:rhodecode,代码行数:50,代码来源:helpers.py


示例8: __call__

    def __call__(self, repo_name, rev, paths):
        if isinstance(paths, str):
            paths = safe_unicode(paths)
        url_l = [link_to(repo_name, url('files_home',
                                        repo_name=repo_name,
                                        revision=rev, f_path=''))]
        paths_l = paths.split('/')
        for cnt, p in enumerate(paths_l):
            if p != '':
                url_l.append(link_to(p, url('files_home',
                                            repo_name=repo_name,
                                            revision=rev,
                                            f_path='/'.join(paths_l[:cnt + 1]))))

        return literal('/'.join(url_l))
开发者ID:lmamsen,项目名称:rhodecode,代码行数:15,代码来源:helpers.py


示例9: link_to_ref

def link_to_ref(repo_name, ref_type, ref_name, rev=None):
    """
    Return full markup for a href to changeset_home for a changeset.
    If ref_type is branch it will link to changelog.
    ref_name is shortened if ref_type is 'rev'.
    if rev is specified show it too, explicitly linking to that revision.
    """
    txt = short_ref(ref_type, ref_name)
    if ref_type == 'branch':
        u = url('changelog_home', repo_name=repo_name, branch=ref_name)
    else:
        u = url('changeset_home', repo_name=repo_name, revision=ref_name)
    l = link_to(repo_name + '#' + txt, u)
    if rev and ref_type != 'rev':
        l = literal('%s (%s)' % (l, link_to(short_id(rev), url('changeset_home', repo_name=repo_name, revision=rev))))
    return l
开发者ID:t-kenji,项目名称:kallithea-mirror,代码行数:16,代码来源:helpers.py


示例10: link_print

def link_print(label, url='', **attrs):
    if attrs.has_key('class_'):
        attrs['class_'] += ' btn action print'
    else:
        attrs['class_'] = ' btn action print'
    span = '<span><span>' + label + '</span></span>'
    return link_to(literal(span), url, **attrs)
开发者ID:rafal-kos,项目名称:pytis,代码行数:7,代码来源:helpers.py


示例11: userInfo

    def userInfo(self):
        checkLogIn(session)

        c.site = "Projects"
        c.name = session['user_id']
        c.menu = genMenu(self)

        res = getUserData(c.name)

        c.lineData = [("Username", res[0]), ("Name", res[1]),
                ("Last name", res[2]), ("Email", res[3])]

        c.content = render("/line_by_line.html") + html.literal("<br />")

        c.header = ["All my projects"]

        proj = userProjects(c.name)

        c.rows = []
        for x in proj:
            url_old = urlparse(request.url)
            url = url_old.scheme +'://' + url_old.netloc + getProjectUrl(x[0])
            c.rows.append((link_to(x[0], url),))

        c.style = "width:70%; text-align: left" #XXX: move css to templates

        c.content += render("/table.html")

        return render("/temp.html")
开发者ID:bulislaw,项目名称:scalak,代码行数:29,代码来源:scalak_user.py


示例12: __unicode__

    def __unicode__(self):
        if self.icon:
            text = self.icon + u' ' + self.text
        else:
            text = self.text

        return link_to(text, self.href or u'#', **self.kw)
开发者ID:samsemilia7,项目名称:SAUCE,代码行数:7,代码来源:menu.py


示例13: image_fixups

def image_fixups(content, msgid, archive, richformat, allowimgs):
    "Replace the CID links stored messages"
    html = local_fromstring(content)
    for element, attribute, link, _ in iterlinks(html):
        if not link.startswith('cid:'):
            if not allowimgs and attribute == 'src':
                element.attrib['src'] = '%simgs/blocked.gif' % media_url()
                element.attrib['title'] = link
                if richformat:
                    if archive:
                        displayurl = url('message-preview-archived-with-imgs',
                                        msgid=msgid)
                    else:
                        displayurl = url('message-preview-with-imgs',
                                        msgid=msgid)
                    flash(ugettext('This message contains external'
                        ' images, which have been blocked. ') +
                        literal(link_to(ugettext('Display images'),
                                displayurl)))
        else:
            imgname = link.replace('cid:', '')
            if archive:
                imgurl = url('messages-preview-archived-img',
                            img=imgname.replace('/', '__xoxo__'),
                            msgid=msgid)
            else:
                imgurl = url('messages-preview-img',
                            img=imgname.replace('/', '__xoxo__'),
                            msgid=msgid)
            element.attrib['src'] = imgurl            
    return tostring(html)
开发者ID:baruwaproject,项目名称:baruwa2,代码行数:31,代码来源:html.py


示例14: options_td

 def options_td(col_num, i, item):
     # XXX This module can't depend on 'app_globals' or 'url' or
     # external data. Define data within this method or class or
     # in a base class.
     # Could use HTML.a() instead of link_to().
     u = url("/tickets/view", ticket_id=item["id"])
     a = link_to(item["options"], u)
     return HTML.td(a)
开发者ID:AntonNguyen,项目名称:easy_api,代码行数:8,代码来源:grid_demo.py


示例15: render

 def render(self, **kwargs):
     return tags.link_to(
             self.field.label(),
             self.field.parent.active_request.route_url(
                 self.field.name[1:],
                 model=self.field.model.__class__.__name__,
                 id=self.field.model.id,
             )
         )
开发者ID:petrblahos,项目名称:faapp-sample,代码行数:9,代码来源:grids.py


示例16: webmaster_email

def webmaster_email(text=None):
    """ E-mail link for the conference contact.
    Renders a link to the committee; optionally takes a text, which will be
    the text of the anchor (defaults to the e-mail address).
    """
    email = lca_info['webmaster_email']
    if text == None:
        text = email

    return link_to(text, 'mailto:' + email)
开发者ID:chispita,项目名称:aqua,代码行数:10,代码来源:helpers.py


示例17: logout

 def logout(self):
     if session.get('identity'):
         # Update last logged in
         user = meta.Session.query(User).filter_by(username=session['identity'].username).filter_by(password=session['identity'].password).first()
         user.lastlogin = datetime.now()
         meta.Session.commit()
         del session['identity']
         session.save()
         
     return "You have successfully logged out<br /><br />%s" % link_to("Log back in?", url_for(controller="account", action="login"))
开发者ID:tdyhacker,项目名称:pythonexploration,代码行数:10,代码来源:account.py


示例18: get_pull_request

 def get_pull_request():
     pull_request_id = action_params
     deleted = user_log.repository is None
     if deleted:
         repo_name = user_log.repository_name
     else:
         repo_name = user_log.repository.repo_name
     return link_to(_('Pull request #%s') % pull_request_id,
                 url('pullrequest_show', repo_name=repo_name,
                 pull_request_id=pull_request_id))
开发者ID:greenboxindonesia,项目名称:rhodecode,代码行数:10,代码来源:helpers.py


示例19: usersRequests

    def usersRequests(self):
        checkLogin()

        c.site = "User requests"
        c.name = session['project_id']
        c.menu = genMenu(self)

        p = Project()
        p.load(c.name, getConfig())
        c.header = ('Login', 'EMail', 'Accept as member', "Decline")

        c.rows = [(x[0], mail_to(x[1]), link_to("Accept", \
                url(controller="project", action='requestAccept', id = x[0])), \
                link_to("Decline", \
                url(controller="project", action='requestDecline', id = x[0]))) \
                for x in p.getRequests()]

        c.style = "width: 70%; text-align: center;"

        c.content = render("/table.html")

        return render("/temp.html")
开发者ID:bulislaw,项目名称:scalak,代码行数:22,代码来源:project.py


示例20: lnk

        def lnk(rev, repo_name):

            if isinstance(rev, BaseChangeset):
                lbl = 'r%s:%s' % (rev.revision, rev.short_id)
                _url = url('changeset_home', repo_name=repo_name,
                           revision=rev.raw_id)
                title = tooltip(rev.message)
            else:
                lbl = '%s' % rev
                _url = '#'
                title = _('Changeset not found')

            return link_to(lbl, _url, title=title, class_='tooltip',)
开发者ID:yujiro,项目名称:rhodecode,代码行数:13,代码来源:helpers.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tags.select函数代码示例发布时间:2022-05-26
下一篇:
Python builder.HTML类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap