From feefa9c5a047d6efd864663ef2c1ef55111d8077 Mon Sep 17 00:00:00 2001 From: Tobias Reich Date: Sat, 27 Jun 2015 21:03:27 +0200 Subject: [PATCH] Updated version, updated deps and added skip duplicates #367 --- dist/main.css | Bin 36134 -> 36228 bytes dist/main.js | Bin 176812 -> 177211 bytes php/database/update_030003.php | 25 +++++++++++++++++ php/modules/Database.php | 3 +- php/modules/Photo.php | 11 +++++++- src/package.json | 10 +++---- src/scripts/lychee.js | 4 +-- src/scripts/upload.js | 50 +++++++++++++++++++++++++-------- src/styles/_message.scss | 7 +++-- 9 files changed, 88 insertions(+), 22 deletions(-) mode change 100644 => 100755 dist/main.css mode change 100644 => 100755 dist/main.js create mode 100644 php/database/update_030003.php diff --git a/dist/main.css b/dist/main.css old mode 100644 new mode 100755 index 77ebe7330c9e836bcd1371a1b91415509ad3905f..22d2bf3360c57e61c819476635f0b0e3c48b7441 GIT binary patch delta 82 zcmZ2Bi>YNc(+0t=$qI!E9D3!6MR}Qd>5~P!LReBQjS?r%?~?x*(7KRqJlNAf)C%^0xU@=NeF`YcIOKP)tcP&2Jk;6xUADv`tdVM?%sh0(;bKcH`}4HwkTtvvw(TWwmJ=nh&HJS4_PVdy>uW zYCoDbsi~SK?#GE@q`mPM6bf}A2ZY204u}uIjRO)=sl7T ze(%li?Y+m%U;NSh$*~qLQ+cgL+@(`Z&?|P!G^ba-X&HP*r?NqPk}nFPC}pZmt=fy= zNnh%!UcgfbEl`e1kAB#=N6%foD)?EwdPIB3 zwdpyY7noKM7=RL|1{(eKJp1^&n(E*Yg^{7enevBDf zA5Q4iM-v<{tvsHzAaru-$Ht}%&z}=A74dv*b6Y)o{!MOQCVfa939>AwX{G-K0q*|y+)()2I@it(t^K{ug)3rQ zm6$dYSb3k>R?HKq#Kfgb#ElUx>Y;AC^Uy~kx#6eRQQKZqQ=|ZX`S6G9DAU06cKF;f z8r^R}>bMGKv?}TF^fH}>~5}7y-wG09Kq~Ku*`YF}V6lja&$~FWD zc>L_d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1i-VP*$Q$gSbJhg%kw#F@M?oj>W)jPN?p(z7$HsoMi zXozpFV0Y*K?;qeJtrWyl^sY;?;>I9&%PP(u+rf|)Qi2k~cmWB0&kf0Byd?g189$$> zF>mp^t2mX2BzZ{*d36;Jb~-v!beod$Aq&4P}DHqBITWB z{03im2eqE2AQl4OUffitO3mD+K2!Jh#0fmqOJQ1_?h5XBCJSNyO&NC}%6~26_73RB uZu$gvMdz&o>Gj=$0BVlQ4y@z$BfEJ}DcHNajtfq#<9Cs_@o*iNr2hfphO@r_ diff --git a/php/database/update_030003.php b/php/database/update_030003.php new file mode 100644 index 0000000..c658bc0 --- /dev/null +++ b/php/database/update_030003.php @@ -0,0 +1,25 @@ +query($query); +if ($result->num_rows===0) { + $query = Database::prepare($database, "INSERT INTO `?` (`key`, `value`) VALUES ('skipDuplicates', '0')", array(LYCHEE_TABLE_SETTINGS)); + $result = $database->query($query); + if (!$result) { + Log::error($database, 'update_030003', __LINE__, 'Could not update database (' . $database->error . ')'); + return false; + } +} + +# Set version +if (Database::setVersion($database, '030003')===false) return false; + +?> \ No newline at end of file diff --git a/php/modules/Database.php b/php/modules/Database.php index 66c1124..13bcff7 100755 --- a/php/modules/Database.php +++ b/php/modules/Database.php @@ -56,7 +56,8 @@ class Database extends Module { '020602', #2.6.2 '020700', #2.7.0 '030000', #3.0.0 - '030001' #3.0.1 + '030001', #3.0.1 + '030003' #3.0.3 ); # For each update diff --git a/php/modules/Photo.php b/php/modules/Photo.php index 8d1c292..0d9eff6 100755 --- a/php/modules/Photo.php +++ b/php/modules/Photo.php @@ -40,7 +40,7 @@ class Photo extends Module { public function add($files, $albumID, $description = '', $tags = '') { # Check dependencies - self::dependencies(isset($this->database)); + self::dependencies(isset($this->database, $this->settings, $files)); # Check permissions if (hasPermissions(LYCHEE_UPLOADS)===false|| @@ -150,6 +150,15 @@ class Photo extends Module { } } + } else { + + # Photo already exists + # Check if the user wants to skip duplicates + if ($this->settings['skipDuplicates']==='1') { + Log::notice($this->database, __METHOD__, __LINE__, 'Skipped upload of existing photo because skipDuplicates is activated'); + exit('Warning: This photo has been skipped because it\'s already in your library.'); + } + } # Read infos diff --git a/src/package.json b/src/package.json index dde5567..7e42746 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "Lychee", - "version": "3.0.2", + "version": "3.0.3", "description": "Self-hosted photo-management done right.", "authors": "Tobias Reich ", "license": "MIT", @@ -10,16 +10,16 @@ "url": "https://github.com/electerious/Lychee.git" }, "devDependencies": { - "basiccontext": "^3.0.3", + "basiccontext": "^3.1.0", "gulp": "^3.9.0", "gulp-autoprefixer": "2.3.1", "gulp-babel": "^5.1.0", - "gulp-concat": "^2.5.2", + "gulp-concat": "^2.6.0", "gulp-inject": "^1.3.1", "gulp-load-plugins": "^1.0.0-rc", - "gulp-minify-css": "^1.1.6", + "gulp-minify-css": "^1.2.0", "gulp-rimraf": "^0.1.1", - "gulp-sass": "^2.0.1", + "gulp-sass": "^2.0.2", "gulp-uglify": "^1.2.0", "jquery": "^2.1.4", "mousetrap": "^1.5.2" diff --git a/src/scripts/lychee.js b/src/scripts/lychee.js index db74cab..8238f18 100644 --- a/src/scripts/lychee.js +++ b/src/scripts/lychee.js @@ -6,8 +6,8 @@ lychee = { title: document.title, - version: '3.0.2', - version_code: '030002', + version: '3.0.3', + version_code: '030003', update_path: 'http://lychee.electerious.com/version/index.php', updateURL: 'https://github.com/electerious/Lychee', diff --git a/src/scripts/upload.js b/src/scripts/upload.js index e50f425..9d5833b 100755 --- a/src/scripts/upload.js +++ b/src/scripts/upload.js @@ -44,6 +44,7 @@ upload.start = { var albumID = album.getID(), error = false, + warning = false, process = function(files, file) { var formData = new FormData(), @@ -56,12 +57,18 @@ upload.start = { $('#upload_files').val(''); - if (error===false) { + if (error===false&&warning===false) { // Success basicModal.close(); upload.notify('Upload complete'); + } else if (error===false&&warning===true) { + + // Warning + $('.basicModal #basicModal__action.hidden').show(); + upload.notify('Upload complete'); + } else { // Error @@ -130,23 +137,44 @@ upload.start = { } else { - // Error - $('.basicModal .rows .row:nth-child(' + (file.num+1) + ') .status') - .html('Error') - .addClass('error'); + if (xhr.responseText.substr(0, 6)==='Error:') { - if (xhr.responseText.substr(0, 6)==='Error:') errorText = xhr.responseText.substr(6) + ' Please take a look at the console of your browser for further details.'; - else errorText = 'Server returned an unknown response. Please take a look at the console of your browser for further details.'; + errorText = xhr.responseText.substr(6) + ' Please take a look at the console of your browser for further details.'; + error = true; + + // Error Status + $('.basicModal .rows .row:nth-child(' + (file.num+1) + ') .status') + .html('Failed') + .addClass('error'); + + } else if (xhr.responseText.substr(0, 8)==='Warning:') { + + errorText = xhr.responseText.substr(8); + warning = true; + + // Warning Status + $('.basicModal .rows .row:nth-child(' + (file.num+1) + ') .status') + .html('Skipped') + .addClass('warning'); + + } else { + + errorText = 'Server returned an unknown response. Please take a look at the console of your browser for further details.'; + error = true; + + // Error Status + $('.basicModal .rows .row:nth-child(' + (file.num+1) + ') .status') + .html('Failed') + .addClass('error'); + + } $('.basicModal .rows .row:nth-child(' + (file.num+1) + ') p.notice') .html(errorText) .show(); - // Set global error - error = true; - // Throw error - lychee.error('Upload failed. Server returned the status code ' + xhr.status + '!', xhr, xhr.responseText); + if (error===true) lychee.error('Upload failed. Server returned the status code ' + xhr.status + '!', xhr, xhr.responseText); } diff --git a/src/styles/_message.scss b/src/styles/_message.scss index a3a4898..7df5676 100644 --- a/src/styles/_message.scss +++ b/src/styles/_message.scss @@ -301,11 +301,14 @@ animation-iteration-count: infinite; &.error, + &.warning, &.success { animation: none; } - &.error { color: rgb(213, 24, 24); } + &.error { color: rgb(233, 42, 0); } - &.success { color: rgb(42, 213, 0); } + &.warning { color: rgb(228, 233, 0); } + + &.success { color: rgb(126, 233, 0); } } p.notice {