Index: trunk/extensions/OggHandler/OggHandler_body.php |
— | — | @@ -199,7 +199,7 @@ |
200 | 200 | //add temporal request parameter if $wgEnableTemporalOggUrls is on: |
201 | 201 | if($wgEnableTemporalOggUrls && isset( $params['start'] ) ){ |
202 | 202 | $targetFileUrl .= '?t=' . seconds2npt( $this->parseTimeString( $params['start'], $length ) ); |
203 | | - if(isset( $params['end'] ) && $params['end'] ) |
| 203 | + if(isset( $params[ 'end' ] ) && $params['end'] ) |
204 | 204 | $targetFileUrl.='/'. seconds2npt( $this->parseTimeString( $params['end'], $length) ); |
205 | 205 | } |
206 | 206 | |
— | — | @@ -596,7 +596,7 @@ |
597 | 597 | |
598 | 598 | function toHtml( $options = array() ) { |
599 | 599 | global $wgEnableTemporalOggUrls, $wgVideoTagOut, |
600 | | - $wgScriptPath, $wgEnableTimedText, $wgVideoPlayerSkin; |
| 600 | + $wgScriptPath, $wgEnableTimedText; |
601 | 601 | |
602 | 602 | wfLoadExtensionMessages( 'OggHandler' ); |
603 | 603 | if ( count( func_get_args() ) == 2 ) { |
— | — | @@ -611,10 +611,12 @@ |
612 | 612 | } else { |
613 | 613 | $url = $this->videoUrl; |
614 | 614 | } |
615 | | - $length = intval( $this->length ); |
616 | | - $offset = intval( $this->offset ); |
| 615 | + // Normalize values |
| 616 | + $length = floatval( $this->length ); |
| 617 | + $offset = floatval( $this->offset ); |
617 | 618 | $width = intval( $this->width ); |
618 | 619 | $height = intval( $this->height ); |
| 620 | + |
619 | 621 | $alt = empty( $options['alt'] ) ? $this->file->getTitle()->getText() : $options['alt']; |
620 | 622 | $scriptPath = OggHandler::getMyScriptPath(); |
621 | 623 | $thumbDivAttribs = array(); |
— | — | @@ -622,101 +624,7 @@ |
623 | 625 | |
624 | 626 | // Check if outputting to video tag or oggHandler |
625 | 627 | 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); |
721 | 629 | }else{ |
722 | 630 | //oggHandler output: |
723 | 631 | if ( $this->isVideo ) { |
— | — | @@ -821,6 +729,117 @@ |
822 | 730 | return $s; |
823 | 731 | } |
824 | 732 | } |
| 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 | + } |
825 | 844 | } |
826 | 845 | |
827 | 846 | class OggVideoDisplay extends OggTransformOutput { |
Index: branches/js2-work/phase3/js/mwEmbed/tests/Player_Themable.html |
— | — | @@ -21,14 +21,14 @@ |
22 | 22 | <video |
23 | 23 | src="http://upload.wikimedia.org/wikipedia/commons/2/29/Charles_Lindbergh_flight_to_Brussels.ogg" |
24 | 24 | 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" |
26 | 26 | durationHint="15"> |
27 | 27 | </video> |
28 | 28 | |
29 | 29 | <video |
30 | 30 | style="width:208px;height:160px;float:left" |
31 | 31 | 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" |
33 | 33 | 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> |
34 | 34 | <b>Source Code used:</b><br> |
35 | 35 | <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 @@ |
40 | 40 | <video |
41 | 41 | class="kskin" |
42 | 42 | 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" |
44 | 44 | poster="http://upload.wikimedia.org/wikipedia/commons/thumb/2/29/Charles_Lindbergh_flight_to_Brussels.ogg/mid-Charles_Lindbergh_flight_to_Brussels.ogg.jpg" |
45 | 45 | durationHint="15"> |
46 | 46 | </video> |
47 | 47 | <video |
48 | 48 | class="kskin" |
49 | | - wikiTitleKey="Charles_Lindbergh_flight_to_Brussels.ogg" |
| 49 | + apiTitleKey="Charles_Lindbergh_flight_to_Brussels.ogg" |
50 | 50 | style="width:208px;height:160px;float:left;" src="http://upload.wikimedia.org/wikipedia/commons/2/29/Charles_Lindbergh_flight_to_Brussels.ogg" |
51 | 51 | poster="http://upload.wikimedia.org/wikipedia/commons/thumb/2/29/Charles_Lindbergh_flight_to_Brussels.ogg/mid-Charles_Lindbergh_flight_to_Brussels.ogg.jpg" |
52 | 52 | durationHint="15"> |
Index: branches/js2-work/phase3/js/mwEmbed/tests/Player_Timed_Text.html |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | durationHint="7:52" |
20 | 20 | src="http://upload.wikimedia.org/wikipedia/commons/d/d6/Yochai_Benkler_-_On_Autonomy%2C_Control_and_Cultureal_Experience.ogg" |
21 | 21 | 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" |
23 | 23 | class="kskin"></video> |
24 | 24 | <td valign="top"> |
25 | 25 | Commons Video API based timedText discovery<br> |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | <video |
28 | 28 | src="http://upload.wikimedia.org/wikipedia/commons/d/d6/Yochai_Benkler_-_On_Autonomy%2C_Control_and_Cultureal_Experience.ogg" |
29 | 29 | 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" |
31 | 31 | class="kskin" |
32 | 32 | ></video> |
33 | 33 | </pre> |
Index: branches/js2-work/phase3/js/mwEmbed/tests/Player_RelatedVideos.html |
— | — | @@ -14,10 +14,10 @@ |
15 | 15 | <table border="1" cellpadding="6" width="600"> |
16 | 16 | <tr> |
17 | 17 | <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> |
19 | 19 | <td valign="top"><b>Sample Related Videos</b><br /> |
20 | 20 | <pre>The Example Code ::: </pre> |
21 | | - <video wikiTitleKey="File:B-36_bomber.ogg" durationHint="2" |
| 21 | + <video apiTitleKey="File:B-36_bomber.ogg" durationHint="2" |
22 | 22 | poster="http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/B-36_bomber.ogg/mid-B-36_bomber.ogg.jpg&size=400x300" |
23 | 23 | src="http://upload.wikimedia.org/wikipedia/commons/0/0d/B-36_bomber.ogg"></video> |
24 | 24 | </br> |
Index: branches/js2-work/phase3/js/mwEmbed/skins/kskin/kskinConfig.js |
— | — | @@ -158,7 +158,7 @@ |
159 | 159 | // Set local player target pointer: |
160 | 160 | var $playerTarget = embedPlayer.$interface; |
161 | 161 | |
162 | | - // check if k-menu already exists: |
| 162 | + // Check if k-menu already exists: |
163 | 163 | if ( $playerTarget.find( '.k-menu' ).length != 0 ) |
164 | 164 | return false; |
165 | 165 | |
— | — | @@ -243,25 +243,30 @@ |
244 | 244 | ); |
245 | 245 | } |
246 | 246 | |
247 | | - if( !embedPlayer.wikiTitleKey ){ |
| 247 | + if( !embedPlayer.apiTitleKey ){ |
248 | 248 | $target.find('.credits_box').text( |
249 | 249 | 'Error: no title key to grab credits with' |
250 | 250 | ); |
251 | 251 | return ; |
252 | 252 | } |
253 | 253 | |
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 |
255 | 255 | 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:/, '' ), |
258 | 258 | 'prop' : 'revisions', |
259 | 259 | 'rvprop' : 'content' |
260 | 260 | }; |
261 | 261 | 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 ) { |
263 | 268 | if( !data || !data.query || !data.query.pages ){ |
264 | 269 | $target.find('.credits_box').text( |
265 | | - 'Error: title key: ' + embedPlayer.wikiTitleKey + ' not found' |
| 270 | + 'Error: title key: ' + embedPlayer.apiTitleKey + ' not found' |
266 | 271 | ); |
267 | 272 | return false; |
268 | 273 | } |
— | — | @@ -288,8 +293,8 @@ |
289 | 294 | var embedPlayer = this.embedPlayer; |
290 | 295 | |
291 | 296 | // 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; |
294 | 299 | |
295 | 300 | var imgWidth = ( this.getOverlayWidth() < 250 )? 45 : 90; |
296 | 301 | |
Index: branches/js2-work/phase3/js/mwEmbed/modules/TimedText/mw.TimedText.js |
— | — | @@ -136,7 +136,7 @@ |
137 | 137 | */ |
138 | 138 | timedTextProviders:{ |
139 | 139 | 'commons':{ |
140 | | - 'api_url': mw.commons_api_url, |
| 140 | + 'api_url': mw.getApiProviderURL( 'commons' ), |
141 | 141 | 'lib' : 'mediaWiki' |
142 | 142 | } |
143 | 143 | }, |
— | — | @@ -272,8 +272,8 @@ |
273 | 273 | this.textSources.push( source ); |
274 | 274 | } |
275 | 275 | |
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){ |
278 | 278 | //no other sources just issue the callback: |
279 | 279 | callback(); |
280 | 280 | return ; |
— | — | @@ -281,7 +281,7 @@ |
282 | 282 | |
283 | 283 | // Try to get sources from text provider: |
284 | 284 | var provider = this.timedTextProviders[ this.textProviderId ]; |
285 | | - var assetKey = this.embedPlayer.wikiTitleKey; |
| 285 | + var assetKey = this.embedPlayer.apiTitleKey; |
286 | 286 | switch( provider.lib ){ |
287 | 287 | case 'mediaWiki': |
288 | 288 | this.textProvider = new mw.MediaWikiTextProvider( { |
— | — | @@ -1249,7 +1249,7 @@ |
1250 | 1250 | if ( sourcePages.error && sourcePages.error.code == 'apunknown_apnamespace' ) { |
1251 | 1251 | var request = { |
1252 | 1252 | 'list' : 'allpages', |
1253 | | - 'apprefix' : _this.getCanonicalTimedTextNS() + ':' + _this.pe.wikiTitleKey |
| 1253 | + 'apprefix' : _this.getCanonicalTimedTextNS() + ':' + _this.pe.apiTitleKey |
1254 | 1254 | }; |
1255 | 1255 | mw.getJSON( apiUrl, request, function( sourcePages ) { |
1256 | 1256 | callback( sourcePages ) |
Index: branches/js2-work/phase3/js/mwEmbed/modules/TimedText/mw.TimedTextEdit.js |
— | — | @@ -298,7 +298,7 @@ |
299 | 299 | |
300 | 300 | // Get timed text target title |
301 | 301 | // NOTE: this should be cleaned up with accessors |
302 | | - var targetTitleKey = this.parentTimedText.embedPlayer.wikiTitleKey; |
| 302 | + var targetTitleKey = this.parentTimedText.embedPlayer.apiTitleKey; |
303 | 303 | |
304 | 304 | // Add TimedText NS and language key and ".srt" |
305 | 305 | 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 @@ |
62 | 62 | 'class="kskin" ' + //We need to centrally store this config somewhere |
63 | 63 | 'poster="' + resource.poster + '" ' + |
64 | 64 | 'src="' + resource.src + '" ' + |
65 | | - 'wikiTitleKey="' + resource.wikiTitleKey + '" >' + |
| 65 | + 'apiTitleKey="' + resource.apiTitleKey + '" >' + |
66 | 66 | '</video><br><br><br><br>' |
67 | 67 | ) |
68 | 68 | ); |
— | — | @@ -178,7 +178,7 @@ |
179 | 179 | */ |
180 | 180 | getResource: function( page ){ |
181 | 181 | return { |
182 | | - 'wikiTitleKey' : page.title.replace(/File:/ig, '' ), |
| 182 | + 'apiTitleKey' : page.title.replace(/File:/ig, '' ), |
183 | 183 | 'link' : page.imageinfo[0].descriptionurl, |
184 | 184 | 'poster' : page.imageinfo[0].thumburl, |
185 | 185 | 'src' : page.imageinfo[0].url, |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.BaseUploadInterface.js |
— | — | @@ -716,7 +716,7 @@ |
717 | 717 | if ( _this.warnings_sessionkey ) { |
718 | 718 | //set to "loading" |
719 | 719 | $j( '#upProgressDialog' ).html( mw.loading_spinner() ); |
720 | | - //setup loading: |
| 720 | + //setup request: |
721 | 721 | var request = { |
722 | 722 | 'action': 'upload', |
723 | 723 | 'sessionkey': _this.warnings_sessionkey, |
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/loader.js |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | |
11 | 11 | //If the Timed Text interface should be displayed: |
12 | 12 | // '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 |
14 | 14 | // 'off' Does not display the timed text interface |
15 | 15 | mw.setConfig( 'textInterface', 'auto' ); |
16 | 16 | |
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/mw.EmbedPlayer.js |
— | — | @@ -142,9 +142,12 @@ |
143 | 143 | // End time of the clip |
144 | 144 | "end" : null, |
145 | 145 | |
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, |
148 | 148 | |
| 149 | + // The apiProvider where to lookup the title key |
| 150 | + "apiProvider" : null, |
| 151 | + |
149 | 152 | // ROE url ( for xml based metadata ) |
150 | 153 | // also see: http://wiki.xiph.org/ROE |
151 | 154 | "roe" : null, |
— | — | @@ -831,14 +834,13 @@ |
832 | 835 | this.thumbnail = $j( video_element ).attr( 'thumbnail' ); |
833 | 836 | |
834 | 837 | if ( $j( video_element ).attr( 'poster' ) ) |
835 | | - this.thumbnail = $j( video_element ).attr( 'poster' ); |
| 838 | + this.thumbnail = $j( video_element ).attr( 'poster' ); |
836 | 839 | |
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' ); |
840 | 842 | |
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' ); |
843 | 845 | |
844 | 846 | if ( $j( video_element ).attr( 'durationHint' ) ) { |
845 | 847 | this.durationHint = $j( video_element ).attr( 'durationHint' ); |
— | — | @@ -846,6 +848,10 @@ |
847 | 849 | this.duration = mw.npt2seconds( this.durationHint ); |
848 | 850 | } |
849 | 851 | |
| 852 | + // Set by default thumb value if not found |
| 853 | + if( ! this.thumbnail ) |
| 854 | + this.thumbnail = mw.getConfig( 'default_video_thumb' ); |
| 855 | + |
850 | 856 | // Process the video_element as a source element: |
851 | 857 | if ( $j( video_element ).attr( "src" ) ){ |
852 | 858 | this.tryAddSource( video_element ); |
— | — | @@ -1378,7 +1384,7 @@ |
1379 | 1385 | */ |
1380 | 1386 | isTimedTextSupported: function(){ |
1381 | 1387 | // Check for timed text sources or api/ roe url |
1382 | | - if ( ( this.roe || this.wikiTitleKey || |
| 1388 | + if ( ( this.roe || this.apiTitleKey || |
1383 | 1389 | this.mediaElement.textSourceExists() ) ){ |
1384 | 1390 | return true; |
1385 | 1391 | } else { |
— | — | @@ -1608,18 +1614,17 @@ |
1609 | 1615 | // mw.log('shopuld embed:' + embed_code); |
1610 | 1616 | $j( '#' + _this.id ).html( _this.getEmbedHTML() ); |
1611 | 1617 | }, |
1612 | | - |
1613 | 1618 | /** |
1614 | 1619 | * Searches for related clips from titleKey |
1615 | 1620 | */ |
1616 | 1621 | getRelatedFromTitleKey: function() { |
1617 | 1622 | var _this = this; |
1618 | 1623 | 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:/,''), |
1621 | 1626 | 'generator' : 'categories' |
1622 | 1627 | }; |
1623 | | - mw.getJSON( mw.commons_api_url, request, function( data ) { |
| 1628 | + mw.getJSON( mw.getApiProviderURL( 'commons' ), request, function( data ) { |
1624 | 1629 | var req_categories = []; |
1625 | 1630 | if ( data.query && data.query.pages ) { |
1626 | 1631 | for ( var pageid in data.query.pages ) { |
— | — | @@ -1722,7 +1727,7 @@ |
1723 | 1728 | 'height:' + parseInt( this.height ) + 'px;">' + |
1724 | 1729 | '</div>' ); |
1725 | 1730 | |
1726 | | - if ( this.wikiTitleKey ) { |
| 1731 | + if ( this.apiTitleKey ) { |
1727 | 1732 | $j( '#dc_' + this.id ).append( |
1728 | 1733 | '<div class="related_vids" >' + |
1729 | 1734 | '<h1>' + gM( 'mwe-related_videos' ) + '</h1>' + |
— | — | @@ -2119,7 +2124,7 @@ |
2120 | 2125 | |
2121 | 2126 | /** |
2122 | 2127 | * 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 |
2124 | 2129 | */ |
2125 | 2130 | updateThumbPerc:function( percent ) { |
2126 | 2131 | return this.updateThumbTime( ( this.getDuration() * percent ) ); |
— | — | @@ -2231,9 +2236,12 @@ |
2232 | 2237 | // Add in the wikiTitle key if provided |
2233 | 2238 | // (in the future we should just include the titleKey on remote embeds |
2234 | 2239 | // and query a roe like xml/json representaiton thing from mediawiki) |
2235 | | - if ( this.wikiTitleKey ) { |
2236 | | - embed_code_html += 'wikiTitleKey="' + escape( this.wikiTitleKey ) + '"'; |
| 2240 | + if ( this.apiTitleKey ) { |
| 2241 | + embed_code_html += 'apiTitleKey="' + escape( this.apiTitleKey ) + '"'; |
2237 | 2242 | } |
| 2243 | + if ( this.apiProvider ) { |
| 2244 | + embed_code_html += 'apiProvider="' + escape( this.apiProvider ) + '"'; |
| 2245 | + } |
2238 | 2246 | |
2239 | 2247 | // close the video tag |
2240 | 2248 | embed_code_html += '></video>'; |
— | — | @@ -2243,6 +2251,7 @@ |
2244 | 2252 | |
2245 | 2253 | /** |
2246 | 2254 | * Display the options div |
| 2255 | + * @@TODO should move to skins "showShare" , "showTextInterface" etc. |
2247 | 2256 | */ |
2248 | 2257 | doOptionsHTML:function() { |
2249 | 2258 | var pos = this.$interface.find( '.options-btn' ).offset(); |
— | — | @@ -2288,8 +2297,9 @@ |
2289 | 2298 | o += '<h2>' + gM( 'mwe-share_this_video' ) + '</h2>' + |
2290 | 2299 | '<ul>' + |
2291 | 2300 | '<li><a href="#" class="active">' + gM( 'mwe-embed_site_or_blog' ) + '</a></li>'; |
2292 | | - if ( this.linkback ) |
| 2301 | + if ( this.linkback ){ |
2293 | 2302 | o += '<li><a href="#" id="k-share-link">' + this.linkback + '</a></li>'; |
| 2303 | + } |
2294 | 2304 | o +='</ul>' + |
2295 | 2305 | '<div class="source_wrap">'+ |
2296 | 2306 | '<textarea>' + embed_code + '</textarea>'+ |
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js |
— | — | @@ -101,7 +101,10 @@ |
102 | 102 | 'import', 'userrights' ], |
103 | 103 | |
104 | 104 | //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' |
106 | 109 | }; |
107 | 110 | |
108 | 111 | /** |
— | — | @@ -118,11 +121,6 @@ |
119 | 122 | // The version of mwEmbed |
120 | 123 | mw.version = '1.1'; |
121 | 124 | |
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 | | - |
127 | 125 | /** |
128 | 126 | * Some global containers flags |
129 | 127 | */ |
— | — | @@ -1795,6 +1793,20 @@ |
1796 | 1794 | ); |
1797 | 1795 | } |
1798 | 1796 | |
| 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 | + |
1799 | 1811 | /** |
1800 | 1812 | * Get Api URL from mediaWiki page defined variables |
1801 | 1813 | * @return {Mixed} |
Index: branches/js2-work/phase3/js/mwEmbed/remotes/mediaWiki.js |
— | — | @@ -210,8 +210,8 @@ |
211 | 211 | var re = new RegExp( /videoUrl(":?\s*)*([^&]*)/ ); |
212 | 212 | src = re.exec( rewriteHTML )[2]; |
213 | 213 | |
214 | | - var wikiTitleKey = src.split( '/' ); |
215 | | - wikiTitleKey = unescape( wikiTitleKey[ wikiTitleKey.length - 1 ] ); |
| 214 | + var apiTitleKey = src.split( '/' ); |
| 215 | + apiTitleKey = unescape( apiTitleKey[ apiTitleKey.length - 1 ] ); |
216 | 216 | |
217 | 217 | var re = new RegExp( /length(":?\s*)*([^,]*)/ ); |
218 | 218 | var dv = re.exec( rewriteHTML )[2]; |
— | — | @@ -227,7 +227,7 @@ |
228 | 228 | var html_out = ''; |
229 | 229 | |
230 | 230 | var common_attr = ' id="mwe_' + vidId + '" ' + |
231 | | - 'wikiTitleKey="' + wikiTitleKey + '" ' + |
| 231 | + 'apiTitleKey="' + apiTitleKey + '" ' + |
232 | 232 | 'src="' + src + '" ' + |
233 | 233 | duration_attr + |
234 | 234 | offset_attr + ' ' + |