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

Python utils.title_to_url函数代码示例

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

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



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

示例1: make_permalink

    def make_permalink(self, sr, force_domain = False,criticism=False):
        from r2.lib.template_helpers import get_domain
	if criticism:
        	p = "criticisms/%s/%s/" % (self._id36, title_to_url(self.title))
	else:
        	p = "comments/%s/%s/" % (self._id36, title_to_url(self.title))
        # promoted links belong to a separate subsciteit and shouldn't
        # include that in the path
        if self.promoted is not None:
            if force_domain:
                res = "http://%s/%s" % (get_domain(cname = False,
                                                   subsciteit = False), p)
            else:
                res = "/%s" % p
        elif not c.cname and not force_domain:
            res = "/r/%s/%s" % (sr.name, p)
        elif sr != c.site or force_domain:
            if(c.cname and sr == c.site):
                res = "http://%s/%s" % (get_domain(cname = True,
                                                    subsciteit = False),p)
            else:
                res = "http://%s/r/%s/%s" % (get_domain(cname = False,
                                                    subsciteit = False),sr.name,p)
        else:
            res = "/%s" % p

        # WARNING: If we ever decide to add any ?foo=bar&blah parameters
        # here, Comment.make_permalink will need to be updated or else
        # it will fail.

        return res
开发者ID:constantAmateur,项目名称:sciteit,代码行数:31,代码来源:link.py


示例2: GET_oldinfo

    def GET_oldinfo(self, article, type, dest, rest=None, comment=''):
        """Legacy: supporting permalink pages from '06,
           and non-search-engine-friendly links"""
        if not (dest in ('comments','related','details')):
                dest = 'comments'
        if type == 'ancient':
            #this could go in config, but it should never change
            max_link_id = 10000000
            new_id = max_link_id - int(article._id)
            return self.redirect('/info/' + to36(new_id) + '/' + rest)
        if type == 'old':
            new_url = "/%s/%s/%s" % \
                      (dest, article._id36, 
                       quote_plus(title_to_url(article.title).encode('utf-8')))
            if not c.default_sr:
                new_url = "/r/%s%s" % (c.site.name, new_url)
            if comment:
                new_url = new_url + "/%s" % comment._id36
            if c.extension:
                new_url = new_url + "/.%s" % c.extension

            new_url = new_url + query_string(request.get)

            # redirect should be smarter and handle extensions, etc.
            return self.redirect(new_url, code=301)
开发者ID:JediWatchman,项目名称:reddit,代码行数:25,代码来源:front.py


示例3: _comment_page_links

def _comment_page_links(comment_page_data):
    for comment_info in comment_page_data:
        path = u"/r/{0}/comments/{1}/{2}/".format(
            comment_info.subreddit,
            to36(int(comment_info.thing_id)),
            urllib.quote(title_to_url(comment_info.title).encode("utf-8")),
        )
        yield _absolute_url(path)
开发者ID:zeantsoi,项目名称:reddit,代码行数:8,代码来源:generate.py


示例4: make_permalink

 def make_permalink(self, sr, force_domain = False):
     from r2.lib.template_helpers import get_domain
     p = "comments/%s/%s/" % (self._id36, title_to_url(self.title))
     if not c.cname:
         res = "/r/%s/%s" % (sr.name, p)
     elif sr != c.site or force_domain:
         res = "http://%s/%s" % (get_domain(cname = (c.cname and sr == c.site),
                                            subreddit = not c.cname), p)
     else:
         res = "/%s" % p
     return res
开发者ID:vin,项目名称:reddit,代码行数:11,代码来源:link.py


示例5: slug

        def slug():
            """
            Retrieves the original URL slug (if any) to prevent the
            URL from changing when the article title is updated.
            """
            # This could probably just check for `self.url == None`.
            if not isinstance(self.url, basestring):
                return self.title

            regex = re.compile("""
              /ea                   # subreddit
              /[^/]+                # ID
              /(?P<title>[^/]+)/    # title
            """, re.X)
            match = regex.match(self.url)
            if match:
                return match.group("title")
            else:
                return title_to_url(self.title)
开发者ID:patbl,项目名称:eaforum,代码行数:19,代码来源:link.py


示例6: build_toolbars

    def build_toolbars(self):
        base_path = "/%s/%s/" % (self.link._id36, title_to_url(self.link.title))
        if isinstance(base_path, unicode):
            base_path = base_path.encode('utf-8')
        def info_button(name):
            return NamedButton(name, dest = '/%s%s' % (name, base_path),
                               aliases = ['/%s/%s' % (name, self.link._id36)])
        
        buttons = [info_button('comments'),
                   info_button('related')]

        if c.user_is_admin:
            buttons += [info_button('details')]

        toolbar = [NavMenu(buttons, base_path = "", type="tabmenu")]

        if c.site != Default and not c.cname:
            toolbar.insert(0, PageNameNav('subreddit'))

        return toolbar
开发者ID:vin,项目名称:reddit,代码行数:20,代码来源:pages.py


示例7: canonical_url

 def canonical_url(self):
     from r2.lib.template_helpers import get_domain
     p = "lw/%s/%s/" % (self._id36, title_to_url(self.title))
     return "http://%s/%s" % (get_domain(subreddit = False), p)
开发者ID:Craigus,项目名称:lesswrong,代码行数:4,代码来源:link.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.to36函数代码示例发布时间:2022-05-26
下一篇:
Python utils.timesince函数代码示例发布时间: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