示例#1
0
    def rendercontent(self, input, fp):
        soup = BeautifulSoup(input)

        output = soup.find("div", {'class': 'wiki', 'id': 'content'})

        # Replace all links to "/wiki/help/..." with "/help/..."
        for link in output.findAll('a'):
            if link.has_key('href') and link['href'].startswith("/wiki/help"):
                link['href'] = link['href'][5:]

        # Add "edit this page" link if the user is allowed to edit the wiki
        if c.user_is_loggedin and c.user.can_wiki():
            edit_text = _('edit this page')
            yes_you_can = _("yes, it's okay!")
            read_first = _('just read this first.')
            url = "http://code.reddit.com/wiki" + websafe(fp) + "?action=edit"

            edittag = """
            <div class="editlink">
             <hr/>
             <a href="%s">%s</a>&#32;
             (<b>%s&#32;
             <a href="/help/editing_help">%s</a></b>)
            </div>
            """ % (url, edit_text, yes_you_can, read_first)

            output.append(edittag)

        output = SC_OFF + unicode(output) + SC_ON

        return HelpPage(_("help"),
                        content=Embed(content=output),
                        show_sidebar=None).render()
示例#2
0
文件: embed.py 项目: wqx081/reddit
    def rendercontent(self, input, fp):
        soup = BeautifulSoup(input)

        output = soup.find("div", {'class': 'wiki', 'id': 'content'})

        # Replace all links to "/wiki/help/..." with "/help/..."
        for link in output.findAll('a'):
            if link.has_key('href') and link['href'].startswith("/wiki/help"):
                link['href'] = link['href'][5:]

        output = SC_OFF + unicode(output) + SC_ON

        return HelpPage(_("help"),
                        content=Embed(content=output),
                        show_sidebar=None).render()