Daniel Friesen has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/188980

Change subject: Update to incorporate new Twitter embed code
......................................................................

Update to incorporate new Twitter embed code

Change-Id: I17adb65265bd1c0918fef57b5b8dddc6b78a774b
---
M README.md
M WikiTwidget.body.php
M WikiTwidget.php
M ext.wikitwidget.js
4 files changed, 41 insertions(+), 23 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikiTwidget 
refs/changes/80/188980/1

diff --git a/README.md b/README.md
index d91e17e..68d4707 100644
--- a/README.md
+++ b/README.md
@@ -64,14 +64,17 @@
 Wiki Compatibility
 ------------------
 
-WikiTwidget uses ResourceLoader, which was introduced in MW 1.17. I only have 
access to a wiki running 1.19.2 and 1.21.1, so I cannot guarantee that 
WikiTwidget will work on earlier versions of MediaWiki. A quick solution for 
earlier MediaWikis is to add the javascript to MediaWiki:Common.js on your wiki:
+WikiTwidget uses ResourceLoader, which was introduced in MW 1.17. WikiTwidget 
has been tested and runs successfully on wikis running 1.19.2, 1.21, 1.22, and 
1.23.
 
-       !function(d,s,id){var 
js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
 
 
 Change Log
 ----------
 
+v0.3.1, Jan 2015:
+
+* Updated WikiTwidget javascript to use the latest code from Twitter. 
Incorporates code changes from MediaWiki Gerrit. Tested on MW 1.25alpha using 
[mediawiki-vagrant](http://www.mediawiki.org/wiki/MediaWiki-Vagrant).
+
 v0.3.0:
 
 * Updated WikiTwidget to use the latest code and settings from Twitter
diff --git a/WikiTwidget.body.php b/WikiTwidget.body.php
index 136c7d4..181c60a 100644
--- a/WikiTwidget.body.php
+++ b/WikiTwidget.body.php
@@ -2,12 +2,13 @@
 
 class WikiTwidget {
 
-       function createWidget($input, array $args, Parser $parser, PPFrame 
$frame ) {   global $wgOut;
+       function createWidget($input, array $args, Parser $parser, PPFrame 
$frame ) {
+               global $wgOut;
 
 #              Widget URL format
 #              <a class="twitter-timeline" 
href="https://twitter.com/twitterapi"; data-widget-id="YOUR-WIDGET-ID-HERE" 
data-theme="dark" data-link-color="#cc0000"  data-related="twitterapi,twitter" 
data-aria-polite="assertive" width="300" height="500" lang="EN">Tweets by 
@twitterapi</a>
 
-               if (isset($args['data-widget-id']) && $args['data-widget-id']){
+               if (isset($args['data-widget-id']) && $args['data-widget-id']) {
                        $id = $args['data-widget-id'];
                }
                else {
@@ -32,24 +33,24 @@
 ## <a class="twitter-timeline" href="https://twitter.com/search?q=STRING"; 
data-widget-id="268946405488476160">Tweets about "STRING"</a>
 
                ## make sure we have a link
-               if (isset($args['href']) && $args['href']){
+               if (isset($args['href']) && $args['href']) {
                        ## make up a string for the link
 
                        ## get rid of the 'twitter' part of the URL
-                       if (preg_match( '@https://twitter.com/search\?q=(.+)@', 
$args['href'], $matches ))
-                       {       ## search is for $matches[1]
+                       if (preg_match( '@https://twitter.com/search\?q=(.+)@', 
$args['href'], $matches )) {
+                               ## search is for $matches[1]
                                $input = 'Tweets about ' . 
htmlspecialchars($matches[1]);
                        }
-                       else if (preg_match( 
'@https://twitter.com/(.+?)/favorites@', $args['href'], $matches ))
-                       {       ## favourite tweets of $matches[1]
+                       else if (preg_match( 
'@https://twitter.com/(.+?)/favorites@', $args['href'], $matches )) {
+                               ## favourite tweets of $matches[1]
                                $input = 'Favourite tweets by ' . 
htmlspecialchars($matches[1]);
                        }
-                       else if (preg_match( '@https://twitter.com/(.+)@', 
$args['href'], $matches ))
-                       {       ## favourite tweets of $matches[1]
+                       else if (preg_match( '@https://twitter.com/(.+)@', 
$args['href'], $matches )) {
+                               ## favourite tweets of $matches[1]
                                $input = 'Tweets by ' . 
htmlspecialchars($matches[1]);
                        }
-                       else
-                       {       ## wtf is going on with this href?!
+                       else {
+                               ## wtf is going on with this href?!
                                $input = 'Twitter timeline';
                                $args['href'] = 'https://twitter.com/';
                        }
@@ -79,9 +80,9 @@
 # `data-aria-polite` (settings for users with assistive technology): polite or 
assertive
                $vars = array('data-theme', 'data-link-color', 
'data-border-color', 'data-chrome', 'data-tweet-limit', 'data-related', 
'data-aria-polite', 'width', 'height', 'lang');
 
-               foreach ($vars as $v)
-               {       if (isset($args[$v]) && $args[$v])
-                       {       ## add to our html tag
+               foreach ($vars as $v) {
+                       if (isset($args[$v]) && $args[$v]) {
+                               ## add to our html tag
                                $txt .= ' ' . $v . '="' . $args[$v] . '"';
                        }
                }
diff --git a/WikiTwidget.php b/WikiTwidget.php
index 80ee0f7..9b534a8 100644
--- a/WikiTwidget.php
+++ b/WikiTwidget.php
@@ -12,18 +12,18 @@
     'name'=>'WikiTwidget',
     'author'=>'Amelia Ireland',
     'descriptionmsg'=>'wikitwidget-desc',
-    'version'=>'0.3.0',
+    'version'=>'0.3.1',
     'url' => 'http://www.mediawiki.org/wiki/Extension:WikiTwidget',
 );
 
-$wgAutoloadClasses['WikiTwidget'] =  dirname( __FILE__ ) . 
"/WikiTwidget.body.php";
+$wgAutoloadClasses['WikiTwidget'] =  __DIR__ . "/WikiTwidget.body.php";
 $wgMessagesDirs['WikiTwidget'] = __DIR__ . '/i18n';
-$wgExtensionMessagesFiles['WikiTwidget'] = dirname( __FILE__ ) . 
'/WikiTwidget.i18n.php';
+$wgExtensionMessagesFiles['WikiTwidget'] = __DIR__ . '/WikiTwidget.i18n.php';
 
 $wgResourceModules['WikiTwidget'] = array(
-'scripts' => 'ext.wikitwidget.js',
-'localBasePath' => dirname( __FILE__ ),
-'remoteExtPath' => 'WikiTwidget'
+       'localBasePath' => __DIR__,
+       'remoteExtPath' => 'WikiTwidget',
+       'scripts' => 'ext.wikitwidget.js'
 );
 
 $wgHooks['ParserFirstCallInit'][] = 'wfWikiTwidgetSetup';
diff --git a/ext.wikitwidget.js b/ext.wikitwidget.js
index abf787d..cfbb4c2 100644
--- a/ext.wikitwidget.js
+++ b/ext.wikitwidget.js
@@ -1 +1,15 @@
-!function(d,s,id){var 
js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
+/*
+       Twitter embed code from https://dev.twitter.com/web/embedded-timelines
+       updated 12 Jan 2015
+*/
+( function ( mw, $ ) {
+       window.twttr = (function (d, s, id) {
+               var js, fjs = d.getElementsByTagName(s)[0], t = window.twttr || 
{};
+               if (d.getElementById(id)) return;
+               js = d.createElement(s); js.id = id;
+               js.src= "https://platform.twitter.com/widgets.js";;
+               fjs.parentNode.insertBefore(js, fjs);
+               t._e = []; t.ready = function (f) { t._e.push(f); };
+               return t;
+       }(document, "script", "twitter-wjs"));
+} )( mediaWiki, jQuery );

-- 
To view, visit https://gerrit.wikimedia.org/r/188980
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I17adb65265bd1c0918fef57b5b8dddc6b78a774b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikiTwidget
Gerrit-Branch: master
Gerrit-Owner: Daniel Friesen <dan...@nadir-seen-fire.com>
Gerrit-Reviewer: Girlwithglasses <amelia.irel...@gmod.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to