Browse Source

Less parsing of photos/albums on client-side

Tobias Reich 9 years ago
parent
commit
911e168b6f

+ 1 - 2
assets/js/album.js

@@ -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";
 
 	},
 

+ 3 - 3
assets/js/albums.js

@@ -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";
 		}
 
 	}

+ 0 - 3
assets/js/lychee.js

@@ -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,

+ 0 - 1
assets/js/photo.js

@@ -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;
 
 	},
 

+ 0 - 1
assets/js/view.js

@@ -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 it is too large
+ 0 - 0
assets/min/main.js


+ 4 - 0
php/define.php

@@ -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/');
+
 ?>

+ 6 - 5
php/modules/Album.php

@@ -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;
 		}

+ 3 - 0
php/modules/Photo.php

@@ -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) {

Some files were not shown because too many files changed in this diff