Index: trunk/extensions/OpenGraphMeta/OpenGraphMeta.php |
— | — | @@ -49,7 +49,7 @@ |
50 | 50 | $file = Title::newFromText( $mainimage, NS_FILE ); |
51 | 51 | $parserOutput->addOutputHook( 'setmainimage', array( 'dbkey' => $file->getDBkey() ) ); |
52 | 52 | $parserOutput->eHasMainImageAlready = true; |
53 | | - |
| 53 | + |
54 | 54 | return $mainimage; |
55 | 55 | } |
56 | 56 | |
— | — | @@ -64,15 +64,23 @@ |
65 | 65 | $wgXhtmlNamespaces["og"] = "http://opengraphprotocol.org/schema/"; |
66 | 66 | $title = $out->getTitle(); |
67 | 67 | $isMainpage = $title->equals(Title::newMainPage()); |
68 | | - |
| 68 | + |
69 | 69 | $meta = array(); |
70 | | - |
| 70 | + |
71 | 71 | $meta["og:type"] = $isMainpage ? "website" : "article"; |
72 | 72 | $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 | + |
74 | 82 | if ( isset($out->mMainImage) ) { |
75 | 83 | $meta["og:image"] = wfExpandUrl($out->mMainImage->createThumb(100*3, 100)); |
76 | | - } elseif ( $isMainpage ) { |
| 84 | + } else if ( $isMainpage ) { |
77 | 85 | $meta["og:image"] = $wgLogo; |
78 | 86 | } |
79 | 87 | if ( isset($out->mDescription) ) // set by Description2 extension, install it if you want proper og:description support |
— | — | @@ -82,13 +90,13 @@ |
83 | 91 | $meta["fb:app_id"] = $egFacebookAppId; |
84 | 92 | if ( $egFacebookAdmins ) |
85 | 93 | $meta["fb:admins"] = $egFacebookAdmins; |
86 | | - |
| 94 | + |
87 | 95 | foreach( $meta as $property => $value ) { |
88 | 96 | if ( $value ){ |
89 | 97 | $out->addMeta("property:$property", $value ); |
90 | 98 | } |
91 | 99 | } |
92 | | - |
| 100 | + |
93 | 101 | return true; |
94 | 102 | } |
95 | 103 | |