Browse Source

V1.3.1

- Twitter Cards and Open Graph support for shared photos
- Option to set album-password directly after clicking "Make Public"
- Download Album works again
Tobias Reich 10 years ago
parent
commit
2abf49ac38

+ 1 - 1
index.html

@@ -97,7 +97,7 @@
 
 	<!-- Production -->
 	<script defer type="text/javascript" src="js/functions.js"></script>
-
+	
 	<script defer type="text/javascript" src="js/main.js"></script>
 
 	</body>

File diff suppressed because it is too large
+ 0 - 0
js/frameworks.js


File diff suppressed because it is too large
+ 0 - 5
js/functions.js


+ 1 - 1
js/main.js

@@ -26,7 +26,7 @@ $(document).ready(function(){
 	});
 	$("#button_share_album").on(event_name, function(e) {
 		if (album.json.public==1) contextMenu.shareAlbum(album.getID(), e);
-		else modal.show("Share Album", "All photos inside this album will be public and visible for everyone. Existing public photos will have the same sharing permission as this album. Are your sure you want to share this album?", [["Share Album", function() { album.setPublic(album.getID(), e) }], ["Cancel", function() {}]]);
+		else modal.show("Share Album", "All photos inside this album will be public and visible for everyone. Existing public photos will have the same sharing permission as this album. Are your sure you want to share this album? <input class='password' type='password' placeholder='password (optional)' value=''>", [["Share Album", function() { album.setPublic(album.getID(), e) }], ["Cancel", function() {}]]);
 	});
 	$("#button_signout").on(event_name, lychee.logout);
 	$("#button_download").on(event_name, function() { window.open(photo.getDirectLink(),"_newtab") });

+ 18 - 8
js/modules/album.js

@@ -65,16 +65,16 @@ album = {
 				if (durationTime>300) waitTime = 0; else if (refresh) waitTime = 0; else waitTime = 300 - durationTime;
 				if (!visible.albums()&&!visible.photo()&&!visible.album()) waitTime = 0;
 
-				$.timer(waitTime, function() {
-
+				setTimeout(function() {
+				
 					view.album.init();
-
+					
 					if (!refresh) {
 						lychee.animate(".album, .photo", "contentZoomIn");
 						view.header.mode("album");
 					}
-
-				}, false);
+				
+				}, waitTime);
 
 			});
 
@@ -188,17 +188,27 @@ album = {
 	setPublic: function(albumID, e) {
 
 		var params;
+		
+		if ($("input.password").length>0&&$("input.password").val().length>0) {
+		
+			params = "setAlbumPublic&albumID=" + albumID + "&password=" + hex_md5($("input.password").val());
+			album.json.password = true;
+			
+		} else {
+		
+			params = "setAlbumPublic&albumID=" + albumID;
+			album.json.password = false;
+			
+		}
 
 		if (visible.album()) {
 
 			album.json.public = (album.json.public==0) ? 1 : 0;
-			album.json.password = (album.json.public==false) ? true : false;
 			view.album.public();
 			if (album.json.public==1) contextMenu.shareAlbum(albumID, e);
 
 		}
-
-		params = "setAlbumPublic&albumID=" + albumID;
+		
 		lychee.api(params, "text", function(data) {
 
 			if (!data) loadingBar.show("error");

+ 2 - 2
js/modules/albums.js

@@ -66,13 +66,13 @@ albums = {
 			if (durationTime>300) waitTime = 0; else waitTime = 300 - durationTime;
 			if (!visible.albums()&&!visible.photo()&&!visible.album()) waitTime = 0;
 
-			$.timer(waitTime,function(){
+			setTimeout(function() {
 
 				view.header.mode("albums");
 				view.albums.init();
 				lychee.animate(".album, .photo", "contentZoomIn");
 
-			});
+			}, waitTime);
 
 		})
 

+ 1 - 1
js/modules/loadingBar.js

@@ -57,7 +57,7 @@ loadingBar = {
 			clearTimeout(lychee.loadingBar.data("timeout"));
 			lychee.loadingBar.html("").css("height", "3px");
 			if (visible.controls()) lychee.header.css("marginTop", "0px");
-			$.timer(300,function(){ lychee.loadingBar.hide(); });
+			setTimeout(function() { lychee.loadingBar.hide() }, 300);
 
 		}
 

+ 2 - 2
js/modules/lychee.js

@@ -12,7 +12,7 @@ var lychee = {
 
 	init: function() {
 
-		this.version = "1.3";
+		this.version = "1.3.1";
 		this.api_path = "php/api.php";
 		this.update_path = "http://lychee.electerious.com/version/index.php";
 		this.updateURL = "https://github.com/electerious/Lychee";
@@ -57,7 +57,7 @@ var lychee = {
 			dataType: type,
 			success:
 				function(data) {
-					$.timer(100, function(){ loadingBar.hide() });
+					setTimeout(function() { loadingBar.hide() }, 100);
 					callback(data);
 				},
 			error: lychee.error

+ 1 - 1
js/modules/modal.js

@@ -30,7 +30,7 @@ modal = {
 
 		modal.fns = null;
 		$(".message_overlay").removeClass("fadeIn").css("opacity", 0);
-		$.timer(300,function(){ $(".message_overlay").remove() });
+		setTimeout(function() { $(".message_overlay").remove() }, 300);
 
 	}
 

+ 3 - 3
js/modules/photo.js

@@ -45,7 +45,7 @@ photo = {
 			view.photo.init();
 
 			lychee.imageview.show();
-			$.timer(300, function() { lychee.content.show(); });
+			setTimeout(function() { lychee.content.show() }, 300);
 
 		});
 
@@ -87,7 +87,7 @@ photo = {
 
 		    		$(".progressbar div").css("width", "100%");
 					$(".upload_overlay").removeClass("fadeIn").css("opacity", 0);
-					$.timer(300, function() { $(".upload_overlay").remove() });
+					setTimeout(function() { $(".upload_overlay").remove() }, 300);
 
 					if (window.webkitNotifications&&BrowserDetect.browser=="Safari") {
 						popup = window.webkitNotifications.createNotification("", "Upload complete", "You can now manage your new photo.");
@@ -148,7 +148,7 @@ photo = {
 				lychee.api(params, "text", function(data) {
 
 					$(".upload_overlay").removeClass("fadeIn").css("opacity", 0);
-					$.timer(300, function() { $(".upload_overlay").remove() });
+					setTimeout(function() { $(".upload_overlay").remove() }, 300);
 
 					if (data) {
 						if (album.getID()=="") lychee.goto("a0");

+ 2 - 2
js/modules/search.js

@@ -57,7 +57,7 @@ search = {
 
 						search.code = hex_md5(code);
 
-						$.timer(300,function(){
+						setTimeout(function() {
 
 							if (code=="error") $("body").append(build.no_content("search"));
 							else {
@@ -65,7 +65,7 @@ search = {
 								lychee.animate(".album, .photo", "contentZoomIn");
 							}
 
-						});
+						}, 300);
 
 					}
 

+ 1 - 1
js/modules/view.js

@@ -310,7 +310,7 @@ view = {
 
 			// Hide Photo
 			lychee.animate(lychee.imageview, "fadeOut");
-			$.timer(300,function(){ lychee.imageview.hide() });
+			setTimeout(function() { lychee.imageview.hide() }, 300);
 
 		},
 

+ 1 - 1
php/api.php

@@ -37,7 +37,7 @@ if (!empty($_POST['function'])||!empty($_GET['function'])) {
 		if ($_POST['function']=='getAlbum'&&isset($_POST['albumID'])) echo json_encode(getAlbum($_POST['albumID']));
 		if ($_POST['function']=='addAlbum'&&isset($_POST['title'])) echo addAlbum($_POST['title']);
 		if ($_POST['function']=='setAlbumTitle'&&isset($_POST['albumID'])&&isset($_POST['title'])) echo setAlbumTitle($_POST['albumID'], $_POST['title']);
-		if ($_POST['function']=='setAlbumPublic'&&isset($_POST['albumID'])) echo setAlbumPublic($_POST['albumID']);
+		if ($_POST['function']=='setAlbumPublic'&&isset($_POST['albumID'])) echo setAlbumPublic($_POST['albumID'], $_POST['password']);
 		if ($_POST['function']=='setAlbumPassword'&&isset($_POST['albumID'])&&isset($_POST['password'])) echo setAlbumPassword($_POST['albumID'], $_POST['password']);
 		if ($_POST['function']=='deleteAlbum'&&isset($_POST['albumID'])&&isset($_POST['delAll'])) echo deleteAlbum($_POST['albumID'], $_POST['delAll']);
 		if (isset($_GET['function'])&&$_GET['function']=='getAlbumArchive'&&isset($_GET['albumID'])) getAlbumArchive($_GET['albumID']);

+ 19 - 32
php/functions.php

@@ -445,7 +445,7 @@ function getAlbumArchive($albumID) {
     $files = array();
     $i=0;
     while($row = $result->fetch_object()) {
-        $files[$i] = "../".$row->url;
+        $files[$i] = "../uploads/big/".$row->url;
         $i++;
     }
     $query = "SELECT * FROM lychee_albums WHERE id = '$albumID';";
@@ -476,7 +476,7 @@ function getAlbumArchive($albumID) {
 
     return true;
 }
-function setAlbumPublic($albumID) {
+function setAlbumPublic($albumID, $password) {
 	global $database;
 	$query = "SELECT public FROM lychee_albums WHERE id = '$albumID';";
 	$result = $database->query($query);
@@ -494,7 +494,8 @@ function setAlbumPublic($albumID) {
 		$result = $database->query($query);
 		if (!$result) return false;
 	}
-	return true;
+	if (strlen($password)>0) return setAlbumPassword($albumID, $password);
+	else return true;
 }
 function setAlbumPassword($albumID, $password) {
 	global $database;
@@ -568,30 +569,6 @@ function getPhoto($photoID, $albumID) {
 
     return $return;
 }
-function downloadPhoto($photoID) {
-	global $database;
-    $query = "SELECT * FROM lychee_photos WHERE id = '$photoID';";
-    $result = $database->query($query);
-    $row = $result->fetch_object();
-
-    $photo = "../".$row->url;
-    $title = $row->title;
-    $type = "appcication/zip";
-    $filename = "./imageDownload.zip";
-
-    $zip = new ZipArchive();
-    if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) return false;
-
-    $newFile = explode("/",$photo);
-    $newFile = array_reverse($newFile);
-    $zip->addFile($photo, $title.$newFile[0]);
-    $zip->close();
-    header("Content-Type: $type");
-    header("Content-Disposition: attachment; filename=\"$title.zip\"");
-    readfile($filename);
-    unlink($filename);
-    return true;
-}
 function setPhotoPublic($photoID, $url) {
 	global $database;
     $query = "SELECT public FROM lychee_photos WHERE id = '$photoID';";
@@ -746,11 +723,21 @@ function facebookHeader($photoID) {
     $row = $result->fetch_object();
 
     $parseUrl = parse_url("http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
-    $thumb = $parseUrl['scheme']."://".$parseUrl['host'].$parseUrl['path']."/../".$row->thumbUrl;
-
-    $return  = '<meta name="title" content="'.$row->title.'" />';
-    $return .= '<meta name="description" content="'.$row->description.' - via Lychee" />';
-    $return .= '<link rel="image_src"  type="image/jpeg" href="'. $thumb .'" />';
+    $thumb = $parseUrl['scheme']."://".$parseUrl['host'].$parseUrl['path']."/../uploads/big/".$row->thumbUrl;
+
+	$return .= '<!-- General Meta Data -->';
+	$return  = '<meta name="title" content="'.$row->title.'" />';
+	$return .= '<meta name="description" content="'.$row->description.' - via Lychee" />';
+	$return .= '<link rel="image_src"  type="image/jpeg" href="'.$thumb.'" />';
+	
+	$return .= '<!-- Twitter Meta Data -->';
+	$return .= '<meta name="twitter:card" content="photo">';
+	$return .= '<meta name="twitter:title" content="'.$row->title.'">';
+	$return .= '<meta name="twitter:image:src" content="'.$thumb.'">';
+	
+	$return .= '<!-- Facebook Meta Data -->';
+	$return .= '<meta property="og:title" content="'.$row->title.'">';
+	$return .= '<meta property="og:image" content="'.$thumb.'">';
 
     return $return;
 }

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