changeset 869:0152984f76ee

use rel nofollow for action links
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 22 Jun 2006 22:26:19 +0200
parents 01750f3c867c
children 1b9748f84aea
files MoinMoin/Page.py MoinMoin/action/AttachFile.py MoinMoin/action/__init__.py MoinMoin/macro/RecentChanges.py MoinMoin/macro/WantedPages.py MoinMoin/theme/__init__.py MoinMoin/theme/classic.py MoinMoin/userform.py docs/CHANGES
diffstat 9 files changed, 48 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/Page.py	Tue Jun 20 21:13:27 2006 +0200
+++ b/MoinMoin/Page.py	Thu Jun 22 22:26:19 2006 +0200
@@ -1263,7 +1263,7 @@
                               " Check your underlay directory setting.")
                 url = '%s?action=edit' % wikiutil.quoteWikinameURL(self.page_name)
                 request.write(wikiutil.link_tag(self.request, url, text=_("Create New Page"),
-                                                formatter=self.formatter))
+                                                formatter=self.formatter, rel='nofollow'))
         elif not request.user.may.read(self.page_name):
             request.write("<strong>%s</strong><br>" % _("You are not allowed to view this page."))
         else:
--- a/MoinMoin/action/AttachFile.py	Tue Jun 20 21:13:27 2006 +0200
+++ b/MoinMoin/action/AttachFile.py	Thu Jun 22 22:26:19 2006 +0200
@@ -124,7 +124,8 @@
     attach_icon = request.theme.make_icon('attach', vars={ 'attach_count': attach_count })
     attach_link = wikiutil.link_tag(request,
         "%s?action=AttachFile" % wikiutil.quoteWikinameURL(pagename),
-        attach_icon)
+        attach_icon,
+        request.formatter, rel='nofollow')
 
     return attach_link
 
--- a/MoinMoin/action/__init__.py	Tue Jun 20 21:13:27 2006 +0200
+++ b/MoinMoin/action/__init__.py	Thu Jun 22 22:26:19 2006 +0200
@@ -594,7 +594,7 @@
                 if rev2: qstr = '%s&rev2=%s' % (qstr, rev2)
                 request.write(Page(request, pagename).link_to(request,
                     text=_('Ignore changes in the amount of whitespace'),
-                    querystr=qstr) + '<p>')
+                    querystr=qstr, rel='nofollow') + '<p>')
 
             request.write('<pre>')
             for line in lines:
@@ -695,24 +695,24 @@
                         querystr=''))
                     actions = '%s&nbsp;%s' % (actions, page.link_to(request,
                         text=_('raw'),
-                        querystr='action=raw'))
+                        querystr='action=raw', rel='nofollow'))
                     actions = '%s&nbsp;%s' % (actions, page.link_to(request,
                         text=_('print'),
-                        querystr='action=print'))
+                        querystr='action=print', rel='nofollow'))
                 else:
                     actions = '%s&nbsp;%s' % (actions, page.link_to(request,
                         text=_('view'),
-                        querystr='action=recall&rev=%d' % rev))
+                        querystr='action=recall&rev=%d' % rev, rel='nofollow'))
                     actions = '%s&nbsp;%s' % (actions, page.link_to(request,
                         text=_('raw'),
-                        querystr='action=raw&rev=%d' % rev))
+                        querystr='action=raw&rev=%d' % rev, rel='nofollow'))
                     actions = '%s&nbsp;%s' % (actions, page.link_to(request,
                         text=_('print'),
-                        querystr='action=print&rev=%d' % rev))
+                        querystr='action=print&rev=%d' % rev, rel='nofollow'))
                     if may_revert and size: # you can only revert to nonempty revisions
                         actions = '%s&nbsp;%s' % (actions, page.link_to(request,
                             text=_('revert'),
-                            querystr='action=revert&rev=%d' % (rev,)))
+                            querystr='action=revert&rev=%d' % rev, rel='nofollow'))
                 if count == 0:
                     rchecked=' checked="checked"'
                     lchecked = ''
@@ -744,18 +744,18 @@
                     if line.action == 'ATTNEW':
                         actions = '%s&nbsp;%s' % (actions, page.link_to(request,
                             text=_('view'),
-                            querystr='action=AttachFile&do=view&target=%s' % filename))
+                            querystr='action=AttachFile&do=view&target=%s' % filename, rel='nofollow'))
                     elif line.action == 'ATTDRW':
                         actions = '%s&nbsp;%s' % (actions, page.link_to(request,
                             text=_('edit'),
-                            querystr='action=AttachFile&drawing=%s' % filename.replace(".draw","")))
+                            querystr='action=AttachFile&drawing=%s' % filename.replace(".draw",""), rel='nofollow'))
 
                     actions = '%s&nbsp;%s' % (actions, page.link_to(request,
                         text=_('get'),
-                        querystr='action=AttachFile&do=get&target=%s' % filename))
+                        querystr='action=AttachFile&do=get&target=%s' % filename, rel='nofollow'))
                     actions = '%s&nbsp;%s' % (actions, page.link_to(request,
                         text=_('del'),
-                        querystr='action=AttachFile&do=del&target=%s' % filename))
+                        querystr='action=AttachFile&do=del&target=%s' % filename, rel='nofollow'))
                     # XXX use?: wikiutil.escape(filename)
 
             history.addRow((
@@ -810,11 +810,11 @@
     request.theme.send_title(_('Info for "%s"') % (title,), pagename=pagename)
 
     historylink =  wikiutil.link_tag(request, '%s?action=info' % qpagename,
-        _('Show "%(title)s"') % {'title': _('Revision History')})
+        _('Show "%(title)s"') % {'title': _('Revision History')}, request.formatter, rel='nofollow')
     generallink =  wikiutil.link_tag(request, '%s?action=info&amp;general=1' % qpagename,
-        _('Show "%(title)s"') % {'title': _('General Page Infos')})
+        _('Show "%(title)s"') % {'title': _('General Page Infos')}, request.formatter, rel='nofollow')
     hitcountlink = wikiutil.link_tag(request, '%s?action=info&amp;hitcounts=1' % qpagename,
-        _('Show chart "%(title)s"') % {'title': _('Page hits and edits')})
+        _('Show chart "%(title)s"') % {'title': _('Page hits and edits')}, request.formatter, rel='nofollow')
     
     request.write('<div id="content">\n') # start content div
     request.write("<p>[%s]  [%s]  [%s]</p>" % (historylink, generallink, hitcountlink))
--- a/MoinMoin/macro/RecentChanges.py	Tue Jun 20 21:13:27 2006 +0200
+++ b/MoinMoin/macro/RecentChanges.py	Thu Jun 22 22:26:19 2006 +0200
@@ -65,25 +65,25 @@
         #img = request.theme.make_icon('help')
         html_link = wikiutil.link_tag(request,
                                       wikiutil.quoteWikinameURL(pagename) + "?action=edit",
-                                      img, formatter=macro.formatter)
+                                      img, formatter=macro.formatter, rel="nofollow")
     elif is_new:
         # show "NEW" icon if page was created after the user's bookmark
         if hilite:
             img = request.theme.make_icon('new')
             html_link = wikiutil.link_tag(request, wikiutil.quoteWikinameURL(pagename),
-                                          img, formatter=macro.formatter)
+                                          img, formatter=macro.formatter, rel="nofollow")
     elif hilite:
         # show "UPDATED" icon if page was edited after the user's bookmark
         img = request.theme.make_icon('updated')
         html_link = wikiutil.link_tag(request,
                                       wikiutil.quoteWikinameURL(pagename) + "?action=diff&date=%d" % bookmark_usecs,
-                                      img, formatter=macro.formatter)
+                                      img, formatter=macro.formatter, rel="nofollow")
     else:
         # show "DIFF" icon else
         img = request.theme.make_icon('diffrc')
         html_link = wikiutil.link_tag(request,
                                       wikiutil.quoteWikinameURL(line.pagename) + "?action=diff",
-                                      img, formatter=macro.formatter)
+                                      img, formatter=macro.formatter, rel="nofollow")
 
     # print name of page, with a link to it
     force_split = len(page.page_name) > _MAX_PAGENAME_LENGTH
@@ -133,7 +133,7 @@
     img = request.theme.make_icon('info')
     info_html = wikiutil.link_tag(request,
                                   wikiutil.quoteWikinameURL(line.pagename) + "?action=info",
-                                  img, formatter=macro.formatter)
+                                  img, formatter=macro.formatter, rel="nofollow")
     d['info_html'] = info_html
     
     return request.theme.recentchanges_entry(d)
@@ -259,14 +259,14 @@
             
             url = wikiutil.quoteWikinameURL(pagename) + "?action=bookmark&time=del"
             deleteBookmark = wikiutil.link_tag(request, url, _("Delete Bookmark"),
-                                               formatter=macro.formatter)
+                                               formatter=macro.formatter, rel="nofollow")
             d['rc_curr_bookmark'] = currentBookmark + ' ' + deleteBookmark
 
         version = wikiutil.timestamp2version(tnow)
         url = wikiutil.quoteWikinameURL(pagename) + \
             "?action=bookmark&time=%d" % version
         d['rc_update_bookmark'] = wikiutil.link_tag(request, url, _("Set bookmark"),
-                                                    formatter=macro.formatter)
+                                                    formatter=macro.formatter, rel="nofollow")
     
     # set max size in days
     max_days = min(int(request.form.get('max_days', [0])[0]), _DAYS_SELECTION[-1])
@@ -314,7 +314,7 @@
                     wikiutil.quoteWikinameURL(
                         macro.formatter.page.page_name) + "?action=bookmark&time=%d" % (pages[0][0].ed_time_usecs,),
                         _("set bookmark"),
-                        formatter=macro.formatter)
+                        formatter=macro.formatter, rel="nofollow")
             else:
                 d['bookmark_link_html'] = None
             d['date'] = request.user.getFormattedDate(wikiutil.version2timestamp(pages[0][0].ed_time_usecs))
@@ -360,7 +360,7 @@
                     wikiutil.quoteWikinameURL(
                         macro.formatter.page.page_name) + "?action=bookmark&time=%d" % (pages[0][0].ed_time_usecs,),
                         _("Set bookmark"),
-                        formatter=macro.formatter)
+                        formatter=macro.formatter, rel="nofollow")
             else:
                 d['bookmark_link_html'] = None
             d['date'] = request.user.getFormattedDate(wikiutil.version2timestamp(pages[0][0].ed_time_usecs))
--- a/MoinMoin/macro/WantedPages.py	Tue Jun 20 21:13:27 2006 +0200
+++ b/MoinMoin/macro/WantedPages.py	Thu Jun 22 22:26:19 2006 +0200
@@ -75,7 +75,7 @@
         if macro.formatter.page.page_name in where:
             where.remove(macro.formatter.page.page_name)
         querystr='highlight=%s' % wikiutil.url_quote_plus(name)
-        wherelinks = [pages[pagename].link_to(request, querystr=querystr)
+        wherelinks = [pages[pagename].link_to(request, querystr=querystr, rel='nofollow')
                       for pagename in where]
         result.append(": " + ', '.join(wherelinks))
         result.append(macro.formatter.listitem(0))
--- a/MoinMoin/theme/__init__.py	Tue Jun 20 21:13:27 2006 +0200
+++ b/MoinMoin/theme/__init__.py	Thu Jun 22 22:26:19 2006 +0200
@@ -222,7 +222,7 @@
                 curpage += s
                 content.append("<li>%s</li>" % Page(self.request, curpage).link_to(self.request, s))
                 curpage += '/'
-            content.append(('<li><a class="backlink" title="%(title)s" href="%(href)s">%(text)s</a></li>') % {
+            content.append(('<li><a class="backlink" title="%(title)s" rel="nofollow" href="%(href)s">%(text)s</a></li>') % {
                 'title': _('Click to do a full-text search for this title'),
                 'href': d['title_link'],
                 'text': wikiutil.escape(segments[-1]),
@@ -264,15 +264,15 @@
             userlinks.append(homelink)        
             # link to userprefs action
             userlinks.append(d['page'].link_to(request, text=_('Preferences'),
-                                               querystr={'action': 'userprefs'}, id="userprefs"))
+                                               querystr={'action': 'userprefs'}, id='userprefs', rel='nofollow'))
            
         if request.cfg.show_login:
             if request.user.valid:
                 userlinks.append(d['page'].link_to(request, text=_('Logout', formatted=False),
-                                                   querystr={'action': 'logout', 'logout': 'logout'}, id="logout"))
+                                                   querystr={'action': 'logout', 'logout': 'logout'}, id='logout', rel='nofollow'))
             else:
                 userlinks.append(d['page'].link_to(request, text=_("Login", formatted=False),
-                                                   querystr={'action': 'login'}, id="login"))
+                                                   querystr={'action': 'login'}, id='login', rel='nofollow'))
 
         userlinks = [u'<li>%s</li>' % link for link in userlinks]
         html = u'<ul id="username">%s</ul>' % ''.join(userlinks)
@@ -1124,16 +1124,16 @@
         if self.showBothEditLinks() and guiworks:
             text = _('Edit (Text)', formatted=False)
             params = params + 'text'
-            attrs = {'name': "texteditlink"}
+            attrs = {'name': 'texteditlink', 'rel': 'nofollow', }
         else:
             text = _('Edit', formatted=False)
             if guiworks:
                 # 'textonly' will be upgraded dynamically to 'guipossible' by JS
                 params = params + 'textonly'
-                attrs = {'name': "editlink"}
+                attrs = {'name': 'editlink', 'rel': 'nofollow', }
             else:
                 params = params + 'text'
-                attrs = {'name': "texteditlink"}
+                attrs = {'name': 'texteditlink', 'rel': 'nofollow', }
         
         return wikiutil.link_tag(self.request, params, text, **attrs)
 
@@ -1177,7 +1177,7 @@
         _ = self.request.getText
         return page.link_to(self.request,
                             text=_('Info', formatted=False), 
-                            querystr='action=info')
+                            querystr='action=info', rel='nofollow')
     
     def subscribeLink(self, page):
         """ Return subscribe/unsubscribe link to valid users
@@ -1194,7 +1194,7 @@
         else:
             text = _("Subscribe", formatted=False)
         params = wikiutil.quoteWikinameURL(page.page_name) + '?action=subscribe'
-        return wikiutil.link_tag(self.request, params, text)
+        return wikiutil.link_tag(self.request, params, text, self.request.formatter, rel='nofollow')
 
     def quicklinkLink(self, page):
         """ Return add/remove quicklink link
@@ -1211,14 +1211,14 @@
         else:
             text = _("Add Link", formatted=False)
         params = wikiutil.quoteWikinameURL(page.page_name) + '?action=quicklink'
-        return wikiutil.link_tag(self.request, params, text)
+        return wikiutil.link_tag(self.request, params, text, self.request.formatter, rel='nofollow')
 
     def attachmentsLink(self, page):
         """ Return link to page attachments """
         _ = self.request.getText
         return page.link_to(self.request,
                             text=_('Attachments', formatted=False), 
-                            querystr='action=AttachFile')
+                            querystr='action=AttachFile', rel='nofollow')
 
     def startPage(self):
         """ Start page div with page language and direction
@@ -1362,7 +1362,8 @@
                     days.append(
                         wikiutil.link_tag(self.request,
                             '%s?max_days=%d' % (d['q_page_name'], day),
-                            str(day)))
+                            str(day),
+                            self.request.formatter, rel='nofollow'))
             days = ' | '.join(days)
             html += (_("Show %s days.") % (days,))
         
--- a/MoinMoin/theme/classic.py	Tue Jun 20 21:13:27 2006 +0200
+++ b/MoinMoin/theme/classic.py	Thu Jun 22 22:26:19 2006 +0200
@@ -195,12 +195,12 @@
                 # Use translated version if available
                 title = _(title, formatted=False)
                 params = '%s?action=%s' % (d['q_page_name'], action)
-                link = wikiutil.link_tag(request, params, title)
+                link = wikiutil.link_tag(request, params, title, request.formatter, rel='nofollow')
                 html.append(link)
                 
         title = _("DeleteCache", formatted=False)
         params = '%s?action=%s' % (d['page_name'], 'refresh')
-        link = wikiutil.link_tag(request, params, title)
+        link = wikiutil.link_tag(request, params, title, request.formatter, rel='nofollow')
         
         cache = caching.CacheEntry(request, page, page.getFormatterName(), scope='item')
         date = request.user.getFormattedDateTime(cache.mtime())
--- a/MoinMoin/userform.py	Tue Jun 20 21:13:27 2006 +0200
+++ b/MoinMoin/userform.py	Thu Jun 22 22:26:19 2006 +0200
@@ -637,7 +637,7 @@
         sn = request.getScriptname()
         pi = request.getPathinfo()
         action = u"%s%s" % (sn, pi)
-        userprefslink = wikiutil.getSysPage(request, "UserPreferences").link_to(request)
+        userprefslink = wikiutil.getSysPage(request, "UserPreferences").link_to(request, rel='nofollow')
         hint = _("To create an account or recover a lost password, see the %(userprefslink)s page.") % {
                'userprefslink': userprefslink}
         self._form = html.FORM(action=action)
@@ -714,7 +714,8 @@
                                  querystr= {"action":"userform",
                                             "email": account.email,  
                                             "account_sendmail": "1",
-                                            "sysadm": "users",})
+                                            "sysadm": "users",},
+                                 rel='nofollow')
         ))
 
     if data:
--- a/docs/CHANGES	Tue Jun 20 21:13:27 2006 +0200
+++ b/docs/CHANGES	Thu Jun 22 22:26:19 2006 +0200
@@ -143,6 +143,9 @@
     * cfg.log_reverse_dns_lookups [default: True] - you can set this to False
       if rev. dns lookups are broken in your network (leading to long delays
       on page saves). With False, edit-log will only contain IP, not hostname.
+    * We use rel="nofollow" for some action links in the hope that some search
+      engines don't fetch the targets (if they do, they will just get 403 and
+      cause unnecessary traffic).
 
   Bugfixes:
     * on action "info" page, "revert" link will not be displayed for empty page