r61059 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61058‎ | r61059 | r61060 >
Date:19:55, 14 January 2010
Author:dale
Status:reverted (Comments)
Tags:
Comment:
* updated api resource info grab ( added apiProvider and apiTitleKey )
* enables a local wiki to include "shared" repos and local files both working with respective api queries
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.BaseUploadInterface.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/loader.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/mw.EmbedPlayer.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/TimedText/mw.TimedText.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/TimedText/mw.TimedTextEdit.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/TimedText/remotes/RemoteMwTimedText.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/mwEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/remotes/mediaWiki.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/skins/kskin/kskinConfig.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/tests/Player_RelatedVideos.html (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/tests/Player_Themable.html (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/tests/Player_Timed_Text.html (modified) (history)
  • /trunk/extensions/OggHandler/OggHandler_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OggHandler/OggHandler_body.php
@@ -199,7 +199,7 @@
200200 //add temporal request parameter if $wgEnableTemporalOggUrls is on:
201201 if($wgEnableTemporalOggUrls && isset( $params['start'] ) ){
202202 $targetFileUrl .= '?t=' . seconds2npt( $this->parseTimeString( $params['start'], $length ) );
203 - if(isset( $params['end'] ) && $params['end'] )
 203+ if(isset( $params[ 'end' ] ) && $params['end'] )
204204 $targetFileUrl.='/'. seconds2npt( $this->parseTimeString( $params['end'], $length) );
205205 }
206206
@@ -596,7 +596,7 @@
597597
598598 function toHtml( $options = array() ) {
599599 global $wgEnableTemporalOggUrls, $wgVideoTagOut,
600 - $wgScriptPath, $wgEnableTimedText, $wgVideoPlayerSkin;
 600+ $wgScriptPath, $wgEnableTimedText;
601601
602602 wfLoadExtensionMessages( 'OggHandler' );
603603 if ( count( func_get_args() ) == 2 ) {
@@ -611,10 +611,12 @@
612612 } else {
613613 $url = $this->videoUrl;
614614 }
615 - $length = intval( $this->length );
616 - $offset = intval( $this->offset );
 615+ // Normalize values
 616+ $length = floatval( $this->length );
 617+ $offset = floatval( $this->offset );
617618 $width = intval( $this->width );
618619 $height = intval( $this->height );
 620+
619621 $alt = empty( $options['alt'] ) ? $this->file->getTitle()->getText() : $options['alt'];
620622 $scriptPath = OggHandler::getMyScriptPath();
621623 $thumbDivAttribs = array();
@@ -622,101 +624,7 @@
623625
624626 // Check if outputting to video tag or oggHandler
625627 if( $wgVideoTagOut ){
626 - //video tag output:
627 - if ( $this->isVideo ) {
628 - $playerHeight = $height;
629 - $thumb_url = $this->url;
630 - }else{
631 - // Sound file
632 - global $wgStylePath;
633 - $thumb_url = "$wgStylePath/common/images/icons/fileicon-ogg.png";
634 - if ( $height < 35 )
635 - $playerHeight = 35;
636 - else
637 - $playerHeight = $height;
638 - }
639 - $id = "ogg_player_" . OggTransformOutput::$serial;
640 - $linkAttribs = $this->getDescLinkAttribs( $alt );
641 - $videoAttr = array(
642 - 'id' => $id,
643 - 'src' => $url,
644 - 'wikiTitleKey' => $this->file->getTitle()->getDBKey(),
645 - 'style' => "width:{$width}px;height:{$playerHeight}px",
646 - 'poster'=>$thumb_url,
647 - 'controls'=> 'true',
648 - 'durationHint' => $length,
649 - 'startOffset' => $offset,
650 - 'linkback' => $linkAttribs['href']
651 - );
652 - // Init $timedTextSources string
653 - $timedTextSources = '';
654 -
655 - if( $this->file->getRepoName() == 'shared' ){
656 - $videoAttr['sharedWiki'] = true;
657 - }else if( $wgEnableTimedText ){
658 - // Get the list of subtitles available
659 - $params = new FauxRequest( array (
660 - 'action' => 'query',
661 - 'list' => 'allpages',
662 - 'apnamespace' => NS_TIMEDTEXT,
663 - 'aplimit' => 200,
664 - 'apprefix' => $this->file->getTitle()->getDBKey()
665 - ));
666 - $api = new ApiMain( $params );
667 - $api->execute();
668 - $data = & $api->getResultData();
669 -
670 - // Get the list of language Names
671 - $langNames = Language::getLanguageNames();
672 -
673 -
674 - if($data['query'] && $data['query']['allpages'] ){
675 - foreach( $data['query']['allpages'] as $na => $page ){
676 - $pageTitle = $page['title'];
677 - $tileParts = explode( '.', $pageTitle );
678 - if( count( $tileParts) >= 3 ){
679 - $subtitle_extension = array_pop( $tileParts );
680 - $languageKey = array_pop( $tileParts );
681 - }
682 - //If there is no valid language continue:
683 - if( !isset( $langNames[ $languageKey ] ) ){
684 - continue;
685 - }
686 - $textAttr = array(
687 - 'src' => "{$wgServer}{$wgScriptPath}/api.php?" .
688 - 'action=parse&format=json&page=' . $pageTitle,
689 - 'lang' => $languageKey,
690 - 'type' => 'text/mw-srt'
691 - );
692 - $timedTextSources.= Xml::tags( 'itext', $textAttr, '' );
693 - }
694 - }
695 - }
696 -
697 - if( $wgEnableTemporalOggUrls ){
698 - $videoAttr['URLTimeEncoding'] = 'true';
699 - }
700 -
701 - // Set player skin:
702 - if( $wgVideoPlayerSkin ){
703 - $videoAttr['class'] = htmlspecialchars ( $wgVideoPlayerSkin );
704 - }
705 -
706 - $s = Xml::tags( 'video', $videoAttr,
707 - Xml::tags('div', array(
708 - 'class'=>'videonojs',
709 - 'style'=>"overflow:hidden;".
710 - "width:{$width}px;height:{$playerHeight}px;".
711 - "border:solid thin black;padding:5px;"
712 - ),
713 - wfMsg('ogg-no-player-js', $url)
714 - ) .
715 - $timedTextSources
716 - );
717 -
718 - return $s;
719 -
720 -
 628+ return $this->outputVideoTag($url, $width, $height, $length, $offset, $alt);
721629 }else{
722630 //oggHandler output:
723631 if ( $this->isVideo ) {
@@ -821,6 +729,117 @@
822730 return $s;
823731 }
824732 }
 733+ /*
 734+ * Output the inline video tag output
 735+ */
 736+ function outputVideoTag($url, $width, $height, $length, $offset, $alt){
 737+ global $wgVideoPlayerSkin, $wgEnableTemporalOggUrls, $wgEnableTimedText;
 738+ // Video tag output:
 739+ if ( $this->isVideo ) {
 740+ $playerHeight = $this->height;
 741+ $thumb_url = $this->url;
 742+ }else{
 743+ // Sound file
 744+ global $wgStylePath;
 745+ $thumb_url = "$wgStylePath/common/images/icons/fileicon-ogg.png";
 746+ if ( $height < 35 )
 747+ $playerHeight = 35;
 748+ else
 749+ $playerHeight = $height;
 750+ }
 751+ $id = "ogg_player_" . OggTransformOutput::$serial;
 752+ $linkAttribs = $this->getDescLinkAttribs( $alt );
 753+ $videoAttr = array(
 754+ 'id' => $id,
 755+ 'src' => $url,
 756+ 'style' => "width:{$width}px;height:{$playerHeight}px",
 757+ 'poster' => $thumb_url,
 758+ 'controls'=> 'true',
 759+ 'durationHint' => $length,
 760+ 'startOffset' => $offset,
 761+ 'linkback' => $linkAttribs['href'],
 762+ 'apiTitleKey' => $this->file->getTitle()->getDBKey()
 763+ );
 764+
 765+ /*
 766+ * Output inline metadata for video tag
 767+ * this will eventually be phased out in favor of "ROE" type xml
 768+ * representation of all media asset info.
 769+ */
 770+
 771+ // Init $timedTextSources string
 772+ $timedTextSources = '';
 773+ if( $this->file->getRepoName() != 'local' ){
 774+
 775+ //Set the api provider name to "commons" for shared
 776+ // ( provider names should have identified the provider
 777+ // instead of the provider type "shared" )
 778+ $apiProviderName = ( $this->file->getRepoName() == 'shared' ) ? 'commons': $this->file->getRepoName();
 779+
 780+ $videoAttr[ 'apiProvider' ] = 'commons';
 781+ } else if( $wgEnableTimedText ){
 782+ // Get the list of subtitles available
 783+ $params = new FauxRequest( array (
 784+ 'action' => 'query',
 785+ 'list' => 'allpages',
 786+ 'apnamespace' => NS_TIMEDTEXT,
 787+ 'aplimit' => 200,
 788+ 'apprefix' => $this->file->getTitle()->getDBKey()
 789+ ));
 790+ $api = new ApiMain( $params );
 791+ $api->execute();
 792+ $data = & $api->getResultData();
 793+
 794+ // Get the list of language Names
 795+ $langNames = Language::getLanguageNames();
 796+
 797+
 798+ if($data['query'] && $data['query']['allpages'] ){
 799+ foreach( $data['query']['allpages'] as $na => $page ){
 800+ $pageTitle = $page['title'];
 801+ $tileParts = explode( '.', $pageTitle );
 802+ if( count( $tileParts) >= 3 ){
 803+ $subtitle_extension = array_pop( $tileParts );
 804+ $languageKey = array_pop( $tileParts );
 805+ }
 806+ //If there is no valid language continue:
 807+ if( !isset( $langNames[ $languageKey ] ) ){
 808+ continue;
 809+ }
 810+ $textAttr = array(
 811+ 'src' => "{$wgServer}{$wgScriptPath}/api.php?" .
 812+ 'action=parse&format=json&page=' . $pageTitle,
 813+ 'lang' => $languageKey,
 814+ 'type' => 'text/mw-srt'
 815+ );
 816+ $timedTextSources.= Xml::tags( 'itext', $textAttr, '' );
 817+ }
 818+ }
 819+ }
 820+
 821+ if( $wgEnableTemporalOggUrls ){
 822+ $videoAttr['URLTimeEncoding'] = 'true';
 823+ }
 824+
 825+ // Set player skin:
 826+ if( $wgVideoPlayerSkin ){
 827+ $videoAttr['class'] = htmlspecialchars ( $wgVideoPlayerSkin );
 828+ }
 829+
 830+ $s = Xml::tags( 'video', $videoAttr,
 831+ Xml::tags('div', array(
 832+ 'class'=>'videonojs',
 833+ 'style'=>"overflow:hidden;".
 834+ "width:{$width}px;height:{$playerHeight}px;".
 835+ "border:solid thin black;padding:5px;"
 836+ ),
 837+ wfMsg('ogg-no-player-js', $url)
 838+ ) .
 839+ $timedTextSources
 840+ );
 841+
 842+ return $s;
 843+ }
825844 }
826845
827846 class OggVideoDisplay extends OggTransformOutput {
Index: branches/js2-work/phase3/js/mwEmbed/tests/Player_Themable.html
@@ -21,14 +21,14 @@
2222 <video
2323 src="http://upload.wikimedia.org/wikipedia/commons/2/29/Charles_Lindbergh_flight_to_Brussels.ogg"
2424 poster="http://upload.wikimedia.org/wikipedia/commons/thumb/2/29/Charles_Lindbergh_flight_to_Brussels.ogg/mid-Charles_Lindbergh_flight_to_Brussels.ogg.jpg"
25 - wikiTitleKey="Charles_Lindbergh_flight_to_Brussels.ogg"
 25+ apiTitleKey="Charles_Lindbergh_flight_to_Brussels.ogg"
2626 durationHint="15">
2727 </video>
2828
2929 <video
3030 style="width:208px;height:160px;float:left"
3131 src="http://upload.wikimedia.org/wikipedia/commons/2/29/Charles_Lindbergh_flight_to_Brussels.ogg"
32 - wikiTitleKey="Charles_Lindbergh_flight_to_Brussels.ogg"
 32+ apiTitleKey="Charles_Lindbergh_flight_to_Brussels.ogg"
3333 poster="http://upload.wikimedia.org/wikipedia/commons/thumb/2/29/Charles_Lindbergh_flight_to_Brussels.ogg/mid-Charles_Lindbergh_flight_to_Brussels.ogg.jpg" durationHint="15"></video>
3434 <b>Source Code used:</b><br>
3535 <textarea cols="50" rows="7"><video style="width:400px;height:288px" poster="http://upload.wikimedia.org/wikipedia/commons/thumb/2/29/Charles_Lindbergh_flight_to_Brussels.ogg/mid-Charles_Lindbergh_flight_to_Brussels.ogg.jpg"
@@ -39,13 +39,13 @@
4040 <video
4141 class="kskin"
4242 src="http://upload.wikimedia.org/wikipedia/commons/2/29/Charles_Lindbergh_flight_to_Brussels.ogg"
43 - wikiTitleKey="Charles_Lindbergh_flight_to_Brussels.ogg"
 43+ apiTitleKey="Charles_Lindbergh_flight_to_Brussels.ogg"
4444 poster="http://upload.wikimedia.org/wikipedia/commons/thumb/2/29/Charles_Lindbergh_flight_to_Brussels.ogg/mid-Charles_Lindbergh_flight_to_Brussels.ogg.jpg"
4545 durationHint="15">
4646 </video>
4747 <video
4848 class="kskin"
49 - wikiTitleKey="Charles_Lindbergh_flight_to_Brussels.ogg"
 49+ apiTitleKey="Charles_Lindbergh_flight_to_Brussels.ogg"
5050 style="width:208px;height:160px;float:left;" src="http://upload.wikimedia.org/wikipedia/commons/2/29/Charles_Lindbergh_flight_to_Brussels.ogg"
5151 poster="http://upload.wikimedia.org/wikipedia/commons/thumb/2/29/Charles_Lindbergh_flight_to_Brussels.ogg/mid-Charles_Lindbergh_flight_to_Brussels.ogg.jpg"
5252 durationHint="15">
Index: branches/js2-work/phase3/js/mwEmbed/tests/Player_Timed_Text.html
@@ -18,7 +18,7 @@
1919 durationHint="7:52"
2020 src="http://upload.wikimedia.org/wikipedia/commons/d/d6/Yochai_Benkler_-_On_Autonomy%2C_Control_and_Cultureal_Experience.ogg"
2121 poster="http://upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Yochai_Benkler_-_On_Autonomy%2C_Control_and_Cultureal_Experience.ogg/mid-Yochai_Benkler_-_On_Autonomy%2C_Control_and_Cultureal_Experience.ogg.jpg"
22 - wikiTitleKey="Yochai_Benkler_-_On_Autonomy,_Control_and_Cultureal_Experience.ogg"
 22+ apiTitleKey="Yochai_Benkler_-_On_Autonomy,_Control_and_Cultureal_Experience.ogg"
2323 class="kskin"></video>
2424 <td valign="top">
2525 Commons Video API based timedText discovery<br>
@@ -26,7 +26,7 @@
2727 &lt;video
2828 src="http://upload.wikimedia.org/wikipedia/commons/d/d6/Yochai_Benkler_-_On_Autonomy%2C_Control_and_Cultureal_Experience.ogg"
2929 poster="http://upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Yochai_Benkler_-_On_Autonomy%2C_Control_and_Cultureal_Experience.ogg/mid-Yochai_Benkler_-_On_Autonomy%2C_Control_and_Cultureal_Experience.ogg.jpg"
30 - wikiTitleKey="Yochai_Benkler_-_On_Autonomy,_Control_and_Cultureal_Experience.ogg"
 30+ apiTitleKey="Yochai_Benkler_-_On_Autonomy,_Control_and_Cultureal_Experience.ogg"
3131 class="kskin"
3232 &gt;&lt;/video&gt;
3333 </pre>
Index: branches/js2-work/phase3/js/mwEmbed/tests/Player_RelatedVideos.html
@@ -14,10 +14,10 @@
1515 <table border="1" cellpadding="6" width="600">
1616 <tr>
1717 <td valign="top">
18 - <video wikiTitleKey="B-36_bomber.ogg" durationHint="2" poster="http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/B-36_bomber.ogg/mid-B-36_bomber.ogg.jpg&size=400x300" src="http://upload.wikimedia.org/wikipedia/commons/0/0d/B-36_bomber.ogg"></video></td>
 18+ <video apiTitleKey="B-36_bomber.ogg" durationHint="2" poster="http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/B-36_bomber.ogg/mid-B-36_bomber.ogg.jpg&size=400x300" src="http://upload.wikimedia.org/wikipedia/commons/0/0d/B-36_bomber.ogg"></video></td>
1919 <td valign="top"><b>Sample Related Videos</b><br />
2020 <pre>The Example Code ::: </pre>
21 - &lt;video wikiTitleKey="File:B-36_bomber.ogg" durationHint="2"
 21+ &lt;video apiTitleKey="File:B-36_bomber.ogg" durationHint="2"
2222 poster="http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/B-36_bomber.ogg/mid-B-36_bomber.ogg.jpg&size=400x300"
2323 src="http://upload.wikimedia.org/wikipedia/commons/0/0d/B-36_bomber.ogg"&gt;&lt;/video&gt;
2424 </br>
Index: branches/js2-work/phase3/js/mwEmbed/skins/kskin/kskinConfig.js
@@ -158,7 +158,7 @@
159159 // Set local player target pointer:
160160 var $playerTarget = embedPlayer.$interface;
161161
162 - // check if k-menu already exists:
 162+ // Check if k-menu already exists:
163163 if ( $playerTarget.find( '.k-menu' ).length != 0 )
164164 return false;
165165
@@ -243,25 +243,30 @@
244244 );
245245 }
246246
247 - if( !embedPlayer.wikiTitleKey ){
 247+ if( !embedPlayer.apiTitleKey ){
248248 $target.find('.credits_box').text(
249249 'Error: no title key to grab credits with'
250250 );
251251 return ;
252252 }
253253
254 - // Do the api request to populate the credits via the wikiTitleKey ( tied to "commons" )
 254+ // Do the api request to populate the credits via the apiTitleKey
255255 var request = {
256 - // Normalize the File NS (ie sometimes its present in wikiTitleKey other times not
257 - 'titles' : 'File:' + embedPlayer.wikiTitleKey.replace(/File:|Image:/, '' ),
 256+ // Normalize the File NS (ie sometimes its present in apiTitleKey other times not
 257+ 'titles' : 'File:' + embedPlayer.apiTitleKey.replace(/File:|Image:/, '' ),
258258 'prop' : 'revisions',
259259 'rvprop' : 'content'
260260 };
261261 var req_categories = new Array();
262 - mw.getJSON( mw.commons_api_url, request, function( data ) {
 262+ var api_url = mw.getApiProviderURL( embedPlayer.apiProvider );
 263+ if( ! api_url ){
 264+ mw.log("Error: can't get credit screen without title key");
 265+ return ;
 266+ }
 267+ mw.getJSON( api_url , request, function( data ) {
263268 if( !data || !data.query || !data.query.pages ){
264269 $target.find('.credits_box').text(
265 - 'Error: title key: ' + embedPlayer.wikiTitleKey + ' not found'
 270+ 'Error: title key: ' + embedPlayer.apiTitleKey + ' not found'
266271 );
267272 return false;
268273 }
@@ -288,8 +293,8 @@
289294 var embedPlayer = this.embedPlayer;
290295
291296 // Get the title str
292 - var titleStr = embedPlayer.wikiTitleKey.replace(/_/g, ' ');
293 - var titleLink = 'http://commons.wikimedia.org/wiki/File:' + embedPlayer.wikiTitleKey;
 297+ var titleStr = embedPlayer.apiTitleKey.replace(/_/g, ' ');
 298+ var titleLink = 'http://commons.wikimedia.org/wiki/File:' + embedPlayer.apiTitleKey;
294299
295300 var imgWidth = ( this.getOverlayWidth() < 250 )? 45 : 90;
296301
Index: branches/js2-work/phase3/js/mwEmbed/modules/TimedText/mw.TimedText.js
@@ -136,7 +136,7 @@
137137 */
138138 timedTextProviders:{
139139 'commons':{
140 - 'api_url': mw.commons_api_url,
 140+ 'api_url': mw.getApiProviderURL( 'commons' ),
141141 'lib' : 'mediaWiki'
142142 }
143143 },
@@ -272,8 +272,8 @@
273273 this.textSources.push( source );
274274 }
275275
276 - //If there are no inline sources check timedTextProviders & wikiTitleKey
277 - if( !this.embedPlayer.wikiTitleKey || !this.timedTextProviders){
 276+ //If there are no inline sources check timedTextProviders & apiTitleKey
 277+ if( !this.embedPlayer.apiTitleKey || !this.timedTextProviders){
278278 //no other sources just issue the callback:
279279 callback();
280280 return ;
@@ -281,7 +281,7 @@
282282
283283 // Try to get sources from text provider:
284284 var provider = this.timedTextProviders[ this.textProviderId ];
285 - var assetKey = this.embedPlayer.wikiTitleKey;
 285+ var assetKey = this.embedPlayer.apiTitleKey;
286286 switch( provider.lib ){
287287 case 'mediaWiki':
288288 this.textProvider = new mw.MediaWikiTextProvider( {
@@ -1249,7 +1249,7 @@
12501250 if ( sourcePages.error && sourcePages.error.code == 'apunknown_apnamespace' ) {
12511251 var request = {
12521252 'list' : 'allpages',
1253 - 'apprefix' : _this.getCanonicalTimedTextNS() + ':' + _this.pe.wikiTitleKey
 1253+ 'apprefix' : _this.getCanonicalTimedTextNS() + ':' + _this.pe.apiTitleKey
12541254 };
12551255 mw.getJSON( apiUrl, request, function( sourcePages ) {
12561256 callback( sourcePages )
Index: branches/js2-work/phase3/js/mwEmbed/modules/TimedText/mw.TimedTextEdit.js
@@ -298,7 +298,7 @@
299299
300300 // Get timed text target title
301301 // NOTE: this should be cleaned up with accessors
302 - var targetTitleKey = this.parentTimedText.embedPlayer.wikiTitleKey;
 302+ var targetTitleKey = this.parentTimedText.embedPlayer.apiTitleKey;
303303
304304 // Add TimedText NS and language key and ".srt"
305305 targetTitleKey = 'TimedText:' + targetTitleKey + '.' + $j('#timed-text-langKey-input').val() + '.srt';
Index: branches/js2-work/phase3/js/mwEmbed/modules/TimedText/remotes/RemoteMwTimedText.js
@@ -61,7 +61,7 @@
6262 'class="kskin" ' + //We need to centrally store this config somewhere
6363 'poster="' + resource.poster + '" ' +
6464 'src="' + resource.src + '" ' +
65 - 'wikiTitleKey="' + resource.wikiTitleKey + '" >' +
 65+ 'apiTitleKey="' + resource.apiTitleKey + '" >' +
6666 '</video><br><br><br><br>'
6767 )
6868 );
@@ -178,7 +178,7 @@
179179 */
180180 getResource: function( page ){
181181 return {
182 - 'wikiTitleKey' : page.title.replace(/File:/ig, '' ),
 182+ 'apiTitleKey' : page.title.replace(/File:/ig, '' ),
183183 'link' : page.imageinfo[0].descriptionurl,
184184 'poster' : page.imageinfo[0].thumburl,
185185 'src' : page.imageinfo[0].url,
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.BaseUploadInterface.js
@@ -716,7 +716,7 @@
717717 if ( _this.warnings_sessionkey ) {
718718 //set to "loading"
719719 $j( '#upProgressDialog' ).html( mw.loading_spinner() );
720 - //setup loading:
 720+ //setup request:
721721 var request = {
722722 'action': 'upload',
723723 'sessionkey': _this.warnings_sessionkey,
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/loader.js
@@ -9,7 +9,7 @@
1010
1111 //If the Timed Text interface should be displayed:
1212 // 'always' Displays link and call to contribute always
13 -// 'auto' Looks for child timed text elements or "wikiTitleKey" & load interface
 13+// 'auto' Looks for child timed text elements or "apiTitleKey" & load interface
1414 // 'off' Does not display the timed text interface
1515 mw.setConfig( 'textInterface', 'auto' );
1616
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -142,9 +142,12 @@
143143 // End time of the clip
144144 "end" : null,
145145
146 - // A wikiTitleKey for looking up subtitles, credits and related videos
147 - "wikiTitleKey" : null,
 146+ // A apiTitleKey for looking up subtitles, credits and related videos
 147+ "apiTitleKey" : null,
148148
 149+ // The apiProvider where to lookup the title key
 150+ "apiProvider" : null,
 151+
149152 // ROE url ( for xml based metadata )
150153 // also see: http://wiki.xiph.org/ROE
151154 "roe" : null,
@@ -831,14 +834,13 @@
832835 this.thumbnail = $j( video_element ).attr( 'thumbnail' );
833836
834837 if ( $j( video_element ).attr( 'poster' ) )
835 - this.thumbnail = $j( video_element ).attr( 'poster' );
 838+ this.thumbnail = $j( video_element ).attr( 'poster' );
836839
837 - // Set by default thumb value if not found
838 - if( ! this.thumbnail )
839 - this.thumbnail = mw.getConfig( 'default_video_thumb' );
 840+ if ( $j( video_element ).attr( 'apiTitleKey' ) )
 841+ this.apiTitleKey = $j( video_element ).attr( 'apiTitleKey' );
840842
841 - if ( $j( video_element ).attr( 'wikiTitleKey' ) )
842 - this.wikiTitleKey = $j( video_element ).attr( 'wikiTitleKey' );
 843+ if ( $j( video_element ).attr( 'apiProvider' ) )
 844+ this.apiProvider = $j( video_element ).attr( 'apiTitleKey' );
843845
844846 if ( $j( video_element ).attr( 'durationHint' ) ) {
845847 this.durationHint = $j( video_element ).attr( 'durationHint' );
@@ -846,6 +848,10 @@
847849 this.duration = mw.npt2seconds( this.durationHint );
848850 }
849851
 852+ // Set by default thumb value if not found
 853+ if( ! this.thumbnail )
 854+ this.thumbnail = mw.getConfig( 'default_video_thumb' );
 855+
850856 // Process the video_element as a source element:
851857 if ( $j( video_element ).attr( "src" ) ){
852858 this.tryAddSource( video_element );
@@ -1378,7 +1384,7 @@
13791385 */
13801386 isTimedTextSupported: function(){
13811387 // Check for timed text sources or api/ roe url
1382 - if ( ( this.roe || this.wikiTitleKey ||
 1388+ if ( ( this.roe || this.apiTitleKey ||
13831389 this.mediaElement.textSourceExists() ) ){
13841390 return true;
13851391 } else {
@@ -1608,18 +1614,17 @@
16091615 // mw.log('shopuld embed:' + embed_code);
16101616 $j( '#' + _this.id ).html( _this.getEmbedHTML() );
16111617 },
1612 -
16131618 /**
16141619 * Searches for related clips from titleKey
16151620 */
16161621 getRelatedFromTitleKey: function() {
16171622 var _this = this;
16181623 var request = {
1619 - //normalize the File NS (ie sometimes its present in wikiTitleKey other times not
1620 - 'titles' : 'File:' + this.wikiTitleKey.replace(/File:|Image:/,''),
 1624+ //normalize the File NS (ie sometimes its present in apiTitleKey other times not
 1625+ 'titles' : 'File:' + this.apiTitleKey.replace(/File:|Image:/,''),
16211626 'generator' : 'categories'
16221627 };
1623 - mw.getJSON( mw.commons_api_url, request, function( data ) {
 1628+ mw.getJSON( mw.getApiProviderURL( 'commons' ), request, function( data ) {
16241629 var req_categories = [];
16251630 if ( data.query && data.query.pages ) {
16261631 for ( var pageid in data.query.pages ) {
@@ -1722,7 +1727,7 @@
17231728 'height:' + parseInt( this.height ) + 'px;">' +
17241729 '</div>' );
17251730
1726 - if ( this.wikiTitleKey ) {
 1731+ if ( this.apiTitleKey ) {
17271732 $j( '#dc_' + this.id ).append(
17281733 '<div class="related_vids" >' +
17291734 '<h1>' + gM( 'mwe-related_videos' ) + '</h1>' +
@@ -2119,7 +2124,7 @@
21202125
21212126 /**
21222127 * Updates the displayed thumbnail via percent of the stream
2123 - * @param {Float} percet Percent of duration to update thumb
 2128+ * @param {Float} percent Percent of duration to update thumb
21242129 */
21252130 updateThumbPerc:function( percent ) {
21262131 return this.updateThumbTime( ( this.getDuration() * percent ) );
@@ -2231,9 +2236,12 @@
22322237 // Add in the wikiTitle key if provided
22332238 // (in the future we should just include the titleKey on remote embeds
22342239 // and query a roe like xml/json representaiton thing from mediawiki)
2235 - if ( this.wikiTitleKey ) {
2236 - embed_code_html += 'wikiTitleKey=&quot;' + escape( this.wikiTitleKey ) + '&quot;';
 2240+ if ( this.apiTitleKey ) {
 2241+ embed_code_html += 'apiTitleKey=&quot;' + escape( this.apiTitleKey ) + '&quot;';
22372242 }
 2243+ if ( this.apiProvider ) {
 2244+ embed_code_html += 'apiProvider=&quot;' + escape( this.apiProvider ) + '&quot;';
 2245+ }
22382246
22392247 // close the video tag
22402248 embed_code_html += '&gt;&lt;/video&gt;';
@@ -2243,6 +2251,7 @@
22442252
22452253 /**
22462254 * Display the options div
 2255+ * @@TODO should move to skins "showShare" , "showTextInterface" etc.
22472256 */
22482257 doOptionsHTML:function() {
22492258 var pos = this.$interface.find( '.options-btn' ).offset();
@@ -2288,8 +2297,9 @@
22892298 o += '<h2>' + gM( 'mwe-share_this_video' ) + '</h2>' +
22902299 '<ul>' +
22912300 '<li><a href="#" class="active">' + gM( 'mwe-embed_site_or_blog' ) + '</a></li>';
2292 - if ( this.linkback )
 2301+ if ( this.linkback ){
22932302 o += '<li><a href="#" id="k-share-link">' + this.linkback + '</a></li>';
 2303+ }
22942304 o +='</ul>' +
22952305 '<div class="source_wrap">'+
22962306 '<textarea>' + embed_code + '</textarea>'+
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js
@@ -101,7 +101,10 @@
102102 'import', 'userrights' ],
103103
104104 //If we are in debug mode ( results in fresh debugg javascript includes )
105 - 'debug' : false
 105+ 'debug' : false,
 106+
 107+ // Set the default providers ( you can add more provider via {provider_id}_apiurl = $api_url
 108+ 'commons_apiurl' : 'http://commons.wikimedia.org/w/api.php'
106109 };
107110
108111 /**
@@ -118,11 +121,6 @@
119122 // The version of mwEmbed
120123 mw.version = '1.1';
121124
122 - // Special case of commons api url
123 - // ( used for default subtitles and related video server for "wikiTitleKey" where no api is provided)
124 - // NOTE: we need to fix that with a standard "roe" jsonp url source ( instead of a non-standard custom attribute )
125 - mw.commons_api_url = 'http://commons.wikimedia.org/w/api.php';
126 -
127125 /**
128126 * Some global containers flags
129127 */
@@ -1795,6 +1793,20 @@
17961794 );
17971795 }
17981796
 1797+ /**
 1798+ * Get the api url for a given content provider key
 1799+ * @return {Mixed}
 1800+ * url for the provider
 1801+ * local wiki api if no apiProvider is set
 1802+ * false if no local wiki api found
 1803+ */
 1804+ mw.getApiProviderURL = function( provider_id ){
 1805+ if( mw.getConfig( provider_id + '_apiurl') ){
 1806+ return mw.getConfig( provider_id + '_apiurl');
 1807+ }
 1808+ return mw.getLocalApiUrl();
 1809+ },
 1810+
17991811 /**
18001812 * Get Api URL from mediaWiki page defined variables
18011813 * @return {Mixed}
Index: branches/js2-work/phase3/js/mwEmbed/remotes/mediaWiki.js
@@ -210,8 +210,8 @@
211211 var re = new RegExp( /videoUrl(&quot;:?\s*)*([^&]*)/ );
212212 src = re.exec( rewriteHTML )[2];
213213
214 - var wikiTitleKey = src.split( '/' );
215 - wikiTitleKey = unescape( wikiTitleKey[ wikiTitleKey.length - 1 ] );
 214+ var apiTitleKey = src.split( '/' );
 215+ apiTitleKey = unescape( apiTitleKey[ apiTitleKey.length - 1 ] );
216216
217217 var re = new RegExp( /length(&quot;:?\s*)*([^,]*)/ );
218218 var dv = re.exec( rewriteHTML )[2];
@@ -227,7 +227,7 @@
228228 var html_out = '';
229229
230230 var common_attr = ' id="mwe_' + vidId + '" ' +
231 - 'wikiTitleKey="' + wikiTitleKey + '" ' +
 231+ 'apiTitleKey="' + apiTitleKey + '" ' +
232232 'src="' + src + '" ' +
233233 duration_attr +
234234 offset_attr + ' ' +

Comments

#Comment by Tim Starling (talk | contribs)   04:53, 26 January 2010

Marking fixme for the usual reasons.

#Comment by Mdale (talk | contribs)   23:05, 5 February 2010

Some clarity added in subsequent commits. Anything specific?

#Comment by Mdale (talk | contribs)   03:39, 12 February 2010

marked reverted since the relevant part of oggHandler was reverted in r62223

Status & tagging log