r75225 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75224‎ | r75225 | r75226 >
Date:05:31, 23 October 2010
Author:dale
Status:deferred
Tags:
Comment:
some minor fixes for miro subs editor to work better with existing subtitle files
Modified paths:
  • /branches/MwEmbedStandAlone/components/mw.Language.js (modified) (history)
  • /branches/MwEmbedStandAlone/components/mw.Parser.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/ApiProxy/mw.ApiProxy.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/MiroSubs/mw.MiroSubsConfig.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/TimedText/mw.TimedText.js (modified) (history)
  • /branches/MwEmbedStandAlone/mwEmbedFrame.php (modified) (history)
  • /branches/MwEmbedStandAlone/remotes/mediaWiki.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/mwEmbedFrame.php
@@ -6,10 +6,6 @@
77 *
88 * This enables sharing mwEmbed player without js includes ie:
99 *
10 - * <object data="mwEmbedFrame.php?apiTitleKey=MyFile.ogg" > </object>
11 - *
12 - * or
13 - *
1410 * <iframe src="mwEmbedFrame.php?src={SRC URL}&poster={POSTER URL}&width={WIDTH}etc"> </iframe>
1511 */
1612
@@ -26,31 +22,20 @@
2723 /**
2824 * Variables set by the Frame request:
2925 */
30 - // The default width of the embedFrame
31 - var $width = null;
 26+ var $playerAttributes = array(
 27+ 'apiTitleKey',
 28+ 'apiProvider',
 29+ 'durationHint',
 30+ 'poster',
 31+ 'kEntryId',
 32+ 'kWidgetId' ,
 33+ 'skin'
 34+ );
3235
33 - // The default height of the embedFrame
34 - var $height = null;
35 -
36 - // The apiTitleKey used for mediaWiki asset lookup
37 - var $apiTitleKey = null;
38 -
39 - // The entryId used for kaltura media asset lookup
40 - var $entryId = null;
41 -
42 - // The player skin ( can be mvpcf or kskin )
43 - var $skin = null;
44 -
45 - // The duration of the media asset.
46 - var $durationHint = null;
47 -
4836 // When used in direct source mode the source asset.
4937 // NOTE: can be an array of sources in cases of "many" sources set
5038 var $sources = array();
5139
52 - // Poster src url for video embed
53 - var $poster = null;
54 -
5540 function __construct(){
5641 //parse input:
5742 $this->parseRequest();
@@ -61,19 +46,15 @@
6247 }
6348
6449 // Parse the embedFrame request and sanitize input
65 - private function parseRequest(){
66 - // Check for apiTitleKey request
67 - if( isset($_GET['apiTitleKey'])){
68 - $this->apiTitleKey = htmlspecialchars( $_GET['apiTitleKey'] );
 50+ private function parseRequest(){
 51+ // Check for attributes
 52+ foreach( $this->playerAttributes as $attributeKey){
 53+ if( isset( $_GET[ $attributeKey ] ) ){
 54+ $this->$attributeKey = htmlspecialchars( $_GET[$attributeKey] );
 55+ }
6956 }
70 -
71 - if( isset($_GET['apiProvider'])){
72 - $this->apiProvider = htmlspecialchars( $_GET['apiProvider'] );
73 - }
74 -
75 - if( isset( $_GET['poster'] ) ){
76 - $this->poster = htmlspecialchars( $_GET['poster'] );
77 - }
 57+
 58+ // Process the special "src" attribute
7859 if( isset( $_GET['src'] ) ){
7960 if( is_array( $_GET['src'] ) ){
8061 foreach($_GET['src'] as $src ){
@@ -83,45 +64,15 @@
8465 $this->sources = array( htmlspecialchars( $_GET['src'] ) );
8566 }
8667 }
87 - if( isset($_GET['skin'])){
88 - $this->skin = htmlspecialchars( $_GET['skin'] );
89 - }
90 -
91 - if( isset($_GET['width'])){
92 - $this->width = (int)$_GET['width'];
93 - }
94 - if( isset( $_GET['height'] ) ){
95 - $this->height = (int)$_GET['height'];
96 - }
97 - if( isset( $_GET['durationHint'] ) ){
98 - $this->durationHint = $_GET['durationHint'];
99 - }
 68+
10069 }
10170 private function getVideoTag(){
102 - $o = '<video ';
103 - // Output attributes
104 - if( $this->apiTitleKey ){
105 - $o.= 'apiTitleKey="' . htmlspecialchars( $this->apiTitleKey ) . '" ';
 71+ // Add default video tag with 100% width / height
 72+ // ( parent embed is responsible for setting the iframe size )
 73+ $o = '<video style="width:100%;height:100%"';
 74+ foreach( $this->playerAttributes as $attributeKey){
 75+ $o.= ' ' . $attributeKey . '="' . htmlspecialchars( $this->$attributeKey ) . '"';
10676 }
107 - if( $this->apiProvider ){
108 - $o.= 'apiProvider="' . htmlspecialchars( $this->apiProvider ) . '" ';
109 - }
110 - if( $this->poster ){
111 - $o.= 'poster="' . htmlspecialchars( $this->poster ) . '" ';
112 - }
113 - if( $this->skin ){
114 - $o.= 'class="' . htmlspecialchars( $this->skin ) . '" ';
115 - }
116 - if( $this->width || $this->height){
117 - $o.= 'style="';
118 - if( $this->width ){
119 - $o.= 'width:' . htmlspecialchars( $this->width ) . 'px;';
120 - }
121 - if( $this->height ){
122 - $o.= 'height:' . htmlspecialchars( $this->height ) . 'px;';
123 - }
124 - $o.= '" ';
125 - }
12677 //Close the video attributes
12778 $o.='>';
12879 // Output each source
@@ -134,6 +85,24 @@
13586 return $o;
13687 }
13788 private function outputEmbedFrame( ){
 89+ // Setup the embed string based on attribute set:
 90+ $embedResourceList = 'window.jQuery,mwEmbed,mw.style.mwCommon,$j.fn.menu,mw.style.jquerymenu,mw.EmbedPlayer,mw.EmbedPlayerNative,mw.EmbedPlayerJava,mw.PlayerControlBuilder,$j.fn.hoverIntent,mw.style.EmbedPlayer,$j.cookie,$j.ui,mw.style.ui_redmond,$j.widget,$j.ui.mouse,mw.PlayerSkinKskin,mw.style.PlayerSkinKskin,mw.TimedText,mw.style.TimedText,$j.ui.slider';
 91+
 92+ if( $this->kEntryId ){
 93+ $embedResourceList.= ',' . implode(',', array(
 94+ 'KalturaClientBase',
 95+ 'KalturaClient',
 96+ 'KalturaAccessControlService',
 97+ 'KalturaAccessControlOrderBy',
 98+ 'KalturaAccessControl',
 99+ 'MD5',
 100+ 'mw.KWidgetSupport',
 101+ 'mw.KAnalytics',
 102+ 'mw.KDPMapping',
 103+ 'mw.MobilePlayerTimeline',
 104+ 'mw.KAds'
 105+ ) );
 106+ }
138107 ?>
139108 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
140109 <html xmlns="http://www.w3.org/1999/xhtml">
@@ -148,7 +117,7 @@
149118 margin-bottom: 0px;
150119 }
151120 </style>
152 - <script type="text/javascript" src="ResourceLoader.php?class=window.jQuery,mwEmbed,mw.style.mwCommon,$j.fn.menu,mw.style.jquerymenu,mw.EmbedPlayer,mw.EmbedPlayerNative,mw.EmbedPlayerJava,mw.PlayerControlBuilder,$j.fn.hoverIntent,mw.style.EmbedPlayer,$j.cookie,$j.ui,mw.style.ui_redmond,$j.widget,$j.ui.mouse,mw.PlayerSkinKskin,mw.style.PlayerSkinKskin,mw.TimedText,mw.style.TimedText,$j.ui.slider"></script>
 121+ <script type="text/javascript" src="ResourceLoader.php?class=<?php echo $embedResourceList?>"></script>
153122 <script type="text/javascript">
154123 //Set some iframe embed config:
155124
Index: branches/MwEmbedStandAlone/components/mw.Language.js
@@ -15,7 +15,6 @@
1616 * Setup the lang object
1717 */
1818 var messageCache = { };
19 - var gRuleSet = { };
2019
2120 /**
2221 * mw.addMessages function
@@ -298,7 +297,7 @@
299298 mw.addTemplateTransform ( {
300299 'PLURAL' : mw.Language.procPLURAL,
301300 'GENDER' : mw.Language.procGENDER
302 - } )
 301+ } );
303302
304303 mw.Language.doneSetup = true;
305304 }
@@ -344,11 +343,7 @@
345344 * [arg] The argument sent to the template
346345 * [params] The template parameters
347346 */
348 - mw.Language.procPLURAL = function( templateObject ) {
349 - // Setup shortcuts
350 - // ( gRuleSet is loaded from script-loader to contains local ruleset )
351 - var rs = gRuleSet[ 'PLURAL' ];
352 -
 347+ mw.Language.procPLURAL = function( templateObject ) {
353348 if( templateObject.arg && templateObject.param && mw.Language.convertPlural) {
354349 // Check if we have forms to replace
355350 if ( templateObject.param.length == 0 ) {
Index: branches/MwEmbedStandAlone/components/mw.Parser.js
@@ -47,7 +47,7 @@
4848
4949 var defaultParserOptions = {
5050 'templateParCount' : 2
51 - }
 51+ };
5252
5353 this.options = $j.extend( defaultParserOptions, parserOptions);
5454 },
Index: branches/MwEmbedStandAlone/modules/MiroSubs/mw.MiroSubsConfig.js
@@ -242,7 +242,6 @@
243243 var _this = this;
244244 var playerTimedText = this.embedPlayer.timedText;
245245
246 - var letters = 'abcdefghijklmnopqrstuvwxyz';
247246 playerTimedText.setupTextSources( function(){
248247 var miroJsonSubs = [];
249248 // NOTE the autoselected default language is a tricky issue
@@ -254,17 +253,22 @@
255254 _this.config.languageKey = source.srclang;
256255 for( var i = 0; i < captions.length ; i ++ ){
257256 var caption = captions[i];
258 - // get random letters
259 - miroJsonSubs.push({
 257+ var miroSub = {
260258 'subtitle_id': 'sub_' + i,
261259 'text': caption.content,
262 - 'start_time': caption.start,
263 - 'end_time': caption.end,
264 - 'sub_order': i
265 - });
 260+ 'sub_order': i+1
 261+ };
 262+ if( caption.end == 0){
 263+ miroSub.start_time = -1;
 264+ miroSub.end_time = -1;
 265+ } else {
 266+ miroSub.start_time = caption.start;
 267+ miroSub.end_time = caption.end;
 268+ }
 269+ miroJsonSubs.push( miroSub );
266270 }
267 - });
 271+ });
268272 callback( miroJsonSubs );
269273 });
270274 }
271 -};
\ No newline at end of file
 275+};
Index: branches/MwEmbedStandAlone/modules/TimedText/mw.TimedText.js
@@ -849,7 +849,7 @@
850850 if( text === this.prevText[ source.category ] )
851851 return ;
852852
853 - //mw.log( 'updateTextDisplay: ' + text );
 853+ mw.log( 'mw.TimedText:: updateTextDisplay: ' + text );
854854
855855 var $playerTarget = this.embedPlayer.$interface;
856856 var $textTarget = $playerTarget.find( '.track_' + source.category + ' span' );
@@ -1042,6 +1042,7 @@
10431043 if( data ) {
10441044 _this.captions = handler( data );
10451045 }
 1046+ mw.log("mw.TimedText:: parsed " + _this.captions.length + ' captions');
10461047 // Update the loaded state:
10471048 _this.loaded = true;
10481049 if( callback ) {
@@ -1089,8 +1090,12 @@
10901091 var startIndex = 0;
10911092 }
10921093 // Start looking for the text via time, return first match:
1093 - for( var i = startIndex ; i < this.captions.length; i++ ) {
 1094+ for( var i = startIndex ; i < this.captions.length; i++ ) {
10941095 caption = this.captions[ i ];
 1096+ // Don't handle captions with 0 or -1 end time:
 1097+ if( caption.end == 0 || caption.end == -1)
 1098+ continue;
 1099+
10951100 if( time >= caption.start &&
10961101 time <= caption.end ) {
10971102 this.prevIndex = i;
@@ -1117,7 +1122,10 @@
11181123 //mw.log( 'pText: ' + currentPtext );
11191124
11201125 //Check if the p matches the "all in one line" match:
1121 - var m = currentPtext.replace('--&gt;', '-->').match(/\d+\s(\d+):(\d+):(\d+)(?:,(\d+))?\s*--?>\s*(\d+):(\d+):(\d+)(?:,(\d+))?\n?(.*)/);
 1126+ var m = currentPtext
 1127+ .replace('--&gt;', '-->')
 1128+ .match(/\d+\s([\d\-]+):([\d\-]+):([\d\-]+)(?:,([\d\-]+))?\s*--?>\s*([\d\-]+):([\d\-]+):([\d\-]+)(?:,([\d\-]+))?\n?(.*)/);
 1129+
11221130 if (m) {
11231131 var startMs = (m[4])? (parseInt(m[4], 10) / 1000):0;
11241132 var endMs = (m[8])? (parseInt(m[8], 10) / 1000) : 0;
@@ -1134,7 +1142,7 @@
11351143 endMs,
11361144 'content': $j.trim( m[9] )
11371145 });
1138 - return 'next';
 1146+ return true;
11391147 }
11401148 // Else check for multi-line match:
11411149 if( parseInt( currentPtext ) == currentPtext ) {
@@ -1144,7 +1152,7 @@
11451153 curentCap = {
11461154 'content': ''
11471155 };
1148 - return 'next';
 1156+ return true;
11491157 }
11501158 //Check only for time match:
11511159 var m = currentPtext.replace('--&gt;', '-->').match(/(\d+):(\d+):(\d+)(?:,(\d+))?\s*--?>\s*(\d+):(\d+):(\d+)(?:,(\d+))?/);
@@ -1161,7 +1169,7 @@
11621170 (parseInt(m[6], 10) * 60) +
11631171 (parseInt(m[7], 10)) +
11641172 endMs;
1165 - return 'next';
 1173+ return true;
11661174 }
11671175 //Else content for the curentCap
11681176 if( currentPtext != '<br>' ) {
Index: branches/MwEmbedStandAlone/modules/ApiProxy/mw.ApiProxy.js
@@ -343,7 +343,7 @@
344344 sendClientMsg( { 'state':'ok' } );
345345
346346 return serverHandleRequest();
347 - }
 347+ };
348348
349349 /**
350350 * Local scoped helper functions:
@@ -452,7 +452,7 @@
453453 'clientFrame' : getClientFrame( context ),
454454 'action' : 'apiRequest',
455455 'request' : context[ 'apiReq' ]
456 - }
 456+ };
457457
458458 mw.log( "Do frame proxy request on src: \n" + getServerFrame( context ) + "\n" + JSON.stringify( context[ 'apiReq' ] ) );
459459 appendIframe( {
Index: branches/MwEmbedStandAlone/remotes/mediaWiki.js
@@ -4,7 +4,7 @@
55 */
66 var urlparts = getRemoteEmbedPath();
77 var mwEmbedHostPath = urlparts[0];
8 -var mwRemoteVersion = 'r169';
 8+var mwRemoteVersion = 'r170';
99 var mwUseScriptLoader = true;
1010
1111 // Log the mwRemote version makes it easy to debug cache issues

Status & tagging log