Merge branch 'main' into feat-opengraph-description

This commit is contained in:
tkf
2026-02-24 21:41:38 +00:00
committed by GitHub
4 changed files with 32 additions and 27 deletions
+14
View File
@@ -30,6 +30,20 @@ html {
object-position: center; object-position: center;
} }
} }
@media (min-width: 801px) {
#lightgallery a.thumb-error {
width: 250px;
height: 250px;
margin: 4px;
}
}
#lightgallery a.thumb-error {
background: #2a2a2a;
}
#lightgallery a.thumb-error img {
display: none;
}
.play-icon { .play-icon {
position: absolute; position: absolute;
+12 -21
View File
@@ -33,24 +33,14 @@ class LGallery {
}, params.lgConfig)) }, params.lgConfig))
this.items = params.items this.items = params.items
let timeout const spinner = document.getElementById('loading-spinner')
window.addEventListener('scroll', () => { if (spinner) {
if (timeout) clearTimeout(timeout) const observer = new IntersectionObserver((entries) => {
timeout = setTimeout(lgallery.handleScroll, 100) if (entries[0].isIntersecting) {
}) lgallery.loadMoreItems(observer, spinner)
lgallery.handleScroll() }
} }, { rootMargin: '200px' })
observer.observe(spinner)
/**
* Listen for scroll events and load more gallery items
*/
handleScroll () {
const rect = lgallery.element.getBoundingClientRect()
const scrollPosition = Math.max(0, rect.bottom - window.innerHeight)
const buffer = 200 // pixels before bottom to trigger load
if (scrollPosition <= buffer) {
lgallery.loadMoreItems()
} }
} }
@@ -58,7 +48,7 @@ class LGallery {
* Load more gallery items as per lightGallery docs * Load more gallery items as per lightGallery docs
* https://www.lightgalleryjs.com/demos/infinite-scrolling/ * https://www.lightgalleryjs.com/demos/infinite-scrolling/
*/ */
loadMoreItems () { loadMoreItems (observer, spinner) {
if (this.index < this.items.length) { if (this.index < this.items.length) {
// Append new thumbnails // Append new thumbnails
this.items this.items
@@ -69,8 +59,9 @@ class LGallery {
this.index += PER_PAGE this.index += PER_PAGE
this.lightGallery.refresh() this.lightGallery.refresh()
} else { } else {
// Remove the loading spinner once all items are loaded // Remove the loading spinner and stop observing once all items are loaded
document.getElementById('loading-spinner')?.remove() observer.disconnect()
spinner.remove()
} }
} }
} }
+4 -4
View File
@@ -142,7 +142,7 @@ class Render {
video ? `<a data-video='${video}'` : `<a href="${previewUrl}"`, video ? `<a data-video='${video}'` : `<a href="${previewUrl}"`,
downloadUrl ? ` data-download-url="${downloadUrl}"` : '', downloadUrl ? ` data-download-url="${downloadUrl}"` : '',
description ? ` data-sub-html='<p>${description}</p>'` : '', description ? ` data-sub-html='<p>${description}</p>'` : '',
` data-download="${this.getFilename(asset)}" data-slide-name="${asset.id}"><img alt="" src="${thumbnailUrl}"/>`, ` data-download="${this.getFilename(asset)}" data-slide-name="${asset.id}"><img alt="${description}" loading="lazy" src="${thumbnailUrl}" onerror="this.closest('a').classList.add('thumb-error')"/>`,
video ? '<div class="play-icon"></div>' : '', video ? '<div class="play-icon"></div>' : '',
'</a>' '</a>'
].join('') ].join('')
@@ -191,7 +191,7 @@ class Render {
res.setHeader('Content-Disposition', `attachment; filename*=UTF-8''${filename}`) res.setHeader('Content-Disposition', `attachment; filename*=UTF-8''${filename}`)
const archive = archiver('zip', { zlib: { level: 6 } }) const archive = archiver('zip', { zlib: { level: 6 } })
archive.pipe(res) archive.pipe(res)
for (const asset of share.assets) { await Promise.all(share.assets.map(async (asset) => {
const url = immich.buildUrl(immich.apiUrl() + '/assets/' + encodeURIComponent(asset.id) + '/original', { const url = immich.buildUrl(immich.apiUrl() + '/assets/' + encodeURIComponent(asset.id) + '/original', {
key: asset.key, key: asset.key,
password: asset.password password: asset.password
@@ -200,10 +200,10 @@ class Render {
// Check the response for validity // Check the response for validity
if (!data.ok) { if (!data.ok) {
console.warn(`Failed to fetch asset: ${asset.id}`) console.warn(`Failed to fetch asset: ${asset.id}`)
continue return
} }
archive.append(Buffer.from(await data.arrayBuffer()), { name: this.getFilename(asset) }) archive.append(Buffer.from(await data.arrayBuffer()), { name: this.getFilename(asset) })
} }))
await archive.finalize() await archive.finalize()
archive.on('end', () => res.end()) archive.on('end', () => res.end())
} }
+2 -2
View File
@@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<%# Meta tags for link previews (title, optionally description and thumbnail) %> <%# Meta tags for link previews (title, optionally description and thumbnail) %>
<title><%= title %></title> <title><%= title %></title>
<meta property="og:title" content="<%= title %>"> <meta property="og:title" content="<%= title %>">
@@ -50,7 +50,7 @@
%><%- item.html %> %><%- item.html %>
<% }) %> <% }) %>
</div> </div>
<div id="loading-spinner"><span class="loader"></span></div> <% if (items.length > 50) { %><div id="loading-spinner"><span class="loader"></span></div><% } %>
<script src="/share/static/web.js"></script> <script src="/share/static/web.js"></script>
<script src="/share/static/lg/lightgallery.min.js"></script> <script src="/share/static/lg/lightgallery.min.js"></script>
<script src="/share/static/lg/lg-fullscreen.min.js"></script> <script src="/share/static/lg/lg-fullscreen.min.js"></script>