diff --git a/dist/main.css b/dist/main.css index 932de00..980c5d3 100644 Binary files a/dist/main.css and b/dist/main.css differ diff --git a/dist/main.js b/dist/main.js index a2b128b..922236e 100644 Binary files a/dist/main.js and b/dist/main.js differ diff --git a/dist/view.js b/dist/view.js index 3b2d68f..21537be 100644 Binary files a/dist/view.js and b/dist/view.js differ diff --git a/php/modules/Album.php b/php/modules/Album.php index a45d398..7ed8d76 100644 --- a/php/modules/Album.php +++ b/php/modules/Album.php @@ -83,7 +83,7 @@ class Album extends Module { $albums = $this->database->query($query); $return = $albums->fetch_assoc(); $return['sysdate'] = date('d M. Y', $return['sysstamp']); - $return['password'] = ($return['password']=='' ? false : true); + $return['password'] = ($return['password']=='' ? '0' : '1'); $query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE album = '?' " . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS, $this->albumIDs)); break; @@ -154,8 +154,15 @@ class Album extends Module { # Call plugins $this->plugins(__METHOD__, 0, func_get_args()); + # Initialize return var + $return = array( + 'smartalbums' => null, + 'albums' => null, + 'num' => 0 + ); + # Get SmartAlbums - if ($public===false) $return = $this->getSmartInfo(); + if ($public===false) $return['smartalbums'] = $this->getSmartInfo(); # Albums query $query = Database::prepare($this->database, 'SELECT id, title, public, sysstamp, password FROM ? WHERE public = 1 AND visible <> 0', array(LYCHEE_TABLE_ALBUMS)); @@ -173,7 +180,7 @@ class Album extends Module { # Parse info $album['sysdate'] = date('F Y', $album['sysstamp']); - $album['password'] = ($album['password'] != ''); + $album['password'] = ($album['password']=='' ? '0' : '1'); # Thumbs if (($public===true&&$album['password']===false)||($public===false)) { @@ -192,7 +199,7 @@ class Album extends Module { } # Add to return - $return['content'][$album['id']] = $album; + $return['albums'][$album['id']] = $album; } @@ -211,29 +218,25 @@ class Album extends Module { # Check dependencies self::dependencies(isset($this->database, $this->settings)); + # Initialize return var + $return = array( + 'unsorted' => null, + 'public' => null, + 'starred' => null, + 'recent' => null + ); + # Unsorted $query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE album = 0 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS)); $unsorted = $this->database->query($query); $i = 0; while($row = $unsorted->fetch_object()) { if ($i<3) { - $return["unsortedThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row->thumbUrl; + $return['unsorted']["thumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row->thumbUrl; $i++; } else break; } - $return['unsortedNum'] = $unsorted->num_rows; - - # Public - $query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE public = 1 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS)); - $public = $this->database->query($query); - $i = 0; - while($row2 = $public->fetch_object()) { - if ($i<3) { - $return["publicThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row2->thumbUrl; - $i++; - } else break; - } - $return['publicNum'] = $public->num_rows; + $return['unsorted']['num'] = $unsorted->num_rows; # Starred $query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE star = 1 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS)); @@ -241,11 +244,23 @@ class Album extends Module { $i = 0; while($row3 = $starred->fetch_object()) { if ($i<3) { - $return["starredThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl; + $return['starred']["thumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl; $i++; } else break; } - $return['starredNum'] = $starred->num_rows; + $return['starred']['num'] = $starred->num_rows; + + # Public + $query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE public = 1 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS)); + $public = $this->database->query($query); + $i = 0; + while($row2 = $public->fetch_object()) { + if ($i<3) { + $return['public']["thumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row2->thumbUrl; + $i++; + } else break; + } + $return['public']['num'] = $public->num_rows; # Recent $query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE LEFT(id, 10) >= unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 DAY)) ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS)); @@ -253,11 +268,11 @@ class Album extends Module { $i = 0; while($row3 = $recent->fetch_object()) { if ($i<3) { - $return["recentThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl; + $return['recent']["thumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl; $i++; } else break; } - $return['recentNum'] = $recent->num_rows; + $return['recent']['num'] = $recent->num_rows; return $return; diff --git a/php/modules/misc.php b/php/modules/misc.php index c449e4a..2094790 100755 --- a/php/modules/misc.php +++ b/php/modules/misc.php @@ -13,6 +13,13 @@ function search($database, $settings, $term) { $return['albums'] = ''; + # Initialize return var + $return = array( + 'photos' => null, + 'albums' => null, + 'hash' => '' + ); + # Photos $query = Database::prepare($database, "SELECT id, title, tags, public, star, album, thumbUrl FROM ? WHERE title LIKE '%?%' OR description LIKE '%?%' OR tags LIKE '%?%'", array(LYCHEE_TABLE_PHOTOS, $term, $term, $term)); $result = $database->query($query); @@ -48,6 +55,9 @@ function search($database, $settings, $term) { } + # Hash + $return['hash'] = md5(json_encode($return)); + return $return; } diff --git a/src/bower.json b/src/bower.json index 13a28eb..892d78a 100644 --- a/src/bower.json +++ b/src/bower.json @@ -3,7 +3,6 @@ "private": true, "dependencies": { "jQuery": "~2.1.3", - "js-md5": "~1.1.0", "mousetrap": "~1.4.6", "basicContext": "~2.0.2", "basicModal": "~2.0.3" diff --git a/src/gulpfile.js b/src/gulpfile.js index fbec696..08ba53a 100644 --- a/src/gulpfile.js +++ b/src/gulpfile.js @@ -59,7 +59,6 @@ paths.main = { ], scripts: [ 'bower_components/jQuery/dist/jquery.min.js', - 'bower_components/js-md5/js/md5.min.js', 'bower_components/mousetrap/mousetrap.min.js', 'bower_components/mousetrap/plugins/global-bind/mousetrap-global-bind.min.js', 'bower_components/basicContext/dist/basicContext.min.js', diff --git a/src/scripts/album.js b/src/scripts/album.js index 61c52b9..00ced60 100644 --- a/src/scripts/album.js +++ b/src/scripts/album.js @@ -179,7 +179,7 @@ album.delete = function(albumIDs) { albumIDs.forEach(function(id) { albums.json.num--; view.albums.content.delete(id); - delete albums.json.content[id]; + delete albums.json.albums[id]; }); } else { @@ -209,7 +209,7 @@ album.delete = function(albumIDs) { // Get title if (album.json) albumTitle = album.json.title; - else if (albums.json) albumTitle = albums.json.content[albumIDs].title; + else if (albums.json) albumTitle = albums.json.albums[albumIDs].title; msg = "
Are you sure you want to delete the album '" + albumTitle + "' and all of the photos it contains? This action can't be undone!
"; @@ -253,7 +253,7 @@ album.setTitle = function(albumIDs) { // Get old title if only one album is selected if (album.json) oldTitle = album.json.title; - else if (albums.json) oldTitle = albums.json.content[albumIDs].title; + else if (albums.json) oldTitle = albums.json.albums[albumIDs].title; if (!oldTitle) oldTitle = ''; oldTitle = oldTitle.replace("'", '''); @@ -280,13 +280,13 @@ album.setTitle = function(albumIDs) { if (albums.json) { var id = albumIDs[0]; - albums.json.content[id].title = newTitle; + albums.json.albums[id].title = newTitle; } } else if (visible.albums()) { albumIDs.forEach(function(id) { - albums.json.content[id].title = newTitle; + albums.json.albums[id].title = newTitle; view.albums.content.title(id); }); @@ -384,7 +384,7 @@ album.setPublic = function(albumID, e) { albums.refresh(); - if (!basicModal.visible()&&album.json.public==0) { + if (!basicModal.visible()&&album.json.public==='0') { var msg = '', action; @@ -456,10 +456,10 @@ album.setPublic = function(albumID, e) { if ($('.basicModal .choice input[name="password"]:checked').length===1) { password = $('.basicModal .choice input[data-name="password"]').val(); - album.json.password = 1; + album.json.password = '1'; } else { password = ''; - album.json.password = 0; + album.json.password = '0'; } if ($('.basicModal .choice input[name="listed"]:checked').length===1) listed = true; @@ -469,13 +469,13 @@ album.setPublic = function(albumID, e) { if (visible.album()) { - album.json.public = (album.json.public==0) ? 1 : 0; - album.json.password = (album.json.public==0) ? 0 : album.json.password; + album.json.public = (album.json.public==='0') ? '1' : '0'; + album.json.password = (album.json.public==='0') ? '0' : album.json.password; view.album.public(); view.album.password(); - if (album.json.public==1) contextMenu.shareAlbum(albumID, e); + if (album.json.public==='1') contextMenu.shareAlbum(albumID, e); } @@ -526,7 +526,7 @@ album.getArchive = function(albumID) { if (location.href.indexOf('index.html')>0) link = location.href.replace(location.hash, '').replace('index.html', url); else link = location.href.replace(location.hash, '') + url; - if (lychee.publicMode) link += '&password=' + password.value; + if (lychee.publicMode===true) link += '&password=' + password.value; location.href = link; diff --git a/src/scripts/albums.js b/src/scripts/albums.js index 8a447ea..72dbb81 100644 --- a/src/scripts/albums.js +++ b/src/scripts/albums.js @@ -25,45 +25,7 @@ albums.load = function() { api.post('Album::getAll', {}, function(data) { /* Smart Albums */ - data.unsortedAlbum = { - id: 0, - title: 'Unsorted', - sysdate: data.unsortedNum + ' photos', - unsorted: '1', - thumb0: data.unsortedThumb0, - thumb1: data.unsortedThumb1, - thumb2: data.unsortedThumb2 - }; - - data.starredAlbum = { - id: 'f', - title: 'Starred', - sysdate: data.starredNum + ' photos', - star: '1', - thumb0: data.starredThumb0, - thumb1: data.starredThumb1, - thumb2: data.starredThumb2 - }; - - data.publicAlbum = { - id: 's', - title: 'Public', - sysdate: data.publicNum + ' photos', - public: '1', - thumb0: data.publicThumb0, - thumb1: data.publicThumb1, - thumb2: data.publicThumb2 - }; - - data.recentAlbum = { - id: 'r', - title: 'Recent', - sysdate: data.recentNum + ' photos', - recent: '1', - thumb0: data.recentThumb0, - thumb1: data.recentThumb1, - thumb2: data.recentThumb2 - }; + if (lychee.publicMode===false) albums._createSmartAlbums(data.smartalbums); albums.json = data; @@ -79,7 +41,7 @@ albums.load = function() { setTimeout(function() { header.setMode('albums'); view.albums.init(); - lychee.animate('.album, .photo', 'contentZoomIn'); + lychee.animate('.album', 'contentZoomIn'); }, waitTime); }); @@ -96,7 +58,7 @@ albums.load = function() { albums.parse = function(album) { - if (album.password&&lychee.publicMode) { + if (album.password==='1'&&lychee.publicMode===true) { album.thumb0 = 'src/images/password.svg'; album.thumb1 = 'src/images/password.svg'; album.thumb2 = 'src/images/password.svg'; @@ -108,6 +70,50 @@ albums.parse = function(album) { } +albums._createSmartAlbums = function(data) { + + data.unsorted = { + id: 0, + title: 'Unsorted', + sysdate: data.unsorted.num + ' photos', + unsorted: '1', + thumb0: data.unsorted.thumb0, + thumb1: data.unsorted.thumb1, + thumb2: data.unsorted.thumb2 + }; + + data.starred = { + id: 'f', + title: 'Starred', + sysdate: data.starred.num + ' photos', + star: '1', + thumb0: data.starred.thumb0, + thumb1: data.starred.thumb1, + thumb2: data.starred.thumb2 + }; + + data.public = { + id: 's', + title: 'Public', + sysdate: data.public.num + ' photos', + public: '1', + thumb0: data.public.thumb0, + thumb1: data.public.thumb1, + thumb2: data.public.thumb2 + }; + + data.recent = { + id: 'r', + title: 'Recent', + sysdate: data.recent.num + ' photos', + recent: '1', + thumb0: data.recent.thumb0, + thumb1: data.recent.thumb1, + thumb2: data.recent.thumb2 + }; + +} + albums.refresh = function() { albums.json = null; diff --git a/src/scripts/build.js b/src/scripts/build.js index 9fcd1c3..15fd865 100644 --- a/src/scripts/build.js +++ b/src/scripts/build.js @@ -92,7 +92,7 @@ build.album = function(data) { if (data.public==='1') html += `${ build.iconic('eye') }`; if (data.unsorted==='1') html += `${ build.iconic('list') }`; if (data.recent==='1') html += `${ build.iconic('clock') }`; - if (data.password===true) html += `${ build.iconic('lock-locked') }`; + if (data.password==='1') html += `${ build.iconic('lock-locked') }`; } @@ -244,12 +244,12 @@ build.uploadModal = function(title, files) { } -build.tags = function(tags, forView) { +build.tags = function(tags, forView = false) { var html = '', editTagsHTML = ''; - if (forView!==true&&lychee.publicMode!==true) editTagsHTML = ' ' + build.editIcon('edit_tags'); + if (forView===false&&lychee.publicMode===false) editTagsHTML = ' ' + build.editIcon('edit_tags'); if (tags!=='') { @@ -271,7 +271,7 @@ build.tags = function(tags, forView) { } -build.infoboxPhoto = function(data, forView) { +build.infoboxPhoto = function(data, forView = false) { var html = '', visible = '', @@ -293,7 +293,7 @@ build.infoboxPhoto = function(data, forView) { } - if (forView!==true&&lychee.publicMode!==true) { + if (forView===false&&lychee.publicMode===false) { editTitleHTML = ' ' + build.editIcon('edit_title'); editDescriptionHTML = ' ' + build.editIcon('edit_description'); } @@ -355,7 +355,7 @@ build.infoboxPhoto = function(data, forView) { case 'Tags': // Tags - if (forView!==true&&lychee.publicMode===false) { + if (forView===false&&lychee.publicMode===false) { html += ` @@ -395,7 +395,7 @@ build.infoboxPhoto = function(data, forView) { } -build.infoboxAlbum = function(data, forView) { +build.infoboxAlbum = function(data, forView = false) { var html = '', visible = '', @@ -418,9 +418,9 @@ build.infoboxAlbum = function(data, forView) { switch (data.password) { - case false: password = 'No'; + case '0': password = 'No'; break; - case true: password = 'Yes'; + case '1': password = 'Yes'; break; default: password = '-'; break; @@ -438,7 +438,7 @@ build.infoboxAlbum = function(data, forView) { } - if (forView!==true&&lychee.publicMode!==true) { + if (forView===false&&lychee.publicMode===false) { editTitleHTML = ' ' + build.editIcon('edit_title_album'); editDescriptionHTML = ' ' + build.editIcon('edit_description_album'); } diff --git a/src/scripts/contextMenu.js b/src/scripts/contextMenu.js index d5a1fa1..2a3e70f 100644 --- a/src/scripts/contextMenu.js +++ b/src/scripts/contextMenu.js @@ -82,7 +82,7 @@ contextMenu.albumTitle = function(albumID, e) { items.push({ type: 'separator' }); // Generate list of albums - $.each(data.content, function(index) { + $.each(data.albums, function(index) { var that = this, title = ''; @@ -220,12 +220,12 @@ contextMenu.move = function(photoIDs, e) { } else { // Generate list of albums - $.each(data.content, function(index) { + $.each(data.albums, function(index) { var that = this; if (!that.thumb0) that.thumb0 = 'src/images/no_cover.svg'; - that.title = "