From bb54ab0db8bfa1ea62bfa2404cb084a9a68d6e20 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Tue, 7 Jun 2016 12:28:02 +0200 Subject: add hide file list option --- apps/files_sharing/js/public.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'apps/files_sharing/js/public.js') diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index 572ccc47b71..7f780fd09e7 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -238,6 +238,11 @@ OCA.Sharing.PublicApp = { $(this).select(); }); + $(document).on('click', '.content-wrapper-upload', function (e) { + //e.preventDefault(); + $('#file_upload_start').focus().trigger('click'); + }); + $('.save-form').submit(function (event) { event.preventDefault(); @@ -302,7 +307,7 @@ OCA.Sharing.PublicApp = { $('#save-button-confirm') .removeClass("icon-loading-small") .addClass("icon-confirm"); - + } else { $('#save-button-confirm') @@ -314,7 +319,7 @@ OCA.Sharing.PublicApp = { toggleLoading(); var location = window.location.protocol + '//' + window.location.host + OC.webroot; - + if(remote.substr(-1) !== '/') { remote += '/' }; -- cgit v1.2.3 From 6e99b0f59d3b0278c45d42dcec01ff554a89d979 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Thu, 9 Jun 2016 17:45:16 +0200 Subject: Make uploading possible via select and cleanup CSS --- apps/files/ajax/upload.php | 23 +++++++++++++++ apps/files_sharing/css/public.css | 51 +++++++++++++++++++++++++-------- apps/files_sharing/js/files_drop.js | 25 ++++++++++------ apps/files_sharing/js/public.js | 10 +------ apps/files_sharing/templates/public.php | 14 ++++++--- 5 files changed, 90 insertions(+), 33 deletions(-) (limited to 'apps/files_sharing/js/public.js') diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index 9cc9c279700..98066845734 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -161,6 +161,15 @@ if (\OC\Files\Filesystem::isValidPath($dir) === true) { $resolution = null; } + if(isset($_POST['dirToken'])) { + // If it is a read only share the resolution will always be autorename + $shareManager = \OC::$server->getShareManager(); + $share = $shareManager->getShareByToken((string)$_POST['dirToken']); + if (!($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) { + $resolution = 'autorename'; + } + } + // target directory for when uploading folders $relativePath = ''; if(!empty($_POST['file_directory'])) { @@ -247,6 +256,20 @@ if (\OC\Files\Filesystem::isValidPath($dir) === true) { } if ($error === false) { + // Do not leak file information if it is a read-only share + if(isset($_POST['dirToken'])) { + $shareManager = \OC::$server->getShareManager(); + $share = $shareManager->getShareByToken((string)$_POST['dirToken']); + if (!($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) { + $newResults = []; + foreach($result as $singleResult) { + $fileName = $singleResult['originalname']; + $newResults['filename'] = $fileName; + $newResults['mimetype'] = \OC::$server->getMimeTypeDetector()->detectPath($fileName); + } + $result = $newResults; + } + } OCP\JSON::encodedPrint($result); } else { OCP\JSON::error(array(array('data' => array_merge(array('message' => $error, 'code' => $errorCode), $storageStats)))); diff --git a/apps/files_sharing/css/public.css b/apps/files_sharing/css/public.css index 18c8781a469..a644b850556 100644 --- a/apps/files_sharing/css/public.css +++ b/apps/files_sharing/css/public.css @@ -159,36 +159,63 @@ thead { cursor: pointer; } -#body-public #emptycontent h2 { + + +#public-upload .avatardiv { + margin: 0 auto; +} + +#public-upload #emptycontent h2 { margin: 10px 0 5px 0; } -#body-public #emptycontent h2+p { +#public-upload #emptycontent h2+p { margin-bottom: 30px; } -#body-public #emptycontent .icon-folder { +#public-upload #emptycontent .icon-folder { height: 16px; width: 16px; background-size: 16px; display: inline-block; vertical-align: text-top; margin-bottom: 0; + margin-right: 5px; opacity: 1; } -#body-public #emptycontent .button { - background-size: 32px; - height: 32px; - width: 32px; - background-position: 16px; +#public-upload #emptycontent .button { + background-size: 16px; + height: 16px; + width: 16px; + background-position: 16px; opacity: .7; font-size: 20px; margin: 20px; padding: 10px 20px; - padding-left: 64px; + padding-left: 42px; + font-weight: normal; } -#body-public .avatardiv { - margin: 0 auto; -} \ No newline at end of file +#public-upload #emptycontent ul { + width: 160px; + margin: 25px auto; + text-align: left; +} + +#public-upload #emptycontent li { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + padding: 7px 0; +} + +#public-upload #emptycontent li img { + vertical-align: text-bottom; + margin-right: 5px; +} + +#public-upload li span.icon-loading-small { + padding-left: 18px; + margin-right: 7px; +} diff --git a/apps/files_sharing/js/files_drop.js b/apps/files_sharing/js/files_drop.js index ced26fda220..3c1ccd63da5 100644 --- a/apps/files_sharing/js/files_drop.js +++ b/apps/files_sharing/js/files_drop.js @@ -15,24 +15,33 @@ // Prevent the default browser drop action: e.preventDefault(); }); - $('#publicUploadDiv').fileupload({ + $('#public-upload').fileupload({ url: OC.linkTo('files', 'ajax/upload.php'), dataType: 'json', - //maxFileSize: fileUploadContainer.data('maxupload'), - messages: { - maxFileSize: t('files_sharing', 'File is bigger than allowed.') - }, - dropZone: $('#publicUploadDiv'), + dropZone: $('#public-upload'), formData: { dirToken: $('#sharingToken').val() + }, + add: function(e, data) { + _.each(data['files'], function(file) { + $('#public-upload ul').append('
  • '+escapeHTML(file.name)+'
  • '); + }); + data.submit(); + }, + success: function (response) { + var mimeTypeUrl = OC.MimeType.getIconUrl(response['mimetype']); + $('#public-upload ul li[data-name="'+escapeHTML(response['filename'])+'"]').html(' '+escapeHTML(response['filename'])); } }); - + $('#public-upload .button.icon-upload').click(function(e) { + e.preventDefault(); + $('#public-upload #emptycontent input').focus().trigger('click'); + }); } }; $(document).ready(function() { - if($('#uploadOnlyInterface').val() === "1") { + if($('#upload-only-interface').val() === "1") { $('.avatardiv').avatar($('#sharingUserId').val(), 128, true); } diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index 7f780fd09e7..bf06b2cd55b 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -238,11 +238,6 @@ OCA.Sharing.PublicApp = { $(this).select(); }); - $(document).on('click', '.content-wrapper-upload', function (e) { - //e.preventDefault(); - $('#file_upload_start').focus().trigger('click'); - }); - $('.save-form').submit(function (event) { event.preventDefault(); @@ -307,9 +302,7 @@ OCA.Sharing.PublicApp = { $('#save-button-confirm') .removeClass("icon-loading-small") .addClass("icon-confirm"); - - } - else { + } else { $('#save-button-confirm') .removeClass("icon-confirm") .addClass("icon-loading-small"); @@ -319,7 +312,6 @@ OCA.Sharing.PublicApp = { toggleLoading(); var location = window.location.protocol + '//' + window.location.host + OC.webroot; - if(remote.substr(-1) !== '/') { remote += '/' }; diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php index 0989b35f3b1..f4c954c76d5 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -41,7 +41,9 @@ OCP\Util::addscript('files', 'keyboardshortcuts'); - + + + @@ -89,7 +91,7 @@ OCP\Util::addscript('files', 'keyboardshortcuts');
    > - +
    @@ -117,13 +119,17 @@ OCP\Util::addscript('files', 'keyboardshortcuts');
    - -
    + +

    t('Upload files to %s', [$_['shareOwner']])) ?>

    + + t('Select')) ?> +
      +
    -- cgit v1.2.3 From e878e786e04b4c4dcf30e9355003f07592bd9b51 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Thu, 9 Jun 2016 18:12:58 +0200 Subject: Fix public upload for normal shares --- apps/files_sharing/css/public.css | 2 -- apps/files_sharing/js/public.js | 5 ++++- apps/files_sharing/templates/public.php | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'apps/files_sharing/js/public.js') diff --git a/apps/files_sharing/css/public.css b/apps/files_sharing/css/public.css index a644b850556..628fd45f242 100644 --- a/apps/files_sharing/css/public.css +++ b/apps/files_sharing/css/public.css @@ -159,8 +159,6 @@ thead { cursor: pointer; } - - #public-upload .avatardiv { margin: 0 auto; } diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index bf06b2cd55b..f207eff7909 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -302,7 +302,9 @@ OCA.Sharing.PublicApp = { $('#save-button-confirm') .removeClass("icon-loading-small") .addClass("icon-confirm"); - } else { + + } + else { $('#save-button-confirm') .removeClass("icon-confirm") .addClass("icon-loading-small"); @@ -312,6 +314,7 @@ OCA.Sharing.PublicApp = { toggleLoading(); var location = window.location.protocol + '//' + window.location.host + OC.webroot; + if(remote.substr(-1) !== '/') { remote += '/' }; diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php index f4c954c76d5..ef9e4bfa574 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -90,9 +90,10 @@ OCP\Util::addscript('files', 'keyboardshortcuts');
    -
    > +
    -
    +
    +
    -- cgit v1.2.3