Browse Source

Merge pull request #9 from electerious/develop

Develop merge
Quentin Ligier 7 years ago
parent
commit
c7d0e5215d

File diff suppressed because it is too large
+ 0 - 0
dist/main.css


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


+ 24 - 0
docs/Changelog.md

@@ -1,3 +1,27 @@
+## v3.1.2
+
+Released June 12, 2016
+
+- `Improved` Added indexes to SQL fields to improve query execution time (Thanks @qligier, #533)
+- `Improved` Protocol-relative URLs for open graph metadata (#546)
+- `Improved` Remove metadata from medium-sized images and thumbnails (Imagick only) (#556)
+- `Improved` Reduce quality of medium-sized images (Imagick only) (#556)
+- `Improved` orientation-handling with Imagick (#556)
+
+## v3.1.1
+
+Released April 30, 2016
+
+- `New` share button when logged out (#473)
+- `New` Import of IPTC photo tags (Thanks @qligier, #514)
+- `New` Added reset username and password to FAQ (#500 #128)
+- `Improved` Removed will-change from the main image to improve the image rendering in Chrome (#501)
+- `Improved` scroll and rendering performance by removing will-change
+- `Improved` Open Facebook and Twitter sharing sheet in new window
+- `Improved` EXIF and IPTC extraction (Thanks @qligier, #518)
+- `Fixed` broken URL in Update.md (#516)
+- `Fixed` error 500 on database connect error (Thanks @tribut, #530)
+
 ## v3.1.0
 
 Released March 29, 2016

+ 1 - 1
docs/Installation.md

@@ -3,7 +3,7 @@ Everything you need is a web-server with PHP 5.5 or later and a MySQL-Database.
 
 The following PHP extensions must be activated:
 
-	exif, gd, json, mbstring, mysqli, zip
+	session, exif, mbstring, gd, mysqli, json, zip
 	
 To use Lychee without restrictions, we recommend to increase the values of the following properties in `php.ini`:
 

+ 5 - 5
php/Modules/Album.php

@@ -99,22 +99,22 @@ final class Album {
 
 			case 'f':
 				$return['public'] = '0';
-				$query = Database::prepare(Database::get(), "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE star = 1 " . Settings::get()['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS));
+				$query = Database::prepare(Database::get(), "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url, medium FROM ? WHERE star = 1 " . Settings::get()['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS));
 				break;
 
 			case 's':
 				$return['public'] = '0';
-				$query = Database::prepare(Database::get(), "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE public = 1 " . Settings::get()['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS));
+				$query = Database::prepare(Database::get(), "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url, medium FROM ? WHERE public = 1 " . Settings::get()['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS));
 				break;
 
 			case 'r':
 				$return['public'] = '0';
-				$query = Database::prepare(Database::get(), "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE LEFT(id, 10) >= unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 DAY)) " . Settings::get()['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS));
+				$query = Database::prepare(Database::get(), "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url, medium FROM ? WHERE LEFT(id, 10) >= unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 DAY)) " . Settings::get()['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS));
 				break;
 
 			case '0':
 				$return['public'] = '0';
-				$query = Database::prepare(Database::get(), "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE album = 0 " . Settings::get()['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS));
+				$query = Database::prepare(Database::get(), "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url, medium FROM ? WHERE album = 0 " . Settings::get()['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS));
 				break;
 
 			default:
@@ -122,7 +122,7 @@ final class Album {
 				$albums = Database::execute(Database::get(), $query, __METHOD__, __LINE__);
 				$return = $albums->fetch_assoc();
 				$return = Album::prepareData($return);
-				$query  = Database::prepare(Database::get(), "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE album = '?' " . Settings::get()['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS, $this->albumIDs));
+				$query  = Database::prepare(Database::get(), "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url, medium FROM ? WHERE album = '?' " . Settings::get()['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS, $this->albumIDs));
 				break;
 
 		}

+ 2 - 1
php/Modules/Database.php

@@ -14,7 +14,8 @@ final class Database {
 		'030000', // 3.0.0
 		'030001', // 3.0.1
 		'030003', // 3.0.3
-		'030100' // 3.1.0
+		'030100', // 3.1.0
+		'030102' // 3.1.2
 	);
 
 	/**

+ 70 - 25
php/Modules/Photo.php

@@ -238,7 +238,6 @@ final class Photo {
 
 		}
 
-		// Save to DB
 		$values = array(LYCHEE_TABLE_PHOTOS, $id, $info['title'], $photo_name, $info['description'], $info['tags'], $info['type'], $info['width'], $info['height'], $info['size'], $info['iso'], $info['aperture'], $info['make'], $info['model'], $info['shutter'], $info['focal'], $info['takestamp'], $path_thumb, $albumID, $public, $star, $checksum, $medium);
 		$query  = Database::prepare(Database::get(), "INSERT INTO ? (id, title, url, description, tags, type, width, height, size, iso, aperture, make, model, shutter, focal, takestamp, thumbUrl, album, public, star, checksum, medium) VALUES ('?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?')", $values);
 		$result = Database::execute(Database::get(), $query, __METHOD__, __LINE__);
@@ -296,7 +295,7 @@ final class Photo {
 		Plugins::get()->activate(__METHOD__, 0, func_get_args());
 
 		// Quality of thumbnails
-		$thumbQuality = 90;
+		$quality = 90;
 
 		// Size of the thumbnail
 		$newWidth  = 200;
@@ -312,9 +311,12 @@ final class Photo {
 			// Read image
 			$thumb = new Imagick();
 			$thumb->readImage($url);
-			$thumb->setImageCompressionQuality($thumbQuality);
+			$thumb->setImageCompressionQuality($quality);
 			$thumb->setImageFormat('jpeg');
 
+			// Remove metadata to save some bytes
+			$thumb->stripImage();
+
 			// Copy image for 2nd thumb version
 			$thumb2x = clone $thumb;
 
@@ -359,12 +361,12 @@ final class Photo {
 
 			// Create thumb
 			fastImageCopyResampled($thumb, $sourceImg, 0, 0, $startWidth, $startHeight, $newWidth, $newHeight, $newSize, $newSize);
-			imagejpeg($thumb, $newUrl, $thumbQuality);
+			imagejpeg($thumb, $newUrl, $quality);
 			imagedestroy($thumb);
 
 			// Create retina thumb
 			fastImageCopyResampled($thumb2x, $sourceImg, 0, 0, $startWidth, $startHeight, $newWidth*2, $newHeight*2, $newSize, $newSize);
-			imagejpeg($thumb2x, $newUrl2x, $thumbQuality);
+			imagejpeg($thumb2x, $newUrl2x, $quality);
 			imagedestroy($thumb2x);
 
 			// Free memory
@@ -395,6 +397,9 @@ final class Photo {
 		// Call plugins
 		Plugins::get()->activate(__METHOD__, 0, func_get_args());
 
+		// Quality of medium-photo
+		$quality = 90;
+
 		// Set to true when creation of medium-photo failed
 		$error = false;
 
@@ -427,6 +432,8 @@ final class Photo {
 
 			// Adjust image
 			$medium->scaleImage($newWidth, $newHeight, true);
+			$medium->stripImage();
+			$medium->setImageCompressionQuality($quality);
 
 			// Save image
 			try { $medium->writeImage($newUrl); }
@@ -472,20 +479,50 @@ final class Photo {
 
 		if (extension_loaded('imagick')&&Settings::get()['imagick']==='1') {
 
-			switch ($info['orientation']) {
+			$image = new Imagick();
+			$image->readImage($path);
 
-				case 3:
-					$rotateImage = 180;
+			$orientation = $image->getImageOrientation();
+
+			switch ($orientation) {
+
+				case Imagick::ORIENTATION_TOPLEFT:
+					return false;
 					break;
 
-				case 6:
-					$rotateImage = 90;
-					$swapSize    = true;
+				case Imagick::ORIENTATION_TOPRIGHT:
+					$image->flopImage();
 					break;
 
-				case 8:
-					$rotateImage = 270;
-					$swapSize    = true;
+				case Imagick::ORIENTATION_BOTTOMRIGHT:
+					$image->rotateImage(new ImagickPixel(), 180);
+					break;
+
+				case Imagick::ORIENTATION_BOTTOMLEFT:
+					$image->flopImage();
+					$image->rotateImage(new ImagickPixel(), 180);
+					break;
+
+				case Imagick::ORIENTATION_LEFTTOP:
+					$image->flopImage();
+					$image->rotateImage(new ImagickPixel(), -90);
+					$swapSize = true;
+					break;
+
+				case Imagick::ORIENTATION_RIGHTTOP:
+					$image->rotateImage(new ImagickPixel(), 90);
+					$swapSize = true;
+					break;
+
+				case Imagick::ORIENTATION_RIGHTBOTTOM:
+					$image->flopImage();
+					$image->rotateImage(new ImagickPixel(), 90);
+					$swapSize = true;
+					break;
+
+				case Imagick::ORIENTATION_LEFTBOTTOM:
+					$image->rotateImage(new ImagickPixel(), -90);
+					$swapSize = true;
 					break;
 
 				default:
@@ -494,15 +531,13 @@ final class Photo {
 
 			}
 
-			if ($rotateImage!==0) {
-				$image = new Imagick();
-				$image->readImage($path);
-				$image->rotateImage(new ImagickPixel(), $rotateImage);
-				$image->setImageOrientation(1);
-				$image->writeImage($path);
-				$image->clear();
-				$image->destroy();
-			}
+			// Adjust photo
+			$image->setImageOrientation(Imagick::ORIENTATION_TOPLEFT);
+			$image->writeImage($path);
+
+			// Free memory
+			$image->clear();
+			$image->destroy();
 
 		} else {
 
@@ -512,6 +547,11 @@ final class Photo {
 
 			switch ($info['orientation']) {
 
+				case 1:
+					// do nothing
+					return false;
+					break;
+
 				case 2:
 					// mirror
 					// not yet implemented
@@ -561,6 +601,7 @@ final class Photo {
 			}
 
 			// Recreate photo
+			// In this step the photos also loses its metadata :(
 			$newSourceImg = imagecreatetruecolor($newWidth, $newHeight);
 			imagecopyresampled($newSourceImg, $sourceImg, 0, 0, 0, 0, $newWidth, $newHeight, $newWidth, $newHeight);
 			imagejpeg($newSourceImg, $path, 100);
@@ -593,7 +634,7 @@ final class Photo {
 	public static function prepareData(array $data) {
 
 		// Excepts the following:
-		// (array) $data = ['id', 'title', 'tags', 'public', 'star', 'album', 'thumbUrl', 'takestamp', 'url']
+		// (array) $data = ['id', 'title', 'tags', 'public', 'star', 'album', 'thumbUrl', 'takestamp', 'url', 'medium']
 
 		// Init
 		$photo = null;
@@ -606,7 +647,11 @@ final class Photo {
 		$photo['star']   = $data['star'];
 		$photo['album']  = $data['album'];
 
-		// Parse urls
+		// Parse medium
+		if ($data['medium']==='1') $photo['medium'] = LYCHEE_URL_UPLOADS_MEDIUM . $data['url'];
+		else                       $photo['medium'] = '';
+
+		// Parse paths
 		$photo['thumbUrl'] = LYCHEE_URL_UPLOADS_THUMB . $data['thumbUrl'];
 		$photo['url']      = LYCHEE_URL_UPLOADS_BIG . $data['url'];
 

+ 2 - 2
php/database/albums_table.sql

@@ -2,7 +2,7 @@
 # ------------------------------------------------------------
 
 CREATE TABLE IF NOT EXISTS `?` (
-  `id` bigint(14) NOT NULL,
+  `id` bigint(14) unsigned NOT NULL,
   `title` varchar(100) NOT NULL DEFAULT '',
   `description` varchar(1000) DEFAULT '',
   `sysstamp` int(11) NOT NULL,
@@ -11,4 +11,4 @@ CREATE TABLE IF NOT EXISTS `?` (
   `downloadable` tinyint(1) NOT NULL DEFAULT '0',
   `password` varchar(100) DEFAULT NULL,
   PRIMARY KEY (`id`)
-) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;

+ 2 - 2
php/database/log_table.sql

@@ -7,6 +7,6 @@ CREATE TABLE IF NOT EXISTS `?` (
   `type` varchar(11) NOT NULL,
   `function` varchar(100) NOT NULL,
   `line` int(11) NOT NULL,
-  `text` TEXT,
+  `text` text,
   PRIMARY KEY (`id`)
-) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;

+ 9 - 7
php/database/photos_table.sql

@@ -2,8 +2,8 @@
 # ------------------------------------------------------------
 
 CREATE TABLE IF NOT EXISTS `?` (
-  `id` bigint(14) NOT NULL,
-  `title` varchar(100) NOT NULL,
+  `id` bigint(14) unsigned NOT NULL,
+  `title` varchar(100) NOT NULL DEFAULT '',
   `description` varchar(1000) DEFAULT '',
   `url` varchar(100) NOT NULL,
   `tags` varchar(1000) NOT NULL DEFAULT '',
@@ -20,9 +20,11 @@ CREATE TABLE IF NOT EXISTS `?` (
   `focal` varchar(20) NOT NULL,
   `takestamp` int(11) DEFAULT NULL,
   `star` tinyint(1) NOT NULL,
-  `thumbUrl` varchar(50) NOT NULL,
-  `album` varchar(30) NOT NULL DEFAULT '0',
-  `checksum` VARCHAR(100) DEFAULT NULL,
+  `thumbUrl` char(37) NOT NULL,
+  `album` bigint(20) unsigned NOT NULL,
+  `checksum` char(40) DEFAULT NULL,
   `medium` tinyint(1) NOT NULL DEFAULT '0',
-  PRIMARY KEY (`id`)
-) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
+  PRIMARY KEY (`id`),
+  KEY `Index_album` (`album`),
+  KEY `Index_star` (`star`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;

+ 1 - 1
php/database/settings_table.sql

@@ -4,4 +4,4 @@
 CREATE TABLE IF NOT EXISTS `?` (
   `key` varchar(50) NOT NULL DEFAULT '',
   `value` varchar(200) DEFAULT ''
-) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;

+ 73 - 0
php/database/update_030102.php

@@ -0,0 +1,73 @@
+<?php
+
+/**
+ * Update to version 3.1.2
+ */
+
+use Lychee\Modules\Database;
+use Lychee\Modules\Response;
+
+// Change type of the album id field
+$query  = Database::prepare($connection, "ALTER TABLE `?` CHANGE `album` `album` BIGINT(14) UNSIGNED NOT NULL", array(LYCHEE_TABLE_PHOTOS));
+$result = Database::execute($connection, $query, 'update_030102', __LINE__);
+
+if ($result===false) Response::error('Could not change type of the album id field!');
+
+// Add index to the album id field
+$query  = Database::prepare($connection, "SHOW INDEX FROM `?` WHERE KEY_NAME = 'Index_album'", array(LYCHEE_TABLE_PHOTOS));
+$result = Database::execute($connection, $query, 'update_030102', __LINE__);
+
+if ($result===false) Response::error('Could not check if Index_album exists!');
+
+if ($result->num_rows===0) {
+
+	$query  = Database::prepare($connection, "ALTER TABLE `?` ADD INDEX `Index_album` (`album`)", array(LYCHEE_TABLE_PHOTOS));
+	$result = Database::execute($connection, $query, 'update_030102', __LINE__);
+
+	if ($result===false) Response::error('Could not add index to the album id field!');
+
+}
+
+// Add index to the star field
+$query  = Database::prepare($connection, "SHOW INDEX FROM `?` WHERE KEY_NAME = 'Index_star'", array(LYCHEE_TABLE_PHOTOS));
+$result = Database::execute($connection, $query, 'update_030102', __LINE__);
+
+if ($result===false) Response::error('Could not check if Index_star exists!');
+
+if ($result->num_rows===0) {
+
+	$query  = Database::prepare($connection, "ALTER TABLE `?` ADD INDEX `Index_star` (`star`)", array(LYCHEE_TABLE_PHOTOS));
+	$result = Database::execute($connection, $query, 'update_030102', __LINE__);
+
+	if ($result===false) Response::error('Could not add index to the star field!');
+
+}
+
+// Change type of the checksum field
+$query  = Database::prepare($connection, "ALTER TABLE `?` CHANGE `checksum` `checksum` CHAR(40) NULL DEFAULT NULL", array(LYCHEE_TABLE_PHOTOS));
+$result = Database::execute($connection, $query, 'update_030102', __LINE__);
+
+if ($result===false) Response::error('Could not change type of the checksum field!');
+
+// Change type of the thumbUrl field
+$query  = Database::prepare($connection, "ALTER TABLE `?` CHANGE `thumbUrl` `thumbUrl` CHAR(37) NOT NULL", array(LYCHEE_TABLE_PHOTOS));
+$result = Database::execute($connection, $query, 'update_030102', __LINE__);
+
+if ($result===false) Response::error('Could not change type of the thumbUrl field!');
+
+// Change type of the id field
+$query  = Database::prepare($connection, "ALTER TABLE `?` CHANGE `id` `id` BIGINT(14) UNSIGNED NOT NULL", array(LYCHEE_TABLE_PHOTOS));
+$result = Database::execute($connection, $query, 'update_030102', __LINE__);
+
+if ($result===false) Response::error('Could not change type of the id field!');
+
+// Change type of the id field
+$query  = Database::prepare($connection, "ALTER TABLE `?` CHANGE `id` `id` BIGINT(14) UNSIGNED NOT NULL", array(LYCHEE_TABLE_ALBUMS));
+$result = Database::execute($connection, $query, 'update_030102', __LINE__);
+
+if ($result===false) Response::error('Could not change type of the id field!');
+
+// Set version
+if (Database::setVersion($connection, '030102')===false) Response::error('Could not update version of database!');
+
+?>

+ 2 - 2
php/helpers/getGraphHeader.php

@@ -24,8 +24,8 @@ function getGraphHeader($photoID) {
 	else                    $dir = 'big';
 
 	$parseUrl = parse_url('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
-	$url      = $parseUrl['scheme'] . '://' . $parseUrl['host'] . $parseUrl['path'] . '?' . $parseUrl['query'];
-	$picture  = $parseUrl['scheme'] . '://' . $parseUrl['host'] . $parseUrl['path'] . '/../uploads/' . $dir . '/' . $row->url;
+	$url      = '//' . $parseUrl['host'] . $parseUrl['path'] . '?' . $parseUrl['query'];
+	$picture  = '//' . $parseUrl['host'] . $parseUrl['path'] . '/../uploads/' . $dir . '/' . $row->url;
 
 	$url     = htmlentities($url);
 	$picture = htmlentities($picture);

+ 11 - 4
plugins/Diagnostics/index.php

@@ -53,10 +53,13 @@ if (hasPermissions(LYCHEE_UPLOADS)===false)        $error .= ('Error: \'uploads/
 if (hasPermissions(LYCHEE_DATA)===false)           $error .= ('Error: \'data/\' is missing or has insufficient read/write privileges' . PHP_EOL);
 
 // About GD
-$gdVersion = gd_info();
-if (!$gdVersion['JPEG Support'])                                          $error .= ('Error: PHP gd extension without jpeg support' . PHP_EOL);
-if (!$gdVersion['PNG Support'])                                           $error .= ('Error: PHP gd extension without png support' . PHP_EOL);
-if (!$gdVersion['GIF Read Support'] || !$gdVersion['GIF Create Support']) $error .= ('Error: PHP gd extension without full gif support' . PHP_EOL);
+$gdVersion = array('GD Version' => '-');
+if (function_exists('gd_info')) {
+	$gdVersion = gd_info();
+	if (!$gdVersion['JPEG Support'])                                          $error .= ('Error: PHP gd extension without jpeg support' . PHP_EOL);
+	if (!$gdVersion['PNG Support'])                                           $error .= ('Error: PHP gd extension without png support' . PHP_EOL);
+	if (!$gdVersion['GIF Read Support'] || !$gdVersion['GIF Create Support']) $error .= ('Error: PHP gd extension without full gif support' . PHP_EOL);
+}
 
 // Load config
 if (!file_exists(LYCHEE_CONFIG_FILE)) exit('Error: Configuration not found. Please install Lychee for additional tests');
@@ -96,6 +99,10 @@ if (empty(ini_get('allow_url_fopen'))) echo('Warning: You may experience problem
 // Check mysql version
 if ($database->server_version<50500) echo('Warning: Lychee uses the GBK charset to avoid sql injections on your MySQL version. Please update to MySQL 5.5 or higher to enable UTF-8 support.' . PHP_EOL);
 
+// Check imagick
+if (!extension_loaded('imagick')) echo('Warning: Pictures that are rotated lose their metadata! Please install Imagick to avoid that.' . PHP_EOL);
+else if (!$settings['imagick']) echo('Warning: Pictures that are rotated lose their metadata! Please enable Imagick in settings to avoid that.' . PHP_EOL);
+
 // Output
 if ($error==='') echo('No critical problems found. Lychee should work without problems!' . PHP_EOL);
 else             echo $error;

File diff suppressed because it is too large
+ 1254 - 105
src/npm-shrinkwrap.json


+ 9 - 9
src/package.json

@@ -1,6 +1,6 @@
 {
   "name": "Lychee",
-  "version": "3.1.0",
+  "version": "3.1.2",
   "description": "Self-hosted photo-management done right.",
   "authors": "Tobias Reich <tobias@electerious.com>",
   "license": "MIT",
@@ -14,20 +14,20 @@
     "compile": "gulp"
   },
   "dependencies": {
-    "babel-preset-es2015": "^6.6.0",
+    "babel-preset-es2015": "^6.13.2",
     "basiccontext": "^3.5.1",
-    "basicmodal": "^3.3.4",
+    "basicmodal": "^3.3.7",
     "gulp": "^3.9.1",
     "gulp-autoprefixer": "3.1.0",
     "gulp-babel": "^6.1.2",
     "gulp-concat": "^2.6.0",
-    "gulp-inject": "^4.0.0",
-    "gulp-load-plugins": "^1.2.0",
+    "gulp-inject": "^4.1.0",
+    "gulp-load-plugins": "^1.2.4",
     "gulp-minify-css": "^1.2.4",
     "gulp-rimraf": "^0.2.0",
-    "gulp-sass": "^2.2.0",
-    "gulp-uglify": "^1.5.3",
-    "jquery": "^2.2.3",
-    "mousetrap": "^1.5.3"
+    "gulp-sass": "^2.3.2",
+    "gulp-uglify": "^2.0.0",
+    "jquery": "^3.1.0",
+    "mousetrap": "^1.6.0"
   }
 }

+ 6 - 2
src/scripts/contextMenu.js

@@ -306,10 +306,12 @@ contextMenu.sharePhoto = function(photoID, e) {
 		{ title: build.iconic('envelope-closed') + 'Mail', fn: () => photo.share(photoID, 'mail') },
 		{ title: build.iconic('dropbox', iconClass) + 'Dropbox', visible: lychee.publicMode===false, fn: () => photo.share(photoID, 'dropbox') },
 		{ title: build.iconic('link-intact') + 'Direct Link', fn: () => window.open(photo.getDirectLink()) },
-		{ visible: lychee.publicMode===false },
+		{ },
 		{ title: build.iconic('ban') + 'Make Private', visible: lychee.publicMode===false, fn: () => photo.setPublic(photoID) }
 	]
 
+	if (lychee.publicMode===true) items.splice(7, 1)
+
 	basicContext.show(items, e.originalEvent)
 	$('.basicContext input#link').focus().select()
 
@@ -325,11 +327,13 @@ contextMenu.shareAlbum = function(albumID, e) {
 		{ title: build.iconic('twitter', iconClass) + 'Twitter', fn: () => album.share('twitter') },
 		{ title: build.iconic('facebook', iconClass) + 'Facebook', fn: () => album.share('facebook') },
 		{ title: build.iconic('envelope-closed') + 'Mail', fn: () => album.share('mail') },
-		{ visible: lychee.publicMode===false },
+		{ },
 		{ title: build.iconic('pencil') + 'Edit Sharing', visible: lychee.publicMode===false, fn: () => album.setPublic(albumID, true, e) },
 		{ title: build.iconic('ban') + 'Make Private', visible: lychee.publicMode===false, fn: () => album.setPublic(albumID, false) }
 	]
 
+	if (lychee.publicMode===true) items.splice(5, 1)
+
 	basicContext.show(items, e.originalEvent)
 	$('.basicContext input#link').focus().select()
 

+ 3 - 11
src/scripts/header.js

@@ -67,8 +67,6 @@ header.bind = function() {
 
 header.show = function() {
 
-	clearTimeout($(window).data('timeout'))
-
 	lychee.imageview.removeClass('full')
 	header.dom().removeClass('header--hidden')
 
@@ -76,18 +74,12 @@ header.show = function() {
 
 }
 
-header.hide = function(e, delay = 500) {
+header.hide = function(e) {
 
 	if (visible.photo() && !visible.sidebar() && !visible.contextMenu() && basicModal.visible()===false) {
 
-		clearTimeout($(window).data('timeout'))
-
-		$(window).data('timeout', setTimeout(function() {
-
-			lychee.imageview.addClass('full')
-			header.dom().addClass('header--hidden')
-
-		}, delay))
+		lychee.imageview.addClass('full')
+		header.dom().addClass('header--hidden')
 
 		return true
 

+ 1 - 1
src/scripts/init.js

@@ -80,7 +80,7 @@ $(document).ready(function() {
 			// Fullscreen on mobile
 			.on('touchend', '#imageview #image', function(e) {
 				if (swipe.obj==null || (swipe.offset>=-5&&swipe.offset<=5)) {
-					if (visible.header()) header.hide(e, 0)
+					if (visible.header()) header.hide(e)
 					else                  header.show()
 				}
 			})

+ 2 - 2
src/scripts/lychee.js

@@ -6,8 +6,8 @@
 lychee = {
 
 	title           : document.title,
-	version         : '3.1.0',
-	versionCode     : '030100',
+	version         : '3.1.2',
+	versionCode     : '030102',
 
 	updatePath      : '//update.electerious.com/index.json',
 	updateURL       : 'https://github.com/electerious/Lychee',

+ 1 - 1
src/scripts/multiselect.js

@@ -159,7 +159,7 @@ multiselect.resize = function(e) {
 
 multiselect.stopResize = function() {
 
-	$(document).off('mousemove mouseup')
+	if (multiselect.position.top!==null) $(document).off('mousemove mouseup')
 
 }
 

+ 5 - 3
src/scripts/photo.js

@@ -82,10 +82,12 @@ photo.preloadNext = function(photoID) {
 	    album.json.content[photoID].nextPhoto!='') {
 
 		let nextPhoto = album.json.content[photoID].nextPhoto
-		let url       = album.json.content[nextPhoto].url
+		let medium    = album.json.content[nextPhoto].medium
 
-		$('head [data-prefetch]').remove()
-		$('head').append(`<link data-prefetch rel="prefetch" href="${ url }">`)
+		if (medium!=null && medium!=='') {
+			$('head [data-prefetch]').remove()
+			$('head').append(`<link data-prefetch rel="prefetch" href="${ medium }">`)
+		}
 
 	}
 

+ 7 - 5
src/scripts/view.js

@@ -309,9 +309,12 @@ view.photo = {
 		$('body').css('overflow', 'hidden')
 
 		// Fullscreen
-		$(document)
-			.bind('mouseenter', header.show)
-			.bind('mouseleave', header.hide)
+		var timeout
+		$(document).bind('mousemove', function() {
+			clearTimeout(timeout)
+			header.show()
+			timeout = setTimeout(header.hide, 1000)
+		})
 
 		lychee.animate(lychee.imageview, 'fadeIn')
 
@@ -329,8 +332,7 @@ view.photo = {
 
 		// Disable Fullscreen
 		$(document)
-			.unbind('mouseenter')
-			.unbind('mouseleave')
+			.unbind('mousemove')
 
 		// Hide Photo
 		lychee.animate(lychee.imageview, 'fadeOut')

+ 9 - 0
src/scripts/view/main.js

@@ -60,6 +60,15 @@ lychee.html = function(literalSections, ...substs) {
 
 }
 
+lychee.getEventName = function() {
+
+	let touchendSupport = (/Android|iPhone|iPad|iPod/i).test(navigator.userAgent || navigator.vendor || window.opera) && ('ontouchend' in document.documentElement)
+	let eventName       = (touchendSupport===true ? 'touchend' : 'click')
+
+	return eventName
+
+}
+
 // Sub-implementation of photo -------------------------------------------------------------- //
 
 let photo = {}

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