Ejemplo n.º 1
0
    def _consider_talk_link(self, links):
        if not self.request.config.talk_pages:
            return links
        lower_links = [ link.lower() for link in links ]
        from Sycamore.Page import Page
        pagename = self.key
        page = Page(pagename, self.request)
        linkto_name = None
        if page.isTalkPage():
            article_page = Page(wikiutil.talk_to_article_pagename(pagename),
                                self.request)
            article_pagename = article_page.proper_name()
            if article_pagename.lower() not in lower_links:
                links.append(article_pagename)
        else:
            talk_pagename = wikiutil.article_to_talk_pagename(pagename)
            talk_page = Page(talk_pagename, self.request)

            # add dependency so that editing/creating the talk page
            # has an affect on the article page's links
            dependency(pagename, talk_pagename.lower(), self.request)

            if talk_page.exists():
                talk_pagename = talk_page.proper_name()
                if talk_pagename.lower() not in lower_links:
                    links.append(talk_pagename)

        return links
Ejemplo n.º 2
0
    def talkicon(self, d):
        if not self.request.config.talk_pages:
            return ''

        if d['page'].isTalkPage():
           article_name = wikiutil.talk_to_article_pagename(d['page_name'])

           icon = self.get_editable_icon('articleicon.png', 'Article')
           
           return ('<td class="pageIcon"><span id="articleIcon">'
                   '%s</span></td>' %
                   (wikiutil.link_tag_explicit(
                       'style="text-decoration: none;"', self.request,
                       wikiutil.quoteWikiname(article_name), icon,
                       script_name=d['script_name'])))
        else:
            talk_page = Page(wikiutil.article_to_talk_pagename(d['page_name']),
                             self.request)

            icon = self.get_editable_icon('talkicon.png', 'Talk')

            if talk_page.exists():
                return ('<td class="pageIcon"><span id="talkIcon">'
                        '%s</span></td>' %
                        (wikiutil.link_tag_explicit(
                            'style="text-decoration: none;"', self.request,
                            wikiutil.quoteWikiname(d['page_name'])+'/Talk',
                            icon, script_name=d['script_name'])))
            else:
                # if the viewer can't edit the talk page, let's spare them
                # from looking at a useless link to an empty page:
                if not self.request.user.may.edit(talk_page):
                    return ''
                return ('<td class="pageIcon"><span id="talkIcon">'
                        '%s</span></td>' %
                        (wikiutil.link_tag_explicit(
                            'class="tinyNonexistent"', self.request,
                            wikiutil.quoteWikiname(d['page_name'])+'/Talk',
                            icon, script_name=d['script_name'])))