From 05fcc405373760b1e845b851b7219ccd6c455e5a Mon Sep 17 00:00:00 2001 From: Bastien Ho Date: Wed, 3 Apr 2013 09:41:46 +0200 Subject: [PATCH 1/2] calc branch --- .gitignore | 5 ++ .project | 17 +++++++ CHANGELOG.txt | 8 +++ README.md | 1 + ajax/host.php | 5 +- appinfo/info.xml | 2 +- appinfo/version | 1 + img/calc.png | Bin 0 -> 598 bytes img/pad.png | Bin 550 -> 654 bytes js/files_etherpad.js | 95 ++++++++++++++++++++++++++++++++++-- js/loader.js | 107 ----------------------------------------- l10n/de.php | 6 ++- l10n/fr.php | 14 ++++-- push | 3 -- settings.php | 1 + templates/settings.php | 10 +++- 16 files changed, 150 insertions(+), 125 deletions(-) create mode 100644 .gitignore create mode 100644 .project create mode 100644 README.md create mode 100644 appinfo/version create mode 100644 img/calc.png delete mode 100644 js/loader.js delete mode 100644 push diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d1b767f --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.class +*.pyc +*.pyo +.svn +_svn diff --git a/.project b/.project new file mode 100644 index 0000000..500f5c4 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + files_etherpad + + + + + + com.aptana.ide.core.unifiedBuilder + + + + + + com.aptana.projects.webnature + + diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 26442d1..37774df 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,11 @@ +v 0.2.0 +Add : OC5 compability +Add : DE translation +Add : Token for pad name +Fix : Security issues +Fix : bug fix +By : Ernesto Ruge + v 0.1.6 Fix : modifications to respect the Coding Style Guide diff --git a/README.md b/README.md new file mode 100644 index 0000000..4e3d429 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +This is a plugin for Owncloud which adds Etherpads as a file. It's a fork of http://apps.owncloud.com/content/show.php/Files+Etherpad?content=155237 diff --git a/ajax/host.php b/ajax/host.php index dc2ded3..4c31b6d 100644 --- a/ajax/host.php +++ b/ajax/host.php @@ -1,4 +1,7 @@ \ No newline at end of file diff --git a/appinfo/info.xml b/appinfo/info.xml index 468f3c2..d7d7fde 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -3,7 +3,7 @@ files_etherpad Files Etherpad Create etherpad shortcuts - 0.1.7 + 0.2.0 CC BY-NC 3.0 Bastien Ho (EELV), Ernesto Ruge 5.0 diff --git a/appinfo/version b/appinfo/version new file mode 100644 index 0000000..0ea3a94 --- /dev/null +++ b/appinfo/version @@ -0,0 +1 @@ +0.2.0 diff --git a/img/calc.png b/img/calc.png new file mode 100644 index 0000000000000000000000000000000000000000..eb534d45e3a09983ba4da36d19d7012a6201913e GIT binary patch literal 598 zcmV-c0;&CpP)fw%_l+kVK@h006C4>vp%>Jq*JT{|f;akH-f|^6T6=ca#cy z0r~*Rthn?yfQ@>+w!gpk?Ck9H8-RBJ5FqtEHG`2b612HPOApa(HaFrpe%|Z#?iC#v z@p^cK%jsoy@q^7>h&M3&{yWQ67Xxg!+wC}xpE~CbQvs1A-i%)2Vsf4p-&(l~S`F_% z{mgRfwGj7jRuM(j6#zjnb70KC=1(V)vMS&(BbYWK7ceUcP|CpO3O+}AVgCeCM#H16 z15Boq+-|f9sDj-)*RtGl=s*%mg}s1zh>fp1h0CJV2*DMxb&%*@Oz6bc27Dgm`x?P0UIyKQD~a^XzCvtp;!LI4%n0SjSCPkl2JILbyMGbij~O(Pc_;57 z|7L}N$Joz69S4J-X(fA@8G%5sgz@1rXNS(`^s{Gl$NirvxH}t-S5+GObzF|)xSVUF zvz#uB{l~)l7`Q7&=gzrDhajW-w?2Vh2hC=)`E7G^Eg49ngz~L+Nlv!APG`kIa(Qj5 b_7%`y>^W#i!(@qh00000NkvXXu0mjfELa-z delta 536 zcmV+z0_XjX1*QZciBL{Q4GJ0x0000DNk~Le0000E0000G2nGNE049`9I*}n7e+v=- z01FZU(%pXi0000SbVXQnQ*UN;cVTj606}DLVr3vkX>w(EZ*psMAVX6&=)AIw0004? zNkl1l z2s)O|ISq%yYv2qhBmpq!x-PbDtJP|?&BbD&*=(libgB@7CX>I>wOlSWpU>4ajY0@ouh(kZR^##b8aOjOcpGEn!}=B8CA`&cwTW*pf4(1>t*Yw6 z0D~Cg?Z2H!DItlJ5;4Z@zOHM^vb?AO$X5<=WNIiae1#pH95eq7}XB^(Bq5+30JCpdq3L+Ynk0jLMLyutL_2Ym|I%ndJ6 zu?HrXA6>ltxmEPW;*`^qZr7)u-t-gPfIfri<0U;u3Dk&s&#(SKGDpDIPdxa9Rt~ie zRvuc%m(yoEm_ty2`TXntoul>li').length > 0) { + + //create pad file type getMimeIcon('text/plain', function(icon) { $('
  • ' + t('files_etherpad', 'Pad') + '

  • ') .attr('id', 'newPadFile') @@ -89,10 +102,11 @@ $(document).ready(function(){ OC.Notification.show(t('files_etherpad', 'Padname cannot be empty')); return false; } - var filename = getUniqueName(rawfilename+'.url'); + var filename = getUniqueName(rawfilename+'.pad.url'); //get etherpad url $.get( OC.filePath('files_etherpad', 'ajax', 'host.php'), + {type:'pad'}, function (url) { //generate .url file var content='[InternetShortcut]\nURL='+url+'/p/'+CryptoJS.MD5('owncloud' + new Date().getMilliseconds() + 'etherpad'); @@ -129,5 +143,76 @@ $(document).ready(function(){ }); }); }); + //create calc file type + getMimeIcon('text/plain', function(icon) { + $('
  • ' + t('files_etherpad', 'Calc') + '

  • ') + .attr('id', 'newCalcFile') + .appendTo('div#new>ul') + .css('background-image', 'url(' + OC.imagePath('files_etherpad', 'calc.png') + ')') + .data('type', 'text') + .off('click') + .click(function() { + //prevent double input + if($(this).children('p').length==0) + return; + //show input for pad name + $(this).children('p').remove(); + var form=$('
    '); + var input=$(''); + form.append(input); + form.appendTo('#newCalcFile'); + input.focus(); + form.submit(function(event){ + event.stopPropagation(); + event.preventDefault(); + //check pad name + var rawfilename = input.val(); + if (rawfilename.length == 0) { + $("#notification").text(''); + OC.Notification.show(t('files_etherpad', 'Document name cannot be empty')); + return false; + } + var filename = getUniqueName(rawfilename+'.calc.url'); + //get etherpad url + $.get( + OC.filePath('files_etherpad', 'ajax', 'host.php'), + {type:'calc'}, + function (url) { + //generate .url file + var content='[InternetShortcut]\nURL='+url+'/'+CryptoJS.MD5('owncloud' + new Date().getMilliseconds() + 'ethercalc'); + //send file to server using files app api + $.post( + OC.filePath('files','ajax','newfile.php'), + {dir:$('#dir').val(),filename:filename,content:content}, + function(result){ + if (result.status == 'success') { + //update file list + var date=new Date(); + FileList.addFile(filename,0,date,false,false); + var tr=$('tr').filterAttr('data-file',filename); + tr.attr('data-mime','text/x-url'); + tr.attr('data-id', result.data.id); + var path = $('#dir').val(); + getMimeIcon('text/plain',function(path){ + tr.find('td.filename').attr('style','background-image:url('+OC.imagePath('files_etherpad', 'calc.png')+')'); + }); + $("#notification").text(''); + OC.Notification.show(t('files_etherpad', t('files_etherpad', 'New document named ')+filename+t('files_etherpad', ' was created.'))); + } + else + OC.dialogs.alert(result.data.message, 'Error'); + } + ); + } + ); + //restore description, close new dialogue + var li=form.parent(); + form.remove(); + li.append('

    '+t('files_etherpad', 'Calc')+'

    '); + $('#new>a').click(); + }); + }); + }); + } }); diff --git a/js/loader.js b/js/loader.js deleted file mode 100644 index 44e90b3..0000000 --- a/js/loader.js +++ /dev/null @@ -1,107 +0,0 @@ -$.fn.filterExtension = function(extension) { - return this.filter(function() { - var filename = $(this).attr('data-file'); - if(filename.lastIndexOf('.')){ - return filename.substr(filename.lastIndexOf('.')+1) === extension; - } - }); -}; - -function FileToPad(dir,file){ - pad=this; - pad.dir=dir; - pad.file=file; - pad.url='about:blank'; - $.get( - OC.filePath('files','ajax','download.php?dir='+dir+'&files='+file), - function name(link) { - pad.url=link.split('\n')[1].substr(4); - pad.show(); - } - ); -} - -FileToPad.prototype={ - show:function(){ - $("#editor").hide(); - $('#content table').hide(); - $('#controls').hide(); - var oldcontent = $('#content').html(); - $('#content').html(oldcontent+'
    Titel: '+pad.file.replace('.pad','')+', Öffentlicher Link: '+pad.url+''+'x
    '); - $('#pageWidthOption').attr('selected','selected'); - $('#filetopad_bar').css('padding-left','30px'); - - $('#filetopad_close').click(function(){pad.hide();}); - $('#filetopad_close').css('float','right'); - $('#filetopad_close').css('padding','5px'); - }, - hide:function(){ - $('#content table').show(); - $('#controls').show(); - $('#editor').show(); - $('iframe').remove(); - $('a.action').remove(); - $('#filetopad_bar').remove(); - } -}; - -$(document).ready(function(){ - if(location.href.indexOf('files')!=-1) { - $('tr').filterAttr('data-type', 'file').filterExtension( 'pad').attr('data-mime','text/x-url'); - $('tr').filterAttr('data-type', 'file').filterExtension( 'pad').children('td:first-child').css('background-image','url('+OC.imagePath('files_etherpad', 'pad.png')+')'); - if (typeof FileActions!=='undefined'){ - FileActions.register('text/x-url',t('files_etherpad','Edit'), OC.PERMISSION_READ, '',function(filename){ - pad=new FileToPad($('#dir').val(),filename); - }); - FileActions.setDefault('text/x-url',t('files_etherpad','Edit')); - } - } - if($('div#new>ul>li').length > 0) { - getMimeIcon('text/plain', function(icon) { - $('
  • ' + t('files_etherpad', 'Pad') + '

  • ') - .attr('id', 'newPadFile') - .appendTo('div#new>ul') - .css('background-image', 'url(' + OC.imagePath('files_etherpad', 'pad.png') + ')') - .data('type', 'text') - .children('p') - .click(function() { - $(this).hide(); - var form=$('
    '); - var input=$(''); - form.append(input); - form.appendTo('#newPadFile'); - input.focus(); - form.submit(function(event){ - event.stopPropagation(); - event.preventDefault(); - $.get( - OC.filePath('files_etherpad', 'ajax', 'host.php'), - function (url) { - var filename=input.val(); - var content='[EtherpadShortcut]\nURL='+url+'/p/'+CryptoJS.MD5('owncloud' + new Date().getMilliseconds() + 'etherpad'); - $.post( - OC.filePath('files','ajax','newfile.php'), - {dir:$('#dir').val(),filename:filename+'.pad',content:content}, - function(result){ - if (result.status == 'success') { - var date=new Date(); - FileList.addFile(filename+'.pad',0,date,false,false); - var tr=$('tr').filterAttr('data-file',filename+'.pad'); - tr.attr('data-mime','text/x-url'); - tr.attr('data-id', result.data.id); - var path = $('#dir').val(); - getMimeIcon('text/plain',function(path){ - tr.find('td.filename').attr('style','background-image:url('+OC.imagePath('files_etherpad', 'pad.png')+')'); - }); - } else { - OC.dialogs.alert(result.data.message, 'Error'); - } - } - ); - } - ); - }); - }); - }); - } -}); diff --git a/l10n/de.php b/l10n/de.php index 90dc4dd..d3eb609 100644 --- a/l10n/de.php +++ b/l10n/de.php @@ -1,12 +1,16 @@ 'Collaborative Documents', 'Edit' => 'Ändern', 'Etherpad Host' => 'Etherpad Host', + 'Ethercalc Host' => 'Ethercalc Host', 'ex' => 'Z.B.', 'Title' => 'Titel', 'public link' => 'öffentlicher Link', 'Pad' => 'Pad', + 'Calc' => 'Calc', 'save' => 'speichern', 'Padname cannot be empty' => 'Pad muss benannt werden', - 'New pad named ' => 'Neues Pad mit dem Namen ', + 'Document name cannot be empty' => 'Document name cannot be empty', + 'New document named ' => 'Neues document mit dem Namen ', ' was created.' => ' wurde erstellt.', ); diff --git a/l10n/fr.php b/l10n/fr.php index 4a8381c..a0b2261 100644 --- a/l10n/fr.php +++ b/l10n/fr.php @@ -1,12 +1,16 @@ 'Documents collaboratifs', 'Edit' => 'Éditer', 'Etherpad Host' => 'Hôte Etherpad', - 'ex' => 'ex', + 'Ethercalc Host' => 'Hôte Ethercalc', + 'ex' => 'ex:', 'Title' => 'Titre', - 'public link' => 'Lien publique', - 'Pad' => 'Pad', - 'save' => 'save', + 'public link' => 'Lien public', + 'Pad' => 'Document collaboratif', + 'Calc' => 'Tableur collaboratif', + 'save' => 'Sauvegarder', 'Padname cannot be empty' => 'Le nom du Pad ne peut être vide', - 'New pad named ' => 'Nouveau Pad nommé ', + 'Document name cannot be empty' => 'Le nom du document ne peut être vide', + 'New document named ' => 'Nouveau document nommé ', ' was created.' => ' a été créé.', ); diff --git a/push b/push deleted file mode 100644 index 85a8912..0000000 --- a/push +++ /dev/null @@ -1,3 +0,0 @@ -sudo -u upload git add . -sudo -u upload git commit -m "init" -sudo -u upload git push -u origin master diff --git a/settings.php b/settings.php index c63a923..9e2283d 100644 --- a/settings.php +++ b/settings.php @@ -22,6 +22,7 @@ */ $params = array( 'files_etherpad_host', + 'files_etherpad_calc_host', ); if ($_POST) { diff --git a/templates/settings.php b/templates/settings.php index 3be797f..26a5c12 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -1,12 +1,18 @@
    - Files Etherpad + t('Collaborative Documents');?>

    t('ex'); ?>: http://lite.framapad.org - +

    +

    + + + t('ex'); ?>: http://framacalc.org +

    From 699df4f493ff6e51a6e6aa17b135107a1f9cb7ac Mon Sep 17 00:00:00 2001 From: Bastien Ho Date: Wed, 3 Apr 2013 10:14:37 +0200 Subject: [PATCH 2/2] bug fix --- CHANGELOG.txt | 4 ++++ appinfo/info.xml | 2 +- appinfo/version | 2 +- js/files_etherpad.js | 9 +++------ l10n/de.php | 2 +- l10n/fr.php | 2 +- templates/settings.php | 4 ++-- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 37774df..93dbcfb 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,7 @@ +v 0.3.0 +Add : Ethercalc support +Fix : Opening a document kill hover actions + v 0.2.0 Add : OC5 compability Add : DE translation diff --git a/appinfo/info.xml b/appinfo/info.xml index d7d7fde..6e5eeb5 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -3,7 +3,7 @@ files_etherpad Files Etherpad Create etherpad shortcuts - 0.2.0 + 0.3.0 CC BY-NC 3.0 Bastien Ho (EELV), Ernesto Ruge 5.0 diff --git a/appinfo/version b/appinfo/version index 0ea3a94..0d91a54 100644 --- a/appinfo/version +++ b/appinfo/version @@ -1 +1 @@ -0.2.0 +0.3.0 diff --git a/js/files_etherpad.js b/js/files_etherpad.js index 89fa2c9..b87d4d6 100644 --- a/js/files_etherpad.js +++ b/js/files_etherpad.js @@ -36,15 +36,12 @@ FileToPad.prototype={ $("#editor").hide(); $('#content table').hide(); $('#controls').hide(); - var oldcontent = $('#content').html(); //pad headline - $('#content').html(oldcontent+'
    '+t('files_etherpad', 'Title')+': '+pad.file.replace('.url','')+', '+t('files_etherpad', 'public link')+': '+pad.url+''+'x
    '); + $('#content').append('
    '+t('files_etherpad', 'Title')+': '+pad.file.replace('.url','')+', '+t('files_etherpad', 'public link')+': '+pad.url+''+'x
    '); $('#pageWidthOption').attr('selected','selected'); - $('#filetopad_bar').css('padding-left','30px'); - + $('#filetopad_bar').css('padding-left','30px'); $('#filetopad_close').click(function(){pad.hide();}); - $('#filetopad_close').css('float','right'); - $('#filetopad_close').css('padding','5px'); + $('#filetopad_close').css({float:'right',padding:'5px'}); }, hide:function(){ $('#controls').show(); diff --git a/l10n/de.php b/l10n/de.php index d3eb609..4bdfdea 100644 --- a/l10n/de.php +++ b/l10n/de.php @@ -3,7 +3,7 @@ 'Edit' => 'Ändern', 'Etherpad Host' => 'Etherpad Host', 'Ethercalc Host' => 'Ethercalc Host', - 'ex' => 'Z.B.', + 'ex:' => 'Z.B.:', 'Title' => 'Titel', 'public link' => 'öffentlicher Link', 'Pad' => 'Pad', diff --git a/l10n/fr.php b/l10n/fr.php index a0b2261..1ae2ca9 100644 --- a/l10n/fr.php +++ b/l10n/fr.php @@ -3,7 +3,7 @@ 'Edit' => 'Éditer', 'Etherpad Host' => 'Hôte Etherpad', 'Ethercalc Host' => 'Hôte Ethercalc', - 'ex' => 'ex:', + 'ex:' => 'ex :', 'Title' => 'Titre', 'public link' => 'Lien public', 'Pad' => 'Document collaboratif', diff --git a/templates/settings.php b/templates/settings.php index 26a5c12..4486d51 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -5,13 +5,13 @@ - t('ex'); ?>: http://lite.framapad.org + t('ex:'); ?> http://lite.framapad.org

    - t('ex'); ?>: http://framacalc.org + t('ex:'); ?> http://framacalc.org