diff options
author | Roman Geber <rgeber@owncloudapps.com> | 2013-06-25 12:24:14 +0200 |
---|---|---|
committer | Roman Geber <rgeber@owncloudapps.com> | 2013-06-25 12:24:14 +0200 |
commit | ddb0ff346d3d8063f88fdba8749e098a81b92d54 (patch) | |
tree | 69004e69ed8ca2537d1029d9729d112feb6b5c20 /apps/files_sharing | |
parent | c3b8f2bf64ef7b6cbdabb382b1c0a721bddb4041 (diff) | |
download | nextcloud-server-ddb0ff346d3d8063f88fdba8749e098a81b92d54.tar.gz nextcloud-server-ddb0ff346d3d8063f88fdba8749e098a81b92d54.zip |
Public upload feature
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/css/public.css | 61 | ||||
-rw-r--r-- | apps/files_sharing/js/public.js | 19 | ||||
-rw-r--r-- | apps/files_sharing/public.php | 18 | ||||
-rw-r--r-- | apps/files_sharing/templates/public.php | 42 |
4 files changed, 133 insertions, 7 deletions
diff --git a/apps/files_sharing/css/public.css b/apps/files_sharing/css/public.css index 13298f113f8..68549d14fe1 100644 --- a/apps/files_sharing/css/public.css +++ b/apps/files_sharing/css/public.css @@ -15,15 +15,26 @@ body { padding:.5em; } -#details { +#header #details { color:#fff; + float: left; } +#header #public_upload, #header #download { font-weight:700; - margin-left:2em; + margin: 0 0.4em 0 2em; + padding: 0 5px; + height: 27px; + float: left; + +} + +#header #public_upload { + margin-left: 0.3em; } +#header #public_upload img, #header #download img { padding-left:.1em; padding-right:.3em; @@ -73,3 +84,49 @@ thead{ background-color: white; padding-left:0 !important; /* fixes multiselect bar offset on shared page */ } + +#data-upload-form { + position: relative; + right: 0; + height: 27px; + overflow: hidden; + padding: 0; + float: right; + display: inline; + margin: 0; +} + +#file_upload_start { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; + filter: alpha(opacity=0); + opacity: 0; + z-index: 20; + position: absolute !important; + top: 0; + left: 0; + width: 100% !important; +} + +.header-right #download span { + position: relative; + bottom: 3px; +} + +#publicUploadButtonMock { + position:relative; + display:block; + width:100%; + height:27px; + cursor:pointer; + z-index:10; + background-image:url('%webroot%/core/img/actions/upload.svg'); + background-repeat:no-repeat; + background-position:7px 6px; +} + +#publicUploadButtonMock span { + margin: 0 5px 0 28px; + position: relative; + top: -2px; + color: #555; +} diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index 916e35419c1..0244f392a0e 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -7,6 +7,8 @@ function fileDownloadPath(dir, file) { return url; } +var form_data; + $(document).ready(function() { if (typeof FileActions !== 'undefined') { @@ -46,4 +48,19 @@ $(document).ready(function() { }); } -});
\ No newline at end of file + // Add some form data to the upload handler + file_upload_param.formData = { + MAX_FILE_SIZE: $('#uploadMaxFilesize').val(), + requesttoken: $('#publicUploadRequestToken').val(), + dirToken: $('#dirToken').val(), + appname: 'files_sharing', + subdir: $('input#dir').val() + }; + + // Add Uploadprogress Wrapper to controls bar + $('#controls').append($('#additional_controls div#uploadprogresswrapper')); + + // Cancel upload trigger + $('#cancel_upload_button').click(Files.cancelUploads); + +}); diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index 98d2a84fb66..fa8c25fc98d 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -132,15 +132,25 @@ if (isset($path)) { } exit(); } else { + OCP\Util::addScript('files', 'file-upload'); OCP\Util::addStyle('files_sharing', 'public'); OCP\Util::addScript('files_sharing', 'public'); OCP\Util::addScript('files', 'fileactions'); + OCP\Util::addScript('files', 'jquery.iframe-transport'); + OCP\Util::addScript('files', 'jquery.fileupload'); + $maxUploadFilesize=OCP\Util::maxUploadFilesize($path); $tmpl = new OCP\Template('files_sharing', 'public', 'base'); $tmpl->assign('uidOwner', $shareOwner); $tmpl->assign('displayName', \OCP\User::getDisplayName($shareOwner)); $tmpl->assign('filename', $file); + $tmpl->assign('directory_path', $linkItem['file_target']); $tmpl->assign('mimetype', \OC\Files\Filesystem::getMimeType($path)); $tmpl->assign('fileTarget', basename($linkItem['file_target'])); + $tmpl->assign('dirToken', $linkItem['token']); + $tmpl->assign('allowPublicUploadEnabled', (($linkItem['permissions'] & OCP\PERMISSION_CREATE) ? true : false )); + $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); + $tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); + $urlLinkIdentifiers= (isset($token)?'&t='.$token:'') .(isset($_GET['dir'])?'&dir='.$_GET['dir']:'') .(isset($_GET['file'])?'&file='.$_GET['file']:''); @@ -191,15 +201,17 @@ if (isset($path)) { $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', ''); $breadcrumbNav->assign('breadcrumb', $breadcrumb); $breadcrumbNav->assign('baseURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&path='); + $maxUploadFilesize=OCP\Util::maxUploadFilesize($path); $folder = new OCP\Template('files', 'index', ''); $folder->assign('fileList', $list->fetchPage()); $folder->assign('breadcrumb', $breadcrumbNav->fetchPage()); $folder->assign('dir', $getPath); $folder->assign('isCreatable', false); - $folder->assign('permissions', 0); + $folder->assign('permissions', OCP\PERMISSION_READ); + $folder->assign('isPublic',true); $folder->assign('files', $files); - $folder->assign('uploadMaxFilesize', 0); - $folder->assign('uploadMaxHumanFilesize', 0); + $folder->assign('uploadMaxFilesize', $maxUploadFilesize); + $folder->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); $folder->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); $folder->assign('usedSpacePercent', 0); $tmpl->assign('folder', $folder->fetchPage()); diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php index adf3c3e9cc8..3a1c370b4c0 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -1,3 +1,7 @@ +<div id="notification-container"> + <div id="notification" style="display: none;"></div> +</div> + <input type="hidden" name="dir" value="<?php p($_['dir']) ?>" id="dir"> <input type="hidden" name="downloadURL" value="<?php p($_['downloadURL']) ?>" id="downloadURL"> <input type="hidden" name="filename" value="<?php p($_['filename']) ?>" id="filename"> @@ -13,13 +17,49 @@ <span id="details"><?php p($l->t('%s shared the file %s with you', array($_['displayName'], $_['fileTarget']))) ?></span> <?php endif; ?> + + <?php if (!isset($_['folder']) || $_['allowZipDownload']): ?> <a href="<?php p($_['downloadURL']); ?>" class="button" id="download"><img class="svg" alt="Download" src="<?php print_unescaped(OCP\image_path("core", "actions/download.svg")); ?>" - /><?php p($l->t('Download'))?></a> + /><span><?php p($l->t('Download'))?></span></a> <?php endif; ?> + + <?php if ($_['allowPublicUploadEnabled']):?> + + + <input type="hidden" id="publicUploadRequestToken" name="requesttoken" value="<?php p($_['requesttoken']) ?>" /> + <input type="hidden" id="dirToken" name="dirToken" value="<?php p($_['dirToken']) ?>" /> + <input type="hidden" id="uploadMaxFilesize" name="uploadMaxFilesize" value="<?php p($_['uploadMaxFilesize']) ?>" /> + <input type="hidden" id="uploadMaxHumanFilesize" name="uploadMaxHumanFilesize" value="<?php p($_['uploadMaxHumanFilesize']) ?>" /> + <input type="hidden" id="directory_path" name="directory_path" value="<?php p($_['directory_path']) ?>" /> + + + <div id="data-upload-form" class="button"> + <input id="file_upload_start" type="file" name="files[]" data-url="<?php print_unescaped(OCP\Util::linkTo('files', 'ajax/upload.php')); ?>" multiple> + <a href="#" id="publicUploadButtonMock" class="svg"> + <span><?php p($l->t('Upload'))?></span> + </a> + </div> + + </div> + + <div id="additional_controls" style="display:none"> + <div id="uploadprogresswrapper"> + <div id="uploadprogressbar"></div> + <input id="cancel_upload_button" type="button" class="stop" style="display:none" + value="<?php p($l->t('Cancel upload'));?>" + /> + </div> + + + + + <?php endif; ?> + </div> </div></header> +<div id="content"> <div id="preview"> <?php if (isset($_['folder'])): ?> <?php print_unescaped($_['folder']); ?> |