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


Python wiki.WikiRevision类代码示例

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


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

示例1: GET_policy_page

    def GET_policy_page(self, page, requested_rev):
        if c.render_style == 'compact':
            self.redirect('/wiki/' + page)
        if page == 'privacypolicy':
            wiki_name = g.wiki_page_privacy_policy
            pagename = _('privacy policy')
        elif page == 'useragreement':
            wiki_name = g.wiki_page_user_agreement
            pagename = _('user agreement')
        elif page == 'contentpolicy':
            wiki_name = g.wiki_page_content_policy
            pagename = _('content policy')
        else:
            abort(404)

        wp = WikiPage.get(Frontpage, wiki_name)

        revs = list(wp.get_revisions())

        # collapse minor edits into revisions with reasons
        rev_info = []
        last_edit = None
        for rev in revs:
            if rev.is_hidden:
                continue

            if not last_edit:
                last_edit = rev

            if rev._get('reason'):
                rev_info.append({
                    'id': str(last_edit._id),
                    'title': rev._get('reason'),
                })
                last_edit = None

        if requested_rev:
            try:
                display_rev = WikiRevision.get(requested_rev, wp._id)
            except (tdb_cassandra.NotFound, WikiBadRevision):
                abort(404)
        else:
            display_rev = revs[0]

        doc_html = wikimarkdown(display_rev.content, include_toc=False)
        soup = BeautifulSoup(doc_html.decode('utf-8'))
        toc = generate_table_of_contents(soup, prefix='section')
        self._number_sections(soup)
        self._linkify_headings(soup)

        content = PolicyView(
            body_html=unsafe(soup),
            toc_html=unsafe(toc),
            revs=rev_info,
            display_rev=str(display_rev._id),
        )
        return PolicyPage(
            pagename=pagename,
            content=content,
        ).render()
开发者ID:My-Favorites,项目名称:reddit,代码行数:60,代码来源:policies.py

示例2: GET_wiki_recent

 def GET_wiki_recent(self, num, after, reverse, count):
     revisions = WikiRevision.get_recent(c.site)
     builder = WikiRecentRevisionBuilder(revisions,  num=num, count=count,
                                         reverse=reverse, after=after,
                                         wrap=default_thing_wrapper(),
                                         skip=not c.is_wiki_mod)
     listing = WikiRevisionListing(builder).listing()
     return WikiRecent(listing).render()
开发者ID:BenHalberstam,项目名称:reddit,代码行数:8,代码来源:wiki.py

示例3: GET_wiki_recent

 def GET_wiki_recent(self, num, after, reverse, count):
     revisions = WikiRevision.get_recent(c.site)
     wikiuser = c.user if c.user_is_loggedin else None
     builder = WikiRecentRevisionBuilder(revisions,  num=num, count=count,
                                         reverse=reverse, after=after,
                                         wrap=default_thing_wrapper(),
                                         skip=not c.is_wiki_mod,
                                         user=wikiuser, sr=c.site)
     listing = WikiRevisionListing(builder).listing()
     return WikiRecent(listing).render()
开发者ID:aldarund,项目名称:reddit,代码行数:10,代码来源:wiki.py

示例4: validversion

 def validversion(self, version, pageid=None):
     if not version:
         return
     try:
         r = WikiRevision.get(version, pageid)
         if not self.allow_hidden_revision and (r.is_hidden and not c.is_wiki_mod):
             self.set_error('HIDDEN_REVISION', code=403)
             raise AbortWikiError
         return r
     except (tdb_cassandra.NotFound, ValueError):
         self.set_error('INVALID_REVISION', code=404)
         raise AbortWikiError
开发者ID:PhearTheCeal,项目名称:reddit,代码行数:12,代码来源:wiki.py

示例5: validversion

 def validversion(self, version, pageid=None):
     if not version:
         return
     try:
         r = WikiRevision.get(version, pageid)
         if r.admin_deleted and not c.user_is_admin:
             self.set_error("INVALID_REVISION", code=404)
             raise AbortWikiError
         if not self.allow_hidden_revision and (r.is_hidden and not c.is_wiki_mod):
             self.set_error("HIDDEN_REVISION", code=403)
             raise AbortWikiError
         return r
     except (tdb_cassandra.NotFound, WikiBadRevision):
         self.set_error("INVALID_REVISION", code=404)
         raise AbortWikiError
开发者ID:karthikv,项目名称:reddit,代码行数:15,代码来源:wiki.py


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