Merge branch 'main' of github.com:e1jo/immich-public-proxy
This commit is contained in:
+15
-12
@@ -6,9 +6,6 @@ on:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
env:
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
build-and-push-image:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -37,7 +34,7 @@ jobs:
|
||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3.2.0
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
@@ -46,7 +43,14 @@ jobs:
|
||||
id: metadata
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ github.repository }}
|
||||
images: |
|
||||
${{ github.repository }}
|
||||
ghcr.io/${{ github.repository }}
|
||||
tags: |
|
||||
type=semver,pattern={{version}},value=v${{ env.PACKAGE_VERSION }}
|
||||
type=semver,pattern={{major}}.{{minor}},value=v${{ env.PACKAGE_VERSION }}
|
||||
type=semver,pattern={{major}},value=v${{ env.PACKAGE_VERSION }}
|
||||
type=raw,value=latest
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
@@ -54,12 +58,11 @@ jobs:
|
||||
context: .
|
||||
file: Dockerfile
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64,linux/arm64/v8
|
||||
platforms: linux/amd64,linux/arm64
|
||||
build-args: |
|
||||
PACKAGE_VERSION=${{ env.PACKAGE_VERSION }}
|
||||
tags: |
|
||||
${{ github.repository }}:${{ env.PACKAGE_VERSION }}
|
||||
${{ github.repository }}:latest
|
||||
ghcr.io/${{ github.repository }}:${{ env.PACKAGE_VERSION }}
|
||||
ghcr.io/${{ github.repository }}:latest
|
||||
annotations: ${{ steps.metadata.output.annotations }}
|
||||
tags: ${{ steps.metadata.outputs.tags }}
|
||||
labels: ${{ steps.metadata.outputs.labels }}
|
||||
annotations: ${{ steps.metadata.outputs.annotations }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
# Immich Public Proxy
|
||||
|
||||
<p align="center" width="100%">
|
||||
<img src="docs/ipp.svg" width="180" height="180">
|
||||
</p>
|
||||
|
||||
<p align="center" width="100%">
|
||||
<a href="https://hub.docker.com/r/alangrainger/immich-public-proxy/tags">
|
||||
<img alt="Docker pulls" src="https://badgen.net/docker/pulls/alangrainger/immich-public-proxy?icon=docker&label=docker%20pulls&color=green&scale=1.1"></a>
|
||||
<a href="https://github.com/alangrainger/immich-public-proxy/releases/latest">
|
||||
<img alt="Latest release" src="https://badgen.net/github/release/alangrainger/immich-public-proxy?scale=1.1"></a>
|
||||
<img alt="Latest release" src="https://badgen.net/github/tag/alangrainger/immich-public-proxy?scale=1.1&label=release"></a>
|
||||
<a href="https://immich-demo.note.sx/share/gJfs8l4LcJJrBUpjhMnDoKXFt1Tm5vKXPbXl8BgwPtLtEBCOOObqbQdV5i0oun5hZjQ"><img alt="Open demo gallery" src="https://badgen.net/static/↗🖼️/live%20demo/green?scale=1.1"></a>
|
||||
</p>
|
||||
|
||||
@@ -16,7 +20,7 @@ serving straight out of my own Immich instance.
|
||||
Setup takes less than a minute, and you never need to touch it again as all of your sharing stays managed within Immich.
|
||||
|
||||
<p align="center" width="100%">
|
||||
<img src="docs/ipp.svg" width="200" height="200">
|
||||
<img src="docs/screenshot.webp" width="602" height="414" border="1px solid white">
|
||||
</p>
|
||||
|
||||
### Table of Contents
|
||||
@@ -29,7 +33,9 @@ Setup takes less than a minute, and you never need to touch it again as all of y
|
||||
- [How it works](#how-it-works)
|
||||
- [Additional configuration](#additional-configuration)
|
||||
- [IPP options](#immich-public-proxy-options)
|
||||
- [lightGallery](#lightgallery)
|
||||
- [Gallery options](#gallery-options)
|
||||
- [Lightbox options](#lightbox-options)
|
||||
- [Metadata](#metadata)
|
||||
- [Custom error pages](#customising-your-error-response-pages)
|
||||
- [Serving from multiple domains](#serving-from-multiple-domains)
|
||||
- [Troubleshooting](#troubleshooting)
|
||||
@@ -51,6 +57,10 @@ surface even further. The only things that the proxy can access are photos that
|
||||
- Supports sharing photos and videos.
|
||||
- Supports password-protected shares.
|
||||
- If sharing a single image, by default the link will directly open the image file so that you can embed it anywhere you would a normal image. (This is configurable.)
|
||||
- Gallery styled to match Immich's native look, with light/dark mode following the visitor's system preference.
|
||||
- Handles very large shares smoothly thanks to virtualized rendering - the browser only keeps tiles near the viewport in the DOM.
|
||||
- Optional multi-select mode so visitors can pick specific photos and download them together as a zip.
|
||||
- Optional date-grouped view (off by default), with month headers like "December 2024".
|
||||
- All usage happens through Immich - you won't need to touch this app after the initial configuration.
|
||||
|
||||
### Why not simply put Immich behind a reverse proxy and only expose the `/share/` path to the public?
|
||||
@@ -150,16 +160,16 @@ Alternatively, you can [pass the configuration inline](docs/inline-configuration
|
||||
### Immich Public Proxy options
|
||||
|
||||
| Option | Type | Description |
|
||||
|--------------------------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
|---------------------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `responseHeaders` | `object` | Change the headers sent with your web responses. By default there is `cache-control` and CORS added. |
|
||||
| `singleImageGallery` | `bool` | By default a link to a single image will directly open the image file. Set to `true` if you want to show a gallery page instead for a single item. |
|
||||
| `downloadOriginalPhoto` | `bool` | Set to `false` if you only want people to be able to download the 'preview' quality photo, rather than your original photo. |
|
||||
| `downloadedFilename` | `int` | The filename of the downloaded image.<br>`0` for the original filename if available, falling back to the Immich asset ID<br>`1` for the Immich asset ID number<br>`2` for a shortened version of the asset ID: `img_` plus the first 8 characters of the asset ID |
|
||||
| `showGalleryTitle` | `bool` | Show a title on the gallery page. This is taken from the album title if it is an album being shared, otherwise the "Description" from the shared link will be used. |
|
||||
| `showGalleryDescription` | `bool` | Show the album description below the title. This only applies if it is an album which is being shared. |
|
||||
| `allowDownloadAll` | `int` | Allow visitors to download all files as a zip.<br>`0` disable downloads<br>`1` follow Immich setting per share ([example](https://github.com/user-attachments/assets/79ea8c08-71ce-42ab-b025-10aec384938a))<br>`2` always allowed |
|
||||
| `allowDownloadAll` | `int` | Allow visitors to download all files as a zip, including the selective-download flow in multi-select mode.<br>`0` disable downloads<br>`1` follow Immich setting per share ([example](https://github.com/user-attachments/assets/79ea8c08-71ce-42ab-b025-10aec384938a))<br>`2` always allowed |
|
||||
| `downloadFromImmichConcurrencyLimit` | `int` | Maximum number of assets IPP will fetch from your Immich server in parallel when building a "download all" zip. Defaults to `8`. Lower this if your Immich server is slow or you see download timeouts on large albums; raise it for faster downloads if your server can handle the load. |
|
||||
| `allowSlugLinks` | `bool` | Enable/disable the custom URL links. |
|
||||
| `showHomePage` | `bool` | Set to `false` to remove the IPP shield page at `/` and at `/share` |
|
||||
| `gallery` | `object` | Gallery-page options, see the [Gallery options](#gallery-options) section below. |
|
||||
| `lightbox` | `object` | Lightbox option, see the [Lightbox options](#lightbox-options) section below. |
|
||||
| `showMetadata` | `object` | See the [Metadata](#metadata) section below. |
|
||||
| `customInvalidResponse` | various | Send a custom response instead of the default 404 - see [Custom responses](docs/custom-responses.md) for more details. |
|
||||
|
||||
@@ -174,34 +184,63 @@ For example, to disable the home page at `/` and at `/share` you need to change
|
||||
}
|
||||
```
|
||||
|
||||
#### Metadata
|
||||
### Gallery options
|
||||
|
||||
Options that control how the gallery page is rendered. Configured under `ipp.gallery`.
|
||||
|
||||
| Option | Type | Description |
|
||||
|---------------|--------|----------------------------------------------------|
|
||||
| `description` | `bool` | Show the description as a caption below the photo. |
|
||||
|----------------------|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `singleImage` | `bool` | By default a link to a single image will directly open the image file. Set to `true` if you want to show a gallery page instead for a single item. |
|
||||
| `singleItemAutoOpen` | `bool` | When a share contains a single item and is opened on its gallery page, automatically open the lightbox on the asset. Default `true`. |
|
||||
| `showTitle` | `bool` | Show a title on the gallery page. This is taken from the album title if it is an album being shared, otherwise the "Description" from the shared link will be used. |
|
||||
| `showDescription` | `bool` | Show the album description below the title. This only applies if it is an album which is being shared. |
|
||||
| `groupByDate` | `bool` | Group the gallery's thumbnails by month, with headers like "December 2024" above each group. Sorts photos newest-first. Items missing a creation date end up under an "Undated" bucket at the end. Default `false`. |
|
||||
|
||||
### lightGallery
|
||||
|
||||
The gallery is created using [lightGallery](https://github.com/sachinchoolur/lightGallery).
|
||||
You can find all of lightGallery's settings here:
|
||||
https://www.lightgalleryjs.com/docs/settings/
|
||||
|
||||
For example, to disable the download button for images, you would edit the `lightGallery` section and change `download` to `false`:
|
||||
Example: show the gallery title and group photos by month:
|
||||
|
||||
```json
|
||||
{
|
||||
"lightGallery": {
|
||||
"controls": true,
|
||||
"download": false,
|
||||
"mobileSettings": {
|
||||
"controls": false,
|
||||
"showCloseIcon": true,
|
||||
"download": false
|
||||
"ipp": {
|
||||
"gallery": {
|
||||
"showTitle": true,
|
||||
"groupByDate": true
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> **Note** for upgraders from earlier versions: the keys `singleImageGallery`, `singleItemAutoOpen`, `showGalleryTitle`, `showGalleryDescription`, and `groupGalleryByDate` used to live directly under `ipp.*`. They've been renamed and moved under `ipp.gallery.*` (see the table above). Existing configs continue to work via a backward-compatibility shim, but you'll see a deprecation notice in the startup log until you migrate them.
|
||||
|
||||
### Lightbox options
|
||||
|
||||
The gallery's lightbox is powered by [PhotoSwipe](https://photoswipe.com/). Configured under `ipp.lightbox`.
|
||||
|
||||
| Option | Type | Description |
|
||||
|----------------|--------|------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `showArrows` | `bool` | Show the prev/next arrows on desktop. They appear when the user hovers the lightbox. Default `true`. |
|
||||
| `showDownload` | `bool` | Show a download button in the lightbox toolbar. Only takes effect when downloads are also allowed by `allowDownloadAll`. Default `true`. |
|
||||
| `mobileArrows` | `bool` | Show prev/next arrows on mobile (under 640px viewport). Off by default since swipe is the natural mobile navigation. |
|
||||
|
||||
Example: hide the download button inside the lightbox even though zip downloads are otherwise allowed:
|
||||
|
||||
```json
|
||||
{
|
||||
"ipp": {
|
||||
"lightbox": {
|
||||
"showDownload": false
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Metadata
|
||||
|
||||
Configured under `ipp.showMetadata`.
|
||||
|
||||
| Option | Type | Description |
|
||||
|---------------|--------|----------------------------------------------------|
|
||||
| `description` | `bool` | Show the description as a caption below the photo. |
|
||||
|
||||
### Customising your error response pages
|
||||
|
||||
You can customise the responses that IPP sends for invalid requests. For example you could:
|
||||
|
||||
@@ -22,5 +22,14 @@
|
||||
"@typescript-eslint/ban-ts-comment": "off",
|
||||
"no-prototype-builtins": "off",
|
||||
"@typescript-eslint/no-empty-function": "off"
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["public/web.js"],
|
||||
"env": { "browser": true, "node": false },
|
||||
"rules": {
|
||||
"import/no-absolute-path": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+12
-13
@@ -4,28 +4,27 @@
|
||||
"Cache-Control": "public, max-age=2592000",
|
||||
"Access-Control-Allow-Origin": "*"
|
||||
},
|
||||
"singleImageGallery": false,
|
||||
"singleItemAutoOpen": true,
|
||||
"downloadOriginalPhoto": true,
|
||||
"downloadedFilename": 0,
|
||||
"allowDownloadAll": 0,
|
||||
"downloadFromImmichConcurrencyLimit": 20,
|
||||
"allowSlugLinks": true,
|
||||
"showHomePage": true,
|
||||
"showGalleryTitle": false,
|
||||
"showGalleryDescription": false,
|
||||
"showMetadata": {
|
||||
"description": false
|
||||
},
|
||||
"customInvalidResponse": false
|
||||
"customInvalidResponse": false,
|
||||
"gallery": {
|
||||
"singleImage": false,
|
||||
"singleItemAutoOpen": true,
|
||||
"showTitle": true,
|
||||
"showDescription": false,
|
||||
"groupByDate": false
|
||||
},
|
||||
"lightGallery": {
|
||||
"controls": true,
|
||||
"download": true,
|
||||
"customSlideName": true,
|
||||
"mobileSettings": {
|
||||
"controls": false,
|
||||
"showCloseIcon": true,
|
||||
"download": true
|
||||
"lightbox": {
|
||||
"showArrows": true,
|
||||
"showDownload": true,
|
||||
"mobileArrows": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+41
-78
@@ -1,20 +1,21 @@
|
||||
{
|
||||
"name": "immich-public-proxy",
|
||||
"version": "1.15.6",
|
||||
"version": "2.0.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "immich-public-proxy",
|
||||
"version": "1.15.6",
|
||||
"version": "2.0.2",
|
||||
"license": "AGPL-3.0",
|
||||
"dependencies": {
|
||||
"archiver": "^7.0.1",
|
||||
"cookie-session": "^2.1.0",
|
||||
"dayjs": "^1.11.13",
|
||||
"dotenv": "^16.4.5",
|
||||
"ejs": "^3.1.10",
|
||||
"express": "^4.21.1",
|
||||
"preact": "^10.29.2",
|
||||
"preact-render-to-string": "^6.7.0",
|
||||
"tslib": "^2.8.1"
|
||||
},
|
||||
"bin": {
|
||||
@@ -1017,9 +1018,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/body-parser": {
|
||||
"version": "1.20.4",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.4.tgz",
|
||||
"integrity": "sha512-ZTgYYLMOXY9qKU/57FAo8F+HA2dGX7bqGc71txDRC1rS4frdFI5R7NhluHxH6M0YItAP0sHB4uqAOcYKxO6uGA==",
|
||||
"version": "1.20.5",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.5.tgz",
|
||||
"integrity": "sha512-3grm+/2tUOvu2cjJkvsIxrv/wVpfXQW4PsQHYm7yk4vfpu7Ekl6nEsYBoJUL6qDwZUx8wUhQ8tR2qz+ad9c9OA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bytes": "~3.1.2",
|
||||
@@ -1030,7 +1031,7 @@
|
||||
"http-errors": "~2.0.1",
|
||||
"iconv-lite": "~0.4.24",
|
||||
"on-finished": "~2.4.1",
|
||||
"qs": "~6.14.0",
|
||||
"qs": "~6.15.1",
|
||||
"raw-body": "~2.5.3",
|
||||
"type-is": "~1.6.18",
|
||||
"unpipe": "~1.0.0"
|
||||
@@ -1088,6 +1089,7 @@
|
||||
"version": "1.1.14",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.14.tgz",
|
||||
"integrity": "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"balanced-match": "^1.0.0",
|
||||
@@ -1238,6 +1240,7 @@
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
|
||||
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-styles": "^4.1.0",
|
||||
@@ -1288,6 +1291,7 @@
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/content-disposition": {
|
||||
@@ -1634,21 +1638,6 @@
|
||||
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/ejs": {
|
||||
"version": "3.1.10",
|
||||
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz",
|
||||
"integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"jake": "^10.8.5"
|
||||
},
|
||||
"bin": {
|
||||
"ejs": "bin/cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/emoji-regex": {
|
||||
"version": "9.2.2",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz",
|
||||
@@ -2315,14 +2304,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/express": {
|
||||
"version": "4.22.1",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.22.1.tgz",
|
||||
"integrity": "sha512-F2X8g9P1X7uCPZMA3MVf9wcTqlyNp7IhH5qPCI0izhaOIYXaW9L535tGA3qmjRzpH+bZczqq7hVKxTR4NWnu+g==",
|
||||
"version": "4.22.2",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.22.2.tgz",
|
||||
"integrity": "sha512-IuL+Elrou2ZvCFHs18/CIzy2Nzvo25nZ1/D2eIZlz7c+QUayAcYoiM2BthCjs+EBHVpjYjcuLDAiCWgeIX3X1Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"accepts": "~1.3.8",
|
||||
"array-flatten": "1.1.1",
|
||||
"body-parser": "~1.20.3",
|
||||
"body-parser": "~1.20.5",
|
||||
"content-disposition": "~0.5.4",
|
||||
"content-type": "~1.0.4",
|
||||
"cookie": "~0.7.1",
|
||||
@@ -2341,7 +2330,7 @@
|
||||
"parseurl": "~1.3.3",
|
||||
"path-to-regexp": "~0.1.12",
|
||||
"proxy-addr": "~2.0.7",
|
||||
"qs": "~6.14.0",
|
||||
"qs": "~6.15.1",
|
||||
"range-parser": "~1.2.1",
|
||||
"safe-buffer": "5.2.1",
|
||||
"send": "~0.19.0",
|
||||
@@ -2455,36 +2444,6 @@
|
||||
"node": "^10.12.0 || >=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/filelist": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz",
|
||||
"integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"minimatch": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/filelist/node_modules/brace-expansion": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.0.tgz",
|
||||
"integrity": "sha512-TN1kCZAgdgweJhWWpgKYrQaMNHcDULHkWwQIspdtjV4Y5aurRdZpjAqn6yX3FPqTA9ngHCc4hJxMAMgGfve85w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"balanced-match": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/filelist/node_modules/minimatch": {
|
||||
"version": "5.1.9",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.9.tgz",
|
||||
"integrity": "sha512-7o1wEA2RyMP7Iu7GNba9vc0RWWGACJOCZBJX2GJWip0ikV+wcOsgVuY9uE8CPiyQhkGFSlhuSkZPavN7u1c2Fw==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"brace-expansion": "^2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/fill-range": {
|
||||
"version": "7.1.1",
|
||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
|
||||
@@ -2891,6 +2850,7 @@
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
@@ -3567,24 +3527,6 @@
|
||||
"@pkgjs/parseargs": "^0.11.0"
|
||||
}
|
||||
},
|
||||
"node_modules/jake": {
|
||||
"version": "10.9.2",
|
||||
"resolved": "https://registry.npmjs.org/jake/-/jake-10.9.2.tgz",
|
||||
"integrity": "sha512-2P4SQ0HrLQ+fw6llpLnOaGAvN2Zu6778SJMrCUwns4fOoG9ayrTiZk3VV8sCPkVZF8ab0zksVpS8FDY5pRCNBA==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"async": "^3.2.3",
|
||||
"chalk": "^4.0.2",
|
||||
"filelist": "^1.0.4",
|
||||
"minimatch": "^3.1.2"
|
||||
},
|
||||
"bin": {
|
||||
"jake": "bin/cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/js-yaml": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
|
||||
@@ -3856,6 +3798,7 @@
|
||||
"version": "3.1.5",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz",
|
||||
"integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
@@ -4215,6 +4158,25 @@
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/preact": {
|
||||
"version": "10.29.2",
|
||||
"resolved": "https://registry.npmjs.org/preact/-/preact-10.29.2.tgz",
|
||||
"integrity": "sha512-7tNmwg/7mzzAoB/8kSg6Hl37JraAZw3Z3A0JSY7VXlZwo82Xn0G7wKbNNs2qoF4ZEEsQGTwDAroNdqKs1ofJxQ==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/preact"
|
||||
}
|
||||
},
|
||||
"node_modules/preact-render-to-string": {
|
||||
"version": "6.7.0",
|
||||
"resolved": "https://registry.npmjs.org/preact-render-to-string/-/preact-render-to-string-6.7.0.tgz",
|
||||
"integrity": "sha512-Z4WR8fmLMRpdYqJ9i7vrlXSsSrxVJydwrkEXHapexfARbWfGb7vGcnvNQnIzN0cXciMVOlz/XLoiMCi9gUsy9Q==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"preact": ">=10 || >= 11.0.0-0"
|
||||
}
|
||||
},
|
||||
"node_modules/prelude-ls": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
|
||||
@@ -4264,9 +4226,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/qs": {
|
||||
"version": "6.14.2",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.2.tgz",
|
||||
"integrity": "sha512-V/yCWTTF7VJ9hIh18Ugr2zhJMP01MY7c5kh4J870L7imm6/DIzBsNLTXzMwUA3yZ5b/KBqLx8Kp3uRvd7xSe3Q==",
|
||||
"version": "6.15.2",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.15.2.tgz",
|
||||
"integrity": "sha512-Rzq0KEyX/w/tEybncDgdkZrJgVUsUMk3xjh3t5bv3S1HTAtg+uOYt72+ZfwiQwKdysThkTBdL/rTi6HDmX9Ddw==",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"side-channel": "^1.1.0"
|
||||
@@ -5077,6 +5039,7 @@
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
||||
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"has-flag": "^4.0.0"
|
||||
|
||||
+3
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "immich-public-proxy",
|
||||
"version": "1.15.6",
|
||||
"version": "2.0.2",
|
||||
"scripts": {
|
||||
"dev": "ts-node src/index.ts",
|
||||
"build": "npx tsc",
|
||||
@@ -21,8 +21,9 @@
|
||||
"cookie-session": "^2.1.0",
|
||||
"dayjs": "^1.11.13",
|
||||
"dotenv": "^16.4.5",
|
||||
"ejs": "^3.1.10",
|
||||
"express": "^4.21.1",
|
||||
"preact": "^10.29.2",
|
||||
"preact-render-to-string": "^6.7.0",
|
||||
"tslib": "^2.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION AND CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
Binary file not shown.
@@ -1,54 +0,0 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<metadata>
|
||||
<json>
|
||||
<![CDATA[
|
||||
{
|
||||
"fontFamily": "lg",
|
||||
"majorVersion": 2,
|
||||
"minorVersion": 0,
|
||||
"fontURL": "",
|
||||
"copyright": "",
|
||||
"license": "",
|
||||
"licenseURL": "",
|
||||
"description": "Font generated by IcoMoon.",
|
||||
"version": "Version 2.0",
|
||||
"fontId": "lg",
|
||||
"psName": "lg",
|
||||
"subFamily": "Regular",
|
||||
"fullName": "lg"
|
||||
}
|
||||
]]>
|
||||
</json>
|
||||
</metadata>
|
||||
<defs>
|
||||
<font id="lg" horiz-adv-x="1024">
|
||||
<font-face units-per-em="1024" ascent="960" descent="-64" />
|
||||
<missing-glyph horiz-adv-x="1024" />
|
||||
<glyph unicode=" " horiz-adv-x="512" d="" />
|
||||
<glyph unicode="" glyph-name="pause_circle_outline" data-tags="pause_circle_outline" d="M554 256.667v340h86v-340h-86zM512 84.667q140 0 241 101t101 241-101 241-241 101-241-101-101-241 101-241 241-101zM512 852.667q176 0 301-125t125-301-125-301-301-125-301 125-125 301 125 301 301 125zM384 256.667v340h86v-340h-86z" />
|
||||
<glyph unicode="" glyph-name="play_circle_outline" data-tags="play_circle_outline" d="M512 84.667q140 0 241 101t101 241-101 241-241 101-241-101-101-241 101-241 241-101zM512 852.667q176 0 301-125t125-301-125-301-301-125-301 125-125 301 125 301 301 125zM426 234.667v384l256-192z" />
|
||||
<glyph unicode="" glyph-name="stack-2" data-tags="stack-2" d="M384 853.334h426.667q53 0 90.5-37.5t37.5-90.5v-426.667q0-53-37.5-90.5t-90.5-37.5h-426.667q-53 0-90.5 37.5t-37.5 90.5v426.667q0 53 37.5 90.5t90.5 37.5zM170.667 675.334v-547.333q0-17.667 12.5-30.167t30.167-12.5h547.333q-13.333-37.667-46.333-61.5t-74.333-23.833h-426.667q-53 0-90.5 37.5t-37.5 90.5v426.667q0 41.333 23.833 74.333t61.5 46.333zM810.667 768h-426.667q-17.667 0-30.167-12.5t-12.5-30.167v-426.667q0-17.667 12.5-30.167t30.167-12.5h426.667q17.667 0 30.167 12.5t12.5 30.167v426.667q0 17.667-12.5 30.167t-30.167 12.5z" />
|
||||
<glyph unicode="" glyph-name="clear" data-tags="clear" d="M810 664.667l-238-238 238-238-60-60-238 238-238-238-60 60 238 238-238 238 60 60 238-238 238 238z" />
|
||||
<glyph unicode="" glyph-name="arrow-left" data-tags="arrow-left" d="M426.667 768q17.667 0 30.167-12.5t12.5-30.167q0-18-12.667-30.333l-225.667-225.667h665q17.667 0 30.167-12.5t12.5-30.167-12.5-30.167-30.167-12.5h-665l225.667-225.667q12.667-12.333 12.667-30.333 0-17.667-12.5-30.167t-30.167-12.5q-18 0-30.333 12.333l-298.667 298.667q-12.333 13-12.333 30.333t12.333 30.333l298.667 298.667q12.667 12.333 30.333 12.333z" />
|
||||
<glyph unicode="" glyph-name="arrow-right" data-tags="arrow-right" d="M597.333 768q18 0 30.333-12.333l298.667-298.667q12.333-12.333 12.333-30.333t-12.333-30.333l-298.667-298.667q-12.333-12.333-30.333-12.333-18.333 0-30.5 12.167t-12.167 30.5q0 18 12.333 30.333l226 225.667h-665q-17.667 0-30.167 12.5t-12.5 30.167 12.5 30.167 30.167 12.5h665l-226 225.667q-12.333 12.333-12.333 30.333 0 18.333 12.167 30.5t30.5 12.167z" />
|
||||
<glyph unicode="" glyph-name="vertical_align_bottom" data-tags="vertical_align_bottom" d="M170 128.667h684v-86h-684v86zM682 384.667l-170-172-170 172h128v426h84v-426h128z" />
|
||||
<glyph unicode="" glyph-name="apps" data-tags="apps" d="M682 84.667v172h172v-172h-172zM682 340.667v172h172v-172h-172zM426 596.667v172h172v-172h-172zM682 768.667h172v-172h-172v172zM426 340.667v172h172v-172h-172zM170 340.667v172h172v-172h-172zM170 84.667v172h172v-172h-172zM426 84.667v172h172v-172h-172zM170 596.667v172h172v-172h-172z" />
|
||||
<glyph unicode="" glyph-name="fullscreen" data-tags="fullscreen" d="M598 724.667h212v-212h-84v128h-128v84zM726 212.667v128h84v-212h-212v84h128zM214 512.667v212h212v-84h-128v-128h-84zM298 340.667v-128h128v-84h-212v212h84z" />
|
||||
<glyph unicode="" glyph-name="fullscreen_exit" data-tags="fullscreen_exit" d="M682 596.667h128v-84h-212v212h84v-128zM598 128.667v212h212v-84h-128v-128h-84zM342 596.667v128h84v-212h-212v84h128zM214 256.667v84h212v-212h-84v128h-128z" />
|
||||
<glyph unicode="" glyph-name="zoom_in" data-tags="zoom_in" d="M512 512.667h-86v-86h-42v86h-86v42h86v86h42v-86h86v-42zM406 340.667q80 0 136 56t56 136-56 136-136 56-136-56-56-136 56-136 136-56zM662 340.667l212-212-64-64-212 212v34l-12 12q-76-66-180-66-116 0-197 80t-81 196 81 197 197 81 196-81 80-197q0-104-66-180l12-12h34z" />
|
||||
<glyph unicode="" glyph-name="zoom_out" data-tags="zoom_out" d="M298 554.667h214v-42h-214v42zM406 340.667q80 0 136 56t56 136-56 136-136 56-136-56-56-136 56-136 136-56zM662 340.667l212-212-64-64-212 212v34l-12 12q-76-66-180-66-116 0-197 80t-81 196 81 197 197 81 196-81 80-197q0-104-66-180l12-12h34z" />
|
||||
<glyph unicode="" glyph-name="share" data-tags="share" d="M768 252.667c68 0 124-56 124-124s-56-126-124-126-124 58-124 126c0 10 0 20 2 28l-302 176c-24-22-54-34-88-34-70 0-128 58-128 128s58 128 128 128c34 0 64-12 88-34l300 174c-2 10-4 20-4 30 0 70 58 128 128 128s128-58 128-128-58-128-128-128c-34 0-64 14-88 36l-300-176c2-10 4-20 4-30s-2-20-4-30l304-176c22 20 52 32 84 32z" />
|
||||
<glyph unicode="" glyph-name="rotate_left" data-tags="rotate_left" d="M554 764.667q126-16 213-112t87-226-87-226-213-112v86q92 16 153 87t61 165-61 165-153 87v-166l-194 190 194 194v-132zM302 156.667l62 62q46-34 106-44v-86q-96 12-168 68zM260 384.667q10-58 42-106l-60-60q-56 74-68 166h86zM304 574.667q-36-52-44-106h-86q12 90 70 166z" />
|
||||
<glyph unicode="" glyph-name="rotate_right" data-tags="rotate_right" d="M720 278.667q34 46 44 106h86q-12-92-68-166zM554 174.667q60 10 106 44l62-62q-72-56-168-68v86zM850 468.667h-86q-10 60-44 106l62 60q58-72 68-166zM664 702.667l-194-190v166q-92-16-153-87t-61-165 61-165 153-87v-86q-126 16-213 112t-87 226 87 226 213 112v132z" />
|
||||
<glyph unicode="" glyph-name="swap_horiz" data-tags="swap_horiz" d="M896 554.667l-170-170v128h-300v84h300v128zM298 468.667v-128h300v-84h-300v-128l-170 170z" />
|
||||
<glyph unicode="" glyph-name="swap_vert" data-tags="swap_vert" d="M384 810.667l170-170h-128v-300h-84v300h-128zM682 212.667h128l-170-170-170 170h128v300h84v-300z" />
|
||||
<glyph unicode="" glyph-name="facebook-with-circle" data-tags="facebook-with-circle" d="M512 952.32c-271.462 0-491.52-220.058-491.52-491.52s220.058-491.52 491.52-491.52 491.52 220.058 491.52 491.52-220.058 491.52-491.52 491.52zM628.429 612.659h-73.882c-8.755 0-18.483-11.52-18.483-26.829v-53.35h92.416l-13.978-76.083h-78.438v-228.403h-87.194v228.403h-79.104v76.083h79.104v44.749c0 64.205 44.544 116.378 105.677 116.378h73.882v-80.947z" />
|
||||
<glyph unicode="" glyph-name="google-with-circle" data-tags="google+-with-circle" d="M512 952.32c-271.462 0-491.52-220.058-491.52-491.52s220.058-491.52 491.52-491.52 491.52 220.058 491.52 491.52-220.058 491.52-491.52 491.52zM483.686 249.805c-30.874-15.002-64.102-16.589-76.954-16.589-2.458 0-3.84 0-3.84 0s-1.178 0-2.765 0c-20.070 0-119.962 4.608-119.962 95.59 0 89.395 108.8 96.41 142.131 96.41h0.87c-19.251 25.702-15.258 51.61-15.258 51.61-1.69-0.102-4.147-0.205-7.168-0.205-12.544 0-36.762 1.997-57.549 15.411-25.498 16.384-38.4 44.288-38.4 82.893 0 109.107 119.142 113.51 120.32 113.613h118.989v-2.611c0-13.312-23.91-15.923-40.192-18.125-5.53-0.819-16.64-1.894-19.763-3.482 30.157-16.128 35.021-41.421 35.021-79.104 0-42.906-16.794-65.587-34.611-81.51-11.059-9.882-19.712-17.613-19.712-28.006 0-10.189 11.878-20.582 25.702-32.717 22.579-19.917 53.555-47.002 53.555-92.723 0-47.258-20.326-81.050-60.416-100.454zM742.4 460.8h-76.8v-76.8h-51.2v76.8h-76.8v51.2h76.8v76.8h51.2v-76.8h76.8v-51.2zM421.018 401.92c-2.662 0-5.325-0.102-8.038-0.307-22.733-1.69-43.725-10.189-58.88-24.013-15.053-13.619-22.733-30.822-21.658-48.179 2.304-36.403 41.37-57.702 88.832-54.323 46.694 3.379 77.824 30.31 75.571 66.714-2.15 34.202-31.898 60.109-75.827 60.109zM465.766 599.808c-12.39 43.52-32.358 56.422-63.386 56.422-3.328 0-6.707-0.512-9.933-1.382-13.466-3.84-24.166-15.053-30.106-31.744-6.093-16.896-6.451-34.509-1.229-54.579 9.472-35.891 34.97-61.901 60.672-61.901 3.379 0 6.758 0.41 9.933 1.382 28.109 7.885 45.722 50.79 34.048 91.802z" />
|
||||
<glyph unicode="" glyph-name="pinterest-with-circle" data-tags="pinterest-with-circle" d="M512 952.32c-271.462 0-491.52-220.058-491.52-491.52s220.058-491.52 491.52-491.52 491.52 220.058 491.52 491.52-220.058 491.52-491.52 491.52zM545.638 344.32c-31.539 2.406-44.749 18.022-69.427 32.973-13.568-71.219-30.157-139.52-79.309-175.206-15.206 107.725 22.221 188.518 39.629 274.381-29.645 49.92 3.533 150.323 66.099 125.645 76.954-30.515-66.662-185.6 29.747-205.005 100.659-20.173 141.773 174.694 79.36 237.978-90.214 91.494-262.502 2.099-241.306-128.87 5.12-32 38.246-41.728 13.21-85.914-57.702 12.8-74.957 58.317-72.704 118.989 3.533 99.328 89.242 168.909 175.155 178.483 108.698 12.083 210.688-39.885 224.819-142.182 15.821-115.405-49.101-240.282-165.274-231.27z" />
|
||||
<glyph unicode="" glyph-name="twitter-with-circle" data-tags="twitter-with-circle" d="M512 952.32c-271.462 0-491.52-220.058-491.52-491.52s220.058-491.52 491.52-491.52 491.52 220.058 491.52 491.52-220.058 491.52-491.52 491.52zM711.936 549.683c0.205-4.198 0.256-8.397 0.256-12.493 0-128-97.331-275.507-275.405-275.507-54.682 0-105.574 15.974-148.378 43.52 7.526-0.922 15.258-1.28 23.091-1.28 45.363 0 87.091 15.411 120.218 41.421-42.342 0.819-78.080 28.774-90.419 67.174 5.888-1.075 11.93-1.69 18.176-1.69 8.806 0 17.408 1.178 25.498 3.379-44.288 8.909-77.67 48.026-77.67 94.925v1.178c13.056-7.219 28.006-11.622 43.878-12.134-26.010 17.408-43.059 47.002-43.059 80.64 0 17.715 4.762 34.406 13.107 48.691 47.77-58.573 119.040-97.075 199.526-101.222-1.69 7.117-2.509 14.49-2.509 22.118 0 53.402 43.315 96.819 96.819 96.819 27.802 0 52.992-11.776 70.656-30.618 22.067 4.403 42.752 12.39 61.44 23.501-7.219-22.579-22.528-41.574-42.547-53.606 19.61 2.406 38.246 7.578 55.603 15.309-12.954-19.405-29.389-36.506-48.282-50.125z" />
|
||||
<glyph unicode="" glyph-name="message-circle" data-tags="message-circle" d="M938.667 448.128v21.205c0 0.725-0.043 1.621-0.085 2.475-5.803 99.755-47.488 190.336-112.725 258.176-68.352 71.125-162.731 117.419-268.843 123.264-0.683 0.043-1.536 0.085-2.347 0.085h-20.864c-59.947 0.683-122.965-13.227-181.931-43.008-52.181-26.496-97.749-63.488-133.931-108.16-56.405-69.717-89.899-158.080-89.941-253.696-0.597-54.4 10.795-111.36 35.157-165.419l-75.605-226.859c-2.816-8.363-3.072-17.835 0-26.965 7.467-22.357 31.616-34.432 53.973-26.965l226.731 75.563c49.493-22.485 105.984-35.243 165.376-35.115 58.539 0.384 115.797 13.141 168.149 36.949 81.579 37.163 151.040 101.248 193.749 186.667 27.477 53.291 43.307 115.84 43.136 181.803zM853.333 447.872c0.128-52.267-12.459-101.333-33.664-142.464-34.176-68.352-88.832-118.827-153.259-148.139-41.387-18.859-86.827-28.971-133.376-29.269-52.096-0.128-101.163 12.459-142.293 33.664-10.624 5.504-22.528 6.059-33.067 2.56l-162.261-54.101 54.101 162.261c3.755 11.221 2.56 22.912-2.389 32.725-23.552 46.677-34.304 96.171-33.792 142.421 0.043 76.331 26.411 145.92 70.955 200.917 28.629 35.371 64.768 64.725 106.24 85.76 46.592 23.552 96.085 34.304 142.336 33.792h19.456c83.712-4.565 158.037-41.003 212.011-97.152 51.285-53.376 84.139-124.416 89.003-202.795z" />
|
||||
<glyph unicode="" glyph-name="maximize-2" data-tags="maximize-2" d="M793.003 768l-225.835-225.835c-16.683-16.683-16.683-43.691 0-60.331s43.691-16.683 60.331 0l225.835 225.835v-153.003c0-23.552 19.115-42.667 42.667-42.667s42.667 19.115 42.667 42.667v256c0 5.803-1.152 11.307-3.243 16.341s-5.163 9.728-9.216 13.781c-0.043 0.043-0.043 0.043-0.085 0.085-3.925 3.925-8.619 7.083-13.781 9.216-5.035 2.091-10.539 3.243-16.341 3.243h-256c-23.552 0-42.667-19.115-42.667-42.667s19.115-42.667 42.667-42.667zM230.997 85.334l225.835 225.835c16.683 16.683 16.683 43.691 0 60.331s-43.691 16.683-60.331 0l-225.835-225.835v153.003c0 23.552-19.115 42.667-42.667 42.667s-42.667-19.115-42.667-42.667v-256c0-23.552 19.115-42.667 42.667-42.667h256c23.552 0 42.667 19.115 42.667 42.667s-19.115 42.667-42.667 42.667z" />
|
||||
<glyph unicode="" glyph-name="minimize-2" data-tags="minimize-2" d="M700.331 554.667l225.835 225.835c16.683 16.683 16.683 43.691 0 60.331s-43.691 16.683-60.331 0l-225.835-225.835v153.003c0 23.552-19.115 42.667-42.667 42.667s-42.667-19.115-42.667-42.667v-256c0-5.803 1.152-11.307 3.243-16.341s5.163-9.728 9.216-13.781c0.043-0.043 0.043-0.043 0.085-0.085 3.925-3.925 8.619-7.083 13.781-9.216 5.035-2.091 10.539-3.243 16.341-3.243h256c23.552 0 42.667 19.115 42.667 42.667s-19.115 42.667-42.667 42.667zM158.165 12.502l225.835 225.835v-153.003c0-23.552 19.115-42.667 42.667-42.667s42.667 19.115 42.667 42.667v256c0 5.803-1.152 11.307-3.243 16.341s-5.163 9.728-9.216 13.781c-0.043 0.043-0.043 0.043-0.085 0.085-4.096 4.053-8.789 7.125-13.781 9.216-5.035 2.091-10.539 3.243-16.341 3.243h-256c-23.552 0-42.667-19.115-42.667-42.667s19.115-42.667 42.667-42.667h153.003l-225.835-225.835c-16.683-16.683-16.683-43.691 0-60.331s43.691-16.683 60.331 0z" />
|
||||
</font></defs></svg>
|
||||
|
Before Width: | Height: | Size: 12 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-folder-down"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/><path d="M12 10v6"/><path d="m15 13-3 3-3-3"/></svg>
|
||||
|
Before Width: | Height: | Size: 391 B |
Binary file not shown.
|
Before Width: | Height: | Size: 4.1 KiB |
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
/**
|
||||
* lightgallery | 2.9.0 | October 1st 2025
|
||||
* http://www.lightgalleryjs.com/
|
||||
* Copyright (c) 2020 Sachin Neravath;
|
||||
* @license GPLv3
|
||||
*/
|
||||
|
||||
!function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l():"function"==typeof define&&define.amd?define(l):(e="undefined"!=typeof globalThis?globalThis:e||self).lgFullscreen=l()}(this,(function(){"use strict";var e=function(){return(e=Object.assign||function(e){for(var l,n=1,t=arguments.length;n<t;n++)for(var c in l=arguments[n])Object.prototype.hasOwnProperty.call(l,c)&&(e[c]=l[c]);return e}).apply(this,arguments)},l={fullScreen:!0,fullscreenPluginStrings:{toggleFullscreen:"Toggle Fullscreen"}};return function(){function n(n,t){return this.core=n,this.$LG=t,this.settings=e(e({},l),this.core.settings),this}return n.prototype.init=function(){var e="";if(this.settings.fullScreen){if(!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled))return;e='<button type="button" aria-label="'+this.settings.fullscreenPluginStrings.toggleFullscreen+'" class="lg-fullscreen lg-icon"></button>',this.core.$toolbar.append(e),this.fullScreen()}},n.prototype.isFullScreen=function(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement},n.prototype.requestFullscreen=function(){var e=document.documentElement;e.requestFullscreen?e.requestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen&&e.webkitRequestFullscreen()},n.prototype.exitFullscreen=function(){document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()},n.prototype.fullScreen=function(){var e=this;this.$LG(document).on("fullscreenchange.lg.global"+this.core.lgId+" \n webkitfullscreenchange.lg.global"+this.core.lgId+" \n mozfullscreenchange.lg.global"+this.core.lgId+" \n MSFullscreenChange.lg.global"+this.core.lgId,(function(){e.core.lgOpened&&e.core.outer.toggleClass("lg-fullscreen-on")})),this.core.outer.find(".lg-fullscreen").first().on("click.lg",(function(){e.isFullScreen()?e.exitFullscreen():e.requestFullscreen()}))},n.prototype.closeGallery=function(){this.isFullScreen()&&this.exitFullscreen()},n.prototype.destroy=function(){this.$LG(document).off("fullscreenchange.lg.global"+this.core.lgId+" \n webkitfullscreenchange.lg.global"+this.core.lgId+" \n mozfullscreenchange.lg.global"+this.core.lgId+" \n MSFullscreenChange.lg.global"+this.core.lgId)},n}()}));
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
/**
|
||||
* lightgallery | 2.9.0 | October 1st 2025
|
||||
* http://www.lightgalleryjs.com/
|
||||
* Copyright (c) 2020 Sachin Neravath;
|
||||
* @license GPLv3
|
||||
*/
|
||||
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).lgHash=e()}(this,(function(){"use strict";var t=function(){return(t=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var s in e=arguments[i])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t}).apply(this,arguments)},e="lgAfterSlide",i="lgAfterClose",o={hash:!0,galleryId:"1",customSlideName:!1};return function(){function s(e,i){return this.core=e,this.$LG=i,this.settings=t(t({},o),this.core.settings),this}return s.prototype.init=function(){var t=this;this.settings.hash&&(this.oldHash=window.location.hash,setTimeout((function(){t.buildFromHash()}),100),this.core.LGel.on(e+".hash",this.onAfterSlide.bind(this)),this.core.LGel.on(i+".hash",this.onCloseAfter.bind(this)),this.$LG(window).on("hashchange.lg.hash.global"+this.core.lgId,this.onHashchange.bind(this)))},s.prototype.onAfterSlide=function(t){var e=this.core.galleryItems[t.detail.index].slideName;e=this.settings.customSlideName&&e||t.detail.index,history.replaceState?history.replaceState(null,"",window.location.pathname+window.location.search+"#lg="+this.settings.galleryId+"&slide="+e):window.location.hash="lg="+this.settings.galleryId+"&slide="+e},s.prototype.getIndexFromUrl=function(t){void 0===t&&(t=window.location.hash);var e=t.split("&slide=")[1],i=0;if(this.settings.customSlideName)for(var o=0;o<this.core.galleryItems.length;o++){if(this.core.galleryItems[o].slideName===e){i=o;break}}else i=parseInt(e,10);return isNaN(i)?0:i},s.prototype.buildFromHash=function(){var t=window.location.hash;if(t.indexOf("lg="+this.settings.galleryId)>0){this.$LG(document.body).addClass("lg-from-hash");var e=this.getIndexFromUrl(t);return this.core.openGallery(e),!0}},s.prototype.onCloseAfter=function(){this.oldHash&&this.oldHash.indexOf("lg="+this.settings.galleryId)<0?history.replaceState?history.replaceState(null,"",this.oldHash):window.location.hash=this.oldHash:history.replaceState?history.replaceState(null,document.title,window.location.pathname+window.location.search):window.location.hash=""},s.prototype.onHashchange=function(){if(this.core.lgOpened){var t=window.location.hash,e=this.getIndexFromUrl(t);t.indexOf("lg="+this.settings.galleryId)>-1?this.core.slide(e,!1,!1):this.core.lGalleryOn&&this.core.closeGallery()}},s.prototype.closeGallery=function(){this.settings.hash&&this.$LG(document.body).removeClass("lg-from-hash")},s.prototype.destroy=function(){this.core.LGel.off(".lg.hash"),this.core.LGel.off(".hash"),this.$LG(window).off("hashchange.lg.hash.global"+this.core.lgId)},s}()}));
|
||||
Vendored
-8
File diff suppressed because one or more lines are too long
Vendored
-8
File diff suppressed because one or more lines are too long
Vendored
-8
File diff suppressed because one or more lines are too long
-1
File diff suppressed because one or more lines are too long
Vendored
-8
File diff suppressed because one or more lines are too long
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
PhotoSwipe overrides to match Immich's AssetViewer aesthetic.
|
||||
Layered on top of photoswipe/photoswipe.css.
|
||||
*/
|
||||
|
||||
.pswp {
|
||||
--pswp-bg: #000;
|
||||
--pswp-placeholder-bg: #111;
|
||||
--pswp-icon-color: #fff;
|
||||
--pswp-icon-color-secondary: transparent;
|
||||
--pswp-icon-stroke-width: 0;
|
||||
--pswp-error-text-color: #fff;
|
||||
--pswp-preloader-color: rgba(255, 255, 255, 0.4);
|
||||
--pswp-preloader-color-secondary: rgba(255, 255, 255, 0.9);
|
||||
--pswp-transition-duration: 250ms;
|
||||
}
|
||||
|
||||
/* Hide UI Immich doesn't show */
|
||||
.pswp__button--zoom,
|
||||
.pswp__counter {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* Top toolbar: subtle dark backdrop, no shadows */
|
||||
.pswp__top-bar {
|
||||
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent);
|
||||
height: 56px;
|
||||
}
|
||||
|
||||
/* Standard icon buttons: cleaner sizing, hover state */
|
||||
.pswp__top-bar .pswp__button {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
margin: 6px;
|
||||
border-radius: 50%;
|
||||
transition: background-color 0.15s;
|
||||
}
|
||||
|
||||
.pswp__top-bar .pswp__button:hover,
|
||||
.pswp__top-bar .pswp__button:focus-visible {
|
||||
background-color: rgba(255, 255, 255, 0.12);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.pswp__top-bar .pswp__button .pswp__icn {
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
color: var(--pswp-icon-color);
|
||||
}
|
||||
|
||||
.pswp__button--close {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.pswp__button--download-button {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* Side arrows: hover-revealed on desktop, hidden by default on mobile */
|
||||
.pswp__button--arrow {
|
||||
width: 56px;
|
||||
height: 100px;
|
||||
margin-top: -50px;
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s, background-color 0.15s;
|
||||
border-radius: 8px;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.pswp:hover .pswp__button--arrow {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.pswp__button--arrow:hover,
|
||||
.pswp__button--arrow:focus-visible {
|
||||
opacity: 1;
|
||||
background-color: rgba(255, 255, 255, 0.12);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* Disable arrows at far ends of gallery */
|
||||
.pswp__button--arrow:disabled {
|
||||
opacity: 0 !important;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
/* Mobile: PhotoSwipe already auto-fades top bar; here we just hide arrows
|
||||
when configured to do so (default, matches Immich mobile). */
|
||||
html.pswp-no-arrows .pswp__button--arrow {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
html.pswp-no-mobile-arrows .pswp__button--arrow {
|
||||
display: none !important;
|
||||
}
|
||||
/* Mobile top bar is shorter and translucent */
|
||||
.pswp__top-bar {
|
||||
height: 48px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Video slide content */
|
||||
.pswp__video-wrap {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
pointer-events: none; /* let PhotoSwipe handle gestures except on the video */
|
||||
}
|
||||
|
||||
.pswp__video-wrap video {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
outline: none;
|
||||
pointer-events: auto;
|
||||
background: #000;
|
||||
}
|
||||
|
||||
/* Smooth backdrop fade in/out to match Immich's open/close feel */
|
||||
.pswp__bg {
|
||||
transition: opacity var(--pswp-transition-duration);
|
||||
}
|
||||
|
||||
/* Image caption (from EXIF description) - centered in the 56px bottom margin
|
||||
carved out by the lightbox `padding.bottom` setting. */
|
||||
.pswp__caption {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
height: 56px;
|
||||
padding: 0 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #fff;
|
||||
font-size: 14px;
|
||||
line-height: 1.4;
|
||||
text-align: center;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.pswp__caption[hidden] {
|
||||
display: none;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,420 @@
|
||||
/*! PhotoSwipe main CSS by Dmytro Semenov | photoswipe.com */
|
||||
|
||||
.pswp {
|
||||
--pswp-bg: #000;
|
||||
--pswp-placeholder-bg: #222;
|
||||
|
||||
|
||||
--pswp-root-z-index: 100000;
|
||||
|
||||
--pswp-preloader-color: rgba(79, 79, 79, 0.4);
|
||||
--pswp-preloader-color-secondary: rgba(255, 255, 255, 0.9);
|
||||
|
||||
/* defined via js:
|
||||
--pswp-transition-duration: 333ms; */
|
||||
|
||||
--pswp-icon-color: #fff;
|
||||
--pswp-icon-color-secondary: #4f4f4f;
|
||||
--pswp-icon-stroke-color: #4f4f4f;
|
||||
--pswp-icon-stroke-width: 2px;
|
||||
|
||||
--pswp-error-text-color: var(--pswp-icon-color);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Styles for basic PhotoSwipe (pswp) functionality (sliding area, open/close transitions)
|
||||
*/
|
||||
|
||||
.pswp {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: var(--pswp-root-z-index);
|
||||
display: none;
|
||||
touch-action: none;
|
||||
outline: 0;
|
||||
opacity: 0.003;
|
||||
contain: layout style size;
|
||||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/* Prevents focus outline on the root element,
|
||||
(it may be focused initially) */
|
||||
.pswp:focus {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
.pswp * {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.pswp img {
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.pswp--open {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.pswp,
|
||||
.pswp__bg {
|
||||
transform: translateZ(0);
|
||||
will-change: opacity;
|
||||
}
|
||||
|
||||
.pswp__bg {
|
||||
opacity: 0.005;
|
||||
background: var(--pswp-bg);
|
||||
}
|
||||
|
||||
.pswp,
|
||||
.pswp__scroll-wrap {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.pswp__scroll-wrap,
|
||||
.pswp__bg,
|
||||
.pswp__container,
|
||||
.pswp__item,
|
||||
.pswp__content,
|
||||
.pswp__img,
|
||||
.pswp__zoom-wrap {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.pswp__img,
|
||||
.pswp__zoom-wrap {
|
||||
width: auto;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.pswp--click-to-zoom.pswp--zoom-allowed .pswp__img {
|
||||
cursor: -webkit-zoom-in;
|
||||
cursor: -moz-zoom-in;
|
||||
cursor: zoom-in;
|
||||
}
|
||||
|
||||
.pswp--click-to-zoom.pswp--zoomed-in .pswp__img {
|
||||
cursor: move;
|
||||
cursor: -webkit-grab;
|
||||
cursor: -moz-grab;
|
||||
cursor: grab;
|
||||
}
|
||||
|
||||
.pswp--click-to-zoom.pswp--zoomed-in .pswp__img:active {
|
||||
cursor: -webkit-grabbing;
|
||||
cursor: -moz-grabbing;
|
||||
cursor: grabbing;
|
||||
}
|
||||
|
||||
/* :active to override grabbing cursor */
|
||||
.pswp--no-mouse-drag.pswp--zoomed-in .pswp__img,
|
||||
.pswp--no-mouse-drag.pswp--zoomed-in .pswp__img:active,
|
||||
.pswp__img {
|
||||
cursor: -webkit-zoom-out;
|
||||
cursor: -moz-zoom-out;
|
||||
cursor: zoom-out;
|
||||
}
|
||||
|
||||
|
||||
/* Prevent selection and tap highlights */
|
||||
.pswp__container,
|
||||
.pswp__img,
|
||||
.pswp__button,
|
||||
.pswp__counter {
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.pswp__item {
|
||||
/* z-index for fade transition */
|
||||
z-index: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.pswp__hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* Allow to click through pswp__content element, but not its children */
|
||||
.pswp__content {
|
||||
pointer-events: none;
|
||||
}
|
||||
.pswp__content > * {
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
PhotoSwipe UI
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
Error message appears when image is not loaded
|
||||
(JS option errorMsg controls markup)
|
||||
*/
|
||||
.pswp__error-msg-container {
|
||||
display: grid;
|
||||
}
|
||||
.pswp__error-msg {
|
||||
margin: auto;
|
||||
font-size: 1em;
|
||||
line-height: 1;
|
||||
color: var(--pswp-error-text-color);
|
||||
}
|
||||
|
||||
/*
|
||||
class pswp__hide-on-close is applied to elements that
|
||||
should hide (for example fade out) when PhotoSwipe is closed
|
||||
and show (for example fade in) when PhotoSwipe is opened
|
||||
*/
|
||||
.pswp .pswp__hide-on-close {
|
||||
opacity: 0.005;
|
||||
will-change: opacity;
|
||||
transition: opacity var(--pswp-transition-duration) cubic-bezier(0.4, 0, 0.22, 1);
|
||||
z-index: 10; /* always overlap slide content */
|
||||
pointer-events: none; /* hidden elements should not be clickable */
|
||||
}
|
||||
|
||||
/* class pswp--ui-visible is added when opening or closing transition starts */
|
||||
.pswp--ui-visible .pswp__hide-on-close {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
/* <button> styles, including css reset */
|
||||
.pswp__button {
|
||||
position: relative;
|
||||
display: block;
|
||||
width: 50px;
|
||||
height: 60px;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
background: none;
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
opacity: 0.85;
|
||||
-webkit-appearance: none;
|
||||
-webkit-touch-callout: none;
|
||||
}
|
||||
|
||||
.pswp__button:hover,
|
||||
.pswp__button:active,
|
||||
.pswp__button:focus {
|
||||
transition: none;
|
||||
padding: 0;
|
||||
background: none;
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.pswp__button:disabled {
|
||||
opacity: 0.3;
|
||||
cursor: auto;
|
||||
}
|
||||
|
||||
.pswp__icn {
|
||||
fill: var(--pswp-icon-color);
|
||||
color: var(--pswp-icon-color-secondary);
|
||||
}
|
||||
|
||||
.pswp__icn {
|
||||
position: absolute;
|
||||
top: 14px;
|
||||
left: 9px;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.pswp__icn-shadow {
|
||||
stroke: var(--pswp-icon-stroke-color);
|
||||
stroke-width: var(--pswp-icon-stroke-width);
|
||||
fill: none;
|
||||
}
|
||||
|
||||
.pswp__icn:focus {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
/*
|
||||
div element that matches size of large image,
|
||||
large image loads on top of it,
|
||||
used when msrc is not provided
|
||||
*/
|
||||
div.pswp__img--placeholder,
|
||||
.pswp__img--with-bg {
|
||||
background: var(--pswp-placeholder-bg);
|
||||
}
|
||||
|
||||
.pswp__top-bar {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 60px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-end;
|
||||
z-index: 10;
|
||||
|
||||
/* allow events to pass through top bar itself */
|
||||
pointer-events: none !important;
|
||||
}
|
||||
.pswp__top-bar > * {
|
||||
pointer-events: auto;
|
||||
/* this makes transition significantly more smooth,
|
||||
even though inner elements are not animated */
|
||||
will-change: opacity;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Close button
|
||||
|
||||
*/
|
||||
.pswp__button--close {
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Arrow buttons
|
||||
|
||||
*/
|
||||
.pswp__button--arrow {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
width: 75px;
|
||||
height: 100px;
|
||||
top: 50%;
|
||||
margin-top: -50px;
|
||||
}
|
||||
|
||||
.pswp__button--arrow:disabled {
|
||||
display: none;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.pswp__button--arrow .pswp__icn {
|
||||
top: 50%;
|
||||
margin-top: -30px;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
background: none;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.pswp--one-slide .pswp__button--arrow {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* hide arrows on touch screens */
|
||||
.pswp--touch .pswp__button--arrow {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
/* show arrows only after mouse was used */
|
||||
.pswp--has_mouse .pswp__button--arrow {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.pswp__button--arrow--prev {
|
||||
right: auto;
|
||||
left: 0px;
|
||||
}
|
||||
|
||||
.pswp__button--arrow--next {
|
||||
right: 0px;
|
||||
}
|
||||
.pswp__button--arrow--next .pswp__icn {
|
||||
left: auto;
|
||||
right: 14px;
|
||||
/* flip horizontally */
|
||||
transform: scale(-1, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Zoom button
|
||||
|
||||
*/
|
||||
.pswp__button--zoom {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pswp--zoom-allowed .pswp__button--zoom {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* "+" => "-" */
|
||||
.pswp--zoomed-in .pswp__zoom-icn-bar-v {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Loading indicator
|
||||
|
||||
*/
|
||||
.pswp__preloader {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
width: 50px;
|
||||
height: 60px;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.pswp__preloader .pswp__icn {
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s linear;
|
||||
animation: pswp-clockwise 600ms linear infinite;
|
||||
}
|
||||
|
||||
.pswp__preloader--active .pswp__icn {
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
@keyframes pswp-clockwise {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
"1 of 10" counter
|
||||
|
||||
*/
|
||||
.pswp__counter {
|
||||
height: 30px;
|
||||
margin-top: 15px;
|
||||
margin-inline-start: 20px;
|
||||
font-size: 14px;
|
||||
line-height: 30px;
|
||||
color: var(--pswp-icon-color);
|
||||
text-shadow: 1px 1px 3px var(--pswp-icon-color-secondary);
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.pswp--one-slide .pswp__counter {
|
||||
display: none;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+332
-66
@@ -1,50 +1,198 @@
|
||||
html {
|
||||
background: #191919;
|
||||
/*
|
||||
Tokens ported from immich-app/immich v2.7.5 (web/src/app.css, 2026-05-23).
|
||||
Re-check approximately once a year for visual drift.
|
||||
|
||||
Font note: Immich uses "GoogleSans" (Google's proprietary font, not freely
|
||||
distributed). We use a system font stack with Inter from Google Fonts as a
|
||||
visually-close substitute. Same approach Immich's open-source consumers use.
|
||||
*/
|
||||
|
||||
/* Inter (OFL-1.1, see fonts/Inter-LICENSE.txt). Single variable WOFF2 covers
|
||||
all weights from 100-900, so we can use any weight in CSS without an extra
|
||||
network request. Vendored locally so IPP runs cleanly air-gapped. */
|
||||
@font-face {
|
||||
font-family: 'Inter';
|
||||
src: url('/share/static/fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
|
||||
font-weight: 100 900;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
#lightgallery a {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
text-decoration: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
:root {
|
||||
/* Immich light-mode tokens (RGB triplets so they compose via rgb(var(...))) */
|
||||
--immich-primary: 66 80 175;
|
||||
--immich-bg: 255 255 255;
|
||||
--immich-fg: 0 0 0;
|
||||
--immich-gray: 235 235 235;
|
||||
|
||||
/* Immich dark-mode tokens */
|
||||
--immich-dark-primary: 172 203 250;
|
||||
--immich-dark-bg: 10 10 10;
|
||||
--immich-dark-fg: 229 231 235;
|
||||
--immich-dark-gray: 33 33 33;
|
||||
|
||||
/* Active palette - light by default; html.dark overrides below */
|
||||
--color-bg: rgb(var(--immich-bg));
|
||||
--color-fg: rgb(var(--immich-fg));
|
||||
--color-primary: rgb(var(--immich-primary));
|
||||
--color-gray: rgb(var(--immich-gray));
|
||||
|
||||
--font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
|
||||
/* Horizontal inset for textual page content (title, description, group
|
||||
headers). The grid itself goes edge-to-edge on mobile so it doesn't use
|
||||
this value. */
|
||||
--gutter: 32px;
|
||||
|
||||
color-scheme: light;
|
||||
}
|
||||
|
||||
#lightgallery img {
|
||||
max-height: 250px;
|
||||
margin: 4px;
|
||||
}
|
||||
|
||||
@media (max-width: 800px) {
|
||||
#lightgallery a {
|
||||
width: calc(100vw / 3 - 10px);
|
||||
height: calc(100vw / 3 - 10px);
|
||||
overflow: hidden;
|
||||
@media (max-width: 640px) {
|
||||
:root {
|
||||
--gutter: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
#lightgallery img {
|
||||
html.dark {
|
||||
--color-bg: rgb(var(--immich-dark-bg));
|
||||
--color-fg: rgb(var(--immich-dark-fg));
|
||||
--color-primary: rgb(var(--immich-dark-primary));
|
||||
--color-gray: rgb(var(--immich-dark-gray));
|
||||
|
||||
color-scheme: dark;
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
|
||||
html, body {
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
background: var(--color-bg);
|
||||
color: var(--color-fg);
|
||||
font-family: var(--font-sans);
|
||||
}
|
||||
|
||||
/* ===== Justified-rows / square-grid gallery (tiles are absolute-positioned by JS) ===== */
|
||||
|
||||
#gallery {
|
||||
/* Container is a positioned box; tiles are absolute-positioned by JS.
|
||||
Container height is set explicitly so the scrollbar reflects the full
|
||||
virtualized layout. */
|
||||
position: relative;
|
||||
margin: 0 var(--gutter) var(--gutter);
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
/* Tiles go edge-to-edge on mobile, so the gallery doesn't use --gutter */
|
||||
#gallery {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
#gallery a {
|
||||
position: absolute;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
background-color: var(--color-gray);
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
/* left / top / width / height set per-tile by layoutGrid() in web.js;
|
||||
background-image is the decoded thumbhash placeholder, set by web.js. */
|
||||
}
|
||||
|
||||
#gallery img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
object-position: center;
|
||||
}
|
||||
}
|
||||
@media (min-width: 801px) {
|
||||
#lightgallery a.thumb-error {
|
||||
width: 250px;
|
||||
height: 250px;
|
||||
margin: 4px;
|
||||
|
||||
/* Hide the <img> until JS sets its src - otherwise Chrome renders its default
|
||||
broken-image glyph for img elements with explicit dimensions but no src
|
||||
(e.g. tiles awaiting load, or tiles whose in-flight fetch was cancelled
|
||||
when the user scrolled past). The <a>'s gray background shows through. */
|
||||
#gallery img:not([src]) {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
#gallery a.thumb-error img {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ===== Group headers (visible when ipp.groupGalleryByDate is enabled) ===== */
|
||||
|
||||
.group-header {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
margin: 0;
|
||||
padding: 16px 0 8px;
|
||||
font-size: 18px;
|
||||
font-weight: 500;
|
||||
line-height: 1.2;
|
||||
letter-spacing: -0.01em;
|
||||
color: var(--color-fg);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
/* On mobile the gallery itself goes edge-to-edge, so the headers need
|
||||
their own left padding to keep the text away from the screen edge. */
|
||||
.group-header {
|
||||
padding-left: var(--gutter);
|
||||
}
|
||||
}
|
||||
|
||||
#lightgallery a.thumb-error {
|
||||
background: #2a2a2a;
|
||||
/* ===== Selection mode (checkmark + selected state) ===== */
|
||||
|
||||
.tile-check {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 10px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 50%;
|
||||
border: 2px solid rgba(255, 255, 255, 0.9);
|
||||
background-color: rgba(0, 0, 0, 0.25);
|
||||
opacity: 0;
|
||||
transition: opacity 0.15s, background-color 0.15s, border-color 0.15s;
|
||||
z-index: 2;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
#lightgallery a.thumb-error img {
|
||||
|
||||
#gallery a:hover .tile-check,
|
||||
#gallery.select-mode .tile-check {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.tile-check svg {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
color: #fff;
|
||||
display: none;
|
||||
}
|
||||
|
||||
#gallery a.selected .tile-check {
|
||||
background-color: var(--color-primary);
|
||||
border-color: var(--color-primary);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
#gallery a.selected .tile-check svg {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#gallery a.selected {
|
||||
outline: 3px solid var(--color-primary);
|
||||
outline-offset: -3px;
|
||||
}
|
||||
|
||||
.play-icon {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
@@ -58,61 +206,179 @@ html {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
#lightgallery a:has(.play-icon):hover .play-icon {
|
||||
#gallery a:has(.play-icon):hover .play-icon {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
#password {
|
||||
color: white;
|
||||
}
|
||||
|
||||
#header, #album-description {
|
||||
font-family: system-ui, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, Helvetica, Arial, "Helvetica Neue", sans-serif;
|
||||
color: white;
|
||||
}
|
||||
/* ===== Header (title + asset count + download action) ===== */
|
||||
|
||||
#header {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
padding: 28px var(--gutter) 12px;
|
||||
color: var(--color-fg);
|
||||
}
|
||||
|
||||
.header-text {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
#header h1 {
|
||||
font-size: 18pt;
|
||||
font-weight: bold;
|
||||
margin: 4px;
|
||||
margin: 0;
|
||||
font-size: 28px;
|
||||
font-weight: 500;
|
||||
line-height: 1.2;
|
||||
letter-spacing: -0.01em;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
#album-description h2 {
|
||||
font-size: 12pt;
|
||||
font-weight: normal;
|
||||
font-style: italic;
|
||||
margin: 4px;
|
||||
white-space: pre-wrap;
|
||||
#header .subtitle {
|
||||
margin: 4px 0 0;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
opacity: 0.55;
|
||||
}
|
||||
|
||||
#download-all {
|
||||
margin: auto 4px auto auto;
|
||||
flex: 0 0 auto;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: 50%;
|
||||
text-decoration: none;
|
||||
color: var(--color-fg);
|
||||
transition: background-color 0.15s;
|
||||
}
|
||||
|
||||
#loading-spinner {
|
||||
text-align: center;
|
||||
margin: 75px 0;
|
||||
#download-all:hover,
|
||||
#download-all:focus-visible {
|
||||
background-color: color-mix(in srgb, var(--color-fg) 10%, transparent);
|
||||
outline: none;
|
||||
}
|
||||
.loader {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: 5px solid #888;
|
||||
border-bottom-color: transparent;
|
||||
|
||||
#download-all svg {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
}
|
||||
|
||||
#album-description {
|
||||
margin: 0;
|
||||
padding: 0 var(--gutter) 16px;
|
||||
color: var(--color-fg);
|
||||
opacity: 0.7;
|
||||
font-size: 15px;
|
||||
line-height: 1.5;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
#header {
|
||||
padding-top: 16px;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
#header h1 {
|
||||
font-size: 22px;
|
||||
}
|
||||
#album-description {
|
||||
padding-bottom: 12px;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
/* ===== Selection toolbar (fixed at top while select-mode is active) ===== */
|
||||
|
||||
#select-toolbar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 56px;
|
||||
background: var(--color-bg);
|
||||
border-bottom: 1px solid color-mix(in srgb, var(--color-fg) 10%, transparent);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 0 8px;
|
||||
z-index: 100;
|
||||
box-shadow: 0 1px 6px color-mix(in srgb, var(--color-fg) 6%, transparent);
|
||||
}
|
||||
|
||||
/* The display rule above is more specific than the browser's default
|
||||
[hidden] { display: none } - explicitly override so the toolbar honors
|
||||
the hidden attribute. */
|
||||
#select-toolbar[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.toolbar-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
padding: 0;
|
||||
border-radius: 50%;
|
||||
display: inline-block;
|
||||
box-sizing: border-box;
|
||||
animation: rotation 1s linear infinite;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--color-fg);
|
||||
cursor: pointer;
|
||||
transition: background-color 0.15s;
|
||||
}
|
||||
@keyframes rotation {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
|
||||
.toolbar-btn:hover,
|
||||
.toolbar-btn:focus-visible {
|
||||
background-color: color-mix(in srgb, var(--color-fg) 10%, transparent);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.toolbar-btn svg {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
}
|
||||
|
||||
#select-count {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
padding: 0 12px;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
color: var(--color-fg);
|
||||
}
|
||||
|
||||
.toolbar-btn-text {
|
||||
flex: 0 0 auto;
|
||||
padding: 8px 16px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--color-fg);
|
||||
cursor: pointer;
|
||||
border-radius: 20px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
transition: background-color 0.15s;
|
||||
}
|
||||
|
||||
.toolbar-btn-text:hover,
|
||||
.toolbar-btn-text:focus-visible {
|
||||
background-color: color-mix(in srgb, var(--color-fg) 10%, transparent);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
#select-toolbar {
|
||||
height: 48px;
|
||||
}
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
#select-count {
|
||||
font-size: 15px;
|
||||
padding: 0 8px;
|
||||
}
|
||||
.toolbar-btn-text {
|
||||
padding: 6px 12px;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
/**
|
||||
* Encodes an RGBA image to a ThumbHash. RGB should not be premultiplied by A.
|
||||
*
|
||||
* @param w The width of the input image. Must be ≤100px.
|
||||
* @param h The height of the input image. Must be ≤100px.
|
||||
* @param rgba The pixels in the input image, row-by-row. Must have w*h*4 elements.
|
||||
* @returns The ThumbHash as a Uint8Array.
|
||||
*/
|
||||
export function rgbaToThumbHash(w, h, rgba) {
|
||||
// Encoding an image larger than 100x100 is slow with no benefit
|
||||
if (w > 100 || h > 100) throw new Error(`${w}x${h} doesn't fit in 100x100`)
|
||||
let { PI, round, max, cos, abs } = Math
|
||||
|
||||
// Determine the average color
|
||||
let avg_r = 0, avg_g = 0, avg_b = 0, avg_a = 0
|
||||
for (let i = 0, j = 0; i < w * h; i++, j += 4) {
|
||||
let alpha = rgba[j + 3] / 255
|
||||
avg_r += alpha / 255 * rgba[j]
|
||||
avg_g += alpha / 255 * rgba[j + 1]
|
||||
avg_b += alpha / 255 * rgba[j + 2]
|
||||
avg_a += alpha
|
||||
}
|
||||
if (avg_a) {
|
||||
avg_r /= avg_a
|
||||
avg_g /= avg_a
|
||||
avg_b /= avg_a
|
||||
}
|
||||
|
||||
let hasAlpha = avg_a < w * h
|
||||
let l_limit = hasAlpha ? 5 : 7 // Use fewer luminance bits if there's alpha
|
||||
let lx = max(1, round(l_limit * w / max(w, h)))
|
||||
let ly = max(1, round(l_limit * h / max(w, h)))
|
||||
let l = [] // luminance
|
||||
let p = [] // yellow - blue
|
||||
let q = [] // red - green
|
||||
let a = [] // alpha
|
||||
|
||||
// Convert the image from RGBA to LPQA (composite atop the average color)
|
||||
for (let i = 0, j = 0; i < w * h; i++, j += 4) {
|
||||
let alpha = rgba[j + 3] / 255
|
||||
let r = avg_r * (1 - alpha) + alpha / 255 * rgba[j]
|
||||
let g = avg_g * (1 - alpha) + alpha / 255 * rgba[j + 1]
|
||||
let b = avg_b * (1 - alpha) + alpha / 255 * rgba[j + 2]
|
||||
l[i] = (r + g + b) / 3
|
||||
p[i] = (r + g) / 2 - b
|
||||
q[i] = r - g
|
||||
a[i] = alpha
|
||||
}
|
||||
|
||||
// Encode using the DCT into DC (constant) and normalized AC (varying) terms
|
||||
let encodeChannel = (channel, nx, ny) => {
|
||||
let dc = 0, ac = [], scale = 0, fx = []
|
||||
for (let cy = 0; cy < ny; cy++) {
|
||||
for (let cx = 0; cx * ny < nx * (ny - cy); cx++) {
|
||||
let f = 0
|
||||
for (let x = 0; x < w; x++)
|
||||
fx[x] = cos(PI / w * cx * (x + 0.5))
|
||||
for (let y = 0; y < h; y++)
|
||||
for (let x = 0, fy = cos(PI / h * cy * (y + 0.5)); x < w; x++)
|
||||
f += channel[x + y * w] * fx[x] * fy
|
||||
f /= w * h
|
||||
if (cx || cy) {
|
||||
ac.push(f)
|
||||
scale = max(scale, abs(f))
|
||||
} else {
|
||||
dc = f
|
||||
}
|
||||
}
|
||||
}
|
||||
if (scale)
|
||||
for (let i = 0; i < ac.length; i++)
|
||||
ac[i] = 0.5 + 0.5 / scale * ac[i]
|
||||
return [dc, ac, scale]
|
||||
}
|
||||
let [l_dc, l_ac, l_scale] = encodeChannel(l, max(3, lx), max(3, ly))
|
||||
let [p_dc, p_ac, p_scale] = encodeChannel(p, 3, 3)
|
||||
let [q_dc, q_ac, q_scale] = encodeChannel(q, 3, 3)
|
||||
let [a_dc, a_ac, a_scale] = hasAlpha ? encodeChannel(a, 5, 5) : []
|
||||
|
||||
// Write the constants
|
||||
let isLandscape = w > h
|
||||
let header24 = round(63 * l_dc) | (round(31.5 + 31.5 * p_dc) << 6) | (round(31.5 + 31.5 * q_dc) << 12) | (round(31 * l_scale) << 18) | (hasAlpha << 23)
|
||||
let header16 = (isLandscape ? ly : lx) | (round(63 * p_scale) << 3) | (round(63 * q_scale) << 9) | (isLandscape << 15)
|
||||
let hash = [header24 & 255, (header24 >> 8) & 255, header24 >> 16, header16 & 255, header16 >> 8]
|
||||
let ac_start = hasAlpha ? 6 : 5
|
||||
let ac_index = 0
|
||||
if (hasAlpha) hash.push(round(15 * a_dc) | (round(15 * a_scale) << 4))
|
||||
|
||||
// Write the varying factors
|
||||
for (let ac of hasAlpha ? [l_ac, p_ac, q_ac, a_ac] : [l_ac, p_ac, q_ac])
|
||||
for (let f of ac)
|
||||
hash[ac_start + (ac_index >> 1)] |= round(15 * f) << ((ac_index++ & 1) << 2)
|
||||
return new Uint8Array(hash)
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes a ThumbHash to an RGBA image. RGB is not be premultiplied by A.
|
||||
*
|
||||
* @param hash The bytes of the ThumbHash.
|
||||
* @returns The width, height, and pixels of the rendered placeholder image.
|
||||
*/
|
||||
export function thumbHashToRGBA(hash) {
|
||||
let { PI, min, max, cos, round } = Math
|
||||
|
||||
// Read the constants
|
||||
let header24 = hash[0] | (hash[1] << 8) | (hash[2] << 16)
|
||||
let header16 = hash[3] | (hash[4] << 8)
|
||||
let l_dc = (header24 & 63) / 63
|
||||
let p_dc = ((header24 >> 6) & 63) / 31.5 - 1
|
||||
let q_dc = ((header24 >> 12) & 63) / 31.5 - 1
|
||||
let l_scale = ((header24 >> 18) & 31) / 31
|
||||
let hasAlpha = header24 >> 23
|
||||
let p_scale = ((header16 >> 3) & 63) / 63
|
||||
let q_scale = ((header16 >> 9) & 63) / 63
|
||||
let isLandscape = header16 >> 15
|
||||
let lx = max(3, isLandscape ? hasAlpha ? 5 : 7 : header16 & 7)
|
||||
let ly = max(3, isLandscape ? header16 & 7 : hasAlpha ? 5 : 7)
|
||||
let a_dc = hasAlpha ? (hash[5] & 15) / 15 : 1
|
||||
let a_scale = (hash[5] >> 4) / 15
|
||||
|
||||
// Read the varying factors (boost saturation by 1.25x to compensate for quantization)
|
||||
let ac_start = hasAlpha ? 6 : 5
|
||||
let ac_index = 0
|
||||
let decodeChannel = (nx, ny, scale) => {
|
||||
let ac = []
|
||||
for (let cy = 0; cy < ny; cy++)
|
||||
for (let cx = cy ? 0 : 1; cx * ny < nx * (ny - cy); cx++)
|
||||
ac.push((((hash[ac_start + (ac_index >> 1)] >> ((ac_index++ & 1) << 2)) & 15) / 7.5 - 1) * scale)
|
||||
return ac
|
||||
}
|
||||
let l_ac = decodeChannel(lx, ly, l_scale)
|
||||
let p_ac = decodeChannel(3, 3, p_scale * 1.25)
|
||||
let q_ac = decodeChannel(3, 3, q_scale * 1.25)
|
||||
let a_ac = hasAlpha && decodeChannel(5, 5, a_scale)
|
||||
|
||||
// Decode using the DCT into RGB
|
||||
let ratio = thumbHashToApproximateAspectRatio(hash)
|
||||
let w = round(ratio > 1 ? 32 : 32 * ratio)
|
||||
let h = round(ratio > 1 ? 32 / ratio : 32)
|
||||
let rgba = new Uint8Array(w * h * 4), fx = [], fy = []
|
||||
for (let y = 0, i = 0; y < h; y++) {
|
||||
for (let x = 0; x < w; x++, i += 4) {
|
||||
let l = l_dc, p = p_dc, q = q_dc, a = a_dc
|
||||
|
||||
// Precompute the coefficients
|
||||
for (let cx = 0, n = max(lx, hasAlpha ? 5 : 3); cx < n; cx++)
|
||||
fx[cx] = cos(PI / w * (x + 0.5) * cx)
|
||||
for (let cy = 0, n = max(ly, hasAlpha ? 5 : 3); cy < n; cy++)
|
||||
fy[cy] = cos(PI / h * (y + 0.5) * cy)
|
||||
|
||||
// Decode L
|
||||
for (let cy = 0, j = 0; cy < ly; cy++)
|
||||
for (let cx = cy ? 0 : 1, fy2 = fy[cy] * 2; cx * ly < lx * (ly - cy); cx++, j++)
|
||||
l += l_ac[j] * fx[cx] * fy2
|
||||
|
||||
// Decode P and Q
|
||||
for (let cy = 0, j = 0; cy < 3; cy++) {
|
||||
for (let cx = cy ? 0 : 1, fy2 = fy[cy] * 2; cx < 3 - cy; cx++, j++) {
|
||||
let f = fx[cx] * fy2
|
||||
p += p_ac[j] * f
|
||||
q += q_ac[j] * f
|
||||
}
|
||||
}
|
||||
|
||||
// Decode A
|
||||
if (hasAlpha)
|
||||
for (let cy = 0, j = 0; cy < 5; cy++)
|
||||
for (let cx = cy ? 0 : 1, fy2 = fy[cy] * 2; cx < 5 - cy; cx++, j++)
|
||||
a += a_ac[j] * fx[cx] * fy2
|
||||
|
||||
// Convert to RGB
|
||||
let b = l - 2 / 3 * p
|
||||
let r = (3 * l - b + q) / 2
|
||||
let g = r - q
|
||||
rgba[i] = max(0, 255 * min(1, r))
|
||||
rgba[i + 1] = max(0, 255 * min(1, g))
|
||||
rgba[i + 2] = max(0, 255 * min(1, b))
|
||||
rgba[i + 3] = max(0, 255 * min(1, a))
|
||||
}
|
||||
}
|
||||
return { w, h, rgba }
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the average color from a ThumbHash. RGB is not be premultiplied by A.
|
||||
*
|
||||
* @param hash The bytes of the ThumbHash.
|
||||
* @returns The RGBA values for the average color. Each value ranges from 0 to 1.
|
||||
*/
|
||||
export function thumbHashToAverageRGBA(hash) {
|
||||
let { min, max } = Math
|
||||
let header = hash[0] | (hash[1] << 8) | (hash[2] << 16)
|
||||
let l = (header & 63) / 63
|
||||
let p = ((header >> 6) & 63) / 31.5 - 1
|
||||
let q = ((header >> 12) & 63) / 31.5 - 1
|
||||
let hasAlpha = header >> 23
|
||||
let a = hasAlpha ? (hash[5] & 15) / 15 : 1
|
||||
let b = l - 2 / 3 * p
|
||||
let r = (3 * l - b + q) / 2
|
||||
let g = r - q
|
||||
return {
|
||||
r: max(0, min(1, r)),
|
||||
g: max(0, min(1, g)),
|
||||
b: max(0, min(1, b)),
|
||||
a
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the approximate aspect ratio of the original image.
|
||||
*
|
||||
* @param hash The bytes of the ThumbHash.
|
||||
* @returns The approximate aspect ratio (i.e. width / height).
|
||||
*/
|
||||
export function thumbHashToApproximateAspectRatio(hash) {
|
||||
let header = hash[3]
|
||||
let hasAlpha = hash[2] & 0x80
|
||||
let isLandscape = hash[4] & 0x80
|
||||
let lx = isLandscape ? hasAlpha ? 5 : 7 : header & 7
|
||||
let ly = isLandscape ? header & 7 : hasAlpha ? 5 : 7
|
||||
return lx / ly
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes an RGBA image to a PNG data URL. RGB should not be premultiplied by
|
||||
* A. This is optimized for speed and simplicity and does not optimize for size
|
||||
* at all. This doesn't do any compression (all values are stored uncompressed).
|
||||
*
|
||||
* @param w The width of the input image. Must be ≤100px.
|
||||
* @param h The height of the input image. Must be ≤100px.
|
||||
* @param rgba The pixels in the input image, row-by-row. Must have w*h*4 elements.
|
||||
* @returns A data URL containing a PNG for the input image.
|
||||
*/
|
||||
export function rgbaToDataURL(w, h, rgba) {
|
||||
let row = w * 4 + 1
|
||||
let idat = 6 + h * (5 + row)
|
||||
let bytes = [
|
||||
137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0,
|
||||
w >> 8, w & 255, 0, 0, h >> 8, h & 255, 8, 6, 0, 0, 0, 0, 0, 0, 0,
|
||||
idat >>> 24, (idat >> 16) & 255, (idat >> 8) & 255, idat & 255,
|
||||
73, 68, 65, 84, 120, 1
|
||||
]
|
||||
let table = [
|
||||
0, 498536548, 997073096, 651767980, 1994146192, 1802195444, 1303535960,
|
||||
1342533948, -306674912, -267414716, -690576408, -882789492, -1687895376,
|
||||
-2032938284, -1609899400, -1111625188
|
||||
]
|
||||
let a = 1, b = 0
|
||||
for (let y = 0, i = 0, end = row - 1; y < h; y++, end += row - 1) {
|
||||
bytes.push(y + 1 < h ? 0 : 1, row & 255, row >> 8, ~row & 255, (row >> 8) ^ 255, 0)
|
||||
for (b = (b + a) % 65521; i < end; i++) {
|
||||
let u = rgba[i] & 255
|
||||
bytes.push(u)
|
||||
a = (a + u) % 65521
|
||||
b = (b + a) % 65521
|
||||
}
|
||||
}
|
||||
bytes.push(
|
||||
b >> 8, b & 255, a >> 8, a & 255, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130
|
||||
)
|
||||
for (let [start, end] of [[12, 29], [37, 41 + idat]]) {
|
||||
let c = ~0
|
||||
for (let i = start; i < end; i++) {
|
||||
c ^= bytes[i]
|
||||
c = (c >>> 4) ^ table[c & 15]
|
||||
c = (c >>> 4) ^ table[c & 15]
|
||||
}
|
||||
c = ~c
|
||||
bytes[end++] = c >>> 24
|
||||
bytes[end++] = (c >> 16) & 255
|
||||
bytes[end++] = (c >> 8) & 255
|
||||
bytes[end++] = c & 255
|
||||
}
|
||||
return 'data:image/png;base64,' + btoa(String.fromCharCode(...bytes))
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes a ThumbHash to a PNG data URL. This is a convenience function that
|
||||
* just calls "thumbHashToRGBA" followed by "rgbaToDataURL".
|
||||
*
|
||||
* @param hash The bytes of the ThumbHash.
|
||||
* @returns A data URL containing a PNG for the rendered ThumbHash.
|
||||
*/
|
||||
export function thumbHashToDataURL(hash) {
|
||||
let image = thumbHashToRGBA(hash)
|
||||
return rgbaToDataURL(image.w, image.h, image.rgba)
|
||||
}
|
||||
+874
-66
@@ -1,78 +1,886 @@
|
||||
// How many thumbnails to load per "page" fetched from Immich
|
||||
const PER_PAGE = 50
|
||||
// @ts-check
|
||||
// ============================================================================
|
||||
// Gallery client - virtualized justified/square grid, PhotoSwipe v5 lightbox
|
||||
//
|
||||
// Layout is pre-computed for all items based on container width. Only tiles
|
||||
// within viewport ± 1 viewport-height buffer exist in the DOM at any moment.
|
||||
// PhotoSwipe runs with a full dataSource array so the lightbox navigates
|
||||
// across all items regardless of which tiles are currently rendered.
|
||||
// ============================================================================
|
||||
|
||||
class LGallery {
|
||||
items
|
||||
lightGallery
|
||||
element
|
||||
index = PER_PAGE
|
||||
// Runtime URLs served by Express, not filesystem paths. TypeScript's resolver
|
||||
// can't follow them, so we silence its module-not-found errors here. The
|
||||
// imports themselves work fine at runtime.
|
||||
// @ts-ignore
|
||||
import PhotoSwipeLightbox from '/share/static/photoswipe/photoswipe-lightbox.esm.js'
|
||||
// @ts-ignore
|
||||
import { thumbHashToDataURL } from '/share/static/thumbhash/thumbhash.js'
|
||||
|
||||
/**
|
||||
* Create a lightGallery instance and populate it with the first page of gallery items
|
||||
/**
|
||||
* @typedef {Object} GalleryItem
|
||||
* @property {string} id
|
||||
* @property {'IMAGE'|'VIDEO'} type
|
||||
* @property {string} previewUrl
|
||||
* @property {string} thumbnailUrl
|
||||
* @property {string} [downloadUrl]
|
||||
* @property {string} [videoData] JSON-stringified video source info
|
||||
* @property {string} [description] Escaped HTML fragment for the lightbox caption
|
||||
* @property {string} downloadFilename
|
||||
* @property {number} [width]
|
||||
* @property {number} [height]
|
||||
* @property {string} [thumbhash]
|
||||
* @property {string} [fileCreatedAt] ISO date
|
||||
*/
|
||||
init (params = {}) {
|
||||
// Create the lightGallery instance
|
||||
this.element = document.getElementById('lightgallery')
|
||||
this.lightGallery = lightGallery(this.element, Object.assign({
|
||||
plugins: [lgZoom, lgThumbnail, lgVideo, lgFullscreen, lgHash],
|
||||
speed: 500,
|
||||
loop: params.items.length <= PER_PAGE,
|
||||
/*
|
||||
This license key was graciously provided by LightGallery under their
|
||||
GPLv3 open-source project license:
|
||||
|
||||
/**
|
||||
* @typedef {Object} LightboxConfig
|
||||
* @property {boolean} [showArrows]
|
||||
* @property {boolean} [showDownload]
|
||||
* @property {boolean} [mobileArrows]
|
||||
*/
|
||||
licenseKey: '8FFA6495-676C4D30-8BFC54B6-4D0A6CEC'
|
||||
/*
|
||||
Please do not take it and use it for other projects, as it was provided
|
||||
specifically for Immich Public Proxy.
|
||||
|
||||
For your own projects you can use the default license key of
|
||||
0000-0000-000-0000 as per their docs:
|
||||
|
||||
https://www.lightgalleryjs.com/docs/settings/#licenseKey
|
||||
/**
|
||||
* @typedef {Object} InitParams
|
||||
* @property {GalleryItem[]} [items]
|
||||
* @property {number} [openItem] 1-based; opens lightbox on the Nth item
|
||||
* @property {LightboxConfig} [lightboxConfig]
|
||||
* @property {boolean} [groupByDate]
|
||||
*/
|
||||
}, params.lgConfig))
|
||||
this.items = params.items
|
||||
|
||||
const spinner = document.getElementById('loading-spinner')
|
||||
let observer = null
|
||||
|
||||
if (spinner) {
|
||||
observer = new IntersectionObserver((entries) => {
|
||||
if (entries[0].isIntersecting) {
|
||||
lgallery.loadMoreItems(observer, spinner)
|
||||
}
|
||||
}, { rootMargin: '200px' })
|
||||
observer.observe(spinner)
|
||||
}
|
||||
|
||||
const preloadThreshold = 8
|
||||
this.element.addEventListener('lgAfterSlide', (event) => {
|
||||
if (event.detail.index >= this.index - preloadThreshold) {
|
||||
lgallery.loadMoreItems(observer, spinner)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Load more gallery items as per lightGallery docs
|
||||
* https://www.lightgalleryjs.com/demos/infinite-scrolling/
|
||||
/**
|
||||
* @typedef {Object} LayoutEntry
|
||||
* @property {number} index
|
||||
* @property {number} left
|
||||
* @property {number} top
|
||||
* @property {number} width
|
||||
* @property {number} height
|
||||
*/
|
||||
loadMoreItems (observer, spinner) {
|
||||
if (this.index < this.items.length) {
|
||||
// Append new thumbnails
|
||||
this.items
|
||||
.slice(this.index, this.index + PER_PAGE)
|
||||
.forEach(item => {
|
||||
this.element.insertAdjacentHTML('beforeend', item.html + '\n')
|
||||
})
|
||||
this.index += PER_PAGE
|
||||
this.lightGallery.refresh()
|
||||
|
||||
/**
|
||||
* @typedef {Object} HeaderEntry
|
||||
* @property {string} label
|
||||
* @property {number} top
|
||||
* @property {number} height
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} GroupSpec
|
||||
* @property {string | null} label
|
||||
* @property {number[]} indices
|
||||
*/
|
||||
|
||||
// Justified-rows target row height (matches Immich's main view)
|
||||
const TARGET_ROW_HEIGHT = 235
|
||||
const GAP = 4
|
||||
const MOBILE_BREAKPOINT = 640
|
||||
const MOBILE_COLS = 3
|
||||
const IMAGE_LOAD_MARGIN_PX = 300
|
||||
const SCROLL_SETTLE_MS = 100
|
||||
const BUFFER_VIEWPORTS = 1
|
||||
// Height reserved for each month header (must agree with .group-header CSS)
|
||||
const HEADER_HEIGHT = 48
|
||||
// Vertical gap between groups
|
||||
const GROUP_GAP = 16
|
||||
|
||||
// MDI icons (Apache 2.0). Same icon set Immich uses for its viewer.
|
||||
const ICON_DOWNLOAD = '<svg class="pswp__icn" viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z"/></svg>'
|
||||
const ICON_FULLSCREEN = '<svg class="pswp__icn" viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="M5,5H10V7H7V10H5V5M14,5H19V10H17V7H14V5M17,14H19V19H14V17H17V14M10,17V19H5V14H7V17H10Z"/></svg>'
|
||||
const ICON_FULLSCREEN_EXIT = '<svg class="pswp__icn" viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="M14,14H19V16H16V19H14V14M5,14H10V19H8V16H5V14M8,5H10V10H5V8H8V5M19,8V10H14V5H16V8H19Z"/></svg>'
|
||||
|
||||
// ----- module state ---------------------------------------------------------
|
||||
|
||||
/** @type {GalleryItem[]} */
|
||||
let items = []
|
||||
/** @type {LayoutEntry[]} - sparse, indexed by GalleryItem index */
|
||||
let layout = []
|
||||
/** @type {HeaderEntry[]} - empty when groupByDate is off */
|
||||
let headers = []
|
||||
let groupByDate = false
|
||||
/** @type {HTMLElement | null} */
|
||||
let container = null
|
||||
/** @type {any} - PhotoSwipeLightbox instance; external module, leave untyped */
|
||||
let lightbox = null
|
||||
/** @type {LightboxConfig} */
|
||||
let lightboxConfig = {}
|
||||
/** @type {boolean} - true while our pushed history entry is live */
|
||||
let lightboxPushedHistory = false
|
||||
/** @type {boolean} - guards against re-entering the popstate handler during our own history.back() */
|
||||
let closingFromHistory = false
|
||||
/** @type {Map<number, HTMLAnchorElement>} */
|
||||
const renderedTiles = new Map()
|
||||
/** @type {Map<string, HTMLElement>} */
|
||||
const renderedHeaders = new Map()
|
||||
let lastContainerW = 0
|
||||
|
||||
// Selection mode (mode-toggle UX: hidden checkmarks until activated)
|
||||
let selectMode = false
|
||||
/** @type {Set<string>} - set of asset IDs */
|
||||
const selected = new Set()
|
||||
/** @type {HTMLElement | null} */
|
||||
let toolbarEl = null
|
||||
/** @type {HTMLElement | null} */
|
||||
let countEl = null
|
||||
/** @type {HTMLButtonElement | null} */
|
||||
let selectAllBtn = null
|
||||
/** @type {HTMLButtonElement | null} */
|
||||
let cancelBtn = null
|
||||
/** @type {HTMLButtonElement | null} */
|
||||
let downloadBtn = null
|
||||
|
||||
// Inline SVG for the check icon shown inside selected tiles' checkmark circle
|
||||
const CHECK_SVG = '<svg viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg>'
|
||||
|
||||
// Long-press threshold for entering select mode via touch/mouse
|
||||
const LONG_PRESS_MS = 500
|
||||
|
||||
// ----- layout computation ---------------------------------------------------
|
||||
|
||||
function computeLayout (containerW) {
|
||||
const tileLayout = new Array(items.length)
|
||||
const newHeaders = []
|
||||
const groups = groupByDate ? groupItemsByMonth() : [{ label: null, indices: itemIndices() }]
|
||||
const isMobile = containerW < MOBILE_BREAKPOINT
|
||||
let y = 0
|
||||
for (let g = 0; g < groups.length; g++) {
|
||||
const group = groups[g]
|
||||
if (group.label) {
|
||||
newHeaders.push({ label: group.label, top: y, height: HEADER_HEIGHT })
|
||||
y += HEADER_HEIGHT
|
||||
}
|
||||
y = isMobile
|
||||
? layoutSquareGroup(containerW, group.indices, y, tileLayout)
|
||||
: layoutJustifiedGroup(containerW, group.indices, y, tileLayout)
|
||||
if (g < groups.length - 1) y += GROUP_GAP
|
||||
}
|
||||
return {
|
||||
layout: tileLayout,
|
||||
headers: newHeaders,
|
||||
totalHeight: Math.max(0, y)
|
||||
}
|
||||
}
|
||||
|
||||
function itemIndices () {
|
||||
const out = new Array(items.length)
|
||||
for (let i = 0; i < items.length; i++) out[i] = i
|
||||
return out
|
||||
}
|
||||
|
||||
/** @returns {GroupSpec[]} */
|
||||
function groupItemsByMonth () {
|
||||
// Preserve item order (already sorted desc by render.ts when grouping is on)
|
||||
/** @type {Map<string, GroupSpec>} */
|
||||
const map = new Map()
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const key = (items[i].fileCreatedAt || '').slice(0, 7) || 'undated'
|
||||
let g = map.get(key)
|
||||
if (!g) {
|
||||
g = { label: monthLabel(key), indices: [] }
|
||||
map.set(key, g)
|
||||
}
|
||||
g.indices.push(i)
|
||||
}
|
||||
return Array.from(map.values())
|
||||
}
|
||||
|
||||
/** @param {string} key @returns {string} */
|
||||
function monthLabel (key) {
|
||||
if (key === 'undated') return 'Undated'
|
||||
const parts = key.split('-')
|
||||
const y = Number(parts[0])
|
||||
const m = Number(parts[1])
|
||||
if (!y || !m) return key
|
||||
// Intl.DateTimeFormat picks up the browser's locale; UTC timeZone keeps
|
||||
// the displayed month consistent with the UTC YYYY-MM bucket key.
|
||||
return new Intl.DateTimeFormat(undefined, {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
timeZone: 'UTC'
|
||||
}).format(new Date(Date.UTC(y, m - 1, 1)))
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} containerW
|
||||
* @param {number[]} indices
|
||||
* @param {number} startY
|
||||
* @param {LayoutEntry[]} tileLayout
|
||||
* @returns {number} The y position past the last tile (no trailing gap)
|
||||
*/
|
||||
function layoutSquareGroup (containerW, indices, startY, tileLayout) {
|
||||
const tileSize = Math.floor((containerW - (MOBILE_COLS - 1) * GAP) / MOBILE_COLS)
|
||||
let col = 0
|
||||
let x = 0
|
||||
let y = startY
|
||||
for (const idx of indices) {
|
||||
tileLayout[idx] = { index: idx, left: x, top: y, width: tileSize, height: tileSize }
|
||||
col++
|
||||
if (col === MOBILE_COLS) {
|
||||
col = 0
|
||||
x = 0
|
||||
y += tileSize + GAP
|
||||
} else {
|
||||
// Remove the loading spinner and stop observing once all items are loaded
|
||||
if (observer) observer.disconnect()
|
||||
if (spinner) spinner.remove()
|
||||
x += tileSize + GAP
|
||||
}
|
||||
}
|
||||
// If the last row was partial, advance y to past it
|
||||
if (col > 0) y += tileSize
|
||||
// Otherwise back off the trailing inter-row gap
|
||||
else if (y > startY) y -= GAP
|
||||
return y
|
||||
}
|
||||
|
||||
function layoutJustifiedGroup (containerW, indices, startY, tileLayout) {
|
||||
let rowItems = []
|
||||
let aspectSum = 0
|
||||
let y = startY
|
||||
|
||||
const applyRow = (rowItems, height, isLastRow) => {
|
||||
const intHeight = Math.floor(height)
|
||||
let x = 0
|
||||
rowItems.forEach(({ idx, aspect }, i) => {
|
||||
const isFinalInRow = i === rowItems.length - 1
|
||||
const w = (!isLastRow && isFinalInRow)
|
||||
? containerW - x
|
||||
: Math.floor(aspect * height)
|
||||
tileLayout[idx] = { index: idx, left: x, top: y, width: w, height: intHeight }
|
||||
x += w + GAP
|
||||
})
|
||||
y += intHeight + GAP
|
||||
}
|
||||
|
||||
for (const idx of indices) {
|
||||
const item = items[idx]
|
||||
const w = item.width || 1
|
||||
const h = item.height || 1
|
||||
const aspect = w / h
|
||||
rowItems.push({ idx, aspect })
|
||||
aspectSum += aspect
|
||||
const projectedH = (containerW - (rowItems.length - 1) * GAP) / aspectSum
|
||||
if (projectedH <= TARGET_ROW_HEIGHT) {
|
||||
applyRow(rowItems, projectedH, false)
|
||||
rowItems = []
|
||||
aspectSum = 0
|
||||
}
|
||||
}
|
||||
if (rowItems.length) applyRow(rowItems, TARGET_ROW_HEIGHT, true)
|
||||
|
||||
// y advanced past the last row's trailing gap; back off
|
||||
return y > startY ? y - GAP : y
|
||||
}
|
||||
|
||||
// ----- tile DOM construction ------------------------------------------------
|
||||
|
||||
function onThumbError () {
|
||||
this.closest('a').classList.add('thumb-error')
|
||||
}
|
||||
|
||||
// Cache of decoded thumbhash → PNG data URL. Same thumbhash on multiple
|
||||
// tile-creations (revisits during virtualization) reuses the same URL.
|
||||
const thumbhashCache = new Map()
|
||||
|
||||
function decodeThumbhash (base64) {
|
||||
const cached = thumbhashCache.get(base64)
|
||||
if (cached) return cached
|
||||
try {
|
||||
const binary = atob(base64)
|
||||
const bytes = new Uint8Array(binary.length)
|
||||
for (let i = 0; i < bytes.length; i++) bytes[i] = binary.charCodeAt(i)
|
||||
const url = thumbHashToDataURL(bytes)
|
||||
thumbhashCache.set(base64, url)
|
||||
return url
|
||||
} catch (e) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
function createTile (index) {
|
||||
const item = items[index]
|
||||
const l = layout[index]
|
||||
const a = document.createElement('a')
|
||||
a.dataset.index = index
|
||||
if (item.type !== 'VIDEO') a.href = item.previewUrl
|
||||
a.style.left = l.left + 'px'
|
||||
a.style.top = l.top + 'px'
|
||||
a.style.width = l.width + 'px'
|
||||
a.style.height = l.height + 'px'
|
||||
|
||||
if (item.thumbhash) {
|
||||
const url = decodeThumbhash(item.thumbhash)
|
||||
if (url) a.style.backgroundImage = 'url(' + url + ')'
|
||||
}
|
||||
|
||||
const img = document.createElement('img')
|
||||
// alt left empty: browsers paint alt text over the thumbhash background
|
||||
// while the thumbnail downloads. Description (if any) is shown in the
|
||||
// lightbox caption instead.
|
||||
img.alt = ''
|
||||
img.dataset.src = item.thumbnailUrl
|
||||
img.onerror = onThumbError
|
||||
a.appendChild(img)
|
||||
|
||||
if (item.type === 'VIDEO') {
|
||||
const playIcon = document.createElement('div')
|
||||
playIcon.className = 'play-icon'
|
||||
a.appendChild(playIcon)
|
||||
}
|
||||
|
||||
// Selection checkmark (rendered only when select mode is even possible -
|
||||
// i.e. when the page included the toolbar element)
|
||||
if (toolbarEl) {
|
||||
const check = document.createElement('div')
|
||||
check.className = 'tile-check'
|
||||
check.innerHTML = CHECK_SVG
|
||||
check.addEventListener('click', (e) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
if (!selectMode) enterSelectMode()
|
||||
toggleSelection(item.id)
|
||||
})
|
||||
a.appendChild(check)
|
||||
if (selected.has(item.id)) a.classList.add('selected')
|
||||
attachLongPress(a, item.id)
|
||||
}
|
||||
|
||||
a.addEventListener('click', (e) => {
|
||||
e.preventDefault()
|
||||
if (selectMode) {
|
||||
toggleSelection(item.id)
|
||||
} else {
|
||||
openLightbox(index)
|
||||
}
|
||||
})
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
// ----- long-press (enter select mode) --------------------------------------
|
||||
|
||||
function attachLongPress (tile, id) {
|
||||
let timer = null
|
||||
let pressed = false
|
||||
const cancel = () => {
|
||||
if (timer) { clearTimeout(timer); timer = null }
|
||||
}
|
||||
tile.addEventListener('pointerdown', (e) => {
|
||||
// Ignore right/middle clicks
|
||||
if (e.button !== undefined && e.button !== 0) return
|
||||
pressed = false
|
||||
timer = setTimeout(() => {
|
||||
timer = null
|
||||
pressed = true
|
||||
if (!selectMode) enterSelectMode()
|
||||
toggleSelection(id)
|
||||
}, LONG_PRESS_MS)
|
||||
})
|
||||
tile.addEventListener('pointerup', cancel)
|
||||
tile.addEventListener('pointercancel', cancel)
|
||||
tile.addEventListener('pointerleave', cancel)
|
||||
tile.addEventListener('pointermove', (e) => {
|
||||
// Cancel long-press if pointer moves significantly (scroll, drag)
|
||||
if (Math.abs(e.movementX) + Math.abs(e.movementY) > 6) cancel()
|
||||
})
|
||||
// Swallow the synthetic click that follows a successful long-press so it
|
||||
// doesn't open the lightbox.
|
||||
tile.addEventListener('click', (e) => {
|
||||
if (pressed) {
|
||||
pressed = false
|
||||
e.preventDefault()
|
||||
e.stopImmediatePropagation()
|
||||
}
|
||||
}, true)
|
||||
}
|
||||
|
||||
// ----- selection state -----------------------------------------------------
|
||||
|
||||
function enterSelectMode () {
|
||||
if (selectMode) return
|
||||
selectMode = true
|
||||
if (container) container.classList.add('select-mode')
|
||||
if (toolbarEl) toolbarEl.hidden = false
|
||||
}
|
||||
|
||||
function exitSelectMode () {
|
||||
if (!selectMode) return
|
||||
selectMode = false
|
||||
// Clear DOM markers on the tiles currently in the DOM
|
||||
for (const a of renderedTiles.values()) a.classList.remove('selected')
|
||||
selected.clear()
|
||||
if (container) container.classList.remove('select-mode')
|
||||
if (toolbarEl) toolbarEl.hidden = true
|
||||
updateSelectionUI()
|
||||
}
|
||||
|
||||
function toggleSelection (id) {
|
||||
if (selected.has(id)) selected.delete(id)
|
||||
else selected.add(id)
|
||||
const idx = items.findIndex(it => it.id === id)
|
||||
const tile = idx >= 0 ? renderedTiles.get(idx) : null
|
||||
if (tile) tile.classList.toggle('selected', selected.has(id))
|
||||
// Auto-exit if user deselected the last item
|
||||
if (selected.size === 0 && selectMode) exitSelectMode()
|
||||
else updateSelectionUI()
|
||||
}
|
||||
|
||||
function updateSelectionUI () {
|
||||
if (countEl) {
|
||||
countEl.textContent = selected.size + ' selected'
|
||||
}
|
||||
if (downloadBtn) downloadBtn.disabled = selected.size === 0
|
||||
if (selectAllBtn) {
|
||||
selectAllBtn.textContent =
|
||||
selected.size === items.length ? 'Deselect all' : 'Select all'
|
||||
}
|
||||
}
|
||||
|
||||
function selectAllOrNone () {
|
||||
if (selected.size === items.length) {
|
||||
// Deselect all but keep select mode active
|
||||
for (const a of renderedTiles.values()) a.classList.remove('selected')
|
||||
selected.clear()
|
||||
updateSelectionUI()
|
||||
} else {
|
||||
if (!selectMode) enterSelectMode()
|
||||
for (const item of items) selected.add(item.id)
|
||||
for (const a of renderedTiles.values()) a.classList.add('selected')
|
||||
updateSelectionUI()
|
||||
}
|
||||
}
|
||||
|
||||
function downloadSelected () {
|
||||
if (selected.size === 0) return
|
||||
// Single selection: download the file directly so the user gets the image
|
||||
// (or video) instead of a one-entry zip.
|
||||
if (selected.size === 1) {
|
||||
const id = selected.values().next().value
|
||||
const item = items.find(it => it.id === id)
|
||||
if (item && item.downloadUrl) {
|
||||
const a = document.createElement('a')
|
||||
a.href = item.downloadUrl
|
||||
a.download = item.downloadFilename || ''
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
a.remove()
|
||||
return
|
||||
}
|
||||
}
|
||||
// Form POST so the browser handles streaming the zip directly to disk.
|
||||
const form = document.createElement('form')
|
||||
form.method = 'POST'
|
||||
form.action = window.location.pathname + '/download'
|
||||
const input = document.createElement('input')
|
||||
input.type = 'hidden'
|
||||
input.name = 'assets'
|
||||
input.value = JSON.stringify(Array.from(selected))
|
||||
form.appendChild(input)
|
||||
document.body.appendChild(form)
|
||||
form.submit()
|
||||
form.remove()
|
||||
}
|
||||
|
||||
function setupToolbar () {
|
||||
toolbarEl = document.getElementById('select-toolbar')
|
||||
// No toolbar means downloads aren't allowed for this share; nothing to wire
|
||||
if (!toolbarEl) return
|
||||
countEl = document.getElementById('select-count')
|
||||
selectAllBtn = /** @type {HTMLButtonElement | null} */ (document.getElementById('select-all'))
|
||||
cancelBtn = /** @type {HTMLButtonElement | null} */ (document.getElementById('select-cancel'))
|
||||
downloadBtn = /** @type {HTMLButtonElement | null} */ (document.getElementById('select-download'))
|
||||
if (cancelBtn) cancelBtn.addEventListener('click', exitSelectMode)
|
||||
if (selectAllBtn) selectAllBtn.addEventListener('click', selectAllOrNone)
|
||||
if (downloadBtn) downloadBtn.addEventListener('click', downloadSelected)
|
||||
updateSelectionUI()
|
||||
}
|
||||
|
||||
// ----- virtualization -------------------------------------------------------
|
||||
|
||||
function getVisibleRange () {
|
||||
const containerTop = container.getBoundingClientRect().top
|
||||
const viewportTopInContainer = -containerTop
|
||||
const viewportBottomInContainer = viewportTopInContainer + window.innerHeight
|
||||
const buffer = window.innerHeight * BUFFER_VIEWPORTS
|
||||
return {
|
||||
top: viewportTopInContainer - buffer,
|
||||
bottom: viewportBottomInContainer + buffer
|
||||
}
|
||||
}
|
||||
|
||||
function createHeader (header) {
|
||||
const el = document.createElement('h2')
|
||||
el.className = 'group-header'
|
||||
el.style.top = header.top + 'px'
|
||||
el.textContent = header.label
|
||||
return el
|
||||
}
|
||||
|
||||
function virtualize () {
|
||||
if (!container || !layout.length) return
|
||||
const { top, bottom } = getVisibleRange()
|
||||
|
||||
// Tiles
|
||||
const neededTiles = new Set()
|
||||
for (const l of layout) {
|
||||
if (!l) continue
|
||||
if (l.top + l.height < top) continue
|
||||
if (l.top > bottom) break
|
||||
neededTiles.add(l.index)
|
||||
}
|
||||
for (const [index, el] of renderedTiles) {
|
||||
if (!neededTiles.has(index)) {
|
||||
el.remove()
|
||||
renderedTiles.delete(index)
|
||||
}
|
||||
}
|
||||
for (const index of neededTiles) {
|
||||
if (renderedTiles.has(index)) continue
|
||||
const tile = createTile(index)
|
||||
container.appendChild(tile)
|
||||
renderedTiles.set(index, tile)
|
||||
}
|
||||
|
||||
// Group headers (when grouping is enabled; headers is empty otherwise)
|
||||
const neededHeaders = new Set()
|
||||
for (const h of headers) {
|
||||
if (h.top + h.height < top) continue
|
||||
if (h.top > bottom) break
|
||||
neededHeaders.add(h.label)
|
||||
}
|
||||
for (const [label, el] of renderedHeaders) {
|
||||
if (!neededHeaders.has(label)) {
|
||||
el.remove()
|
||||
renderedHeaders.delete(label)
|
||||
}
|
||||
}
|
||||
for (const label of neededHeaders) {
|
||||
if (renderedHeaders.has(label)) continue
|
||||
const h = headers.find(x => x.label === label)
|
||||
if (!h) continue
|
||||
const el = createHeader(h)
|
||||
container.appendChild(el)
|
||||
renderedHeaders.set(label, el)
|
||||
}
|
||||
}
|
||||
|
||||
function computeLayoutAndRender () {
|
||||
if (!container) return
|
||||
const containerW = container.clientWidth
|
||||
if (containerW <= 0) return
|
||||
if (containerW === lastContainerW) {
|
||||
virtualize()
|
||||
return
|
||||
}
|
||||
lastContainerW = containerW
|
||||
|
||||
const result = computeLayout(containerW)
|
||||
layout = result.layout
|
||||
headers = result.headers
|
||||
container.style.height = result.totalHeight + 'px'
|
||||
|
||||
for (const [, el] of renderedTiles) el.remove()
|
||||
renderedTiles.clear()
|
||||
for (const [, el] of renderedHeaders) el.remove()
|
||||
renderedHeaders.clear()
|
||||
|
||||
virtualize()
|
||||
loadVisibleTiles()
|
||||
}
|
||||
|
||||
// ----- image src lifecycle --------------------------------------------------
|
||||
|
||||
function loadVisibleTiles () {
|
||||
if (!container) return
|
||||
const vpHeight = window.innerHeight
|
||||
const containerTop = container.getBoundingClientRect().top
|
||||
for (const a of renderedTiles.values()) {
|
||||
const img = a.firstElementChild
|
||||
if (!(img instanceof HTMLImageElement)) continue
|
||||
const aTopInVp = containerTop + parseFloat(a.style.top || '0')
|
||||
const aHeight = parseFloat(a.style.height || '0')
|
||||
const isFar = aTopInVp + aHeight < -IMAGE_LOAD_MARGIN_PX ||
|
||||
aTopInVp > vpHeight + IMAGE_LOAD_MARGIN_PX
|
||||
if (isFar) {
|
||||
if (img.src && !img.complete) {
|
||||
img.dataset.src = img.src
|
||||
img.removeAttribute('src')
|
||||
}
|
||||
} else if (img.dataset.src) {
|
||||
img.src = img.dataset.src
|
||||
img.removeAttribute('data-src')
|
||||
}
|
||||
}
|
||||
}
|
||||
const lgallery = new LGallery()
|
||||
|
||||
// ----- scroll handling ------------------------------------------------------
|
||||
|
||||
let scrollFrame = null
|
||||
let loadTimer = null
|
||||
|
||||
function onScroll () {
|
||||
if (scrollFrame == null) {
|
||||
scrollFrame = requestAnimationFrame(() => {
|
||||
scrollFrame = null
|
||||
virtualize()
|
||||
})
|
||||
}
|
||||
if (loadTimer) clearTimeout(loadTimer)
|
||||
loadTimer = setTimeout(() => {
|
||||
loadTimer = null
|
||||
loadVisibleTiles()
|
||||
}, SCROLL_SETTLE_MS)
|
||||
}
|
||||
|
||||
// ----- PhotoSwipe -----------------------------------------------------------
|
||||
|
||||
function parseVideoData (item) {
|
||||
try {
|
||||
const data = JSON.parse(item.videoData || '{}')
|
||||
const source = (data.source && data.source[0]) || {}
|
||||
return { src: source.src || '', type: source.type || 'video/mp4' }
|
||||
} catch (e) {
|
||||
return { src: '', type: 'video/mp4' }
|
||||
}
|
||||
}
|
||||
|
||||
function escapeAttr (s) {
|
||||
return String(s).replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>')
|
||||
}
|
||||
|
||||
function buildDataSource () {
|
||||
return items.map(item => {
|
||||
if (item.type === 'VIDEO') {
|
||||
const v = parseVideoData(item)
|
||||
return {
|
||||
html:
|
||||
'<div class="pswp__video-wrap">' +
|
||||
'<video controls playsinline poster="' + escapeAttr(item.thumbnailUrl) + '">' +
|
||||
'<source src="' + escapeAttr(v.src) + '" type="' + escapeAttr(v.type) + '">' +
|
||||
'</video>' +
|
||||
'</div>'
|
||||
}
|
||||
}
|
||||
return {
|
||||
src: item.previewUrl,
|
||||
width: item.width || 1600,
|
||||
height: item.height || 1200,
|
||||
msrc: item.thumbnailUrl,
|
||||
alt: item.description || ''
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function initLightbox () {
|
||||
lightbox = new PhotoSwipeLightbox({
|
||||
dataSource: buildDataSource(),
|
||||
pswpModule: () => import('/share/static/photoswipe/photoswipe.esm.js'),
|
||||
bgOpacity: 1,
|
||||
showHideAnimationType: 'fade',
|
||||
closeOnVerticalDrag: true,
|
||||
arrowKeys: true,
|
||||
loop: false,
|
||||
padding: { top: 56, bottom: 56, left: 16, right: 16 }
|
||||
})
|
||||
|
||||
// Download button (only registered if config enables it)
|
||||
if (lightboxConfig.showDownload) {
|
||||
lightbox.on('uiRegister', () => {
|
||||
lightbox.pswp.ui.registerElement({
|
||||
name: 'download-button',
|
||||
order: 8,
|
||||
isButton: true,
|
||||
tagName: 'a',
|
||||
ariaLabel: 'Download',
|
||||
html: ICON_DOWNLOAD,
|
||||
onInit: (el, pswp) => {
|
||||
el.setAttribute('target', '_blank')
|
||||
el.setAttribute('rel', 'noopener')
|
||||
const update = () => {
|
||||
const item = items[pswp.currIndex]
|
||||
if (item && item.downloadUrl) {
|
||||
el.href = item.downloadUrl
|
||||
el.setAttribute('download', item.downloadFilename || '')
|
||||
} else {
|
||||
el.removeAttribute('href')
|
||||
}
|
||||
}
|
||||
update()
|
||||
pswp.on('change', update)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Fullscreen toggle. Skipped on browsers without Fullscreen API support
|
||||
// for arbitrary elements (notably iOS Safari on iPhone).
|
||||
if (document.fullscreenEnabled) {
|
||||
lightbox.on('uiRegister', () => {
|
||||
lightbox.pswp.ui.registerElement({
|
||||
name: 'fullscreen-button',
|
||||
order: 9,
|
||||
isButton: true,
|
||||
html: ICON_FULLSCREEN,
|
||||
onInit: (el, pswp) => {
|
||||
const update = () => {
|
||||
const active = document.fullscreenElement === pswp.element
|
||||
el.innerHTML = active ? ICON_FULLSCREEN_EXIT : ICON_FULLSCREEN
|
||||
el.setAttribute('aria-label', active ? 'Exit fullscreen' : 'Fullscreen')
|
||||
el.setAttribute('title', active ? 'Exit fullscreen' : 'Fullscreen')
|
||||
}
|
||||
update()
|
||||
el.addEventListener('click', () => {
|
||||
if (document.fullscreenElement) {
|
||||
document.exitFullscreen().catch(() => {})
|
||||
} else {
|
||||
pswp.element.requestFullscreen().catch(() => {})
|
||||
}
|
||||
})
|
||||
document.addEventListener('fullscreenchange', update)
|
||||
pswp.on('destroy', () => {
|
||||
document.removeEventListener('fullscreenchange', update)
|
||||
if (document.fullscreenElement === pswp.element) {
|
||||
document.exitFullscreen().catch(() => {})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Caption from EXIF description (only present when item.description is set;
|
||||
// server-side gated on ipp.showMetadata.description). Content is already
|
||||
// HTML-escaped in render.ts, so innerHTML assignment is safe.
|
||||
lightbox.on('uiRegister', () => {
|
||||
lightbox.pswp.ui.registerElement({
|
||||
name: 'caption',
|
||||
order: 9,
|
||||
isButton: false,
|
||||
appendTo: 'root',
|
||||
onInit: (el, pswp) => {
|
||||
el.classList.add('pswp__caption')
|
||||
const render = () => {
|
||||
const item = items[pswp.currIndex]
|
||||
const text = (item && item.description) || ''
|
||||
el.innerHTML = text
|
||||
el.hidden = !text
|
||||
}
|
||||
render()
|
||||
pswp.on('change', render)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
// Hash navigation + back-button handling: push a history entry on open so
|
||||
// the mobile back gesture closes the lightbox; sync the hash with the
|
||||
// current slide as the user pages through.
|
||||
lightbox.on('uiRegister', () => {
|
||||
const pswp = lightbox.pswp
|
||||
const item = items[pswp.currIndex]
|
||||
if (item) {
|
||||
history.pushState({ pswp: true }, '', '#' + item.id)
|
||||
lightboxPushedHistory = true
|
||||
}
|
||||
pswp.on('change', () => {
|
||||
const it = items[pswp.currIndex]
|
||||
if (it) history.replaceState({ pswp: lightboxPushedHistory }, '', '#' + it.id)
|
||||
})
|
||||
pswp.on('close', () => {
|
||||
scrollToCurrentSlide(pswp.currIndex)
|
||||
const wasFromHistory = closingFromHistory
|
||||
closingFromHistory = false
|
||||
if (wasFromHistory) {
|
||||
// popstate already moved us back; nothing more to do
|
||||
lightboxPushedHistory = false
|
||||
} else if (lightboxPushedHistory) {
|
||||
// UI close (button / Esc / swipe-down): consume our pushed entry
|
||||
closingFromHistory = true
|
||||
lightboxPushedHistory = false
|
||||
history.back()
|
||||
} else {
|
||||
history.replaceState(null, '', window.location.pathname + window.location.search)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
window.addEventListener('popstate', () => {
|
||||
if (closingFromHistory) {
|
||||
// Our own history.back() during a UI-driven close
|
||||
closingFromHistory = false
|
||||
return
|
||||
}
|
||||
if (lightbox && lightbox.pswp && lightboxPushedHistory) {
|
||||
closingFromHistory = true
|
||||
lightbox.pswp.close()
|
||||
}
|
||||
})
|
||||
|
||||
// Optional control hiding (defaults match Immich's behavior)
|
||||
const docEl = document.documentElement
|
||||
if (!lightboxConfig.showArrows) docEl.classList.add('pswp-no-arrows')
|
||||
if (!lightboxConfig.mobileArrows) docEl.classList.add('pswp-no-mobile-arrows')
|
||||
|
||||
lightbox.init()
|
||||
}
|
||||
|
||||
function openLightbox (index) {
|
||||
if (lightbox) lightbox.loadAndOpen(index)
|
||||
}
|
||||
|
||||
/**
|
||||
* Scroll the page so the tile for the given item is comfortably in view.
|
||||
* Called from the lightbox close handler - if the user navigated prev/next
|
||||
* inside the lightbox, or arrived via a #asset-id deep link, the tile they
|
||||
* end on may be far from the original scroll position. We only scroll when
|
||||
* the tile is genuinely off-screen, so closing on a still-visible tile
|
||||
* doesn't jiggle the page.
|
||||
*/
|
||||
function scrollToCurrentSlide (index) {
|
||||
if (!container || index == null || !layout[index]) return
|
||||
const entry = layout[index]
|
||||
const containerTop = container.getBoundingClientRect().top + window.scrollY
|
||||
const tileTop = containerTop + entry.top
|
||||
const tileBottom = tileTop + entry.height
|
||||
const viewportTop = window.scrollY
|
||||
const viewportBottom = viewportTop + window.innerHeight
|
||||
// Already mostly visible - leave the scroll alone
|
||||
if (tileTop >= viewportTop && tileBottom <= viewportBottom) return
|
||||
// Center the tile vertically in the viewport
|
||||
const targetScroll = tileTop - (window.innerHeight - entry.height) / 2
|
||||
window.scrollTo({ top: Math.max(0, targetScroll), behavior: 'instant' })
|
||||
}
|
||||
|
||||
// ----- entry point ----------------------------------------------------------
|
||||
|
||||
function readInitParams () {
|
||||
const el = document.getElementById('ipp-init')
|
||||
if (!el) return {}
|
||||
try { return JSON.parse(el.textContent || '{}') } catch (e) { return {} }
|
||||
}
|
||||
|
||||
function init () {
|
||||
const params = readInitParams()
|
||||
items = params.items || []
|
||||
lightboxConfig = params.lightboxConfig || {}
|
||||
groupByDate = !!params.groupByDate
|
||||
container = document.getElementById('gallery')
|
||||
if (!container) return
|
||||
|
||||
setupToolbar()
|
||||
initLightbox()
|
||||
|
||||
let resizeFrame
|
||||
const resizeObserver = new ResizeObserver(() => {
|
||||
if (resizeFrame) cancelAnimationFrame(resizeFrame)
|
||||
resizeFrame = requestAnimationFrame(computeLayoutAndRender)
|
||||
})
|
||||
resizeObserver.observe(container)
|
||||
|
||||
window.addEventListener('scroll', onScroll, { passive: true })
|
||||
|
||||
// Deep-link: prefer #asset-id in the URL hash, fall back to ?openItem
|
||||
const hash = window.location.hash.slice(1)
|
||||
if (hash) {
|
||||
const idx = items.findIndex(it => it.id === hash)
|
||||
if (idx >= 0) openLightbox(idx)
|
||||
} else if (params.openItem && params.openItem > 0 && params.openItem <= items.length) {
|
||||
openLightbox(params.openItem - 1)
|
||||
}
|
||||
}
|
||||
|
||||
init()
|
||||
|
||||
+52
-2
@@ -2,7 +2,7 @@ import dayjs from 'dayjs'
|
||||
import { Response } from 'express-serve-static-core'
|
||||
import { DownloadAll, SharedLink } from './types'
|
||||
|
||||
let config = {}
|
||||
let config: { [key: string]: unknown } = {}
|
||||
try {
|
||||
if (process.env.CONFIG) {
|
||||
// Attempt to parse docker-compose config string into JSON (if specified)
|
||||
@@ -15,6 +15,56 @@ try {
|
||||
console.log(e)
|
||||
}
|
||||
|
||||
// Backward-compatability shim for 1.x users with a legacy `lightGallery.*` config section
|
||||
if (config.lightGallery && typeof config.lightGallery === 'object') {
|
||||
const lg = config.lightGallery as Record<string, unknown>
|
||||
const mobile = (lg.mobileSettings || {}) as Record<string, unknown>
|
||||
const ipp = (config.ipp || (config.ipp = {})) as Record<string, unknown>
|
||||
const lightbox = (ipp.lightbox || (ipp.lightbox = {})) as Record<string, unknown>
|
||||
// Only fill in fields the user hasn't already set on ipp.lightbox.
|
||||
if (lightbox.showArrows === undefined && lg.controls !== undefined) {
|
||||
lightbox.showArrows = !!lg.controls
|
||||
}
|
||||
if (lightbox.showDownload === undefined && lg.download !== undefined) {
|
||||
lightbox.showDownload = !!lg.download
|
||||
}
|
||||
if (lightbox.mobileArrows === undefined && mobile.controls !== undefined) {
|
||||
lightbox.mobileArrows = !!mobile.controls
|
||||
}
|
||||
console.log(
|
||||
'[IPP] The `lightGallery` config section is deprecated; relevant keys ' +
|
||||
'have been mapped to `ipp.lightbox.*`. See README for the current options.'
|
||||
)
|
||||
}
|
||||
|
||||
// Backward-compat shim: gallery-related keys that used to live directly on
|
||||
// `ipp` now live under `ipp.gallery`. Map legacy keys forward, only filling
|
||||
// in fields the user hasn't already set on the new path.
|
||||
{
|
||||
const ipp = (config.ipp || (config.ipp = {})) as Record<string, unknown>
|
||||
const galleryKeyMigrations: Array<[string, string]> = [
|
||||
['singleImageGallery', 'singleImage'],
|
||||
['singleItemAutoOpen', 'singleItemAutoOpen'],
|
||||
['showGalleryTitle', 'showTitle'],
|
||||
['showGalleryDescription', 'showDescription'],
|
||||
['groupGalleryByDate', 'groupByDate']
|
||||
]
|
||||
const legacyPresent = galleryKeyMigrations.some(([oldKey]) => ipp[oldKey] !== undefined)
|
||||
if (legacyPresent) {
|
||||
const gallery = (ipp.gallery || (ipp.gallery = {})) as Record<string, unknown>
|
||||
for (const [oldKey, newKey] of galleryKeyMigrations) {
|
||||
if (ipp[oldKey] !== undefined && gallery[newKey] === undefined) {
|
||||
gallery[newKey] = ipp[oldKey]
|
||||
}
|
||||
}
|
||||
console.log(
|
||||
'[IPP] Top-level gallery keys (singleImageGallery, singleItemAutoOpen, ' +
|
||||
'showGalleryTitle, showGalleryDescription, groupGalleryByDate) are ' +
|
||||
'deprecated; please move them under `ipp.gallery.*`. See README.'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a configuration option fron config.json using dotted notation.
|
||||
*
|
||||
@@ -22,7 +72,7 @@ try {
|
||||
* @param [defaultOption] - Specify a default option to return if no configuation value is found
|
||||
*
|
||||
* @example
|
||||
* getConfigOption('ipp.singleImageGallery')
|
||||
* getConfigOption('ipp.gallery.singleImage')
|
||||
*/
|
||||
export const getConfigOption = (path: string, defaultOption?: unknown) => {
|
||||
const value = path.split('.').reduce((obj: { [key: string]: unknown }, key) => (obj || {})[key], config)
|
||||
|
||||
+77
-10
@@ -13,9 +13,38 @@ import dayjs from 'dayjs'
|
||||
import { addResponseHeaders, canDownload, getConfigOption, log } from './functions'
|
||||
import render from './render'
|
||||
import { Response } from 'express-serve-static-core'
|
||||
import { h } from 'preact'
|
||||
import { renderPage } from './views/_render'
|
||||
import { Password } from './views/password'
|
||||
import { respondToInvalidRequest } from './invalidRequestHandler'
|
||||
import { encrypt } from './encrypt'
|
||||
|
||||
/*
|
||||
In-process cache for share-link lookups. Each direct-asset request (e.g.
|
||||
`/share/photo/:key/:id/thumbnail`) re-validates the share by calling
|
||||
getShareByKey, which for album shares also pulls the entire album asset
|
||||
list from Immich. Without this cache, a gallery view of N tiles fans out
|
||||
into N concurrent full-album fetches against Immich and serializes there,
|
||||
pushing per-thumbnail latency into seconds. The cache holds Promises
|
||||
(not resolved values) so concurrent cold misses coalesce into one upstream
|
||||
call instead of stampeding.
|
||||
|
||||
CAUTION: a cache hit returns the SAME SharedLinkResult reference across
|
||||
requests. Callers MUST treat the result (and its `link.assets`) as
|
||||
read-only. In-place mutation persists for the cache lifetime and leaks
|
||||
across concurrent requests. Current callers (notably the in-place
|
||||
`share.assets.sort(...)` in render.ts) happen to be idempotent so this is
|
||||
safe today, but new callers should clone before mutating.
|
||||
|
||||
Eviction is LRU: each cache hit moves the entry to the end of the Map's
|
||||
insertion order, and overflow drops the oldest (least-recently-used)
|
||||
entry. TTL handles freshness; size cap handles memory.
|
||||
*/
|
||||
type ShareCacheEntry = { promise: Promise<SharedLinkResult>; expiresAt: number }
|
||||
const shareCache = new Map<string, ShareCacheEntry>()
|
||||
const shareCacheTtlMs = 120_000
|
||||
const shareCacheMax = 100
|
||||
|
||||
class Immich {
|
||||
/**
|
||||
* Make a request to Immich API. We're not using the SDK to limit
|
||||
@@ -90,12 +119,11 @@ class Immich {
|
||||
// Password required - show the visitor the password page
|
||||
if (sharedLinkRes.passwordRequired) {
|
||||
// `request.key` is already sanitised at this point, but it never hurts to be explicit
|
||||
const key = request.key.replace(/[^\w-]/g, '')
|
||||
res.render('password', {
|
||||
key,
|
||||
lgConfig: render.lgConfig,
|
||||
const shareKey = request.key.replace(/[^\w-]/g, '')
|
||||
res.send(renderPage(h(Password, {
|
||||
shareKey,
|
||||
notifyInvalidPassword: !!request.password
|
||||
})
|
||||
})))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -122,13 +150,13 @@ class Immich {
|
||||
// This is an individual item (not a gallery)
|
||||
log('Serving link ' + request.key)
|
||||
const asset = link.assets[0]
|
||||
if (asset.type === AssetType.image && !getConfigOption('ipp.singleImageGallery') && !request.password) {
|
||||
if (asset.type === AssetType.image && !getConfigOption('ipp.gallery.singleImage') && !request.password) {
|
||||
// For photos, output the image directly unless configured to show a gallery,
|
||||
// or unless it's a password-protected link
|
||||
await render.assetBuffer(request, res, link.assets[0], ImageSize.preview)
|
||||
} else {
|
||||
// Show a gallery page
|
||||
const openItem = getConfigOption('ipp.singleItemAutoOpen', true) ? 1 : 0
|
||||
const openItem = getConfigOption('ipp.gallery.singleItemAutoOpen', true) ? 1 : 0
|
||||
await render.gallery(res, link, openItem)
|
||||
}
|
||||
} else {
|
||||
@@ -139,10 +167,49 @@ class Immich {
|
||||
}
|
||||
|
||||
/**
|
||||
* Query Immich for the SharedLink metadata for a given key.
|
||||
* The key is what is returned in the URL when you create a share in Immich.
|
||||
* Query Immich for the SharedLink metadata for a given key, with a short
|
||||
* in-process cache + in-flight de-duplication. See the cache notes at the
|
||||
* top of this file for the why.
|
||||
*
|
||||
* The cache holds the full post-album-population SharedLinkResult, so warm
|
||||
* hits skip both the `/shared-links/me` and `/albums/:id` round trips.
|
||||
* Negative results (`valid: false`) and rejections are dropped from the
|
||||
* cache immediately so a transient Immich blip doesn't poison the cache.
|
||||
*/
|
||||
async getShareByKey (key: string, password?: string, keyType: KeyType = KeyType.key): Promise<SharedLinkResult> {
|
||||
const cacheKey = `${keyType}:${key}:${password ?? ''}`
|
||||
const now = Date.now()
|
||||
const cached = shareCache.get(cacheKey)
|
||||
if (cached && cached.expiresAt > now) {
|
||||
// Move-to-end to mark this entry as most-recently-used for LRU eviction
|
||||
shareCache.delete(cacheKey)
|
||||
shareCache.set(cacheKey, cached)
|
||||
return cached.promise
|
||||
}
|
||||
|
||||
const promise = this.fetchShareByKey(key, password, keyType)
|
||||
shareCache.set(cacheKey, {
|
||||
promise,
|
||||
expiresAt: now + shareCacheTtlMs
|
||||
})
|
||||
if (shareCache.size > shareCacheMax) {
|
||||
const oldest = shareCache.keys().next().value
|
||||
if (oldest !== undefined && oldest !== cacheKey) shareCache.delete(oldest)
|
||||
}
|
||||
promise.then(
|
||||
(result) => { if (!result?.valid) shareCache.delete(cacheKey) },
|
||||
() => { shareCache.delete(cacheKey) }
|
||||
)
|
||||
return promise
|
||||
}
|
||||
|
||||
/**
|
||||
* Underlying fetch for getShareByKey. Always hits Immich; the public
|
||||
* getShareByKey wraps this with the cache. Don't call this directly from
|
||||
* outside the class — going through getShareByKey is what gives us the
|
||||
* coalescing on cold misses.
|
||||
*/
|
||||
private async fetchShareByKey (key: string, password?: string, keyType: KeyType = KeyType.key): Promise<SharedLinkResult> {
|
||||
let link
|
||||
const url = this.buildUrl(this.apiUrl() + '/shared-links/me', {
|
||||
[keyType]: key,
|
||||
@@ -235,7 +302,7 @@ class Immich {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the content-type of a video, for passing back to lightGallery
|
||||
* Get the content-type of a video, for the lightbox <video> element
|
||||
*/
|
||||
async getVideoContentType (asset: Asset) {
|
||||
const data = await this.request(this.buildUrl('/assets/' + encodeURIComponent(asset.id) + '/video/playback', {
|
||||
|
||||
+52
-5
@@ -8,9 +8,12 @@ import render from './render'
|
||||
import dayjs from 'dayjs'
|
||||
import { NextFunction, Request, Response } from 'express-serve-static-core'
|
||||
import { Asset, AssetType, ImageSize, KeyType } from './types'
|
||||
import { addResponseHeaders, getConfigOption, toString } from './functions'
|
||||
import { addResponseHeaders, canDownload, getConfigOption, toString } from './functions'
|
||||
import { decrypt, encrypt } from './encrypt'
|
||||
import { respondToInvalidRequest } from './invalidRequestHandler'
|
||||
import { h } from 'preact'
|
||||
import { renderPage } from './views/_render'
|
||||
import { Home } from './views/home'
|
||||
|
||||
// Extend the Request type with a `password` property
|
||||
declare module 'express-serve-static-core' {
|
||||
@@ -28,10 +31,10 @@ app.use(cookieSession({
|
||||
sameSite: 'strict',
|
||||
secret: crypto.randomBytes(32).toString('base64url')
|
||||
}))
|
||||
// Add the EJS view engine, to render the gallery page
|
||||
app.set('view engine', 'ejs')
|
||||
// For parsing the password unlock form
|
||||
// For parsing the password unlock form and POSTed JSON payloads
|
||||
app.use(express.json())
|
||||
// For parsing the selective-download form POST (form-encoded body)
|
||||
app.use(express.urlencoded({ extended: false, limit: '1mb' }))
|
||||
// Serve static assets from the 'public' folder as /share/static
|
||||
app.use('/share/static', express.static('public', { setHeaders: addResponseHeaders }))
|
||||
// Serve the same assets on /, to allow for /robots.txt and /favicon.ico
|
||||
@@ -110,6 +113,50 @@ app.post('/share/unlock', async (req, res) => {
|
||||
res.send()
|
||||
})
|
||||
|
||||
/*
|
||||
* [ROUTE] Selective download - POST a list of asset IDs, get a zip of just those.
|
||||
* The list arrives as a single "assets" form field containing a JSON array.
|
||||
* Validates each ID against share.assets so the request can't pull anything
|
||||
* outside the share.
|
||||
*/
|
||||
app.post('/:shareType(share|s)/:key/download', decodeCookie, async (req, res) => {
|
||||
const keyType = immich.getKeyTypeFromShare(req.params.shareType)
|
||||
let requestedIds: unknown
|
||||
try {
|
||||
requestedIds = JSON.parse(String(req.body?.assets ?? '[]'))
|
||||
} catch (e) {
|
||||
respondToInvalidRequest(res, 400, 'Malformed assets list')
|
||||
return
|
||||
}
|
||||
if (!Array.isArray(requestedIds) || requestedIds.length === 0) {
|
||||
respondToInvalidRequest(res, 400, 'No assets selected')
|
||||
return
|
||||
}
|
||||
|
||||
const result = await immich.getShareByKey(req.params.key, req.password, keyType)
|
||||
if (!result?.valid || !result.link) {
|
||||
respondToInvalidRequest(res, 404, 'Invalid share link')
|
||||
return
|
||||
}
|
||||
if (result.passwordRequired) {
|
||||
respondToInvalidRequest(res, 401, 'Password required')
|
||||
return
|
||||
}
|
||||
if (!canDownload(result.link)) {
|
||||
respondToInvalidRequest(res, 403, 'Downloads disabled for this share')
|
||||
return
|
||||
}
|
||||
|
||||
const requested = new Set(requestedIds.map(String))
|
||||
const validAssets = result.link.assets.filter(a => requested.has(a.id))
|
||||
if (validAssets.length === 0) {
|
||||
respondToInvalidRequest(res, 400, 'No valid assets in selection')
|
||||
return
|
||||
}
|
||||
|
||||
await render.downloadAssets(res, result.link, validAssets)
|
||||
})
|
||||
|
||||
/*
|
||||
* [ROUTE] Catch accidental POST requests to share URLs (e.g. from browser history
|
||||
* state issues) and force a clean GET redirect.
|
||||
@@ -185,7 +232,7 @@ app.get('/share/:type(photo|video)/:key/:id/:size?', decodeCookie, async (req, r
|
||||
if (getConfigOption('ipp.showHomePage', true)) {
|
||||
app.get(/^\/(|share)\/*$/, (_req, res) => {
|
||||
addResponseHeaders(res)
|
||||
res.render('home')
|
||||
res.send(renderPage(h(Home, {})))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+200
-103
@@ -1,120 +1,124 @@
|
||||
import immich from './immich'
|
||||
import { Response } from 'express-serve-static-core'
|
||||
import { Asset, AssetType, ImageSize, IncomingShareRequest, SharedLink } from './types'
|
||||
import { canDownload, escapeHtml, getConfigOption } from './functions'
|
||||
import { canDownload, escapeHtml, getConfigOption, log, toString } from './functions'
|
||||
import archiver from 'archiver'
|
||||
import { respondToInvalidRequest } from './invalidRequestHandler'
|
||||
import { sanitize } from './includes/sanitize'
|
||||
import { h } from 'preact'
|
||||
import { renderPage } from './views/_render'
|
||||
import { Gallery, GalleryItem, GalleryProps } from './views/gallery'
|
||||
|
||||
class Render {
|
||||
lgConfig
|
||||
|
||||
constructor () {
|
||||
this.lgConfig = getConfigOption('lightGallery', {})
|
||||
}
|
||||
|
||||
/**
|
||||
* Stream data from Immich back to the client
|
||||
* Stream an asset from Immich back to the client.
|
||||
*
|
||||
* Errors from Immich are always reported to the client as 404 — see
|
||||
* invalidRequestHandler. Upstream status codes are never surfaced. Trashed
|
||||
* or locked assets are handled implicitly: Immich's own endpoints refuse
|
||||
* to serve them, and the upstream failure surfaces as a client 404.
|
||||
*/
|
||||
async assetBuffer (req: IncomingShareRequest, res: Response, asset: Asset, size?: ImageSize | string) {
|
||||
// Get meta info regarding the asset
|
||||
const metaRes = await fetch(immich.buildUrl(immich.apiUrl() + '/assets/' + encodeURIComponent(asset.id), {
|
||||
key: asset.key
|
||||
}))
|
||||
const meta = await metaRes.json()
|
||||
|
||||
// Make sure we should display this asset
|
||||
if (meta.isTrashed || meta.visibility === 'locked') {
|
||||
respondToInvalidRequest(res, 404, `Asset ${asset.id} is trashed or locked`)
|
||||
return
|
||||
}
|
||||
|
||||
// Prepare the request
|
||||
const headerList = ['content-type', 'content-length', 'last-modified', 'etag']
|
||||
size = immich.validateImageSize(size)
|
||||
let subpath, sizeQueryParam
|
||||
const fetchHeaders: Record<string, string> = {}
|
||||
let subpath: string
|
||||
let sizeQueryParam: string | undefined
|
||||
let attachment = false
|
||||
|
||||
if (asset.type === AssetType.video) {
|
||||
subpath = '/video/playback'
|
||||
} else if (asset.type === AssetType.image) {
|
||||
// For images, there are three combinations of path + query string, depending on image size
|
||||
if (size === ImageSize.original && getConfigOption('ipp.downloadOriginalPhoto', true)) {
|
||||
subpath = '/original'
|
||||
} else if (size === ImageSize.preview || size === ImageSize.original) {
|
||||
// IPP is configured in config.json to send the preview size instead of the original size
|
||||
subpath = '/thumbnail'
|
||||
sizeQueryParam = 'preview'
|
||||
} else {
|
||||
subpath = '/' + size
|
||||
}
|
||||
}
|
||||
const headers = { range: '' }
|
||||
|
||||
// For videos, request them in 2.5MB chunks rather than the entire video
|
||||
if (asset.type === AssetType.video) {
|
||||
// Stream videos in 2.5 MB chunks rather than the entire file
|
||||
const range = (req.range || '').replace(/bytes=/, '').split('-')
|
||||
const start = parseInt(range[0], 10) || 0
|
||||
const end = parseInt(range[1], 10) || start + 2499999
|
||||
headers.range = `bytes=${start}-${end}`
|
||||
fetchHeaders.range = `bytes=${start}-${end}`
|
||||
headerList.push('cache-control', 'content-range')
|
||||
res.setHeader('accept-ranges', 'bytes')
|
||||
res.status(206) // Partial Content
|
||||
} else {
|
||||
const endpoint = this.resolveImageEndpoint(immich.validateImageSize(size))
|
||||
subpath = endpoint.subpath
|
||||
sizeQueryParam = endpoint.sizeQueryParam
|
||||
attachment = endpoint.attachment
|
||||
}
|
||||
|
||||
// Request data from Immich
|
||||
const url = immich.buildUrl(immich.apiUrl() + '/assets/' + encodeURIComponent(asset.id) + subpath, {
|
||||
[asset.keyType || 'key']: asset.key,
|
||||
size: sizeQueryParam,
|
||||
password: asset.password
|
||||
})
|
||||
const data = await fetch(url, { headers })
|
||||
const data = await fetch(url, { headers: fetchHeaders })
|
||||
|
||||
// Add the filename for downloaded assets
|
||||
if (size === ImageSize.original && asset.originalFileName && getConfigOption('ipp.downloadOriginalPhoto', true)) {
|
||||
res.setHeader('Content-Disposition', `attachment; filename="${this.getFilename(asset)}"`)
|
||||
}
|
||||
|
||||
// Return the response to the client
|
||||
if (data.status >= 200 && data.status < 300) {
|
||||
// Populate the whitelisted response headers
|
||||
headerList.forEach(header => {
|
||||
const value = data.headers.get(header)
|
||||
if (value) res.setHeader(header, value)
|
||||
})
|
||||
// Return the Immich asset binary data
|
||||
await data.body?.pipeTo(
|
||||
new WritableStream({
|
||||
write (chunk) { res.write(chunk) }
|
||||
})
|
||||
)
|
||||
res.end()
|
||||
} else {
|
||||
if (data.status < 200 || data.status >= 300) {
|
||||
let immichMessage = ''
|
||||
try {
|
||||
const json = await data.json()
|
||||
if (json.message) immichMessage = '\nResponse from Immich: ' + json.message
|
||||
} catch (e) { }
|
||||
respondToInvalidRequest(res, 404, 'Failed response from Immich for asset ' + asset.id + ' on this URL:\n' + url + immichMessage)
|
||||
return
|
||||
}
|
||||
|
||||
if (attachment && asset.originalFileName) {
|
||||
res.setHeader('Content-Disposition', `attachment; filename="${this.getFilename(asset)}"`)
|
||||
}
|
||||
headerList.forEach(header => {
|
||||
const value = data.headers.get(header)
|
||||
if (value) res.setHeader(header, value)
|
||||
})
|
||||
await data.body?.pipeTo(
|
||||
new WritableStream({
|
||||
write (chunk) { res.write(chunk) }
|
||||
})
|
||||
)
|
||||
res.end()
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a gallery page for a given SharedLink, using EJS and lightGallery.
|
||||
* Map an ImageSize to the Immich endpoint that serves it.
|
||||
*
|
||||
* Policy: when `ipp.downloadOriginalPhoto` is off, requests for the original
|
||||
* image are silently downgraded to preview — the operator has opted out of
|
||||
* serving full-resolution files. (The original may also be a RAW/HEIC file
|
||||
* the browser can't render.)
|
||||
*/
|
||||
private resolveImageEndpoint (size: ImageSize): { subpath: string; sizeQueryParam?: string; attachment: boolean } {
|
||||
const allowOriginal = getConfigOption('ipp.downloadOriginalPhoto', true)
|
||||
if (size === ImageSize.original && allowOriginal) {
|
||||
return { subpath: '/original', attachment: true }
|
||||
}
|
||||
if (size === ImageSize.thumbnail) {
|
||||
return { subpath: '/thumbnail', attachment: false }
|
||||
}
|
||||
// preview, or original downgraded because downloadOriginalPhoto is off
|
||||
return { subpath: '/thumbnail', sizeQueryParam: 'preview', attachment: false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a gallery page for a given SharedLink.
|
||||
*
|
||||
* @param res - ExpressJS Response
|
||||
* @param share - Immich `shared-link` containing the assets to show in the gallery
|
||||
* @param [openItem] - Immediately open a lightbox to the Nth item when the gallery loads
|
||||
* @param [openItem] - Immediately open the lightbox to the Nth item when the gallery loads
|
||||
*/
|
||||
async gallery (res: Response, share: SharedLink, openItem?: number) {
|
||||
// publicBaseUrl is used for the og:image, which requires a fully qualified URL.
|
||||
// You can specify this in your docker-compose file, or send it dynamically as a `publicBaseUrl` header
|
||||
const publicBaseUrl = process.env.PUBLIC_BASE_URL || res.req.headers.publicBaseUrl || (res.req.protocol + '://' + res.req.headers.host)
|
||||
|
||||
// Use .map to generate an array of promises, then await them all to load in parallel.
|
||||
const items = await Promise.all(share.assets.map(async (asset) => {
|
||||
let video, downloadUrl
|
||||
// Date grouping needs chronological order; sort newest-first when enabled
|
||||
// (overrides any album.order the upstream applied).
|
||||
const groupByDate = !!getConfigOption('ipp.gallery.groupByDate', false)
|
||||
if (groupByDate) {
|
||||
share.assets.sort((a, b) => (b.fileCreatedAt || '').localeCompare(a.fileCreatedAt || ''))
|
||||
}
|
||||
|
||||
// Build structured items in parallel
|
||||
const items: GalleryItem[] = await Promise.all(share.assets.map(async (asset): Promise<GalleryItem> => {
|
||||
let videoData: string | undefined
|
||||
let downloadUrl: string | undefined
|
||||
if (asset.type === AssetType.video) {
|
||||
// Populate the data-video property
|
||||
video = JSON.stringify({
|
||||
videoData = JSON.stringify({
|
||||
source: [
|
||||
{
|
||||
src: immich.videoUrl(share.key, asset.id),
|
||||
@@ -129,42 +133,58 @@ class Render {
|
||||
downloadUrl = immich.videoUrl(share.key, asset.id)
|
||||
}
|
||||
if (getConfigOption('ipp.downloadOriginalPhoto', true)) {
|
||||
// Add a download link for the original-size image, if configured in config.json
|
||||
downloadUrl = immich.photoUrl(share.key, asset.id, ImageSize.original)
|
||||
}
|
||||
|
||||
const thumbnailUrl = immich.photoUrl(share.key, asset.id, ImageSize.thumbnail)
|
||||
const previewUrl = immich.photoUrl(share.key, asset.id, immich.getPreviewImageSize(asset))
|
||||
const description = getConfigOption('ipp.showMetadata.description', false) && typeof asset?.exifInfo?.description === 'string' ? escapeHtml(asset.exifInfo.description) : ''
|
||||
const description = getConfigOption('ipp.showMetadata.description', false) && typeof asset?.exifInfo?.description === 'string'
|
||||
? escapeHtml(asset.exifInfo.description)
|
||||
: ''
|
||||
|
||||
// Create the full HTML element source to pass to the gallery view
|
||||
const itemHtml = [
|
||||
video ? `<a data-video='${video}'` : `<a href="${previewUrl}"`,
|
||||
downloadUrl ? ` data-download-url="${downloadUrl}"` : '',
|
||||
description ? ` data-sub-html='<p>${description}</p>'` : '',
|
||||
` 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>' : '',
|
||||
'</a>'
|
||||
].join('')
|
||||
let width = asset.exifInfo?.exifImageWidth
|
||||
let height = asset.exifInfo?.exifImageHeight
|
||||
const orientation = asset.exifInfo?.orientation
|
||||
if (orientation && ['5', '6', '7', '8'].includes(orientation) && width && height) {
|
||||
[width, height] = [height, width]
|
||||
}
|
||||
|
||||
return {
|
||||
html: itemHtml,
|
||||
id: asset.id,
|
||||
type: asset.type,
|
||||
previewUrl,
|
||||
thumbnailUrl,
|
||||
previewUrl
|
||||
downloadUrl,
|
||||
videoData,
|
||||
description: description || undefined,
|
||||
downloadFilename: this.getFilename(asset),
|
||||
width,
|
||||
height,
|
||||
thumbhash: asset.thumbhash,
|
||||
fileCreatedAt: asset.fileCreatedAt
|
||||
}
|
||||
}))
|
||||
|
||||
res.render('gallery', {
|
||||
const downloadAllowed = canDownload(share)
|
||||
const props: GalleryProps = {
|
||||
items,
|
||||
openItem,
|
||||
title: this.title(share),
|
||||
description: getConfigOption('ipp.showGalleryDescription', false) ? this.description(share) : '',
|
||||
publicBaseUrl,
|
||||
description: getConfigOption('ipp.gallery.showDescription', false) ? this.description(share) : '',
|
||||
publicBaseUrl: toString(publicBaseUrl),
|
||||
path: '/share/' + share.key,
|
||||
showDownload: canDownload(share),
|
||||
showTitle: getConfigOption('ipp.showGalleryTitle', false),
|
||||
lgConfig: getConfigOption('lightGallery', {})
|
||||
})
|
||||
showDownload: downloadAllowed,
|
||||
showTitle: !!getConfigOption('ipp.gallery.showTitle', true),
|
||||
openItem,
|
||||
lightboxConfig: {
|
||||
// Show download button only if downloading is allowed AND configured.
|
||||
showDownload: downloadAllowed && !!getConfigOption('ipp.lightbox.showDownload', true),
|
||||
showArrows: !!getConfigOption('ipp.lightbox.showArrows', true),
|
||||
mobileArrows: !!getConfigOption('ipp.lightbox.mobileArrows', false)
|
||||
},
|
||||
groupByDate
|
||||
}
|
||||
|
||||
res.send(renderPage(h(Gallery, props)))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,33 +202,110 @@ class Render {
|
||||
}
|
||||
|
||||
/**
|
||||
* Download all assets as a zip file
|
||||
* Download all assets in a share as a zip file.
|
||||
*/
|
||||
async downloadAll (res: Response, share: SharedLink) {
|
||||
const downloadOriginalAsset = getConfigOption('ipp.downloadOriginalPhoto', true)
|
||||
await this.downloadAssets(res, share, share.assets)
|
||||
}
|
||||
|
||||
/**
|
||||
* Stream the given assets back as a zip file.
|
||||
*
|
||||
* Assets are fetched from Immich with a bounded concurrency (configurable via
|
||||
* `ipp.downloadFromImmichConcurrencyLimit`, default 8) rather than all at once.
|
||||
* Fetching every asset in parallel overwhelms the Immich server on large albums
|
||||
* and causes the client download to time out before the first bytes are sent.
|
||||
*
|
||||
* Each asset is retried up to 3 times with linear backoff. If any asset still
|
||||
* fails after retries, the in-flight download is aborted mid-stream: the
|
||||
* archive is aborted, the HTTP response socket is destroyed, and the failure
|
||||
* is logged. We do this (rather than silently omitting the asset) because by
|
||||
* the time we know the asset failed we've already sent a 200 response to the
|
||||
* client, so the only way to signal "your zip is incomplete" is to terminate
|
||||
* the response — leaving the user with a visibly broken/truncated download
|
||||
* instead of a zip that's quietly missing files.
|
||||
*/
|
||||
async downloadAssets (res: Response, share: SharedLink, assets: Asset[]) {
|
||||
const concurrency = Math.max(1, getConfigOption('ipp.downloadFromImmichConcurrencyLimit', 8) as number)
|
||||
const endpoint = this.resolveImageEndpoint(ImageSize.original)
|
||||
res.setHeader('Content-Type', 'application/zip')
|
||||
let filename = (sanitize(this.title(share)) || 'photos') + '.zip'
|
||||
filename = encodeURI(filename)
|
||||
res.setHeader('Content-Disposition', `attachment; filename*=UTF-8''${filename}`)
|
||||
const archive = archiver('zip', { zlib: { level: 6 } })
|
||||
archive.pipe(res)
|
||||
await Promise.all(share.assets.map(async (asset) => {
|
||||
const endpoint = downloadOriginalAsset ? 'original' : 'thumbnail'
|
||||
const url = immich.buildUrl(immich.apiUrl() + '/assets/' + encodeURIComponent(asset.id) + '/' + endpoint, {
|
||||
|
||||
let aborted = false
|
||||
let failure: { asset: Asset, url: string, status?: number, error?: unknown } | null = null
|
||||
const fail = (info: { asset: Asset, url: string, status?: number, error?: unknown }) => {
|
||||
if (!aborted) {
|
||||
aborted = true
|
||||
failure = info
|
||||
}
|
||||
}
|
||||
|
||||
const maxAttempts = 3
|
||||
const queue = assets.slice()
|
||||
const worker = async () => {
|
||||
while (queue.length > 0) {
|
||||
if (aborted) return
|
||||
const asset = queue.shift()
|
||||
if (!asset) return
|
||||
const url = immich.buildUrl(immich.apiUrl() + '/assets/' + encodeURIComponent(asset.id) + endpoint.subpath, {
|
||||
key: asset.key,
|
||||
password: asset.password,
|
||||
size: downloadOriginalAsset ? '' : 'preview'
|
||||
size: endpoint.sizeQueryParam
|
||||
})
|
||||
const data = await fetch(url)
|
||||
// Check the response for validity
|
||||
if (!data.ok) {
|
||||
console.warn(`Failed to fetch asset: ${asset.id}`)
|
||||
|
||||
let buffer: Buffer | undefined
|
||||
let lastStatus: number | undefined
|
||||
let lastError: unknown
|
||||
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
||||
if (aborted) return
|
||||
try {
|
||||
const data = await fetch(url, { signal: AbortSignal.timeout(20_000) })
|
||||
if (data.ok) {
|
||||
buffer = Buffer.from(await data.arrayBuffer())
|
||||
break
|
||||
}
|
||||
lastStatus = data.status
|
||||
lastError = undefined
|
||||
} catch (e) {
|
||||
lastError = e
|
||||
lastStatus = undefined
|
||||
}
|
||||
if (attempt < maxAttempts) {
|
||||
const reason = lastStatus !== undefined
|
||||
? `HTTP ${lastStatus}`
|
||||
: (lastError instanceof Error ? lastError.message : String(lastError))
|
||||
log(`Retrying asset ${asset.id} (attempt ${attempt + 1}/${maxAttempts}) after ${reason}`)
|
||||
// Linear backoff between attempts to avoid hammering a struggling server.
|
||||
await new Promise(resolve => setTimeout(resolve, 500 * attempt))
|
||||
}
|
||||
}
|
||||
|
||||
if (!buffer) {
|
||||
fail({ asset, url, status: lastStatus, error: lastError })
|
||||
return
|
||||
}
|
||||
archive.append(Buffer.from(await data.arrayBuffer()), { name: this.getFilename(asset) })
|
||||
}))
|
||||
if (aborted) return
|
||||
archive.append(buffer, { name: this.getFilename(asset) })
|
||||
}
|
||||
}
|
||||
await Promise.all(Array.from({ length: concurrency }, () => worker()))
|
||||
|
||||
if (aborted && failure) {
|
||||
const f = failure as { asset: Asset, url: string, status?: number, error?: unknown }
|
||||
const detail = f.status !== undefined
|
||||
? `HTTP ${f.status}`
|
||||
: (f.error instanceof Error ? f.error.message : String(f.error))
|
||||
log(`Aborting zip download for share ${share.key}: failed to fetch asset ${f.asset.id} from ${f.url} (${detail})`)
|
||||
archive.abort()
|
||||
res.destroy()
|
||||
return
|
||||
}
|
||||
|
||||
await archive.finalize()
|
||||
archive.on('end', () => res.end())
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,6 +12,11 @@ export enum KeyType {
|
||||
|
||||
export interface ExifInfo {
|
||||
description?: string;
|
||||
exifImageWidth?: number;
|
||||
exifImageHeight?: number;
|
||||
// EXIF orientation string ("1".."8") or null. Values 5-8 indicate the image
|
||||
// is rotated 90°/270°, so the displayed aspect ratio swaps width/height.
|
||||
orientation?: string | null;
|
||||
}
|
||||
|
||||
export enum AlbumType {
|
||||
@@ -30,6 +35,8 @@ export interface Asset {
|
||||
type: AssetType;
|
||||
isTrashed: boolean;
|
||||
exifInfo?: ExifInfo;
|
||||
// Base64-encoded thumbhash for tasteful blur placeholders during lazy-load
|
||||
thumbhash?: string;
|
||||
}
|
||||
|
||||
export interface Album {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { renderToString } from 'preact-render-to-string'
|
||||
import { VNode } from 'preact'
|
||||
|
||||
/**
|
||||
* Render a JSX component to a complete HTML response string.
|
||||
* Prepends the doctype so the result is a valid HTML5 document.
|
||||
*/
|
||||
export function renderPage (component: VNode): string {
|
||||
return '<!DOCTYPE html>' + renderToString(component)
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Mirrors Immich's FOUC-prevention pattern: read color-theme from localStorage
|
||||
// (or fall back to OS preference), then add/remove .dark on <html> before paint.
|
||||
// Source: immich-app/immich v2.7.5 web/src/app.html (2026-05-23).
|
||||
const themeScript = `
|
||||
const key = 'color-theme';
|
||||
let theme = localStorage.getItem(key);
|
||||
if (!theme) {
|
||||
theme = { value: 'light', system: true };
|
||||
} else if (theme === 'dark' || theme === 'light') {
|
||||
theme = { value: theme, system: false };
|
||||
localStorage.setItem(key, JSON.stringify(theme));
|
||||
} else {
|
||||
theme = JSON.parse(theme);
|
||||
}
|
||||
let v = theme.value;
|
||||
if (theme.system) {
|
||||
v = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
||||
}
|
||||
if (v === 'dark') document.documentElement.classList.add('dark');
|
||||
else document.documentElement.classList.remove('dark');
|
||||
`
|
||||
|
||||
export function ThemeScript () {
|
||||
return <script dangerouslySetInnerHTML={{ __html: themeScript }}/>
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
import { AssetType } from '../types'
|
||||
import { ThemeScript } from './_theme'
|
||||
|
||||
export interface GalleryItem {
|
||||
id: string
|
||||
type: AssetType
|
||||
previewUrl: string
|
||||
thumbnailUrl: string
|
||||
downloadUrl?: string
|
||||
// pre-stringified JSON describing the video source (used to build a <video>
|
||||
// element for video slides in the PhotoSwipe lightbox)
|
||||
videoData?: string
|
||||
// already-escaped HTML fragment used as a caption in the lightbox
|
||||
description?: string
|
||||
downloadFilename: string
|
||||
// Display dimensions after EXIF orientation correction; needed for the
|
||||
// pre-computed justified-rows layout that virtualization depends on.
|
||||
width?: number
|
||||
height?: number
|
||||
// Base64-encoded thumbhash for an optional blur placeholder behind each tile
|
||||
thumbhash?: string
|
||||
// ISO date string from Immich; used to group tiles by month when enabled.
|
||||
fileCreatedAt?: string
|
||||
}
|
||||
|
||||
export interface LightboxConfig {
|
||||
showArrows: boolean
|
||||
showDownload: boolean
|
||||
mobileArrows: boolean
|
||||
}
|
||||
|
||||
export interface GalleryProps {
|
||||
items: GalleryItem[]
|
||||
title: string
|
||||
description: string
|
||||
publicBaseUrl: string
|
||||
path: string
|
||||
showDownload: boolean
|
||||
showTitle: boolean
|
||||
openItem?: number
|
||||
lightboxConfig: LightboxConfig
|
||||
groupByDate: boolean
|
||||
}
|
||||
|
||||
export function Gallery (props: GalleryProps) {
|
||||
const initJson = JSON.stringify({
|
||||
items: props.items,
|
||||
openItem: props.openItem,
|
||||
lightboxConfig: props.lightboxConfig,
|
||||
groupByDate: props.groupByDate
|
||||
})
|
||||
const firstItem = props.items[0]
|
||||
const ogImageUrl = firstItem ? props.publicBaseUrl + firstItem.previewUrl : ''
|
||||
|
||||
return (
|
||||
<html lang="en">
|
||||
<head>
|
||||
<ThemeScript/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>{props.title}</title>
|
||||
<meta property="og:title" content={props.title}/>
|
||||
<meta name="twitter:title" content={props.title}/>
|
||||
{props.description && <>
|
||||
<meta name="description" content={props.description}/>
|
||||
<meta property="og:description" content={props.description}/>
|
||||
<meta property="twitter:description" content={props.description}/>
|
||||
</>}
|
||||
{firstItem && <>
|
||||
<meta property="og:image" content={ogImageUrl}/>
|
||||
<meta name="twitter:image" content={ogImageUrl}/>
|
||||
<meta name="twitter:card" content="summary_large_image"/>
|
||||
</>}
|
||||
<link rel="icon" href="/share/static/favicon.ico" type="image/x-icon"/>
|
||||
<link type="text/css" rel="stylesheet" href="/share/static/style.css"/>
|
||||
<link type="text/css" rel="stylesheet" href="/share/static/photoswipe/photoswipe.css"/>
|
||||
<link type="text/css" rel="stylesheet" href="/share/static/photoswipe-overrides.css"/>
|
||||
</head>
|
||||
<body>
|
||||
{(props.showTitle || props.showDownload) && (
|
||||
<header id="header">
|
||||
{props.showTitle && (
|
||||
<div class="header-text">
|
||||
<h1>{props.title || 'Gallery'}</h1>
|
||||
<p class="subtitle">
|
||||
{props.items.length}{' '}
|
||||
{props.items.length === 1 ? 'item' : 'items'}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
{props.showDownload && (
|
||||
<a id="download-all" href={props.path + '/download'} title="Download all" aria-label="Download all">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path fill="currentColor" d="M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z"/>
|
||||
</svg>
|
||||
</a>
|
||||
)}
|
||||
</header>
|
||||
)}
|
||||
{props.description && (
|
||||
<p id="album-description">{props.description}</p>
|
||||
)}
|
||||
{/* Container is intentionally empty - web.js's virtualization manager
|
||||
populates it with only the tiles within the viewport buffer. */}
|
||||
<div id="gallery"></div>
|
||||
{props.showDownload && (
|
||||
<div id="select-toolbar" hidden>
|
||||
<button id="select-cancel" class="toolbar-btn" type="button" aria-label="Exit selection mode">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path fill="currentColor" d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"/>
|
||||
</svg>
|
||||
</button>
|
||||
<span id="select-count">0 selected</span>
|
||||
<button id="select-all" class="toolbar-btn-text" type="button">Select all</button>
|
||||
<button id="select-download" class="toolbar-btn" type="button" aria-label="Download selected">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path fill="currentColor" d="M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
{/* Init params for web.js (read at module load). Using a JSON script
|
||||
block avoids the cross-script-type coordination problems that come
|
||||
with mixing classic and module scripts. */}
|
||||
<script
|
||||
type="application/json"
|
||||
id="ipp-init"
|
||||
dangerouslySetInnerHTML={{ __html: initJson }}
|
||||
/>
|
||||
<script type="module" src="/share/static/web.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
export function Home () {
|
||||
return (
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
|
||||
<title></title>
|
||||
<link rel="icon" href="/share/static/favicon.ico" type="image/x-icon"/>
|
||||
<style dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
html, body {
|
||||
margin: 0;
|
||||
height: 100vh;
|
||||
background: #262626;
|
||||
}
|
||||
body {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
img {
|
||||
max-width: 280px;
|
||||
height: 280px;
|
||||
opacity: 0.3;
|
||||
}
|
||||
`
|
||||
}}/>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<a href="https://github.com/alangrainger/immich-public-proxy">
|
||||
<img src="/share/static/images/ipp.svg" alt=""/>
|
||||
</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
interface PasswordProps {
|
||||
shareKey: string
|
||||
notifyInvalidPassword: boolean
|
||||
}
|
||||
|
||||
const submitScript = `
|
||||
async function submitForm (formElement) {
|
||||
const formData = new FormData(formElement)
|
||||
try {
|
||||
const res = await fetch('/share/unlock', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(Object.fromEntries(formData.entries()))
|
||||
})
|
||||
if (res.status === 200) {
|
||||
window.location.reload()
|
||||
}
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
document.getElementById('unlock')
|
||||
.addEventListener('submit', function (e) {
|
||||
e.preventDefault()
|
||||
submitForm(this)
|
||||
})
|
||||
`
|
||||
|
||||
export function Password ({ shareKey, notifyInvalidPassword }: PasswordProps) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
|
||||
<title>Password required</title>
|
||||
<link rel="icon" href="/share/static/favicon.ico" type="image/x-icon"/>
|
||||
<link type="text/css" rel="stylesheet" href="/share/static/pico.min.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<header></header>
|
||||
<main class="container">
|
||||
<div class="grid">
|
||||
<div></div>
|
||||
<div>
|
||||
<form id="unlock" method="post">
|
||||
<input
|
||||
type="password"
|
||||
name="password"
|
||||
placeholder="Password"
|
||||
aria-label="Password"
|
||||
required
|
||||
autoFocus
|
||||
/>
|
||||
{notifyInvalidPassword && <small>Invalid password</small>}
|
||||
<input type="hidden" name="key" value={shareKey}/>
|
||||
<button type="submit">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
|
||||
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
||||
class="lucide lucide-lock-open">
|
||||
<rect width="18" height="11" x="3" y="11" rx="2" ry="2"/>
|
||||
<path d="M7 11V7a5 5 0 0 1 9.9-1"/>
|
||||
</svg>
|
||||
Unlock
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<div></div>
|
||||
</div>
|
||||
</main>
|
||||
<script dangerouslySetInnerHTML={{ __html: submitScript }}/>
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
+5
-2
@@ -19,9 +19,12 @@
|
||||
"ES6",
|
||||
"ES7"
|
||||
],
|
||||
"allowSyntheticDefaultImports": true
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "preact"
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts"
|
||||
"**/*.ts",
|
||||
"**/*.tsx"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<%# Meta tags for link previews (title, optionally description and thumbnail) %>
|
||||
<title><%= title %></title>
|
||||
<meta property="og:title" content="<%= title %>">
|
||||
<meta name="twitter:title" content="<%= title %>">
|
||||
<% if (description) { %>
|
||||
<meta name="description" content="<%= description %>">
|
||||
<meta property="og:description" content="<%= description %>">
|
||||
<meta property="twitter:description" content="<%= description %>">
|
||||
<% } %>
|
||||
<%
|
||||
// Add an og-image using the first image's thumbnail
|
||||
if (items?.[0]?.previewUrl) {
|
||||
%>
|
||||
<meta property="og:image" content="<%- publicBaseUrl %><%- items[0].previewUrl %>">
|
||||
<meta name="twitter:image" content="<%- publicBaseUrl %><%- items[0].previewUrl %>">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<% } %>
|
||||
<link rel="icon" href="/share/static/favicon.ico" type="image/x-icon">
|
||||
<link type="text/css" rel="stylesheet" href="/share/static/style.css"/>
|
||||
<link type="text/css" rel="stylesheet" href="/share/static/lg/lightgallery-bundle.min.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="header">
|
||||
<% if (showTitle) { %>
|
||||
<h1><%= title || 'Gallery' %></h1>
|
||||
<% } %>
|
||||
<%
|
||||
if (showDownload) {
|
||||
%>
|
||||
<div id="download-all">
|
||||
<a href="<%- path %>/download" title="Download all"><img src="/share/static/images/download-all.svg"
|
||||
height="24"
|
||||
width="24" alt="Download all"></a>
|
||||
</div>
|
||||
<% } %>
|
||||
</div>
|
||||
<% if (description) { %>
|
||||
<div id="album-description">
|
||||
<h2><%= description %></h2>
|
||||
</div>
|
||||
<% } %>
|
||||
<div id="lightgallery">
|
||||
<%
|
||||
// Load the first 50 thumbnails, then load more as the user scrolls. See web.js
|
||||
items.slice(0, 50).forEach(item => {
|
||||
%><%- item.html %>
|
||||
<% }) %>
|
||||
</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/lg/lightgallery.min.js"></script>
|
||||
<script src="/share/static/lg/lg-fullscreen.min.js"></script>
|
||||
<script src="/share/static/lg/lg-thumbnail.min.js"></script>
|
||||
<script src="/share/static/lg/lg-video.min.js"></script>
|
||||
<script src="/share/static/lg/lg-zoom.min.js"></script>
|
||||
<script src="/share/static/lg/lg-hash.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
lgallery.init(<%- JSON.stringify({
|
||||
lgConfig,
|
||||
items,
|
||||
openItem
|
||||
}) %>) // initLightGallery imported from web.js
|
||||
<% if (openItem) { %>
|
||||
const openItem = <%- openItem %>
|
||||
const thumbs = document.querySelectorAll('#lightgallery a')
|
||||
if (thumbs.length >= openItem) {
|
||||
thumbs[openItem - 1].click()
|
||||
}
|
||||
<% } %>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,30 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||
<title></title>
|
||||
<link rel="icon" href="/share/static/favicon.ico" type="image/x-icon">
|
||||
<style>
|
||||
html, body {
|
||||
margin: 0;
|
||||
height: 100vh;
|
||||
background: #262626;
|
||||
}
|
||||
body {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
img {
|
||||
max-width: 280px;
|
||||
height: 280px;
|
||||
opacity: 0.3;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<a href="https://github.com/alangrainger/immich-public-proxy"><img src="/share/static/images/ipp.svg" alt=""></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,78 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||
<title>Password required</title>
|
||||
<link rel="icon" href="/share/static/favicon.ico" type="image/x-icon">
|
||||
<link type="text/css" rel="stylesheet" href="/share/static/lg/lightgallery-bundle.min.css"/>
|
||||
<link type="text/css" rel="stylesheet" href="/share/static/pico.min.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<header></header>
|
||||
<main class="container">
|
||||
<div class="grid">
|
||||
<div></div>
|
||||
<div>
|
||||
<form id="unlock" method="post">
|
||||
<input
|
||||
type="password"
|
||||
name="password"
|
||||
placeholder="Password"
|
||||
aria-label="Password"
|
||||
required
|
||||
autofocus
|
||||
/>
|
||||
<% if (notifyInvalidPassword) { %>
|
||||
<small>Invalid password</small>
|
||||
<% } %>
|
||||
<input
|
||||
type="hidden"
|
||||
name="key"
|
||||
value="<%- key %>"
|
||||
/>
|
||||
<button type="submit">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
|
||||
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
||||
class="lucide lucide-lock-open">
|
||||
<rect width="18" height="11" x="3" y="11" rx="2" ry="2"/>
|
||||
<path d="M7 11V7a5 5 0 0 1 9.9-1"/>
|
||||
</svg>
|
||||
Unlock
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<div></div>
|
||||
</div>
|
||||
</main>
|
||||
<script src="/share/static/web.js"></script>
|
||||
<script>
|
||||
async function submitForm (formElement) {
|
||||
const formData = new FormData(formElement)
|
||||
try {
|
||||
// Validate password
|
||||
const res = await fetch('/share/unlock', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(Object.fromEntries(formData.entries()))
|
||||
})
|
||||
if (res.status === 200) {
|
||||
// Valid password - redirect to the gallery
|
||||
window.location.reload()
|
||||
}
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
document.getElementById('unlock')
|
||||
.addEventListener('submit', function (e) {
|
||||
e.preventDefault()
|
||||
submitForm(this)
|
||||
})
|
||||
</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-thumbnail.min.js"></script>
|
||||
<script src="/share/static/lg/lg-video.min.js"></script>
|
||||
<script src="/share/static/lg/lg-zoom.min.js"></script>
|
||||
<script src="/share/static/lg/lg-hash.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 129 KiB After Width: | Height: | Size: 95 KiB |
Reference in New Issue
Block a user