r91710 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91709‎ | r91710 | r91711 >
Date:04:22, 8 July 2011
Author:sean_colombo
Status:deferred
Tags:
Comment:
OpenGraphMeta: attempted to optimize the title a little to be more like the general convention for titles. Now using non-prefixed text with a special case of using only the subpage name for wikis which have blogging extensions installed (gracefully degrades to normal behavior on wikis without blogging extensions).
Modified paths:
  • /trunk/extensions/OpenGraphMeta/OpenGraphMeta.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenGraphMeta/OpenGraphMeta.php
@@ -49,7 +49,7 @@
5050 $file = Title::newFromText( $mainimage, NS_FILE );
5151 $parserOutput->addOutputHook( 'setmainimage', array( 'dbkey' => $file->getDBkey() ) );
5252 $parserOutput->eHasMainImageAlready = true;
53 -
 53+
5454 return $mainimage;
5555 }
5656
@@ -64,15 +64,23 @@
6565 $wgXhtmlNamespaces["og"] = "http://opengraphprotocol.org/schema/";
6666 $title = $out->getTitle();
6767 $isMainpage = $title->equals(Title::newMainPage());
68 -
 68+
6969 $meta = array();
70 -
 70+
7171 $meta["og:type"] = $isMainpage ? "website" : "article";
7272 $meta["og:site_name"] = $wgSitename;
73 - $meta["og:title"] = $title->getPrefixedText();
 73+
 74+ // Try to chose the most appropriate title for showing in news feeds.
 75+ if ((defined('NS_BLOG_ARTICLE') && $title->getNamespace() == NS_BLOG_ARTICLE) ||
 76+ (defined('NS_BLOG_ARTICLE_TALK') && $title->getNamespace() == NS_BLOG_ARTICLE_TALK)){
 77+ $meta["og:title"] = $title->getSubpageText();
 78+ } else {
 79+ $meta["og:title"] = $title->getText();
 80+ }
 81+
7482 if ( isset($out->mMainImage) ) {
7583 $meta["og:image"] = wfExpandUrl($out->mMainImage->createThumb(100*3, 100));
76 - } elseif ( $isMainpage ) {
 84+ } else if ( $isMainpage ) {
7785 $meta["og:image"] = $wgLogo;
7886 }
7987 if ( isset($out->mDescription) ) // set by Description2 extension, install it if you want proper og:description support
@@ -82,13 +90,13 @@
8391 $meta["fb:app_id"] = $egFacebookAppId;
8492 if ( $egFacebookAdmins )
8593 $meta["fb:admins"] = $egFacebookAdmins;
86 -
 94+
8795 foreach( $meta as $property => $value ) {
8896 if ( $value ){
8997 $out->addMeta("property:$property", $value );
9098 }
9199 }
92 -
 100+
93101 return true;
94102 }
95103

Status & tagging log