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()
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()
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()
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
def validversion(self, version, pageid=None): if not version: return try: r = WikiRevision.get(version, pageid) if 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
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
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
def GET_wiki_recent(self, num, after, reverse, count): """Retrieve a list of recently changed wiki pages in this subreddit""" 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, sr_path=not c.site.is_homepage).render()