]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add generic 'share by link' URL generator in share.js
authorlibasys <sebastian.doell@libasys.de>
Fri, 14 Mar 2014 11:10:05 +0000 (12:10 +0100)
committerMorris Jobke <hey@morrisjobke.de>
Mon, 19 May 2014 11:12:59 +0000 (13:12 +0200)
Some more global definition to autogenerate a "Shared by Link" with token! Why we not add these lines for more global use of the public service feature? At the moment there is a pr for sharing a calendar by Link. With this little mod the calendar can work with the core share api and needs no own js share definition!

core/js/share.js

index 92db67117be9ac28e8d99b1f0bf9d7038ef9e50a..583f92dd39d024fedb1ef0d890dc5ac076223e51 100644 (file)
@@ -495,6 +495,10 @@ OC.Share={
        showLink:function(token, password, itemSource) {
                OC.Share.itemShares[OC.Share.SHARE_TYPE_LINK] = true;
                $('#linkCheckbox').attr('checked', true);
+               
+               //check itemType
+               var linkSharetype=$('#dropdown').data('item-type');
+               
                if (! token) {
                        //fallback to pre token link
                        var filename = $('tr').filterAttr('data-id', String(itemSource)).data('file');
@@ -508,7 +512,15 @@ OC.Share={
                        var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=files&'+type+'='+encodeURIComponent(file);
                } else {
                        //TODO add path param when showing a link to file in a subfolder of a public link share
-                       var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=files&t='+token;
+                       var service='';
+                       if(linkSharetype === 'folder' || linkSharetype === 'file'){
+                               service='files';
+                       }else{
+                               service=linkSharetype;
+                       }
+                       
+                       var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service='+service+'&t='+token;
+
                }
                $('#linkText').val(link);
                $('#linkText').show('blind');