Less parsing of photos/albums on client-side

This commit is contained in:
Tobias Reich 2014-07-12 20:12:38 +02:00
parent a244f2ed51
commit 911e168b6f
9 changed files with 20 additions and 18 deletions

View File

@ -88,8 +88,7 @@ album = {
parse: function(photo) {
if (photo&&photo.thumbUrl) photo.thumbUrl = lychee.upload_path_thumb + photo.thumbUrl;
else if (!album.json.title) album.json.title = "Untitled";
if (!album.json.title) album.json.title = "Untitled";
},

View File

@ -88,9 +88,9 @@ albums = {
album.thumb1 = "assets/img/password.svg";
album.thumb2 = "assets/img/password.svg";
} else {
if (album.thumb0) album.thumb0 = lychee.upload_path_thumb + album.thumb0; else album.thumb0 = "assets/img/no_images.svg";
if (album.thumb1) album.thumb1 = lychee.upload_path_thumb + album.thumb1; else album.thumb1 = "assets/img/no_images.svg";
if (album.thumb2) album.thumb2 = lychee.upload_path_thumb + album.thumb2; else album.thumb2 = "assets/img/no_images.svg";
if (!album.thumb0) album.thumb0 = "assets/img/no_images.svg";
if (!album.thumb1) album.thumb1 = "assets/img/no_images.svg";
if (!album.thumb2) album.thumb2 = "assets/img/no_images.svg";
}
}

View File

@ -16,9 +16,6 @@ var lychee = {
updateURL: "https://github.com/electerious/Lychee",
website: "http://lychee.electerious.com",
upload_path_thumb: "uploads/thumb/",
upload_path_big: "uploads/big/",
publicMode: false,
viewMode: false,
debugMode: false,

View File

@ -52,7 +52,6 @@ photo = {
parse: function() {
if (!photo.json.title) photo.json.title = "Untitled";
photo.json.url = lychee.upload_path_big + photo.json.url;
},

View File

@ -246,7 +246,6 @@ view = {
var photosData = "";
$.each(album.json.content, function() {
album.parse(this);
photosData += build.photo(this);
});
lychee.content.html(photosData);

File diff suppressed because one or more lines are too long

View File

@ -21,4 +21,8 @@ define('LYCHEE_PLUGINS', LYCHEE . 'plugins/');
# Define files
define('LYCHEE_CONFIG_FILE', LYCHEE_DATA . 'config.php');
# Define urls
define('LYCHEE_URL_UPLOADS_THUMB', 'uploads/thumb/');
define('LYCHEE_URL_UPLOADS_BIG', 'uploads/big/');
?>

View File

@ -97,6 +97,7 @@ class Album extends Module {
$photo['sysdate'] = date('d F Y', substr($photo['id'], 0, -4));
$photo['previousPhoto'] = $previousPhotoID;
$photo['nextPhoto'] = '';
$photo['thumbUrl'] = LYCHEE_URL_UPLOADS_THUMB . $photo['thumbUrl'];
if ($photo['takestamp']!=='0') {
$photo['cameraDate'] = 1;
@ -175,7 +176,7 @@ class Album extends Module {
# For each thumb
$k = 0;
while ($thumb = $thumbs->fetch_object()) {
$album["thumb$k"] = $thumb->thumbUrl;
$album["thumb$k"] = LYCHEE_URL_UPLOADS_THUMB . $thumb->thumbUrl;
$k++;
}
@ -206,7 +207,7 @@ class Album extends Module {
$i = 0;
while($row = $unsorted->fetch_object()) {
if ($i<3) {
$return["unsortedThumb$i"] = $row->thumbUrl;
$return["unsortedThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row->thumbUrl;
$i++;
} else break;
}
@ -217,7 +218,7 @@ class Album extends Module {
$i = 0;
while($row2 = $public->fetch_object()) {
if ($i<3) {
$return["publicThumb$i"] = $row2->thumbUrl;
$return["publicThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row2->thumbUrl;
$i++;
} else break;
}
@ -228,7 +229,7 @@ class Album extends Module {
$i = 0;
while($row3 = $starred->fetch_object()) {
if ($i<3) {
$return["starredThumb$i"] = $row3->thumbUrl;
$return["starredThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl;
$i++;
} else break;
}
@ -239,7 +240,7 @@ class Album extends Module {
$i = 0;
while($row3 = $recent->fetch_object()) {
if ($i<3) {
$return["recentThumb$i"] = $row3->thumbUrl;
$return["recentThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl;
$i++;
} else break;
}

View File

@ -390,6 +390,9 @@ class Photo extends Module {
$photo['sysdate'] = date('d M. Y', substr($photo['id'], 0, -4));
if (strlen($photo['takestamp'])>1) $photo['takedate'] = date('d M. Y', $photo['takestamp']);
# Parse url
$photo['url'] = LYCHEE_URL_UPLOADS_BIG . $photo['url'];
if ($albumID!='false') {
if ($photo['album']!=0) {