Move static assets to shared location

This commit is contained in:
Alan Grainger
2026-10-06 09:28:53 +13:00
parent 255260ccb3
commit 9e6c00da35
12 changed files with 104 additions and 82 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

-92
View File
@@ -1,92 +0,0 @@
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.
-4
View File
File diff suppressed because one or more lines are too long
+1 -60
View File
@@ -1,50 +1,10 @@
/*
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;
}
/* Theme tokens, the Inter font and the page base come from @ipp/core's theme.css */
: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;
}
@media (max-width: 640px) {
@@ -53,25 +13,6 @@
}
}
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 {
+11 -9
View File
@@ -10,6 +10,7 @@ import {
Asset,
AssetType,
asyncHandler,
CORE_PUBLIC_DIR,
decodeCookie,
enforceMinimumImmichVersion,
errorHandler,
@@ -65,17 +66,18 @@ app.use(sessionMiddleware({ name: 'session' }))
app.use(express.json())
// For parsing the selective-download form POST (form-encoded body)
app.use(express.urlencoded({ extended: false, limit: '1mb' }))
/** Serve IPP's own `public` folder, then core's, at `path`. */
function serveStatic (path: string, options: Parameters<typeof express.static>[1] = {}) {
for (const dir of ['public', CORE_PUBLIC_DIR]) {
app.use(path, express.static(dir, { ...options, setHeaders: addResponseHeaders }))
}
}
// Cache-busted, immutable static assets under a per-release version segment.
const inProduction = process.env.NODE_ENV === 'production'
app.use('/share/static/' + ASSET_VERSION, express.static('public', {
immutable: inProduction,
maxAge: inProduction ? '365d' : 0,
setHeaders: addResponseHeaders
}))
// 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
app.use(express.static('public', { setHeaders: addResponseHeaders }))
serveStatic('/share/static/' + ASSET_VERSION, { immutable: inProduction, maxAge: inProduction ? '365d' : 0 })
serveStatic('/share/static')
// The same assets on /, to allow for /robots.txt and /favicon.ico
serveStatic('/')
// Remove the X-Powered-By ExpressJS header
app.disable('x-powered-by')
+5 -11
View File
@@ -1,4 +1,4 @@
import { Asset, log, readableFromWeb, respondToInvalidRequest, SharedLink } from '@ipp/core'
import { abortOnClose, Asset, log, readableFromWeb, respondToInvalidRequest, SharedLink } from '@ipp/core'
import {
assetFetchUrl,
authHeadersForAsset,
@@ -20,14 +20,8 @@ import { pipeline } from 'stream/promises'
* to serve them, and the upstream failure surfaces as a client 404.
*/
export async function assetBuffer (req: IncomingShareRequest, res: Response, asset: Asset, size?: ImageSize | string, share?: SharedLink, forceVideoPlayback = false) {
/*
Abort the upstream fetch as soon as the visitor goes away, so a cancelled
download doesn't leave Immich streaming #288.
*/
const upstream = new AbortController()
const onClose = () => { if (!res.writableFinished) upstream.abort() }
res.once('close', onClose)
if (res.closed) onClose()
// A cancelled download must not leave Immich streaming #288
const upstream = abortOnClose(res)
const headerList = ['content-type', 'content-length', 'last-modified', 'etag']
const fetchHeaders: Record<string, string> = {}
@@ -78,9 +72,9 @@ export async function assetBuffer (req: IncomingShareRequest, res: Response, ass
const reqHeaders = await authHeadersForAsset(asset)
let data: globalThis.Response
try {
data = await fetch(url, { headers: { ...fetchHeaders, ...reqHeaders }, signal: upstream.signal })
data = await fetch(url, { headers: { ...fetchHeaders, ...reqHeaders }, signal: upstream })
} catch (e) {
if (upstream.signal.aborted) return // visitor left before Immich answered
if (upstream.aborted) return // visitor left before Immich answered
throw e
}
+1
View File
@@ -63,6 +63,7 @@ export function Gallery (props: GalleryProps) {
<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/${ASSET_VERSION}/theme.css`}/>
<link type="text/css" rel="stylesheet" href={`/share/static/${ASSET_VERSION}/style.css`}/>
<link type="text/css" rel="stylesheet" href="/share/static/photoswipe/photoswipe.css"/>
<link type="text/css" rel="stylesheet" href={`/share/static/${ASSET_VERSION}/photoswipe-overrides.css`}/>