Page MenuHomePhabricator

nofollow_on_interwikis_nonlocal_discrimination.patch

Authored By
bzimport
Nov 21 2014, 9:31 PM
Size
1 KB
Referenced Files
None
Subscribers
None

nofollow_on_interwikis_nonlocal_discrimination.patch

Index: includes/DefaultSettings.php
===================================================================
--- includes/DefaultSettings.php (revision 21792)
+++ includes/DefaultSettings.php (working copy)
@@ -2169,6 +2169,20 @@
$wgNoFollowNsExceptions = array();
/**
+ * If true, non-local interwiki links in wiki text will be given
+ * the rel="nofollow" attribute as a hint to search engines that
+ * they should not be followed for ranking purposes.
+ */
+$wgNoFollowNonLocalInterwikiLinks = false;
+
+/**
+ * If true, all interwiki links in wiki text will be given the
+ * rel="nofollow" attribute as a hint to search engines that
+ * they should not be followed for ranking purposes.
+ */
+$wgNoFollowAllInterwikiLinks = false;
+
+/**
* Robot policies per namespaces.
* The default policy is 'index,follow', the array is made of namespace
* constants as defined in includes/Defines.php
Index: includes/Linker.php
===================================================================
--- includes/Linker.php (revision 21792)
+++ includes/Linker.php (working copy)
@@ -200,7 +200,19 @@
$link = $nt->getPrefixedURL();
if ( '' == $text ) { $text = $nt->getPrefixedText(); }
$style = $this->getInterwikiLinkAttributes( $link, $text, 'extiw' );
-
+
+ # Check to see if nofollow should be applied
+ global $wgNoFollowAllInterwikiLinks, $wgNoFollowNonLocalInterwikiLinks;
+ if( $wgNoFollowAllInterwikiLinks ) {
+ # apply nofollow to all interwiki links
+ $style .= ' rel="nofollow"';
+ } elseif ( $wgNoFollowNonLocalInterwikiLinks ) {
+ # apply nofollow only to non-local interwiki links
+ if( !$nt->isLocal() ) {
+ $style .= ' rel="nofollow"';
+ }
+ }
+
$inside = '';
if ( '' != $trail ) {
$m = array();

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3077
Default Alt Text
nofollow_on_interwikis_nonlocal_discrimination.patch (1 KB)

Event Timeline