Added new SmartAlbum which shows all recent uploads

This commit is contained in:
Tobias Reich 2014-06-29 15:40:06 +02:00
parent 8e8fd91497
commit ce373c26d5
12 changed files with 62 additions and 13 deletions

View File

@ -176,6 +176,10 @@
.photo .badge.icon-share { .photo .badge.icon-share {
padding: 12px 6px 3px 8px; padding: 12px 6px 3px 8px;
} }
.album .badge.icon-time,
.photo .badge.icon-time {
padding: 12px 8px 3px 9px;
}
.album .badge::after, .album .badge::after,
.photo .badge::after { .photo .badge::after {
content: ""; content: "";
@ -198,6 +202,10 @@
.photo .badge.icon-share::after { .photo .badge.icon-share::after {
margin-left: -31px; margin-left: -31px;
} }
.album .badge.icon-time::after,
.photo .badge.icon-time::after {
margin-left: -29px;
}
.album .badge.icon-reorder::after { .album .badge.icon-reorder::after {
margin-left: -30px; margin-left: -30px;
} }

View File

@ -53,6 +53,16 @@ albums = {
thumb2: data.publicThumb2 thumb2: data.publicThumb2
}; };
data.recentAlbum = {
id: "r",
title: "Recent",
sysdate: data.recentNum + " photos",
recent: 1,
thumb0: data.recentThumb0,
thumb1: data.recentThumb1,
thumb2: data.recentThumb2
};
albums.json = data; albums.json = data;
durationTime = (new Date().getTime() - startTime); durationTime = (new Date().getTime() - startTime);

View File

@ -54,9 +54,10 @@ build = {
album += "<a>" + albumJSON.sysdate + "</a>"; album += "<a>" + albumJSON.sysdate + "</a>";
album += "</div>"; album += "</div>";
if(!lychee.publicMode&&albumJSON.star==1) album += "<a class='badge red icon-star'></a>"; if(!lychee.publicMode&&albumJSON.star===1) album += "<a class='badge red icon-star'></a>";
if(!lychee.publicMode&&albumJSON.public==1) album += "<a class='badge red icon-share'></a>"; if(!lychee.publicMode&&albumJSON.public===1) album += "<a class='badge red icon-share'></a>";
if(!lychee.publicMode&&albumJSON.unsorted==1) album += "<a class='badge red icon-reorder'></a>"; if(!lychee.publicMode&&albumJSON.unsorted===1) album += "<a class='badge red icon-reorder'></a>";
if(!lychee.publicMode&&albumJSON.recent===1) album += "<a class='badge red icon-time'></a>";
album += "</div>"; album += "</div>";

View File

@ -114,7 +114,7 @@ contextMenu = {
mouse_y = e.pageY - $(document).scrollTop(), mouse_y = e.pageY - $(document).scrollTop(),
items; items;
if (albumID==="0"||albumID==="f"||albumID==="s") return false; if (albumID==="0"||albumID==="f"||albumID==="s"||albumID==="r") return false;
contextMenu.fns = [ contextMenu.fns = [
function() { album.setTitle([albumID]) }, function() { album.setTitle([albumID]) },

View File

@ -135,7 +135,7 @@ multiselect = {
id = $(this).data('id'); id = $(this).data('id');
if (id!=='0'&&id!==0&&id!=='f'&&id!=='s'&&id!==null&id!==undefined) { if (id!=='0'&&id!==0&&id!=='f'&&id!=='s'&&id!=='r'&&id!==null&id!==undefined) {
ids.push(id); ids.push(id);
$(this).addClass('active'); $(this).addClass('active');

View File

@ -64,7 +64,7 @@ view = {
$("#tools_albums, #tools_photo").hide(); $("#tools_albums, #tools_photo").hide();
$("#tools_album").show(); $("#tools_album").show();
album.json.content === false ? $("#button_archive").hide() : $("#button_archive").show(); album.json.content === false ? $("#button_archive").hide() : $("#button_archive").show();
if (albumID==="s"||albumID==="f") { if (albumID==="s"||albumID==="f"||albumID==="r") {
$("#button_info_album, #button_trash_album, #button_share_album").hide(); $("#button_info_album, #button_trash_album, #button_share_album").hide();
} else if (albumID==="0") { } else if (albumID==="0") {
$("#button_info_album, #button_share_album").hide(); $("#button_info_album, #button_share_album").hide();
@ -130,7 +130,8 @@ view = {
albums.parse(albums.json.unsortedAlbum); albums.parse(albums.json.unsortedAlbum);
albums.parse(albums.json.publicAlbum); albums.parse(albums.json.publicAlbum);
albums.parse(albums.json.starredAlbum); albums.parse(albums.json.starredAlbum);
if (!lychee.publicMode) smartData = build.divider("Smart Albums") + build.album(albums.json.unsortedAlbum) + build.album(albums.json.starredAlbum) + build.album(albums.json.publicAlbum); albums.parse(albums.json.recentAlbum);
if (!lychee.publicMode) smartData = build.divider("Smart Albums") + build.album(albums.json.unsortedAlbum) + build.album(albums.json.starredAlbum) + build.album(albums.json.publicAlbum) + build.album(albums.json.recentAlbum);
/* Albums */ /* Albums */
if (albums.json.content) { if (albums.json.content) {
@ -216,6 +217,9 @@ view = {
case "s": case "s":
lychee.setTitle("Public", false); lychee.setTitle("Public", false);
break; break;
case "r":
lychee.setTitle("Recent", false);
break;
case "0": case "0":
lychee.setTitle("Unsorted", false); lychee.setTitle("Unsorted", false);
break; break;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -61,7 +61,7 @@ if (!empty($_POST['function'])||!empty($_GET['function'])) {
# Validate parameters # Validate parameters
if (isset($_POST['albumIDs'])&&preg_match('/^[0-9\,]{1,}$/', $_POST['albumIDs'])!==1) exit('Error: Wrong parameter type for albumIDs!'); if (isset($_POST['albumIDs'])&&preg_match('/^[0-9\,]{1,}$/', $_POST['albumIDs'])!==1) exit('Error: Wrong parameter type for albumIDs!');
if (isset($_POST['photoIDs'])&&preg_match('/^[0-9\,]{1,}$/', $_POST['photoIDs'])!==1) exit('Error: Wrong parameter type for photoIDs!'); if (isset($_POST['photoIDs'])&&preg_match('/^[0-9\,]{1,}$/', $_POST['photoIDs'])!==1) exit('Error: Wrong parameter type for photoIDs!');
if (isset($_POST['albumID'])&&preg_match('/^[0-9sf]{1,}$/', $_POST['albumID'])!==1) exit('Error: Wrong parameter type for albumID!'); if (isset($_POST['albumID'])&&preg_match('/^[0-9sfr]{1,}$/', $_POST['albumID'])!==1) exit('Error: Wrong parameter type for albumID!');
if (isset($_POST['photoID'])&&preg_match('/^[0-9]{14}$/', $_POST['photoID'])!==1) exit('Error: Wrong parameter type for photoID!'); if (isset($_POST['photoID'])&&preg_match('/^[0-9]{14}$/', $_POST['photoID'])!==1) exit('Error: Wrong parameter type for photoID!');
# Function for switch statement # Function for switch statement

View File

@ -71,6 +71,10 @@ class Album extends Module {
$query = "SELECT id, title, tags, public, star, album, thumbUrl, takestamp FROM lychee_photos WHERE public = 1 " . $this->settings['sorting']; $query = "SELECT id, title, tags, public, star, album, thumbUrl, takestamp FROM lychee_photos WHERE public = 1 " . $this->settings['sorting'];
break; break;
case 'r': $return['public'] = false;
$query = "SELECT id, title, tags, public, star, album, thumbUrl, takestamp FROM lychee_photos WHERE LEFT(id, 10) >= unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 DAY)) " . $this->settings['sorting'];
break;
case '0': $return['public'] = false; case '0': $return['public'] = false;
$query = "SELECT id, title, tags, public, star, album, thumbUrl, takestamp FROM lychee_photos WHERE album = 0 " . $this->settings['sorting']; $query = "SELECT id, title, tags, public, star, album, thumbUrl, takestamp FROM lychee_photos WHERE album = 0 " . $this->settings['sorting'];
break; break;
@ -230,6 +234,17 @@ class Album extends Module {
} }
$return['starredNum'] = $starred->num_rows; $return['starredNum'] = $starred->num_rows;
# Recent
$recent = $this->database->query("SELECT thumbUrl FROM lychee_photos WHERE LEFT(id, 10) >= unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 DAY)) " . $this->settings['sorting']);
$i = 0;
while($row3 = $recent->fetch_object()) {
if ($i<3) {
$return["recentThumb$i"] = $row3->thumbUrl;
$i++;
} else break;
}
$return['recentNum'] = $recent->num_rows;
return $return; return $return;
} }
@ -258,6 +273,10 @@ class Album extends Module {
$photos = "SELECT title, url FROM lychee_photos WHERE star = '1';"; $photos = "SELECT title, url FROM lychee_photos WHERE star = '1';";
$zipTitle = 'Starred'; $zipTitle = 'Starred';
break; break;
case 'r':
$photos = "SELECT title, url FROM lychee_photos WHERE LEFT(id, 10) >= unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 DAY));";
$zipTitle = 'Recent';
break;
default: default:
$photos = "SELECT title, url FROM lychee_photos WHERE album = '$this->albumIDs';"; $photos = "SELECT title, url FROM lychee_photos WHERE album = '$this->albumIDs';";
$zipTitle = 'Unsorted'; $zipTitle = 'Unsorted';

View File

@ -68,6 +68,13 @@ class Photo extends Module {
$albumID = 0; $albumID = 0;
break; break;
case 'r':
# r for recent
$public = 0;
$star = 0;
$albumID = 0;
break;
default: default:
$star = 0; $star = 0;
$public = 0; $public = 0;