diff options
-rw-r--r-- | .gitignore | 3 | ||||
m--------- | 3rdparty | 0 | ||||
-rw-r--r-- | apps/files/css/files.css | 15 | ||||
-rw-r--r-- | apps/files/js/filelist.js | 110 | ||||
-rw-r--r-- | apps/files/templates/part.list.php | 40 | ||||
-rw-r--r-- | apps/files_trashbin/js/trash.js | 2 | ||||
-rw-r--r-- | apps/files_trashbin/lib/trash.php | 5 | ||||
-rw-r--r-- | config/config.sample.php | 15 | ||||
-rw-r--r-- | core/js/placeholder.js | 65 | ||||
-rw-r--r-- | lib/base.php | 16 | ||||
-rw-r--r-- | lib/log/rotate.php | 35 |
11 files changed, 258 insertions, 48 deletions
diff --git a/.gitignore b/.gitignore index 43f3cab9121..724f2460b04 100644 --- a/.gitignore +++ b/.gitignore @@ -82,6 +82,9 @@ nbproject # Tests /tests/phpunit.xml +# Node Modules +/build/node_modules/ + # Tests - auto-generated files /data-autotest /tests/coverage* diff --git a/3rdparty b/3rdparty -Subproject 03c3817ff132653c794fd04410977952f69fd61 +Subproject 21b466b72cdd4c823c011669593ecef1defb1f3 diff --git a/apps/files/css/files.css b/apps/files/css/files.css index 7d5fe6445b7..a9b93dc2dee 100644 --- a/apps/files/css/files.css +++ b/apps/files/css/files.css @@ -170,7 +170,20 @@ a.action>img { max-height:16px; max-width:16px; vertical-align:text-bottom; } } .summary { - opacity: .5; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)"; + filter: alpha(opacity=30); + opacity: .3; + height: 70px; +} + +.summary:hover, .summary, table tr.summary td { + background-color: transparent; +} + +.summary td { + padding-top: 8px; + padding-bottom: 8px; + border-bottom: none; } .summary .info { diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 10801af3ead..e11cc70802b 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -144,6 +144,7 @@ var FileList={ remove:function(name){ $('tr').filterAttr('data-file',name).find('td.filename').draggable('destroy'); $('tr').filterAttr('data-file',name).remove(); + FileList.updateFileSummary(); if($('tr[data-file]').length==0){ $('#emptyfolder').show(); } @@ -176,6 +177,7 @@ var FileList={ $('#fileList').append(element); } $('#emptyfolder').hide(); + FileList.updateFileSummary(); }, loadingDone:function(name, id){ var mime, tr=$('tr').filterAttr('data-file',name); @@ -391,6 +393,7 @@ var FileList={ }); procesSelection(); checkTrashStatus(); + FileList.updateFileSummary(); } else { $.each(files,function(index,file) { var deleteAction = $('tr').filterAttr('data-file',files[i]).children("td.date").children(".action.delete"); @@ -398,6 +401,111 @@ var FileList={ }); } }); + }, + createFileSummary: function() { + if( $('#fileList tr').length > 0 ) { + var totalDirs = 0; + var totalFiles = 0; + var totalSize = 0; + + // Count types and filesize + $.each($('tr[data-file]'), function(index, value) { + if ($(value).data('type') === 'dir') { + totalDirs++; + } else if ($(value).data('type') === 'file') { + totalFiles++; + } + totalSize += parseInt($(value).data('size')); + }); + + // Get translations + var directoryInfo = n('files', '%n folder', '%n folders', totalDirs); + var fileInfo = n('files', '%n file', '%n files', totalFiles); + + var infoVars = { + dirs: '<span class="dirinfo">'+directoryInfo+'</span><span class="connector">', + files: '</span><span class="fileinfo">'+fileInfo+'</span>' + } + + var info = t('files', '{dirs} and {files}', infoVars); + + // don't show the filesize column, if filesize is NaN (e.g. in trashbin) + if (isNaN(totalSize)) { + var fileSize = ''; + } else { + var fileSize = '<td class="filesize">'+humanFileSize(totalSize)+'</td>'; + } + + $('#fileList').append('<tr class="summary"><td><span class="info">'+info+'</span></td>'+fileSize+'<td></td></tr>'); + + var $dirInfo = $('.summary .dirinfo'); + var $fileInfo = $('.summary .fileinfo'); + var $connector = $('.summary .connector'); + + // Show only what's necessary, e.g.: no files: don't show "0 files" + if ($dirInfo.html().charAt(0) === "0") { + $dirInfo.hide(); + $connector.hide(); + } + if ($fileInfo.html().charAt(0) === "0") { + $fileInfo.hide(); + $connector.hide(); + } + } + }, + updateFileSummary: function() { + var $summary = $('.summary'); + + // Check if we should remove the summary to show "Upload something" + if ($('#fileList tr').length === 1 && $summary.length === 1) { + $summary.remove(); + } + // If there's no summary create one (createFileSummary checks if there's data) + else if ($summary.length === 0) { + FileList.createFileSummary(); + } + // There's a summary and data -> Update the summary + else if ($('#fileList tr').length > 1 && $summary.length === 1) { + var totalDirs = 0; + var totalFiles = 0; + var totalSize = 0; + $.each($('tr[data-file]'), function(index, value) { + if ($(value).data('type') === 'dir') { + totalDirs++; + } else if ($(value).data('type') === 'file') { + totalFiles++; + } + if ($(value).data('size') !== undefined) { + totalSize += parseInt($(value).data('size')); + } + }); + + var $dirInfo = $('.summary .dirinfo'); + var $fileInfo = $('.summary .fileinfo'); + var $connector = $('.summary .connector'); + + // Substitute old content with new translations + $dirInfo.html(n('files', '%n folder', '%n folders', totalDirs)); + $fileInfo.html(n('files', '%n file', '%n files', totalFiles)); + $('.summary .filesize').html(humanFileSize(totalSize)); + + // Show only what's necessary (may be hidden) + if ($dirInfo.html().charAt(0) === "0") { + $dirInfo.hide(); + $connector.hide(); + } else { + $dirInfo.show(); + } + if ($fileInfo.html().charAt(0) === "0") { + $fileInfo.hide(); + $connector.hide(); + } else { + $fileInfo.show(); + } + if ($dirInfo.html().charAt(0) !== "0" && $fileInfo.html().charAt(0) !== "0") { + $connector.show(); + } + } } }; @@ -599,4 +707,6 @@ $(document).ready(function(){ $(window).unload(function (){ $(window).trigger('beforeunload'); }); + + FileList.createFileSummary(); }); diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php index 0c7d6936697..3e6f619868d 100644 --- a/apps/files/templates/part.list.php +++ b/apps/files/templates/part.list.php @@ -1,14 +1,5 @@ <input type="hidden" id="disableSharing" data-status="<?php p($_['disableSharing']); ?>"> -<?php $totalfiles = 0; -$totaldirs = 0; -$totalsize = 0; ?> <?php foreach($_['files'] as $file): - $totalsize += $file['size']; - if ($file['type'] === 'dir') { - $totaldirs++; - } else { - $totalfiles++; - } // the bigger the file, the darker the shade of grey; megabytes*2 $simple_size_color = intval(160-$file['size']/(1024*1024)*2); if($simple_size_color<0) $simple_size_color = 0; @@ -64,33 +55,4 @@ $totalsize = 0; ?> </span> </td> </tr> -<?php endforeach; ?> - <?php if ($totaldirs !== 0 || $totalfiles !== 0): ?> - <tr class="summary"> - <td><span class="info"> - <?php if ($totaldirs !== 0) { - p($totaldirs.' '); - if ($totaldirs === 1) { - p($l->t('directory')); - } else { - p($l->t('directories')); - } - } - if ($totaldirs !== 0 && $totalfiles !== 0) { - p(' & '); - } - if ($totalfiles !== 0) { - p($totalfiles.' '); - if ($totalfiles === 1) { - p($l->t('file')); - } else { - p($l->t('files')); - } - } ?> - </span></td> - <td class="filesize"> - <?php print_unescaped(OCP\human_file_size($totalsize)); ?> - </td> - <td></td> - </tr> - <?php endif; +<?php endforeach; diff --git a/apps/files_trashbin/js/trash.js b/apps/files_trashbin/js/trash.js index b14a7240cbe..40c0bdb3829 100644 --- a/apps/files_trashbin/js/trash.js +++ b/apps/files_trashbin/js/trash.js @@ -20,6 +20,7 @@ $(document).ready(function() { OC.dialogs.alert(result.data.message, t('core', 'Error')); } enableActions(); + FileList.updateFileSummary(); }); }); @@ -48,6 +49,7 @@ $(document).ready(function() { OC.dialogs.alert(result.data.message, t('core', 'Error')); } enableActions(); + FileList.updateFileSummary(); }); }); diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index 0dcb2fc82e1..880832f9afa 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -72,11 +72,6 @@ class Trashbin { $mime = $view->getMimeType('files' . $file_path); if ($view->is_dir('files' . $file_path)) { - $dirContent = $view->getDirectoryContent('files' . $file_path); - // no need to move empty folders to the trash bin - if (empty($dirContent)) { - return true; - } $type = 'dir'; } else { $type = 'file'; diff --git a/config/config.sample.php b/config/config.sample.php index 24ba541ac5c..f5cb33732f8 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -141,10 +141,22 @@ $CONFIG = array( /* Loglevel to start logging at. 0=DEBUG, 1=INFO, 2=WARN, 3=ERROR (default is WARN) */ "loglevel" => "", +/* date format to be used while writing to the owncloud logfile */ +'logdateformat' => 'F d, Y H:i:s', + /* Append all database queries and parameters to the log file. (watch out, this option can increase the size of your log file)*/ "log_query" => false, +/* + * Configure the size in bytes log rotation should happen, 0 or false disables the rotation. + * This rotates the current owncloud logfile to a new name, this way the total log usage + * will stay limited and older entries are available for a while longer. The + * total disk usage is twice the configured size. + * WARNING: When you use this, the log entries will eventually be lost. + */ +'log_rotate_size' => false, // 104857600, // 100 MiB + /* Lifetime of the remember login cookie, default is 15 days */ "remember_login_cookie_lifetime" => 60*60*24*15, @@ -189,7 +201,4 @@ $CONFIG = array( 'customclient_desktop' => '', //http://owncloud.org/sync-clients/ 'customclient_android' => '', //https://play.google.com/store/apps/details?id=com.owncloud.android 'customclient_ios' => '', //https://itunes.apple.com/us/app/owncloud/id543672169?mt=8 - -// date format to be used while writing to the owncloud logfile -'logdateformat' => 'F d, Y H:i:s' ); diff --git a/core/js/placeholder.js b/core/js/placeholder.js new file mode 100644 index 00000000000..16543541cb4 --- /dev/null +++ b/core/js/placeholder.js @@ -0,0 +1,65 @@ +/** + * ownCloud + * + * @author Morris Jobke + * @copyright 2013 Morris Jobke <morris.jobke@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ + +/* + * Adds a background color to the element called on and adds the first character + * of the passed in string. This string is also the seed for the generation of + * the background color. + * + * You have following HTML: + * + * <div id="albumart"></div> + * + * And call this from Javascript: + * + * $('#albumart').placeholder('The Album Title'); + * + * Which will result in: + * + * <div id="albumart" style="background-color: rgb(123, 123, 123); ... ">T</div> + * + */ + +(function ($) { + $.fn.placeholder = function(seed) { + var hash = md5(seed), + maxRange = parseInt('ffffffffff', 16), + red = parseInt(hash.substr(0,10), 16) / maxRange * 256, + green = parseInt(hash.substr(10,10), 16) / maxRange * 256, + blue = parseInt(hash.substr(20,10), 16) / maxRange * 256, + rgb = [Math.floor(red), Math.floor(green), Math.floor(blue)], + height = this.height(); + this.css('background-color', 'rgb(' + rgb.join(',') + ')'); + + // CSS rules + this.css('color', 'rgb(255, 255, 255)'); + this.css('font-weight', 'bold'); + this.css('text-align', 'center'); + + // calculate the height + this.css('line-height', height + 'px'); + this.css('font-size', (height * 0.55) + 'px'); + + if(seed !== null && seed.length) { + this.html(seed[0].toUpperCase()); + } + }; +}(jQuery)); diff --git a/lib/base.php b/lib/base.php index 0c9fe329b8f..2e6a37c9f4e 100644 --- a/lib/base.php +++ b/lib/base.php @@ -491,6 +491,7 @@ class OC { self::registerCacheHooks(); self::registerFilesystemHooks(); self::registerShareHooks(); + self::registerLogRotate(); //make sure temporary files are cleaned up register_shutdown_function(array('OC_Helper', 'cleanTmp')); @@ -553,6 +554,21 @@ class OC { } /** + * register hooks for the cache + */ + public static function registerLogRotate() { + if (OC_Config::getValue('installed', false) && OC_Config::getValue('log_rotate_size', false)) { + //don't try to do this before we are properly setup + // register cache cleanup jobs + try { //if this is executed before the upgrade to the new backgroundjob system is completed it will throw an exception + \OCP\BackgroundJob::registerJob('OC\Log\Rotate', OC_Config::getValue("datadirectory", OC::$SERVERROOT.'/data').'/owncloud.log'); + } catch (Exception $e) { + + } + } + } + + /** * register hooks for the filesystem */ public static function registerFilesystemHooks() { diff --git a/lib/log/rotate.php b/lib/log/rotate.php new file mode 100644 index 00000000000..bf23ad588b3 --- /dev/null +++ b/lib/log/rotate.php @@ -0,0 +1,35 @@ +<?php +/** + * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Log; + +/** + * This rotates the current logfile to a new name, this way the total log usage + * will stay limited and older entries are available for a while longer. + * For more professional log management set the 'logfile' config to a different + * location and manage that with your own tools. + */ +class Rotate extends \OC\BackgroundJob\Job { + private $max_log_size; + public function run($logFile) { + $this->max_log_size = \OC_Config::getValue('log_rotate_size', false); + if ($this->max_log_size) { + $filesize = @filesize($logFile); + if ($filesize >= $this->max_log_size) { + $this->rotate($logFile); + } + } + } + + protected function rotate($logfile) { + $rotatedLogfile = $logfile.'.1'; + rename($logfile, $rotatedLogfile); + $msg = 'Log file "'.$logfile.'" was over '.$this->max_log_size.' bytes, moved to "'.$rotatedLogfile.'"'; + \OC_Log::write('OC\Log\Rotate', $msg, \OC_Log::WARN); + } +} |