diff --git a/CanonURL.i18n.php b/CanonURL.i18n.php index b832187..ae31326 100644 --- a/CanonURL.i18n.php +++ b/CanonURL.i18n.php @@ -1,19 +1,19 @@ - 'CanonURL', - 'canonurl-desc' => "Adds the canonical links to the head of Mediawiki pages according to [http://support.google.com/webmasters/bin/answer.py?hl=en&answer=139394 Google Canonicalization Content Guidelines]", -); + 'CanonURL', + 'canonurl-desc' => "Adds the canonical links to the head of Mediawiki pages according to [http://support.google.com/webmasters/bin/answer.py?hl=en&answer=139394 Google Canonicalization Content Guidelines]", +); diff --git a/CanonURL.php b/CanonURL.php index ec495f9..d12d855 100644 --- a/CanonURL.php +++ b/CanonURL.php @@ -1,48 +1,42 @@ - __FILE__, - 'name' => 'CanonURL', - 'version' => CanonURL_VERSION, - 'author' => array( '[http://www.mediawiki.org/wiki/User:Abhi_M_Balakrishnan Abhi M Balakrishnan]' ), - 'url' => 'https://mediawiki.org/wiki/Extension:CanonURL', - 'descriptionmsg' => 'canonurl-desc', - ); - - $wgExtensionMessagesFiles['CanonURL'] = dirname( __FILE__ ) . '/CanonURL.i18n.php'; - - global $wgHooks; - $wgHooks['BeforePageDisplay'][] = 'CanonURL'; - - function CanonURL($out) - { - global $CanonBaseURL; - global $wgRequest; - $pg_title = urlencode($wgRequest->getVal( 'title' )); - $out->addHeadItem( 'canonical', - ''."\n" - - ); - return true; + __FILE__, + 'name' => 'CanonURL', + 'author' => array( '[https://www.mediawiki.org/wiki/User:Abhi_M_Balakrishnan Abhi M Balakrishnan]' ), + 'version' => CanonURL_VERSION, + 'url' => 'https://mediawiki.org/wiki/Extension:CanonURL', + 'descriptionmsg' => 'canonurl-desc', +); + +$wgExtensionMessagesFiles['CanonURL'] = dirname( __FILE__ ) . '/CanonURL.i18n.php'; + +$wgHooks['BeforePageDisplay'][] = 'efCanonURL'; + +/** + * @param OutputPage $out + * @param Skin $skin + */ +function efCanonURL( $out ) { + $out->setCanonicalUrl( $out->getTitle()->getCanonicalURL() ); + return true; } diff --git a/README b/README index 02f0b74..d241627 100644 --- a/README +++ b/README @@ -1,26 +1,25 @@ --------------------------------------------------------------------------- -README for the CanonURL extension 0.2 -Licenses: GNU General Public Licence (GPL) - GNU Free Documentation License (GFDL) --------------------------------------------------------------------------- +# CanonURL + Adds the canonical links to the head of Mediawiki pages according to Google Canonicalization Content Guidelines. - -Written by Abhi M Balakrishnan (http://about.me/abhim) -== Prerequisites == + + +Written by Abhi M Balakrishnan (http://about.me/abhim). + +## Prerequisites This version of CanonURL requires MediaWiki 1.19 or later. -== Installing == -* Copy the CanonURL directory into the extensions folder of your MediaWiki installation. -* Add following lines to your LocalSettings.php file towards the end: - $CanonBaseURL = "http://127.0.0.1/wiki/"; - require_once("$IP/extensions/CanonURL/CanonURL.php"); +## Installing +Copy the CanonURL directory into the extensions folder of your MediaWiki installation. -== Verifying the installation == -See [[Special:Version]] and confirm the presence of CanonURL under "Installed extensions", "other" category +## Verifying the installation +See [[Special:Version]] and confirm the presence of CanonURL under "Installed extensions", "other" category. -== Verifying the configuration == -* Clear the cache of your browser -* Reload any Mediawiki page -* Check the HTML source and confirm the presence of following line before : +## Verifying the configuration +- Clear the cache of your browser +- Reload any Mediawiki page +- Check the HTML source and confirm the presence of following line before : + +## License +This extension is licensed under GNU General Public Licence v3. diff --git a/README.md b/README.md deleted file mode 100644 index 2f5142c..0000000 --- a/README.md +++ /dev/null @@ -1,29 +0,0 @@ -CanonURL -======== -Adds the canonical links to the head of Mediawiki pages according to Google Canonicalization Content Guidelines --------------------------------------------------------------------------- -README for the CanonURL extension 0.1 -Licenses: GNU General Public Licence (GPL) - GNU Free Documentation License (GFDL) --------------------------------------------------------------------------- -Adds the canonical links to the head of Mediawiki pages according to Google Canonicalization Content Guidelines. - -Written by Abhi M Balakrishnan (http://about.me/abhim) - -== Prerequisites == -This version of CanonURL requires MediaWiki 1.19 or later. - -== Installing == -* Copy the CanonURL directory into the extensions folder of your MediaWiki installation. -* Add following lines to your LocalSettings.php file towards the end: - $CanonBaseURL = "http://127.0.0.1/wiki/"; - require_once("$IP/extensions/CanonURL/CanonURL.php"); - -== Verifying the installation == -See [[Special:Version]] and confirm the presence of CanonURL under "Installed extensions", "other" category - -== Verifying the configuration == -* Clear the cache of your browser -* Reload any Mediawiki page -* Check the HTML source and confirm the presence of following line before : - diff --git a/README.md b/README.md new file mode 120000 index 0000000..100b938 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +README \ No newline at end of file