Last modified: 2006-05-22 21:17:57 UTC
The attached patch adds a new config option, $wgNoFollowNsExceptions, which allows disabling rel="nofollow" attributes from external links in some namespaces while leaving them enabled in others. This allows, for example, enabling rel="nofollow" only in talk pages, or everywhere outside the main namespace.
Created attachment 1509 [details] Patch against SVN HEAD to add the $wgNoFollowNsExceptions config option. Added default param
Tested the patch: It works, but needs an extra "= null" after the first occurrence of "$ns" to avoid a spurious warning. I won't upload a new patch for this -- if someone knows how to edit the patch, feel free to do so.
Comment on attachment 1509 [details] Patch against SVN HEAD to add the $wgNoFollowNsExceptions config option. Added default param >Index: mediawiki-svn/phase3/includes/Linker.php >=================================================================== >--- mediawiki-svn/phase3/includes/Linker.php (revision 13561) >+++ mediawiki-svn/phase3/includes/Linker.php (working copy) >@@ -732,10 +732,10 @@ > } > > /** @todo document */ >- function makeExternalLink( $url, $text, $escape = true, $linktype = '' ) { >+ function makeExternalLink( $url, $text, $escape = true, $linktype = '', $ns = NULL) { > $style = $this->getExternalLinkAttributes( $url, $text, 'external ' . $linktype ); >- global $wgNoFollowLinks; >- if( $wgNoFollowLinks ) { >+ global $wgNoFollowLinks, $wgNoFollowNsExceptions; >+ if( $wgNoFollowLinks && !(isset($ns) && in_array($ns, $wgNoFollowNsExceptions)) ) { > $style .= ' rel="nofollow"'; > } > $url = htmlspecialchars( $url ); >Index: mediawiki-svn/phase3/includes/Parser.php >=================================================================== >--- mediawiki-svn/phase3/includes/Parser.php (revision 13561) >+++ mediawiki-svn/phase3/includes/Parser.php (working copy) >@@ -1190,7 +1190,7 @@ > # This means that users can paste URLs directly into the text > # Funny characters like ö aren't valid in URLs anyway > # This was changed in August 2004 >- $s .= $sk->makeExternalLink( $url, $text, false, $linktype ) . $dtrail . $trail; >+ $s .= $sk->makeExternalLink( $url, $text, false, $linktype, $this->mTitle->getNamespace() ) . $dtrail . $trail; > > # Register link in the output object. > # Replace unnecessary URL escape codes with the referenced character >@@ -1270,7 +1270,7 @@ > $text = $this->maybeMakeExternalImage( $url ); > if ( $text === false ) { > # Not an image, make a link >- $text = $sk->makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free' ); >+ $text = $sk->makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free', $this->mTitle->getNamespace() ); > # Register it in the output object... > # Replace unnecessary URL escape codes with their equivalent characters > $pasteurized = Parser::replaceUnusualEscapes( $url ); >Index: mediawiki-svn/phase3/includes/DefaultSettings.php >=================================================================== >--- mediawiki-svn/phase3/includes/DefaultSettings.php (revision 13561) >+++ mediawiki-svn/phase3/includes/DefaultSettings.php (working copy) >@@ -1719,6 +1719,12 @@ > $wgNoFollowLinks = true; > > /** >+ * Namespaces in which $wgNoFollowLinks doesn't apply. >+ * See Language.php for a list of namespaces. >+ */ >+$wgNoFollowNsExceptions = array(); >+ >+/** > * Specifies the minimal length of a user password. If set to > * 0, empty passwords are allowed. > */
Well, that's not really what i intended but i think that was the corrected patch?
We have the attachments feature to provide patches.
I know, Rob. I used its edit link, and thought it would save as an attachment too. But something went wrong :s
Come on, the right way to do it is to upload as a new attachment, and mark it as obsoleting the previous one. The "obsoletes" feature is there for exactly that reason.
This was a mistake, sorry. These are the cases when you want an 'edit' button to clean the mess. :(
Created attachment 1789 [details] Fixed patch, see comments
Applied on trunk in r14346.