From 0f2ad9862e98e00fdc250bf8405bf6404d40b1ed Mon Sep 17 00:00:00 2001 From: kondou Date: Mon, 7 Apr 2014 23:16:25 +0200 Subject: Initial work on shorter links --- core/ajax/share.php | 2 ++ core/js/share.js | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/ajax/share.php b/core/ajax/share.php index c6da79a8a42..536f0e2ebd8 100644 --- a/core/ajax/share.php +++ b/core/ajax/share.php @@ -46,6 +46,8 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo (!empty($_POST['expirationDate']) ? new \DateTime($_POST['expirationDate']) : null) ); + $token = base_convert($token, 16, 36); + if (is_string($token)) { OC_JSON::success(array('data' => array('token' => $token))); } else { diff --git a/core/js/share.js b/core/js/share.js index f1652370d35..d00b5f1ccf9 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -663,6 +663,8 @@ OC.Share={ // TODO: use oc webroot ? var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service=files&'+type+'='+encodeURIComponent(file); } else { + // convert the token to base36 + //token = parseInt(token, 16).toString(36); //TODO add path param when showing a link to file in a subfolder of a public link share var service=''; if(linkSharetype === 'folder' || linkSharetype === 'file'){ @@ -672,8 +674,11 @@ OC.Share={ } // TODO: use oc webroot ? - var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service='+service+'&t='+token; - + if (service !== 'files') { + var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service='+service+'&t='+token; + } else { + var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 's.php')+'?t='+token; + } } $('#linkText').val(link); $('#linkText').show('blind'); -- cgit v1.2.3