From e5363e2f7a16ec9eeffd4fa9fec0cd6101f53228 Mon Sep 17 00:00:00 2001 From: Shane Liesegang Date: Wed, 27 Jan 2021 12:36:13 +0200 Subject: [PATCH 1/5] adding backend setting to disable display of GPS direction on map --- .../Administration/SettingsController.php | 18 +++++++++ ...27_085903_config_map_display_direction.php | 40 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 database/migrations/2021_01_27_085903_config_map_display_direction.php diff --git a/app/Http/Controllers/Administration/SettingsController.php b/app/Http/Controllers/Administration/SettingsController.php index 03b527f5ee..215aa20b8d 100644 --- a/app/Http/Controllers/Administration/SettingsController.php +++ b/app/Http/Controllers/Administration/SettingsController.php @@ -241,6 +241,24 @@ public function setMapDisplayPublic(Request $request) return Configs::set('map_display_public', '0') ? 'true' : 'false'; } + /** + * Enable display of photo direction on map. + * + * @param Request $request + * + * @return string + */ + public function setMapDisplayDirection(Request $request) + { + $request->validate(['map_display_direction' => 'required|string']); + + if ($request['map_display_direction'] == '1') { + return Configs::set('map_display_direction', '1') ? 'true' : 'false'; + } + + return Configs::set('map_display_direction', '0') ? 'true' : 'false'; + } + /** * Set provider of OSM map tiles. * diff --git a/database/migrations/2021_01_27_085903_config_map_display_direction.php b/database/migrations/2021_01_27_085903_config_map_display_direction.php new file mode 100644 index 0000000000..43bb19609c --- /dev/null +++ b/database/migrations/2021_01_27_085903_config_map_display_direction.php @@ -0,0 +1,40 @@ +insert([ + [ + 'key' => 'map_display_direction', + 'value' => '1', + 'confidentiality' => 1, + 'cat' => 'Mod Map', + 'type_range' => BOOL, + ], + ]); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Configs::where('key', '=', 'map_display_direction')->delete(); + } +} From b5c1aa33032b968f1b76adedbf9623fdcad52366 Mon Sep 17 00:00:00 2001 From: Shane Liesegang Date: Wed, 27 Jan 2021 13:45:12 +0200 Subject: [PATCH 2/5] fixing confidentiality --- .../2021_01_27_085903_config_map_display_direction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/migrations/2021_01_27_085903_config_map_display_direction.php b/database/migrations/2021_01_27_085903_config_map_display_direction.php index 43bb19609c..924daabacc 100644 --- a/database/migrations/2021_01_27_085903_config_map_display_direction.php +++ b/database/migrations/2021_01_27_085903_config_map_display_direction.php @@ -21,7 +21,7 @@ public function up() [ 'key' => 'map_display_direction', 'value' => '1', - 'confidentiality' => 1, + 'confidentiality' => 0, 'cat' => 'Mod Map', 'type_range' => BOOL, ], From 308a293ea567313cba3c5579bd3ddff2adadbb11 Mon Sep 17 00:00:00 2001 From: Shane Liesegang Date: Wed, 27 Jan 2021 17:19:26 +0200 Subject: [PATCH 3/5] removing unneeded code since this isn't exposed in the GUI --- .../Administration/SettingsController.php | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/app/Http/Controllers/Administration/SettingsController.php b/app/Http/Controllers/Administration/SettingsController.php index 215aa20b8d..02e35e917f 100644 --- a/app/Http/Controllers/Administration/SettingsController.php +++ b/app/Http/Controllers/Administration/SettingsController.php @@ -223,24 +223,6 @@ public function setMapDisplay(Request $request) return Configs::set('map_display', '0') ? 'true' : 'false'; } - /** - * Enable display of photos on map for public albums. - * - * @param Request $request - * - * @return string - */ - public function setMapDisplayPublic(Request $request) - { - $request->validate(['map_display_public' => 'required|string']); - - if ($request['map_display_public'] == '1') { - return Configs::set('map_display_public', '1') ? 'true' : 'false'; - } - - return Configs::set('map_display_public', '0') ? 'true' : 'false'; - } - /** * Enable display of photo direction on map. * From 0e2daf7b57df22d231e0c2a2b0a09efc603dbdf2 Mon Sep 17 00:00:00 2001 From: Shane Liesegang Date: Wed, 27 Jan 2021 17:20:59 +0200 Subject: [PATCH 4/5] whoops wrong thing --- .../Administration/SettingsController.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Administration/SettingsController.php b/app/Http/Controllers/Administration/SettingsController.php index 02e35e917f..03b527f5ee 100644 --- a/app/Http/Controllers/Administration/SettingsController.php +++ b/app/Http/Controllers/Administration/SettingsController.php @@ -224,21 +224,21 @@ public function setMapDisplay(Request $request) } /** - * Enable display of photo direction on map. + * Enable display of photos on map for public albums. * * @param Request $request * * @return string */ - public function setMapDisplayDirection(Request $request) + public function setMapDisplayPublic(Request $request) { - $request->validate(['map_display_direction' => 'required|string']); + $request->validate(['map_display_public' => 'required|string']); - if ($request['map_display_direction'] == '1') { - return Configs::set('map_display_direction', '1') ? 'true' : 'false'; + if ($request['map_display_public'] == '1') { + return Configs::set('map_display_public', '1') ? 'true' : 'false'; } - return Configs::set('map_display_direction', '0') ? 'true' : 'false'; + return Configs::set('map_display_public', '0') ? 'true' : 'false'; } /** From d5eca808814a6150cbd872c131218547cdac1b4b Mon Sep 17 00:00:00 2001 From: ildyria Date: Sat, 30 Jan 2021 12:05:14 +0100 Subject: [PATCH 5/5] sync Lychee-front --- public/Lychee-front | 2 +- public/dist/main.js | 140 +++++++++++++++++++++++++++++++------------- 2 files changed, 99 insertions(+), 43 deletions(-) diff --git a/public/Lychee-front b/public/Lychee-front index 5ad5a22a72..fa05c2ac31 160000 --- a/public/Lychee-front +++ b/public/Lychee-front @@ -1 +1 @@ -Subproject commit 5ad5a22a7283b1084dbc60a0a9c9b6bee007c337 +Subproject commit fa05c2ac31f8645ae2e986612f5c00c366aea9f4 diff --git a/public/dist/main.js b/public/dist/main.js index 753a6554d1..1372f26e25 100644 --- a/public/dist/main.js +++ b/public/dist/main.js @@ -347,7 +347,7 @@ var _templateObject = _taggedTemplateLiteral(["

", " Lychee ", "\n\t\t\t\t

\n\t\t\t\t

", "

\n\t\t\t\t

Lychee ", "

\n\t\t\t "], ["\n\t\t\t\t

Lychee ", "

\n\t\t\t\t\n\t\t\t\t

", "

\n\t\t\t\t

Lychee ", "

\n\t\t\t "]), _templateObject50 = _taggedTemplateLiteral(["\n\t\t\t", "\n\t\t\t
\n\t\t\t\t\n\t\t\t\t

Lychee ", "", "

\n\t\t\t
\n\t\t\t"], ["\n\t\t\t", "\n\t\t\t
\n\t\t\t\t\n\t\t\t\t

Lychee ", "", "

\n\t\t\t
\n\t\t\t"]), _templateObject51 = _taggedTemplateLiteral([""], [""]), - _templateObject52 = _taggedTemplateLiteral(["

", " '", "' ", "

"], ["

", " '", "' ", "

"]), + _templateObject52 = _taggedTemplateLiteral(["

", " '", "'", "

"], ["

", " '", "'", "

"]), _templateObject53 = _taggedTemplateLiteral(["

", " ", " ", "

"], ["

", " ", " ", "

"]), _templateObject54 = _taggedTemplateLiteral([""], [""]), _templateObject55 = _taggedTemplateLiteral(["

", " ", " ", " ", "

"], ["

", " ", " ", " ", "

"]), @@ -1757,6 +1757,35 @@ album.isUploadable = function () { return album.json.owner === lychee.username; }; +album.updatePhoto = function (data) { + if (album.json) { + $.each(album.json.photos, function () { + if (this.id === data.id) { + this.width = data.width; + this.height = data.height; + this.small = data.small; + this.small_dim = data.small_dim; + this.small2x = data.small2x; + this.small2x_dim = data.small2x_dim; + this.medium = data.medium; + this.medium_dim = data.medium_dim; + this.medium2x = data.medium2x; + this.medium2x_dim = data.medium2x_dim; + this.thumbUrl = data.thumbUrl; + this.thumb2x = data.thumb2x; + this.url = data.url; + this.size = data.size; + + view.album.content.updatePhoto(this); + albums.refresh(); + + return false; + } + return true; + }); + } +}; + album.reload = function () { var albumID = album.getID(); @@ -4035,6 +4064,7 @@ var lychee = { image_overlay_type_default: "exif", // image overlay type default type map_display: false, // display photo coordinates on map map_display_public: false, // display photos of public album on map (user not logged in) + map_display_direction: true, // use the GPS direction data on displayed maps map_provider: "Wikimedia", // Provider of OSM Tiles map_include_subalbums: false, // include photos of subalbums on map location_decoding: false, // retrieve location name from GPS data @@ -4197,6 +4227,7 @@ lychee.init = function () { lychee.image_overlay_type_default = lychee.image_overlay_type; lychee.map_display = data.config.map_display && data.config.map_display === "1" || false; lychee.map_display_public = data.config.map_display_public && data.config.map_display_public === "1" || false; + lychee.map_display_direction = data.config.map_display_direction && data.config.map_display_direction === "1" || false; lychee.map_provider = !data.config.map_provider ? "Wikimedia" : data.config.map_provider; lychee.map_include_subalbums = data.config.map_include_subalbums && data.config.map_include_subalbums === "1" || false; lychee.location_decoding = data.config.location_decoding && data.config.location_decoding === "1" || false; @@ -4269,6 +4300,7 @@ lychee.init = function () { lychee.image_overlay_type_default = lychee.image_overlay_type; lychee.map_display = data.config.map_display && data.config.map_display === "1" || false; lychee.map_display_public = data.config.map_display_public && data.config.map_display_public === "1" || false; + lychee.map_display_direction = data.config.map_display_direction && data.config.map_display_direction === "1" || false; lychee.map_provider = !data.config.map_provider ? "Wikimedia" : data.config.map_provider; lychee.map_include_subalbums = data.config.map_include_subalbums && data.config.map_include_subalbums === "1" || false; lychee.location_show = data.config.location_show && data.config.location_show === "1" || false; @@ -7064,14 +7096,6 @@ _photo.showDirectLinks = function (photoID) { photoeditor = {}; photoeditor.rotate = function (photoID, direction) { - var swapDims = function swapDims(d) { - var p = d.indexOf("x"); - if (p !== -1) { - return d.substr(0, p) + "x" + d.substr(p + 1); - } - return d; - }; - if (!photoID) return false; if (!direction) return false; @@ -7081,39 +7105,26 @@ photoeditor.rotate = function (photoID, direction) { }; api.post("PhotoEditor::rotate", params, function (data) { - if (data !== true) { + if (data === false) { lychee.error(null, params, data); } else { - var mr = "?" + Math.random(); - var sel_big = "img#image"; - var sel_thumb = "div[data-id=" + photoID + "] > span > img"; - var sel_div = "div[data-id=" + photoID + "]"; - $(sel_big).prop("src", $(sel_big).attr("src") + mr); - $(sel_big).prop("srcset", $(sel_big).attr("src")); - $(sel_thumb).prop("src", $(sel_thumb).attr("src") + mr); - $(sel_thumb).prop("srcset", $(sel_thumb).attr("src")); - var arrayLength = album.json.photos.length; - for (var i = 0; i < arrayLength; i++) { - if (album.json.photos[i].id === photoID) { - var w = album.json.photos[i].width; - var h = album.json.photos[i].height; - album.json.photos[i].height = w; - album.json.photos[i].width = h; - album.json.photos[i].small += mr; - album.json.photos[i].small_dim = swapDims(album.json.photos[i].small_dim); - album.json.photos[i].small2x += mr; - album.json.photos[i].small2x_dim = swapDims(album.json.photos[i].small2x_dim); - album.json.photos[i].medium += mr; - album.json.photos[i].medium_dim = swapDims(album.json.photos[i].medium_dim); - album.json.photos[i].medium2x += mr; - album.json.photos[i].medium2x_dim = swapDims(album.json.photos[i].medium2x_dim); - album.json.photos[i].thumb2x += mr; - album.json.photos[i].thumbUrl += mr; - album.json.photos[i].url += mr; - view.album.content.justify(); - break; - } + _photo.json = data; + _photo.json.original_album = _photo.json.album; + if (album.json) { + _photo.json.album = album.json.id; + } + + var image = $("img#image"); + if (_photo.json.hasOwnProperty("medium2x") && _photo.json.medium2x !== "") { + image.prop("srcset", _photo.json.medium + " " + parseInt(_photo.json.medium_dim, 10) + "w, " + _photo.json.medium2x + " " + parseInt(_photo.json.medium2x_dim, 10) + "w"); + } else { + image.prop("srcset", ""); } + image.prop("src", _photo.json.medium !== "" ? _photo.json.medium : _photo.json.url); + view.photo.onresize(); + view.photo.sidebar(); + + album.updatePhoto(data); } }); }; @@ -9655,8 +9666,8 @@ view.album = { }, cover: function cover(photoID) { - $('.album .icn-cover').removeClass("badge--cover"); - $('.photo .icn-cover').removeClass("badge--cover"); + $(".album .icn-cover").removeClass("badge--cover"); + $(".photo .icn-cover").removeClass("badge--cover"); if (album.json.cover_id === photoID) { var badge = $('.photo[data-id="' + photoID + '"] .icn-cover'); @@ -9673,6 +9684,42 @@ view.album = { } }, + updatePhoto: function updatePhoto(data) { + var src = void 0, + srcset = ""; + + // This mimicks the structure of build.photo + if (lychee.layout === "0") { + src = data.thumbUrl; + if (data.hasOwnProperty("thumb2x") && data.thumb2x !== "") { + srcset = data.thumb2x + " 2x"; + } + } else { + if (data.small !== "") { + src = data.small; + if (data.hasOwnProperty("small2x") && data.small2x !== "") { + srcset = data.small + " " + parseInt(data.small_dim, 10) + "w, " + data.small2x + " " + parseInt(data.small2x_dim, 10) + "w"; + } + } else if (data.medium !== "") { + src = data.medium; + if (data.hasOwnProperty("medium2x") && data.medium2x !== "") { + srcset = data.medium + " " + parseInt(data.medium_dim, 10) + "w, " + data.medium2x + " " + parseInt(data.medium2x_dim, 10) + "w"; + } + } else if (!data.type || data.type.indexOf("video") !== 0) { + src = data.url; + } else { + src = data.thumbUrl; + if (data.hasOwnProperty("thumb2x") && data.thumb2x !== "") { + srcset = data.thumbUrl + " 200w, " + data.thumb2x + " 400w"; + } + } + } + + $('.photo[data-id="' + data.id + '"] > span.thumbimg > img').attr("data-src", src).attr("data-srcset", srcset).addClass("lazyload"); + + view.album.content.justify(); + }, + delete: function _delete(photoID) { var justify = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; @@ -9917,6 +9964,7 @@ view.photo = { view.photo.title(); view.photo.star(); view.photo.public(); + view.photo.header(); view.photo.photo(autoplay); _photo.json.init = 1; @@ -10134,7 +10182,7 @@ view.photo = { attribution: map_provider_layer_attribution[lychee.map_provider].attribution }).addTo(mymap); - if (!_photo.json.imgDirection || _photo.json.imgDirection === "") { + if (!lychee.map_display_direction || !_photo.json.imgDirection || _photo.json.imgDirection === "") { // Add Marker to map, direction is not set L.marker([_photo.json.latitude, _photo.json.longitude]).addTo(mymap); } else { @@ -10151,6 +10199,14 @@ view.photo = { } }, + header: function header() { + if (_photo.json.type && (_photo.json.type.indexOf("video") === 0 || _photo.json.type === "raw") || _photo.json.livePhotoUrl !== "" && _photo.json.livePhotoUrl !== null) { + $("#button_rotate_cwise, #button_rotate_ccwise").hide(); + } else { + $("#button_rotate_cwise, #button_rotate_ccwise").show(); + } + }, + onresize: function onresize() { if (!_photo.json || _photo.json.medium === "" || !_photo.json.medium2x || _photo.json.medium2x === "") return;