Index: trunk/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/mwEmbedSupport.js |
— | — | @@ -157,13 +157,13 @@ |
158 | 158 | return 'mw_message_swap_index_' + key + '_' + index; |
159 | 159 | }; |
160 | 160 | |
161 | | - var doSpecialSwap = false; |
162 | | - |
163 | | - |
| 161 | + var doSpecialSwap = false; |
164 | 162 | |
| 163 | + var text = mediaWiki.messages.get( key ); |
| 164 | + if( !text){ |
| 165 | + return '<' + key + '>'; |
| 166 | + } |
165 | 167 | |
166 | | - var text = mediaWiki.messages.get( key ) |
167 | | - |
168 | 168 | // replace links: |
169 | 169 | text = text.replace( /\[(\S+)\s+([^\]]*)\]/g, function( matched, link, linkText ) { |
170 | 170 | var indexIdAttribute = ''; |
Index: trunk/extensions/TimedMediaHandler/TimedMediaTransformOutput.php |
— | — | @@ -251,7 +251,7 @@ |
252 | 252 | $data = $api->getResultData(); |
253 | 253 | // Get the list of language Names |
254 | 254 | $langNames = Language::getLanguageNames(); |
255 | | - |
| 255 | + |
256 | 256 | if( $data['query'] && $data['query']['allpages'] ){ |
257 | 257 | foreach( $data['query']['allpages'] as $na => $page ){ |
258 | 258 | $subTitle = Title::newFromText( $page['title'] ) ; |
— | — | @@ -269,6 +269,7 @@ |
270 | 270 | $this->textTracks[] = array( |
271 | 271 | 'kind' => 'subtitles', |
272 | 272 | 'data-mwtitle' => $subTitle->getNsText() . ':' . $subTitle->getDBkey(), |
| 273 | + 'data-mwprovider' => 'local', |
273 | 274 | 'type' => 'text/x-srt', |
274 | 275 | // TODO Should add a special entry point and output proper WebVTT format: |
275 | 276 | // http://www.whatwg.org/specs/web-apps/current-work/webvtt.html |
Index: trunk/extensions/TimedMediaHandler/MwEmbedModules/TimedText/resources/mw.TimedText.js |
— | — | @@ -18,7 +18,8 @@ |
19 | 19 | mw.mergeConfig( 'EmbedPlayer.SourceAttributes', [ |
20 | 20 | 'srclang', |
21 | 21 | 'category', |
22 | | - 'label' |
| 22 | + 'label', |
| 23 | + 'data-mwtitle' |
23 | 24 | ]); |
24 | 25 | |
25 | 26 | /** |
— | — | @@ -129,7 +130,7 @@ |
130 | 131 | // Load user preferences config: |
131 | 132 | var preferenceConfig = $.cookie( 'TimedText.Prefrences' ); |
132 | 133 | if( preferenceConfig !== null ) { |
133 | | - this.config = preferenceConfig; |
| 134 | + this.config = JSON.parse( preferenceConfig ); |
134 | 135 | } |
135 | 136 | // Set up embedPlayer hooks: |
136 | 137 | |
— | — | @@ -398,23 +399,7 @@ |
399 | 400 | loadTextSources: function( callback ) { |
400 | 401 | var _this = this; |
401 | 402 | this.textSources = [ ]; |
402 | | - // Get local reference to all timed text sources: ( text/xml, text/x-srt etc ) |
403 | | - var inlineSources = this.embedPlayer.mediaElement.getSources( 'text' ); |
404 | 403 | |
405 | | - // Add all the sources to textSources |
406 | | - for( var i = 0 ; i < inlineSources.length ; i++ ) { |
407 | | - // Make a new textSource: |
408 | | - var source = new TextSource( inlineSources[i] ); |
409 | | - this.textSources.push( source ); |
410 | | - } |
411 | | - |
412 | | - // If there are inline sources or no apiTitleKey we are done loading |
413 | | - if( this.textSources.length != 0 || !this.embedPlayer.apiTitleKey ) { |
414 | | - // No other sources just issue the callback: |
415 | | - callback(); |
416 | | - return ; |
417 | | - } |
418 | | - |
419 | 404 | // Try to get sources from text provider: |
420 | 405 | var provider_id = ( this.embedPlayer.apiProvider ) ? this.embedPlayer.apiProvider : 'local'; |
421 | 406 | var apiUrl = mw.getApiProviderURL( provider_id ); |
— | — | @@ -430,6 +415,21 @@ |
431 | 416 | 'apiUrl': apiUrl, |
432 | 417 | 'embedPlayer': this.embedPlayer |
433 | 418 | } ); |
| 419 | + // Get local reference to all timed text sources: ( text/xml, text/x-srt etc ) |
| 420 | + var inlineSources = this.embedPlayer.mediaElement.getSources( 'text' ); |
| 421 | + |
| 422 | + // Add all the sources to textSources |
| 423 | + for( var i = 0 ; i < inlineSources.length ; i++ ) { |
| 424 | + // Make a new textSource: |
| 425 | + var source = new TextSource( inlineSources[i] , this.textProvider); |
| 426 | + this.textSources.push( source); |
| 427 | + } |
| 428 | + |
| 429 | + // If there are inline sources don't check the api ) |
| 430 | + if( this.textSources.length != 0 ){ |
| 431 | + callback(); |
| 432 | + return ; |
| 433 | + } |
434 | 434 | |
435 | 435 | // Load the textProvider sources |
436 | 436 | this.textProvider.loadSources( apiTitleKey, function( textSources ) { |
— | — | @@ -933,7 +933,7 @@ |
934 | 934 | */ |
935 | 935 | refreshDisplay: function() { |
936 | 936 | // Update the configuration object |
937 | | - $.cookie( 'TimedText.Prefrences', this.config ); |
| 937 | + $.cookie( 'TimedText.Prefrences', JSON.stringify( this.config ) ); |
938 | 938 | |
939 | 939 | // Empty out previous text to force an interface update: |
940 | 940 | this.prevText = []; |
— | — | @@ -1071,7 +1071,6 @@ |
1072 | 1072 | mw.log(" addItextDiv: " + category ); |
1073 | 1073 | // Get the relative positioned player class from the controlBuilder: |
1074 | 1074 | var $playerTarget = this.embedPlayer.$interface; |
1075 | | - |
1076 | 1075 | //Remove any existing track divs for this player; |
1077 | 1076 | $playerTarget.find('.track_' + category ).remove(); |
1078 | 1077 | |
— | — | @@ -1165,11 +1164,14 @@ |
1166 | 1165 | /** |
1167 | 1166 | * @constructor Inherits mediaSource from embedPlayer |
1168 | 1167 | * @param {source} Base source element |
| 1168 | + * @param {Object} Pointer to the textProvider |
1169 | 1169 | */ |
1170 | | - init: function( source , textProvider) { |
1171 | | - for( var i in source) { |
1172 | | - this[i] = source[i]; |
| 1170 | + init: function( source , textProvider) { |
| 1171 | + // Inherits mediaSource |
| 1172 | + for( var i in source){ |
| 1173 | + this[ i ] = source[ i]; |
1173 | 1174 | } |
| 1175 | + |
1174 | 1176 | // Set default category to subtitle if unset: |
1175 | 1177 | if( ! this.category ) { |
1176 | 1178 | this.category = 'SUB'; |
— | — | @@ -1177,7 +1179,16 @@ |
1178 | 1180 | //Set the textProvider if provided |
1179 | 1181 | if( textProvider ) { |
1180 | 1182 | this.textProvider = textProvider; |
| 1183 | + |
| 1184 | + // switch type to mw-srt if we are going to load via api |
| 1185 | + // ( this is need because we want to represent one thing to search engines / crawlers, |
| 1186 | + // while representing the mw-srt type internally so that mediawiki parsed text |
| 1187 | + // gets converted to html before going into the video |
| 1188 | + if( this.mwtitle ){ |
| 1189 | + this.mimeType = 'text/mw-srt'; |
| 1190 | + } |
1181 | 1191 | } |
| 1192 | + return this; |
1182 | 1193 | }, |
1183 | 1194 | |
1184 | 1195 | /** |
— | — | @@ -1195,7 +1206,6 @@ |
1196 | 1207 | } |
1197 | 1208 | }; |
1198 | 1209 | _this.loaded = true; |
1199 | | - |
1200 | 1210 | // Set parser handler: |
1201 | 1211 | switch( this.getMIMEType() ) { |
1202 | 1212 | //Special mediaWiki srt format ( support wiki-text in srt's ) |
— | — | @@ -1216,13 +1226,12 @@ |
1217 | 1227 | mw.log("Error: no handler for type: " + this.getMIMEType() ); |
1218 | 1228 | return ; |
1219 | 1229 | } |
1220 | | - |
1221 | 1230 | // Try to load src via textProvider: |
1222 | | - if( this.textProvider && this.titleKey ) { |
1223 | | - this.textProvider.loadTitleKey( this.titleKey, function( data ) { |
| 1231 | + if( this.textProvider && this.mwtitle) { |
| 1232 | + this.textProvider.loadTitleKey( this.mwtitle, function( data ) { |
1224 | 1233 | if( data ) { |
1225 | 1234 | _this.captions = handler( data ); |
1226 | | - } |
| 1235 | + } |
1227 | 1236 | mw.log("mw.TimedText:: loaded from titleKey: " + _this.captions.length + ' captions'); |
1228 | 1237 | // Update the loaded state: |
1229 | 1238 | _this.loaded = true; |
Index: trunk/extensions/TimedMediaHandler/MwEmbedModules/EmbedPlayer/resources/MediaPlayers.js |
— | — | @@ -134,7 +134,7 @@ |
135 | 135 | */ |
136 | 136 | setFormatPreference : function ( mimeFormat ) { |
137 | 137 | this.preference['formatPreference'] = mimeFormat; |
138 | | - $.cookie( 'EmbedPlayer.Preference', this.preference); |
| 138 | + $.cookie( 'EmbedPlayer.Preference', JSON.stringify( this.preference) ); |
139 | 139 | }, |
140 | 140 | |
141 | 141 | /** |
— | — | @@ -152,7 +152,7 @@ |
153 | 153 | selectedPlayer = this.players[i]; |
154 | 154 | mw.log( 'EmbedPlayer::setPlayerPreference: choosing ' + playerId + ' for ' + mimeType ); |
155 | 155 | this.preference[ mimeType ] = playerId; |
156 | | - $.cookie( 'EmbedPlayer.Preference', this.preference ); |
| 156 | + $.cookie( 'EmbedPlayer.Preference', JSON.stringify( this.preference ) ); |
157 | 157 | break; |
158 | 158 | } |
159 | 159 | } |
— | — | @@ -176,7 +176,7 @@ |
177 | 177 | this.preference = { }; |
178 | 178 | // See if we have a cookie set to a clientSupported type: |
179 | 179 | if( $.cookie( 'EmbedPlayer.Preference' ) ) { |
180 | | - this.preference = $.cookie( 'EmbedPlayer.Preference' ); |
| 180 | + this.preference = JSON.parse( $.cookie( 'EmbedPlayer.Preference' ) ); |
181 | 181 | } |
182 | 182 | } |
183 | 183 | }; |