* Only firefogg non-proxied api based uploads supported so far.
<br />
<table border="1" cellpadding="6" width="600">
<tr>
- <td valign="top"><video duration="26" poster="http://metavid.org/w/index.php?action=ajax&rs=mv_frame_server&stream_id=71&t=1:23:16&size=400x300" src="http://metavidstorage01.ucsc.edu/media/house_proceeding_07-18-06_00.ogg?t=1:23:16/1:23:44"></video></video></td>
+ <td valign="top"><video durationHint="26" poster="http://metavid.org/w/index.php?action=ajax&rs=mv_frame_server&stream_id=71&t=1:23:16&size=400x300" src="http://metavidstorage01.ucsc.edu/media/house_proceeding_07-18-06_00.ogg?t=1:23:16/1:23:44"></video></video></td>
<td valign="top"><b>Sample Embed</b><br />
Simple video Embed:
<pre><video poster="http://metavid.org/w/index.php?action=ajax&rs=mv_frame_server&stream_id=71&t=1:23:16&size=400x300"
setupForm:function(){
var _this = this;
//set up the local pointer to the edit form:
- _this.editForm = _this.getEditForm();
+ _this.editForm = _this.getEditForm();
if( _this.editForm ){
//set up the org_onsubmit if not set:
_this.org_onsubmit = _this.editForm.onsubmit;
//have to define the onsubmit function inline or its hard to pass the "_this" instance
- $j( '#mw-upload-form' ).submit( function(){
+ $j( _this.editForm ).submit( function(){
//run the original onsubmit (if not run yet set flag to avoid excessive chaining )
if( typeof( _this.org_onsubmit ) == 'function' ){
if( ! _this.org_onsubmit() ){
}
}
//check for post action override:
- if( _this.form_post_override ){
- //alert('will submit here');
+ if( _this.form_post_override ){
return true;
}
//get the input form data in flat json:
var out = '';
$j.each(default_firefogg_options, function(target, na){
if(target.substring(0, 6)=='target'){
- js_log('check for target html: ' + target);
+ //js_log('check for target html: ' + target);
//check for the target if missing add to the output:
if( _this[target] === false){
out += _this.getTargetHtml(target) + ' ';
//doChunkUpload does both uploading and encoding at the same time and uploads one meg chunks as they are ready
doChunkUpload : function(){
js_log('doChunkUpload::');
- var _this = this;
+ var _this = this;
_this.action_done = false;
//extension should already be ogg but since its user editable,
//check again
_this.formData['wpDestFile'] = sf.replace(extreg, '.ogg');
}
//add chunk response hook to build the resultURL when uploading chunks
-
+
+ //check for editToken:
+ if(!this.etoken){
+ if( _this.formData['wpEditToken']){
+ _this.etoken = _this.formData['wpEditToken'];
+ _this.doChunkWithFormData();
+ }else{
+ get_mw_token(
+ 'File:'+ _this.formData['wpDestFile'],
+ _this.api_url,
+ function( eToken ){
+ _this.etoken = eToken;
+ _this.doChunkWithFormData();
+ }
+ );
+ }
+ }else{
+ _this.doChunkWithFormData();
+ }
+ },
+ doChunkWithFormData:function(){
+ var _this = this;
+ js_log("doChunkWithFormData::" + _this.etoken);
//build the api url:
var aReq ={
'action' : 'upload',
'comment' : _this.formData['wpUploadDescription'],
'enablechunks' : 'true'
};
- //check for editToken:
- if(!this.etoken)
- this.etoken = _this.formData['wpEditToken'];
-
- if( this.etoken )
+
+ if( _this.etoken )
aReq['token'] = this.etoken;
if( _this.formData['wpWatchthis'] )
},
doUploadStatus:function() {
var _this = this;
- $j('#up-status-state').html( gM('uploaded-status') );
+ $j( '#up-status-state' ).html( gM('uploaded-status') );
_this.oldResponseText = '';
//setup a local function for timed callback:
"rsd_results_prev" : "previous ",
"rsd_no_results" : "No search results for <b>$1</b>",
- "mv_upload" : "Upload",
+ "upload_tab" : "Upload",
"rsd_layout" : "Layout:",
"rsd_resource_edit" : "Edit Resource: $1",
"resource_description_page": "Resource Description Page",
"no_import_by_url": "This User or Wiki <b>can not</b> import assets from remote URLs. </p><p> Do you need to Login? </p><p> If permissions are set you may have to enable $wgAllowCopyUploads, <a href=\"http://www.mediawiki.org/wiki/Manual:$wgAllowCopyUploads\">more info</a></p>",
"results_from": "Results from <a href=\"$1\" target=\"_new\" >$2</a>",
- "missing_desc_see_soruce": "This Asset is missing a description. Please see the [$1 orginal source] and help describe it"
+ "missing_desc_see_soruce": "This Asset is missing a description. Please see the [$1 orginal source] and help describe it",
+
+ "rsd_config_error": "Add media Wizard configuation error: $1"
});
var default_remote_search_options = {
'profile':'mediawiki_edit',
'cFileNS':'File', //what is the cannonical namespace for images
//@@todo (should get that from the api or inpage vars)
- 'enable_upload_tab':true // if we want to enable an uploads tab:
+ 'enable_upload_tab':true, // if we want to enable an uploads tab:
+ 'upload_api_target' : 'http://127.0.0.1/wiki_trunk/api.php' // can be local or the url of the upload api.
}
if(typeof wgServer == 'undefined')
wgServer = '';
* sets the default display item:
* can be any content_providers key or 'all'
*/
- disp_item : 'this_wiki',
+ disp_item : 'upload',
/** the default content providers list.
*
* (should be note that special tabs like "upload" and "combined" don't go into the content proviers list:
}
}
- //make sure the selected cp has an api to query against:
- if(! this.content_providers[ this.disp_item ].api_url ){
+ //make sure the selected cp has an api to query against (if its a content_provider
+ if( this.content_providers[ this.disp_item ] &&
+ !this.content_providers[ this.disp_item ].api_url ){
for(var inx in this.content_providers){
if( this.content_providers[ inx ].api_url ){
this.disp_item = inx;
break;
}
}
- }
+ }
//set up the default model config:
});
},
doUploadInteface:function(){
- var _this = this;
- mv_set_loading('#tab-upload');
- $j('#tab-upload').html('upload interface goes here ;)');
-
- //todo include firefogg support:
- /*mvJsLoader.doLoad( [
- 'mvUploader'
- ],function(){
- _this.cUpLoader = new mvUploader({
- 'target_div': '#tab-upload',
- 'upload_done_action:': function( rTitle){
- //set to loading:
- mv_set_loading('#tab-upload');
- //do a direct api query for resource info (to build rObj
- _this.getResourceFromTitle( rTitle, function(rObj){
- //call resource Edit:
- _this.resourceEdit( rObj );
- });
- }
- });
- }); */
+ js_log("doUploadInteface::");
+ var _this = this;
+ //set it to loading:
+ mv_set_loading('#tab-upload');
+
+ //do config variable reality checks:
+ if( _this.upload_api_target == 'local' ){
+ if( ! _this.local_wiki_api_url ){
+ $j('#tab-upload').html( gM( 'rsd_config_error', 'missing_local_api_url' ) );
+ return false;
+ }else{
+ _this.upload_api_target = _this.local_wiki_api_url;
+ }
+ }
+ //make sure we have a url for the upload target:
+ if( parseUri( _this.upload_api_target ).host == _this.upload_api_target ){
+ $j('#tab-upload').html( gM('rsd_config_error', 'bad_api_url') );
+ return false;
+ }
+ //output the form
+ mvJsLoader.doLoad(['$j.fn.simpleUploadForm'],function(){
+ //set the form action based on domain:
+ if( parseUri( document.URL ).host == parseUri( _this.upload_api_target ).host ){
+ //deal with the api form upload form directly:
+ $j('#tab-upload').simpleUploadForm({
+ "api_target" : _this.upload_api_target
+ })
+ }else{
+ //setup the proxy
+ }
+ });
},
runSearch: function(){
js_log("f:runSearch::" + this.disp_item);
//draw_direct_flag
var draw_direct_flag = true;
- if( !this.content_providers[this.disp_item] ){
- js_log("can't run search for:" + this.disp_item);
+ if( !this.content_providers[this.disp_item] ){
+ //check if its the special upload tab case:
+ if( this.disp_item == 'upload'){
+ this.doUploadInteface();
+ }else{
+ js_log("can't run search for:" + this.disp_item);
+ }
return false;
}
cp = this.content_providers[this.disp_item];
}
//do an upload tab if enabled:
if( this.enable_upload_tab ){
- o+='<li class="rsd_cp_tab" ><a id="rsd_tab_upload" href="#tab-upload">' + gM('upload') + '</a></li>';
+ o+='<li class="rsd_cp_tab" ><a id="rsd_tab_upload" href="#tab-upload">' + gM('upload_tab') + '</a></li>';
tabc+='<div id="tab-upload" />';
+ if(this.disp_item == 'upload')
+ selected_tab = inx++;
}
o+='</ul>';
//output the tab content containers:
},
/*set-up the control actions for clipEdit with relevent callbacks */
- getClipEditControlActions:function(){
+ getClipEditControlActions:function( cp ){
var _this = this;
- return {
- 'insert' :function(rObj){
- _this.insertResource(rObj);
- },
- 'preview':function(rObj){
+ var cConf= {};
+
+ cConf['insert'] = function(rObj){
+ _this.insertResource(rObj);
+ }
+ //if not directly inserting the resource is support a preview option:
+ if( _this.import_url_mode != 'remote_link'){
+ cConf['preview'] = function(rObj){
_this.previewResource( rObj )
- },
- 'cancel' :function(){
- _this.cancelClipEditCB()
- }
- };
+ };
+ }
+ cConf['cancel'] = function(){
+ _this.cancelClipEditCB()
+ }
+ return cConf;
},
//loads the media editor:
doMediaEdit:function( rObj , mediaType){
- var _this = this;
+ var _this = this;
+ var cp = rObj.pSobj.cp;
var mvClipInit = {
'rObj':rObj, //the resource object
- 'parent_ct':'rsd_modal_target',
- 'clip_disp_ct':'clip_edit_disp',
- 'control_ct': 'clip_edit_ctrl',
- 'media_type': mediaType,
- 'p_rsdObj': _this,
- 'controlActionsCb':_this.getClipEditControlActions()
+ 'parent_ct' : 'rsd_modal_target',
+ 'clip_disp_ct' : 'clip_edit_disp',
+ 'control_ct' : 'clip_edit_ctrl',
+ 'media_type' : mediaType,
+ 'p_rsdObj' : _this,
+ 'controlActionsCb' : _this.getClipEditControlActions( cp )
};
var clibs = ['mvClipEdit'];
updatePreviewText:function( rObj ){
var _this = this;
- if(_this.import_url_mode=='remote_link'){
+ if( _this.import_url_mode == 'remote_link' ){
_this.cur_embed_code = rObj.pSobj.getEmbedHTML(rObj);
}else{
_this.cur_embed_code = rObj.pSobj.getEmbedWikiCode( rObj );
--- /dev/null
+/*
+ * simple form output jquery binding
+ * enables dynamic form output to a given target
+ *
+ */
+
+loadGM({
+ "select_file" : "Select File",
+ "more_licence_options" : "For more licence options view the <a href=\"$1\">normal upload page</a>",
+ "select_ownwork" : "I am uploading entirely my own work, and licencing it under:",
+ "licence_cc-by-sa" : "Creative Commons Share Alike (3.0)",
+ "upload" : "Upload File",
+ "destfilename" : "Destination filename:",
+ "summary" : "Summary"
+});
+
+var default_form_options = {
+ 'enable_fogg' : true,
+ 'licence_options':['cc-by-sa'],
+ 'api_target' : false
+};
+
+(function($) {
+ $.fn.simpleUploadForm = function( opt , callback){
+ //set the options:
+ for(var i in default_form_options){
+ if(!opt[i])
+ opt[i] = default_form_options[i];
+ }
+
+ //first do a reality check on the options:
+ if(!opt.api_target){
+ $(this.selector).html('Error: Missing api target');
+ return false;
+ }
+
+
+ //@@todo this is just a proof of concept
+ //much todo to improved this web form
+ var o = '<div style="margin: 0 auto;">'+
+ '<form id="suf-upload" enctype="multipart/form-data" action="" method="post">' +
+ '<label for="wpUploadFile">' + gM('select_file') + '</label><br>'+
+ '<input type="file" style="display: inline;" name="wpUploadFile" id="wpUploadFile" size="10"/><br>' +
+ '<label for="wpDestFile">' +gM('destfilename') + '</label><br>'+
+ '<input type="text" id="wpDestFile" name="wpDestFile" size="30" /><br>'+
+ '<label for="wpUploadDescription">' + gM('summary') + ':</label><br>' +
+ '<textarea cols="30" rows="3" id="wpUploadDescription" name="wpUploadDescription" tabindex="3"/><br>'+
+ gM('select_ownwork') + '<br>' +
+ '<input type="checkbox" id="wpLicence" name="wpLicence" value="cc-by-sa">' + gM('licence_cc-by-sa') + '<br>' +
+
+ '<input type="submit" accesskey="s" value="' + gM('upload') + '" name="wpUploadBtn" id="wpUploadBtn" tabindex="9"/>' +
+ //close the form and div
+ '</form></div>';
+
+ //set the target with the form output:
+ $(this.selector).html( o );
+ //by default dissable:
+ $j('#wpUploadBtn').attr('disabled', 'disabled');
+
+ //set up basic binding:
+ $j('#wpLicence').click(function(){
+ if( $j(this).is(':checked') ){
+ $j('#wpUploadBtn').removeAttr('disabled');
+ }else{
+ $j('#wpUploadBtn').attr('disabled', 'disabled');
+ }
+ });
+
+ //set up the binding per the config
+ if( opt.enable_fogg ){
+ $j('#wpUploadFile').firefogg({
+ //an api url (we won't submit directly to action of the form)
+ 'api_url' : opt.api_target,
+ 'form_rewrite': true,
+ 'target_edit_from' : '#suf-upload',
+ 'new_source_cb' : function( orgFilename, oggName ){
+ $j('#wpDestFile').val( oggName );
+ //@@TODO:
+ //mwUploadHelper.doDestCheck();
+ }
+ });
+ }else{
+ //simple web form rewrite
+ }
+ }
+})(jQuery);
\ No newline at end of file
this.doDisplayEdit();
}else{
//check the media_type:
- js_log('mvClipEdit:: media type:' + this.media_type + ' base width: ' + this.rObj.width + ' bh: ' + this.rObj.height);
+ //js_log('mvClipEdit:: media type:' + this.media_type + ' base width: ' + this.rObj.width + ' bh: ' + this.rObj.height);
//could seperate out into media Types objects for now just call method
if(this.media_type == 'image'){
this.setUpImageCtrl();
var b_target = _this.p_rsdObj.target_container + '~ .ui-dialog-buttonpane';
//empty the ui-dialog-buttonpane bar:
$j(b_target).empty();
- for(var cbType in _this.controlActionsCb){
+ for( var cbType in _this.controlActionsCb ){
switch(cbType){
case 'insert_seq':
$j(b_target).append( $j.btnHtml(gM('mv_insert_into_sequence'), 'mv_insert_sequence', 'check' ) + ' ' )
if( force_id == null && force_id != '' ){
var j_selector = 'video,audio,playlist';
}else{
- var j_selector = '#'+force_id;
+ var j_selector = '#' + force_id;
}
//process selected elements:
//ie8 does not play well with the jQuery video,audio,playlist selector use native:
$j("#mv_play_pause_button_" + this_id + ' span').removeClass('ui-icon-play').addClass('ui-icon-pause');
$j("#mv_play_pause_button_" + this_id).unbind().btnBind().click(function(){
- $j('#' + this_id ).get(0).pause();
- }).attr('title', gM('pause_clip'));
+ $j('#' + this_id ).get(0).pause();
+ }).attr('title', gM('pause_clip'));
},
load:function(){
var val = parseInt( perc*1000 );
$j('#mv_play_head_'+this_id).slider('value', val);
- js_log("embed video set: " + '#mv_play_head_'+this_id + ' to ' + val);
+ //js_log("embed video set: " + '#mv_play_head_'+this_id + ' to ' + val);
}
//js_log('set#mv_seeker_slider_'+this_id + ' perc in: ' + perc + ' * ' + $j('#mv_seeker_'+this_id).width() + ' = set to: '+ val + ' - '+ Math.round(this.mv_seeker_width*perc) );
//js_log('op:' + offset_perc + ' *('+perc+' * ' + $j('#slider_'+id).width() + ')');
'$j.fn.datePicker' : 'jquery/plugins/jquery.datePicker.js',
'$j.ui' : 'jquery/jquery.ui-1.7.1/ui/ui.core.js',
'$j.fn.ColorPicker' : 'libClipEdit/colorpicker/js/colorpicker.js',
- '$j.Jcrop' : 'libClipEdit/Jcrop/js/jquery.Jcrop.js'
+ '$j.Jcrop' : 'libClipEdit/Jcrop/js/jquery.Jcrop.js',
+ '$j.fn.simpleUploadForm': 'libAddMedia/simpleUploadForm.js'
});
//query plugins
lcPaths( 'jquery/plugins/', [
'$j.secureEvalJSON',
'$j.cookie',
- '$j.contextMenu',
+ '$j.contextMenu'
]);
//jquery ui
lcPaths('jquery/jquery.ui-1.7.1/ui/', [
'$j.effects.slide',
'$j.ui.accordion',
'$j.ui.draggable',
- '$j.ui.selectable',
+ '$j.ui.selectable'
],
{'j_replace':''});
//add mediaLibs
'mvAdvFirefogg',
'mvBaseUploadInterface',
'remoteSearchDriver',
- 'seqRemoteSearchDriver',
+ 'seqRemoteSearchDriver'
]);
//search libs:
lcPaths('libAddMedia/searchLibs/', [
* @param api_url 'optional' the target api url
* @param callback the callback function to pass the token or "false" to
*/
-function get_mw_token( title, api_url, callback){
+function get_mw_token( title, api_url, callback){
+ js_log(':get_mw_token:');
if(!title && wgUserName){
title = 'User:' + wgUserName;
}
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <title></title>
+ <script type="text/javascript">
+
+ </script>
+</head>
+<body>
+<h3> This file should be inclued by external sites that want to be proxied: </h3>
+</body>
+</html>
+
// libAddMedia:
$wgJSAutoloadLocalClasses['mvFirefogg'] = $wgMwEmbedDirectory . 'libAddMedia/mvFirefogg.js';
$wgJSAutoloadLocalClasses['mvAdvFirefogg'] = $wgMwEmbedDirectory . 'libAddMedia/mvAdvFirefogg.js';
+$wgJSAutoloadLocalClasses['j.fn.simpleUploadForm'] = $wgMwEmbedDirectory . 'libAddMedia/simpleUploadForm.js';
$wgJSAutoloadLocalClasses['mvBaseUploadInterface'] = $wgMwEmbedDirectory . 'libAddMedia/mvBaseUploadInterface.js';
$wgJSAutoloadLocalClasses['remoteSearchDriver'] = $wgMwEmbedDirectory . 'libAddMedia/remoteSearchDriver.js';
$wgJSAutoloadLocalClasses['seqRemoteSearchDriver'] = $wgMwEmbedDirectory . 'libAddMedia/seqRemoteSearchDriver.js';
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <title>Javascript Api Proxy</title>
+ <style type="text/css">
+ body{
+ font-size:80%;
+ }
+ img {
+ border:medium none;
+ }
+ </style>
+ <script type="text/javascript">
+ var domainList = [
+ '127.0.0.1'
+ ];
+ </script>
+</head>
+<body>
+<h3> This file proxies api and html output for source domains: </h3>
+<div id="domainList"></div>
+ <script type="text/javascript">
+ var o='';
+ for( var i in domainList){
+ o+='<br><i>'+ domainList[i] + '</i>';
+ }
+ </script>
+</body>
+</html>
+