Skip to content

Commit 61062ed

Browse files
committed
feat: allow build-time metadata config for web library
1 parent 190d88b commit 61062ed

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

.env.stage.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ WEB_LIBRARY_PORT=8281
1313

1414
# Base URL that the Web Library should use when linking to the PDF proxy (update to your staging hostname/IP)
1515
PDF_PROXY_BASE_URL=http://nas.local:8280/pdf
16+
17+
# Optional: metadata source (used at build time for the Web Library image)
18+
ZOTERO_API_KEY=
19+
ZOTERO_API_AUTHORITY_PART=api.zotero.org
20+
ZOTERO_USER_SLUG=
21+
ZOTERO_USER_ID=

Dockerfile.web-library

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ COPY app/web-library-upstream/ /app/web-library-upstream/
1010
COPY app/web-library-overlay/ /app/web-library-overlay/
1111

1212
# Apply overlay into a build directory
13-
RUN mkdir -p /app/web-library-build \
13+
RUN apt-get update \
14+
&& apt-get install -y --no-install-recommends rsync gettext-base \
15+
&& rm -rf /var/lib/apt/lists/* \
16+
&& mkdir -p /app/web-library-build \
1417
&& rsync -a /app/web-library-upstream/ /app/web-library-build/ \
1518
&& if [ -d /app/web-library-overlay/src ]; then rsync -a /app/web-library-overlay/src/ /app/web-library-build/src/; fi \
1619
&& if [ -d /app/web-library-overlay/config ]; then rsync -a /app/web-library-overlay/config/ /app/web-library-build/config/; fi
@@ -24,6 +27,20 @@ RUN git clone --depth 1 --recurse-submodules --shallow-submodules https://github
2427
&& git clone --depth 1 --recurse-submodules --shallow-submodules https://github.com/zotero/web-common.git modules/web-common \
2528
&& git clone --depth 1 --recurse-submodules --shallow-submodules https://github.com/zotero/zotero-schema.git modules/zotero-schema
2629

30+
# Inject build-time metadata config for overlay (api key/authority, user slug/id, pdf proxy base)
31+
ARG ZOTERO_API_KEY=""
32+
ARG ZOTERO_API_AUTHORITY_PART="api.zotero.org"
33+
ARG ZOTERO_USER_SLUG=""
34+
ARG ZOTERO_USER_ID="0"
35+
ARG PDF_PROXY_BASE_URL="http://localhost:8280/pdf"
36+
ENV ZOTERO_API_KEY=$ZOTERO_API_KEY \
37+
ZOTERO_API_AUTHORITY_PART=$ZOTERO_API_AUTHORITY_PART \
38+
ZOTERO_USER_SLUG=$ZOTERO_USER_SLUG \
39+
ZOTERO_USER_ID=$ZOTERO_USER_ID \
40+
PDF_PROXY_BASE_URL=$PDF_PROXY_BASE_URL
41+
42+
RUN envsubst < /app/web-library-overlay/src/html/index.html > /app/web-library-build/src/html/index.html
43+
2744
# Build Web Library (combined subtree + overlay)
2845
RUN npm ci \
2946
&& npm run build

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ The sample data generator creates keys like `SAMPLE1` and `SAMPLE2` under `sampl
180180
- `.env.stage.example``.env.stage`: staging/NAS stack via `docker compose --env-file .env.stage up -d` (defaults to GHCR `:main` tags).
181181
- `.env.portainer.example``.env.portainer`: Portainer stack env file (same vars as staging) when deploying through the UI.
182182
- `.env` remains ignored; keep real secrets/paths out of the repo.
183+
- Metadata config (build-time for Web Library): optional `ZOTERO_API_KEY`, `ZOTERO_API_AUTHORITY_PART`, `ZOTERO_USER_SLUG`, `ZOTERO_USER_ID` to point the Web Library at zotero.org or an on-prem metadata source. Set in your env file before building the Web Library image.
183184

184185
---
185186

app/web-library-overlay/src/html/index.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@
1515
<div id="zotero-web-library"></div>
1616
<script type="application/json" id="zotero-web-library-config">
1717
{
18-
"userSlug": "zotero-user",
19-
"userId": "475425",
20-
"pdfProxyBaseUrl": "http://localhost:8280/pdf",
18+
"userSlug": "$ZOTERO_USER_SLUG",
19+
"userId": "$ZOTERO_USER_ID",
20+
"apiKey": "$ZOTERO_API_KEY",
21+
"apiConfig": {
22+
"apiAuthorityPart": "$ZOTERO_API_AUTHORITY_PART"
23+
},
24+
"pdfProxyBaseUrl": "$PDF_PROXY_BASE_URL",
2125
"libraries": {
2226
"include": [
2327
{

0 commit comments

Comments
 (0)