r39665 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r39664‎ | r39665 | r39666 >
Date:22:02, 19 August 2008
Author:dale
Status:old
Tags:
Comment:
updates to interface styles
updates to lazy load ROE file
updates to mediaURL handling
Modified paths:
  • /trunk/extensions/MetavidWiki/includes/MV_DefaultSettings.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_MagicWords.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_MetavidInterface/MV_VideoPlayer.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_Title.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/specials/MV_SpecialExport.php (modified) (history)
  • /trunk/extensions/MetavidWiki/languages/MV_Messages.php (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/mv_vlcEmbed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skin/styles.css (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_stream.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/includes/MV_MagicWords.php
@@ -158,16 +158,19 @@
159159 $getText=true,
160160 $smw_properties=array('Speech_by', 'Bill'),
161161 $options=array('limit'=>1)
162 - );
 162+ );
163163 if(count($mvd_rows)!=0){
164 - $mvd_row = current($mvd_rows);
165 - if($mvd_row->Speech_by){
 164+ reset($mvd_rows);
 165+ $mvd_row = current($mvd_rows);
 166+ //print_r($mvd_rows);
 167+ //print "type of: " . gettype($mvd_row);
 168+ if(isset($mvd_row->Speech_by)){
166169 $ptitle = Title::MakeTitle(NS_MAIN, $mvd_row->Speech_by);
167170 $o.='<span class="keywords">'.
168171 $sk->makeKnownLinkObj($ptitle, $ptitle->getText()).
169172 '</span>';
170173 }
171 - if($mvd_row->Bill){
 174+ if(isset($mvd_row->Bill)){
172175 $btitle = Title::MakeTitle(NS_MAIN, $mvd_row->Bill);
173176 $o.='<span class="keywords">Bill:'.
174177 $sk->makeKnownLinkObj($btitle).'
Index: trunk/extensions/MetavidWiki/includes/MV_DefaultSettings.php
@@ -91,8 +91,10 @@
9292 $mvVideoArchivePaths['mvprime']= 'http://metavid.ucsc.edu/media/';
9393 $mvVideoArchivePaths['cap1'] = 'http://128.114.20.64/media/';
9494
 95+//stream msgKeys that support ?t=start_time/end_time temporal url media serving:
9596 $mvDefaultVideoQualityKey = 'mv_ogg_low_quality';
9697 $mvDefaultFlashQualityKey = 'mv_flash_low_quality';
 98+$mvDefaultVideoHighQualityKey = 'mv_ogg_high_quality';
9799
98100 #local path to video archive (if hosted locally)
99101 $mvLocalVideoLoc = '/metavid/video_archive';
Index: trunk/extensions/MetavidWiki/includes/specials/MV_SpecialExport.php
@@ -180,7 +180,8 @@
181181 }*/
182182 //start high level:
183183 function get_roe_xml($header=true){
184 - global $mvDefaultVideoQualityKey, $wgServer;
 184+ global $wgServer;
 185+ global $mvDefaultVideoQualityKey, $mvDefaultFlashQualityKey,$mvDefaultVideoHighQualityKey;
185186 $dbr =& wfGetDB(DB_SLAVE);
186187
187188 $this->get_row_data();
@@ -213,7 +214,12 @@
214215 <switch distinction="quality">
215216 <? foreach($this->file_list as $file){
216217 $dAttr=($file->getNameKey()==$mvDefaultVideoQualityKey)?' default="true"':'';
217 - $dSrc=($file->getPathType()=='url_anx')?$this->mvTitle->getWebStreamURL($file->getNameKey()):$file->getFullURL();
 218+ $dSrc=($file->getNameKey() == $mvDefaultVideoQualityKey ||
 219+ $file->getNameKey() == $mvDefaultFlashQualityKey ||
 220+ $file->getNameKey() == $mvDefaultVideoHighQualityKey )
 221+ ? $this->mvTitle->getWebStreamURL($file->getNameKey())
 222+ : $file->getFullURL();
 223+
218224 //if not ogg include start and end times in the attribute:
219225 //@@todo in the future support client side ogg seeking (and don't automaticly put .anx at the end)
220226 $startendattr= (htmlentities($file->getContentType())!='video/ogg')?
Index: trunk/extensions/MetavidWiki/includes/MV_Title.php
@@ -274,13 +274,19 @@
275275 *
276276 */
277277 function getWebStreamURL($quality=null){
278 - global $mvStreamFilesTable, $mvVideoArchivePaths, $mvDefaultVideoQualityKey;
 278+ global $mvStreamFilesTable, $mvVideoArchivePaths;
 279+ global $mvDefaultVideoQualityKey,$mvDefaultVideoHighQualityKey,$mvDefaultFlashQualityKey;
279280 //@@todo mediawiki path for media (insted of hard link to $mvVideoArchive)
280281 //@@todo make sure file exisits
281282 if(!$quality)$quality=$mvDefaultVideoQualityKey;
282 - $anx_req='';
 283+ $time_req='';
283284 if( $this->getStartTime()!='' && $this->getEndTime()!=''){
284 - $anx_req ='.anx?t='. $this->getStartTime() . '/' . $this->getEndTime();
 285+ if($quality==$mvDefaultVideoQualityKey ||
 286+ $quality==$mvDefaultVideoHighQualityKey){
 287+ $time_req ='.anx?t='. $this->getStartTime() . '/' . $this->getEndTime();
 288+ }else if($quality== $mvDefaultFlashQualityKey){
 289+ $time_req ='?t='. $this->getStartTime() . '/' . $this->getEndTime();
 290+ }
285291 }
286292 if( $this->doesStreamExist() ){
287293 //@@todo cache this / have a more organized store for StreamFiles in streamTitle
@@ -297,7 +303,7 @@
298304 $mvStreamFile = new MV_StreamFile($this->mvStream, $streamFile);
299305 //if link empty return false:
300306 if($mvStreamFile->getFullURL()=='')return false;
301 - return $mvStreamFile->getFullURL() . $anx_req;
 307+ return $mvStreamFile->getFullURL() . $time_req;
302308 }else{
303309 //@@todo throw ERROR
304310 return false;
Index: trunk/extensions/MetavidWiki/includes/MV_MetavidInterface/MV_VideoPlayer.php
@@ -51,21 +51,22 @@
5252 }
5353 $flash_stream_url = $mvTitle->getWebStreamURL($mvDefaultFlashQualityKey);
5454 if($flash_stream_url!=''){
55 - $o.=$coma.' <a href="'.htmlspecialchars($ogg_stream_url).'">
 55+ $o.=$coma.' <a href="'.htmlspecialchars($flash_stream_url).'">
5656 Flash Video
5757 </a>';
5858 $coma=', ';
5959 }
6060 $o.='</span>';
61 - $o.='<span class="download"><a href="javascript:">More Download Options</a></span>';
 61+ $o.='<span class="download"><a href="javascript:$j(\'#'.htmlspecialchars($this->embed_id).'\').get(0).showVideoDownload()">More Download Options</a></span>';
6262 }
6363 $o.='<span class="embed"><a href="javascript:hideShowEmbedCode();">Embed Video</a></span>'.
6464 '</p>';
6565 //about file:
 66+ $talkPage = Title::newFromText('Anno_en:'.strtolower($mvTitle->wiki_title), MV_NS_MVD_TALK);
6667 $o.='<p class="about_file">
6768 <span class="views">Views:'.htmlspecialchars($mvTitle->getViewCount()).'</span>
6869 <span class="duration">Duration: '.htmlspecialchars($mvTitle->getSegmentDurationNTP()).'</span>
69 - <span class="comments">na</span>
 70+ <span class="comments">'.$sk->makeKnownLinkObj($talkPage, wfMsg('talk')).'</span>
7071 </p>
7172 </div>';
7273 return $o;
Index: trunk/extensions/MetavidWiki/languages/MV_Messages.php
@@ -17,6 +17,7 @@
1818 #stream/files key descriptions:
1919 'mv_ogg_low_quality' => 'Web streamable - Ogg Theora 300kbs',
2020 'mv_ogg_high_quality' => 'High quality - Ogg Theora 900kbs',
 21+ 'mv_flash_low_quality' => 'Web streamable - Flash video',
2122 'mv_archive_org_link' => 'Links into Archive.org mpeg2 originals',
2223 'ao_file_64Kb_MPEG4' => 'Archive.org - mpeg4 64kbs',
2324 'ao_file_256Kb_MPEG4' => 'Archive.org - mpeg4 256kbs',
Index: trunk/extensions/MetavidWiki/skins/mv_stream.js
@@ -112,6 +112,11 @@
113113 ebvid['org_eb_stop'] = ebvid['stop'];
114114 ebvid['stop'] = function(){mv_do_stop();}
115115 }
 116+ if(ebvid['showVideoDownload'].toString!='function(){mv_doShowVideoDownload();}'){
 117+ ebvid['org_showVideoDownload'] = ebvid['showVideoDownload'];
 118+ ebvid['showVideoDownload'] = function(){mv_doShowVideoDownload();}
 119+ }
 120+
116121 //js_log("post stop: " +ebvid['stop'].toString());
117122 }
118123 //call stop override
@@ -269,7 +274,11 @@
270275 }
271276 }
272277 }
273 -
 278+function mv_doShowVideoDownload(){
 279+ //restores orginal state before showing download links:
 280+ mv_init_interface.doRestore();
 281+ return $j('#embed_vid').get(0).org_showVideoDownload();
 282+}
274283 /* the mvdObject
275284 *
276285 * eventually a lot of mvd_based functionality should be ported over to this structure.
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js
@@ -156,7 +156,11 @@
157157 mvJsLoader.doLoad(this.lib_jquery,function(){
158158 //once jQuery is loaded set up no conflict & load plugins:
159159 _global['$j'] = jQuery.noConflict();
160 - js_log('jquery loaded');
 160+ //set up ajax to not send dynamic urls for loading scripts
 161+ $j.ajaxSetup({
 162+ cache: true
 163+ });
 164+ js_log('jquery loaded');
161165 mvJsLoader.doLoad(_this.lib_plugins, function(){
162166 js_log('plugins loaded');
163167 mvEmbed.libs_loaded=true;
@@ -228,8 +232,7 @@
229233 supported_types:null,
230234 library:null,
231235 loaded:false,
232 - loading_callbacks:null,
233 -
 236+ loading_callbacks:null,
234237 supportsMIMEType : function(type)
235238 {
236239 for (var i in this.supported_types)
@@ -241,14 +244,6 @@
242245 {
243246 return getMsg('ogg-player-' + this.id);
244247 },
245 - getLibraryFile : function()
246 - {
247 - return 'mv_'+this.library+'Embed.js';
248 - },
249 - getLibraryObject : function()
250 - {
251 - return this.library+'Embed';
252 - },
253248 load : function(callback)
254249 {
255250 if(this.loaded)
@@ -262,12 +257,13 @@
263258 this.loading_callbacks.push(callback);
264259 if(this.loading_callbacks.length==1)
265260 {
266 - js_log('requesting plugin: ' + mv_embed_path + this.getLibraryFile());
 261+ js_log('requesting plugin: ' + mv_embed_path + 'mv_'+this.library+'Embed.js');
267262 var _this = this;
268 - $j.getScript(mv_embed_path + _this.getLibraryFile(), function()
269 - {
 263+ //swaped for doLoad so that we use cache
 264+ // getScript has cache disabled for some reason (probably could be set up at init to cache)
 265+ $j.getScript(mv_embed_path + 'mv_'+_this.library+'Embed.js', function(){
270266 js_log(_this.id + ' plugin loaded');
271 - _this.loaded = true;
 267+ _this.loaded = true;
272268 for(var i in _this.loading_callbacks)
273269 _this.loading_callbacks[i]();
274270 _this.loading_callbacks = null;
@@ -570,19 +566,20 @@
571567 libreq:{},
572568 load_time:0,
573569 doLoad:function(libs,callback){
574 - if(libs){this.libs=libs;}else{libs=this.libs;}
 570+ this.libs = libs;
575571 this.callback=(callback)?callback:this.callback;
576572 var loading=0;
577573 var i=null;
578574 //js_log("doLoad_ load set to 0 on libs:"+ libs);
579575 for(i in libs){
 576+ //if(i=='vlcEmbed')alert('got called with '+i+' ' + typeof(vlcEmbed));
580577 //itor the objPath (to avoid 'has no properties' errors)
581578 var objPath = i.split('.');
582579 var cur_path ='';
583580 var cur_load=0;
584581 for(p in objPath){
585582 cur_path = (cur_path=='')?cur_path+objPath[p]:cur_path+'.'+objPath[p];
586 - //js_log("looking at path: "+ cur_path);
 583+ //if(i=='vlcEmbed')alert("looking at path: "+ cur_path);
587584 //js_log("eval: " + eval('typeof ('+cur_path+');'));
588585 if(eval('typeof '+cur_path)=='undefined'){
589586 cur_load = loading=1;
@@ -1107,11 +1104,6 @@
11081105 getMenu:function(){
11091106 var out='';
11101107 //add in loading icon:
1111 - /*
1112 - out+= '<div class="mv_loading_icon" style="background:url(\''+mv_embed_path+'images/indicator.gif\');display:';
1113 - out+= (this.roe_xml)? 'none':'inline';
1114 - out+='"/>';
1115 - */
11161108 var as_checked = (this.autoscroll)?'checked':'';
11171109 out+= '<div id="mmenu_'+this.pe.id+'" style="background:#AAF;font-size:small;position:absolute;top:0;height:20px;left:0px;right:0px;">' +
11181110 '<a style="font-color:#000;" title="'+getMsg('close')+'" href="#" onClick="document.getElementById(\''+this.pe.id+'\').closeTextInterface();return false;">'+
@@ -1287,7 +1279,8 @@
12881280 */
12891281 detectType:function(uri)
12901282 {
1291 - //@@todo if media is on the same server as the javascript we can issue a HEAD request and read the mime type of the media...
 1283+ //@@todo if media is on the same server as the javascript or we have mv_proxy configured
 1284+ //we can issue a HEAD request and read the mime type of the media...
12921285 // (this will detect media mime type independently of the url name)
12931286 //http://www.jibbering.com/2002/4/httprequest.html (this should be done by extending jquery's ajax objects)
12941287 switch(uri.substr(uri.lastIndexOf('.'),4)){
@@ -1316,6 +1309,7 @@
13171310 sources:null,
13181311 /** Playable sources **/
13191312 playable_sources:null,
 1313+ addedROEData:false,
13201314 /** Selected mediaSource element. */
13211315 selected_source:null,
13221316 thumbnail:null,
@@ -1407,13 +1401,22 @@
14081402 return mime_type=='video/ogg' || mime_type=='video/annodex' || mime_type=='video/x-flv';
14091403 },
14101404 /** Adds a single mediaSource using the provided element if
1411 - the element has a 'src' attribute.
 1405+ the element has a 'src' attribute.
14121406 @param element {element} <video>, <source> or <mediaSource> element.
14131407 */
14141408 tryAddSource:function(element)
14151409 {
14161410 if (!element.hasAttribute('src'))
14171411 return;
 1412+ var new_src = element.getAttribute('src');
 1413+ //make sure an existing element with the same src does not already exist:
 1414+ js_log("New src: "+new_src);
 1415+ for(i in this.sources){
 1416+ js_log(' ext src: '+this.sources[i].getURI());
 1417+ if(this.sources[i].getURI()==new_src){
 1418+ return false;
 1419+ }
 1420+ }
14181421 var source = new mediaSource(element);
14191422 this.sources.push(source);
14201423 if(this.isPlayableType(source.mime_type))
@@ -1423,8 +1426,9 @@
14241427 @param roe_data ROE data.
14251428 */
14261429 addROE:function(roe_data)
1427 - {
1428 - var _this = this;
 1430+ {
 1431+ this.addedROEData=true;
 1432+ var _this = this;
14291433 if(typeof roe_data == 'string')
14301434 {
14311435 var parser=new DOMParser();
@@ -1452,7 +1456,8 @@
14531457 })
14541458 }
14551459 else
1456 - js_log('ROE data empty.');
 1460+ js_log('ROE data empty.');
 1461+
14571462 }
14581463 };
14591464
@@ -1467,8 +1472,7 @@
14681473 embedVideo.prototype = {
14691474 /** The mediaElement object containing all mediaSource objects */
14701475 media_element:null,
1471 - slider:null,
1472 - roe_xml:null,
 1476+ slider:null,
14731477 load_external_data:false,
14741478 //utility functions for property values:
14751479 hx : function ( s ) {
@@ -1858,7 +1862,6 @@
18591863
18601864 thumb_html+='</div>';
18611865 return thumb_html;
1862 -
18631866 },
18641867 GetEmbeddingHTML:function()
18651868 {
@@ -2060,8 +2063,10 @@
20612064 '<div class="videoOptionsComplete">'+
20622065 //@@TODO: this style should go to .css
20632066 '<div style="width: 247px;border:none;position:absolute;z-index:13;padding: 12px 19px; text-align:right;"><span>'+
2064 - '<a href="#" style="color:white;" onClick="$j(\'#'+sel_id+'\').get(0).closeDisplayedHTML();">close</a></span></div>'+
2065 - html_code +
 2067+ '<a href="#" style="color:white;" onClick="$j(\'#'+sel_id+'\').get(0).closeDisplayedHTML();return false;">close</a></span></div>'+
 2068+ '<div id="mv_disp_inner_'+sel_id+'">'+
 2069+ html_code
 2070+ +'</div>'+
20662071 // close_link+'</span>'+
20672072 '</div></div>';
20682073 $j('#'+sel_id).append(div_code);
@@ -2142,33 +2147,51 @@
21432148 out+='</blockquote></span>';
21442149 return out;
21452150 },
2146 - showVideoDownload:function(){
2147 - var select_code=this.getDLlist(function(index, source)
2148 - {
2149 - return '<a style="color:white" href="' + source.getURI() +'"> '
2150 - + source.getTitle()+'</a>';
2151 - });
2152 - this.displayHTML(select_code);
 2151+ /*download list is exessivly complicated ... rewrite for clarity: */
 2152+ showVideoDownload:function(){
 2153+ //load the roe if avaliable (to populate out download options:
 2154+ if(this.roe && this.media_element.addedROEData==false){
 2155+ var _this = this;
 2156+ this.displayHTML(getMsg('loading_txt'));
 2157+ do_request(this.roe, function(data)
 2158+ {
 2159+ _this.media_element.addROE(data);
 2160+ $j('#mv_disp_inner_'+_this.id).html(_this.getShowVideoDownload());
 2161+ });
 2162+ }else{
 2163+ this.displayHTML(this.getShowVideoDownload());
 2164+ }
21532165 },
2154 - getDLlist:function(transform_function){
2155 - var out='<b style="color:white;">'+getMsg('download_from')/*+' '+parseUri(this.src).queryKey['t']*/+'</b><br>';
 2166+ getShowVideoDownload:function(){
 2167+ var out='<b style="color:white;">'+getMsg('download_from')+'</b><br>';
21562168 out+='<span style="color:white"><blockquote>';
2157 - var dl_list=dl_txt_list='';
2158 - $j.each(this.media_element.getSources(), function(index, source)
2159 - {
2160 - var dl_line = '<li>' + transform_function(index, source) + '</li>'+"\n";
2161 - if(this.getMIMEType()=="video/ogg"){
 2169+ var dl_list='';
 2170+ var dl_txt_list='';
 2171+ $j.each(this.media_element.getSources(), function(index, source){
 2172+ var dl_line = '<li>' + '<a style="color:white" href="' + source.getURI() +'"> '
 2173+ + source.getTitle()+'</a> '+ '</li>'+"\n";
 2174+ if( source.getURI().indexOf('?t=')!==-1){
21622175 out+=dl_line;
21632176 }else if(this.getMIMEType()=="text/cmml"){
21642177 dl_txt_list+=dl_line;
21652178 }else{
21662179 dl_list+=dl_line;
21672180 }
 2181+ });
 2182+ out+='</blockquote>'+getMsg('download_full')+"<blockquote>"+dl_list+'</blockquote>';
 2183+ out+='</blockquote>'+getMsg('download_text')+"<blockquote>"+dl_txt_list+'</blockquote></span>';
 2184+ return out;
 2185+ },
 2186+ /*getDLlist:function(transform_function){
 2187+
 2188+ var dl_list=dl_txt_list='';
 2189+ $j.each(this.media_element.getSources(), function(index, source)
 2190+ {
 2191+
21682192 });
2169 - out+='</blockquote>'+getMsg('download_full')+"<blockquote>"+dl_list+'</blockquote>';
2170 - out+='</blockquote>'+getMsg('download_text')+"<blockquote>"+dl_txt_list+'</blockquote></span>';
 2193+
21712194 return out;
2172 - },
 2195+ },*/
21732196 /*
21742197 * base embed controls
21752198 * the play button calls
@@ -2537,7 +2560,7 @@
25382561 //@@todo swich over to jQuery injection
25392562 function loadExternalJs(url){
25402563 js_log('load js: '+ url);
2541 -/* if(window['$j'])
 2564+ if(window['$j'])
25422565 //have to use direct ajax call insted of $j.getScript()
25432566 //since you can't send "cache" option to $j.getScript()
25442567 $j.ajax({
@@ -2546,8 +2569,7 @@
25472570 dataType: 'script',
25482571 cache: true
25492572 });
2550 - else*/
2551 - {
 2573+ else{
25522574 var e = document.createElement("script");
25532575 e.setAttribute('src', url);
25542576 e.setAttribute('type',"text/javascript");
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_vlcEmbed.js
@@ -3,7 +3,6 @@
44 * javascript api: http://www.videolan.org/doc/play-howto/en/ch04.html
55 * assume version > 0.8.5.1
66 */
7 -
87 var vlcEmbed = {
98 instanceOf:'vlcEmbed',
109 supports: {'play_head':true, 'play_or_pause':true, 'stop':true, 'fullscreen':true, 'time_display':true, 'volume_control':true},
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skin/styles.css
@@ -320,15 +320,16 @@
321321
322322 /* margin: -305px 0 0 0; */
323323 .videoComplete .videoOptionsComplete {
324 - background: url(images/player_video_options_bg.png) 0 0 no-repeat;
325 - width: 266px;
326 - height: 172px;
327 - margin: 5px auto;
328 - padding: 12px 19px;
329 -/* font-size: 14px;*/
330 - font-size:10pt;
331 - overflow: auto;
332 - color: #7a7a7a;
 324+ background:transparent url('images/player_video_options_bg.png') no-repeat scroll 0pt;
 325+ color:#7A7A7A;
 326+ font-size:10pt;
 327+ height:158px;
 328+ left:10%;
 329+ overflow:auto;
 330+ padding:19px;
 331+ position:relative;
 332+ top:16%;
 333+ width:283px;
333334 }
334335 .videoComplete .videoOptionsComplete p {text-align: center; margin: 3px 0; padding: 0;}
335336 .videoComplete .videoOptionsComplete a {

Status & tagging log