Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
de2e1ed
Migrate resource viewer to ogm-viewer
ewlarson Aug 21, 2026
9d504b4
Upgrade OGM Viewer to 1.6.0 with OpenFreeMap basemaps
ewlarson Oct 28, 2026
e989002
Migrate geographic maps and static rendering to MapLibre
ewlarson Oct 28, 2026
08991cc
Align MCP viewer HTML with pinned OpenFreeMap viewer
ewlarson Oct 28, 2026
91d0ac7
Fix homepage initial camera and user movement detection
ewlarson Oct 28, 2026
c386a50
Match production homepage hero map offset
ewlarson Oct 28, 2026
fffd363
Fix basemap menu hover and offer all five OpenFreeMap styles
ewlarson Oct 28, 2026
034ead8
Fix test isolation and frontend quality checks
ewlarson Oct 28, 2026
d7b4dfb
Stabilize CI dependencies and analytics accessibility audits
ewlarson Oct 28, 2026
ea62403
Isolate Redis pools and exhaustive analytics audits
ewlarson Oct 28, 2026
ee8ac2f
Isolate Redis edge cases and trim unused accessibility diagnostics
ewlarson Oct 28, 2026
6f58853
Budget full-report WCAG audits for shared CI CPUs
ewlarson Oct 28, 2026
3e0d71b
Avoid repeated full-table role queries in month switching test
ewlarson Oct 28, 2026
fecd29c
Keep homepage hex layers stable during featured carousel animations
ewlarson Oct 28, 2026
ece750f
Restore toggled map layers after initial MapLibre load
ewlarson Oct 28, 2026
7a94799
Render featured highlights above density hexes with production point …
ewlarson Oct 29, 2026
f78ba47
Preserve density hexes through zoom refreshes and transient API failures
ewlarson Oct 29, 2026
5eddac0
Match production zoom control symbol size and weight
ewlarson Oct 29, 2026
439f2ea
Start search map attribution collapsed behind the native info control
ewlarson Oct 29, 2026
455b7b0
Collapse initial attribution on resource Location maps
ewlarson Oct 29, 2026
0a0ef3d
Serve MapLibre module workers with JavaScript MIME type
ewlarson Oct 29, 2026
38a4d97
Add IIIF manifest downloads with per-canvas options
ewlarson Oct 29, 2026
cb1e589
Sync IIIF downloads with the active OGM Viewer image
ewlarson Oct 29, 2026
f003061
Restore two-way IIIF page selection in Downloads
ewlarson Oct 29, 2026
9683ac6
Simplify synchronized Downloads copy
ewlarson Oct 29, 2026
6c57be0
Match Downloads label styling to citation labels
ewlarson Oct 29, 2026
59b369e
Prefer IIIF manifests and recover from failed image previews
ewlarson Oct 29, 2026
ea7cabd
Hide standalone image tabs when a manifest opens
ewlarson Oct 29, 2026
01db775
Omit duplicate Location previews and skip viewers without content
ewlarson Oct 29, 2026
6321c9f
Render a single primary canvas without flashing preview tabs
ewlarson Oct 29, 2026
972c1e2
Remove the repeated viewer title and menu row on resource pages
ewlarson Oct 29, 2026
17503bd
Include pinned OGM viewer backport in the application image
ewlarson Oct 29, 2026
e9f1885
Include WMS reference in legacy resource viewer fixture
ewlarson Oct 29, 2026
5fa107c
Use OGM Viewer for standalone previews and active image downloads
ewlarson Oct 29, 2026
d488c00
Restore peer dependency entries for standard npm ci
ewlarson Oct 29, 2026
120c44a
Adopt the source-built OGM Viewer fork and add browser contract tests
ewlarson Oct 29, 2026
87313f0
Upgrade OGM Viewer fork to 1.6.0-btaa.2 for resource bounds
ewlarson Oct 29, 2026
a35c302
Fill the fullscreen viewer frame with map and image canvases
ewlarson Oct 29, 2026
c07971b
Upgrade OGM Viewer fork to upstream 1.7.0
ewlarson Oct 29, 2026
b725aff
Align application MapLibre controls on the right
ewlarson Oct 30, 2026
eb27315
Frame resource viewers from data extents when record bounds are global
ewlarson Oct 30, 2026
e2c15cc
Use viewer-native bounds for data-informed framing
ewlarson Oct 30, 2026
fae9d70
Reconcile viewer dependencies and browser checks after develop rebase
ewlarson Nov 12, 2026
36832a3
Pin viewer browser CI to a supported Ubuntu runner
ewlarson Nov 12, 2026
c750c01
Use encoded UW–Madison IIIF URLs for viewer tiles and downloads
ewlarson Nov 24, 2026
ef8c152
Move embedded viewer preview tabs into the resource header
ewlarson Nov 24, 2026
5ea9a1d
Default Geoportal maps and thumbnails to OpenFreeMap Positron
ewlarson Nov 24, 2026
0d68bed
Keep shared map controls in the same order across Geoportal maps and …
ewlarson Nov 24, 2026
48d9fe9
Serve viewer JavaScript independently of the data request quota
ewlarson Nov 24, 2026
dc5eacb
Pin OGM Viewer with independent PMTiles archive tabs
ewlarson Nov 24, 2026
23c31ad
Reconcile viewer and map changes with current develop
ewlarson Nov 24, 2026
108bb77
Format map geosearch regression test for combined CI
ewlarson Nov 24, 2026
22cde7a
Resolve viewer review findings in IIIF downloads and native map rende…
ewlarson Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,7 @@ frontend/dist/

# --- Optional: keep small in-repo samples available to builds ---
#!samples/**

**/.viewer-browser-build/
**/test-results/
**/playwright-report/
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,8 @@ ANALYTICS_PASSWORD=

# Catalog relevance: v2 requires a completed source reindex; legacy is the default.
SEARCH_RELEVANCE_VERSION=legacy

# Local private MapLibre Native renderer (no public port required).
STATIC_MAP_RENDERER_URL=http://map_renderer:8080
STATIC_MAP_RENDER_REVISION=openfreemap-positron-native-v1
STATIC_MAP_STYLE_URL=https://tiles.openfreemap.org/styles/positron
38 changes: 34 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,17 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: "3.12"
cache: pip
cache-dependency-path: |
backend/pyproject.toml
backend/uv.lock

- name: Install backend dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e "backend[dev]"
python -m pip install uv
uv sync --project backend --locked --extra dev --python 3.12
echo "$GITHUB_WORKSPACE/backend/.venv/bin" >> "$GITHUB_PATH"

- name: Prepare backend test database
working-directory: backend
Expand Down Expand Up @@ -166,7 +167,7 @@ jobs:
run: |
python scripts/run_with_timeout.py \
python -X faulthandler -m pytest \
-n 2 \
-n 2 --dist=loadgroup \
-m "not network" \
--cov=app \
--cov-report=term-missing \
Expand Down Expand Up @@ -209,12 +210,41 @@ jobs:
- name: Install frontend dependencies
run: npm ci

- name: Check frontend lint and formatting
run: |
npm run lint
npm run format:check

- name: Run frontend tests
run: npm test -- --run

- name: Build frontend
run: npm run build

viewer-browser:
name: Viewer browser contracts
# Keep the runner compatible with the pinned Playwright browser binaries.
runs-on: ubuntu-24.04
timeout-minutes: 15
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm
cache-dependency-path: frontend/package-lock.json
- run: npm ci
- run: npx playwright install --with-deps chromium
- run: npm run test:viewer:browser
- uses: actions/upload-artifact@v4
if: failure()
with:
name: viewer-browser-failures
path: frontend/test-results/

cli:
name: CLI
runs-on: ubuntu-latest
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ ENV PATH="/root/.local/bin:$PATH"
# Copy backend pyproject.toml and uv.lock first to leverage Docker cache
COPY backend/pyproject.toml backend/uv.lock ./

## Frontend assets are served by the dedicated `frontend` container.
## The API container no longer bundles or serves frontend static files.
# API-only images also serve the browser module used by the standalone viewer.
COPY frontend/package-lock.json /tmp/frontend-package-lock.json
COPY backend/scripts/install_viewer_assets.py /tmp/install_viewer_assets.py
RUN python /tmp/install_viewer_assets.py /tmp/frontend-package-lock.json /opt/ogm-viewer

# Ensure operational scripts are present in the runtime image (for kamal exec)
COPY backend/scripts ./scripts
Expand Down
6 changes: 2 additions & 4 deletions Dockerfile.kamal
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins
g++ \
&& rm -rf /var/lib/apt/lists/*
COPY frontend/package.json frontend/package-lock.json* ./
# Remove lockfile first to avoid npm optional deps edge-cases (mirrors frontend/Dockerfile).
RUN rm -f package-lock.json 2>/dev/null || true

FROM frontend_npm_base AS frontend_deps
RUN npm install --legacy-peer-deps
RUN npm ci --legacy-peer-deps

FROM frontend_npm_base AS frontend_prod_deps
RUN npm install --omit=dev --legacy-peer-deps
RUN npm ci --omit=dev --legacy-peer-deps

FROM node:22-bookworm-slim AS frontend_builder
WORKDIR /frontend
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1958,3 +1958,10 @@ analytics-evidence-check: ## Reproduce and verify evidence packets without chang
SEARCH_RELEVANCE_TEST_URL ?= http://localhost:19283
test-search-relevance: ## Run isolated Elasticsearch 9 relevance contracts and unit tests
cd backend && SEARCH_RELEVANCE_TEST_URL="$(SEARCH_RELEVANCE_TEST_URL)" BTAA_SKIP_TEST_DB=1 ENDPOINT_CACHE=false REDIS_DB=15 python -m pytest tests/elasticsearch/test_relevance.py tests/elasticsearch/test_relevance_integration.py tests/elasticsearch/test_relevance_postgres.py tests/scripts/test_reindex_relevance.py tests/services/test_bridge_search_index.py -q

.PHONY: native-map-test native-map-start
native-map-start: ## Build and start the local MapLibre Native renderer
docker compose up -d --build map_renderer

native-map-test: ## Run renderer camera tests in its compatible Linux image
docker compose exec -T map_renderer npm test
4 changes: 4 additions & 0 deletions backend/app/api/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,15 @@ class DownloadOption(PublicAPIModel):
generated: bool | None = None
download_type: str | None = None
generation_path: str | None = None
source: str | None = None
canvas_id: str | None = None
canvas_label: str | None = None


class ResourceDownloadsResponse(PublicAPIModel):
id: str
downloads: list[DownloadOption] = Field(default_factory=list)
iiif_error: bool = False


class GeneratedDownloadResponse(PublicAPIModel):
Expand Down
14 changes: 14 additions & 0 deletions backend/app/api/v1/endpoint_modules/resources/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,23 @@ async def get_resource_downloads(
download_service = DownloadService(resource_dict, distribution_context=distribution_context)
downloads = await download_service.get_download_options_with_bridge_asset_downloads()

iiif_error = False
try:
iiif_downloads = await download_service.resolve_iiif_downloads()
if iiif_downloads:
# Replace provisional image links, retaining all non-IIIF downloads.
downloads = [d for d in downloads if d.get("source") != "iiif"]
existing_urls = {d["url"] for d in downloads}
downloads.extend(
d for d in iiif_downloads if d.get("canvas_id") or d["url"] not in existing_urls
)
except ValueError:
iiif_error = True

response_payload = {
"id": id,
"downloads": downloads,
"iiif_error": iiif_error,
}

return create_response(response_payload, callback)
Expand Down
43 changes: 2 additions & 41 deletions backend/app/api/v1/endpoint_modules/resources/ogm_viewer.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import html
import os
from urllib.parse import quote

from fastapi import HTTPException, Query
from fastapi.responses import HTMLResponse
from sqlalchemy.sql import select

from app.services.viewer_html import resource_viewer_html
from db.models import resources

from . import get_async_session, logger, router
Expand All @@ -27,46 +26,8 @@ async def get_resource_viewer(
if not row:
raise HTTPException(status_code=404, detail="Resource not found")

# Build the record URL for the viewer
base_url = os.getenv("APPLICATION_URL", "http://localhost:8000")
record_url = f"{base_url}/api/v1/resources/{quote(id, safe='')}/metadata/ogm"
escaped_record_url = html.escape(record_url, quote=True)
escaped_id = html.escape(id)

# Create the HTML content
html_content = f"""
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OGM Viewer - Resource {escaped_id}</title>
<style>
body {{
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}}
.viewer-container {{
width: 100vw;
height: 100vh;
}}
{".viewer-container { height: 600px; }" if embed else ""}
</style>
</head>
<body>
<div class="viewer-container">
<ogm-viewer
record-url="{escaped_record_url}"
>
</ogm-viewer>
</div>

<!-- Load the OGM Viewer web component -->
<script type="module" src="https://unpkg.com/ogm-viewer"></script>
</body>
</html>
"""
html_content = resource_viewer_html(base_url, id, embed)

# Create response with iframe-friendly headers
response = HTMLResponse(content=html_content)
Expand Down
8 changes: 4 additions & 4 deletions backend/app/api/v1/endpoint_modules/static_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import os

from fastapi import APIRouter, HTTPException, Request
from fastapi import APIRouter, HTTPException, Query, Request
from fastapi.responses import Response
from PIL import Image
from sqlalchemy.sql import select
Expand Down Expand Up @@ -207,9 +207,9 @@ async def _get_or_generate_map_data(
async def get_institution_static_map(
map_id: str,
request: Request,
lat: float,
lon: float,
zoom: int = 15,
lat: float = Query(..., ge=-85.05112878, le=85.05112878, allow_inf_nan=False),
lon: float = Query(..., ge=-180, le=180, allow_inf_nan=False),
zoom: int = Query(15, ge=1, le=20),
):
"""Serve or generate a cached campus-centered static basemap image."""
cache_id = f"institution:{map_id}"
Expand Down
11 changes: 11 additions & 0 deletions backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import sys
from contextlib import asynccontextmanager
from pathlib import Path

try:
import appsignal
Expand Down Expand Up @@ -319,6 +320,16 @@ async def private_analytics_responses(request: Request, call_next):
return response


# The combined image and local frontend share the npm installation. API-only
# images keep the same locked browser distribution outside the source mount.
viewer_assets = Path("/opt/ogm-viewer")
if not viewer_assets.is_dir():
viewer_assets = (
Path(__file__).resolve().parents[2] / "frontend/node_modules/ogm-viewer/dist/components"
)
if viewer_assets.is_dir():
app.mount("/api/v1/viewer-assets", StaticFiles(directory=viewer_assets), name="viewer-assets")

app.include_router(public_router, prefix="/api/v1")
app.include_router(ogc_router, prefix="/api/v1/ogc")

Expand Down
6 changes: 6 additions & 0 deletions backend/app/middleware/rate_limit_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def _bypass_rate_limit_for_tests() -> bool:
r"^/api/v1/static-map-assets/[0-9a-f]{64}$",
re.IGNORECASE,
)
VIEWER_MODULE_PATH_RE = re.compile(r"/api/v1/viewer-assets/[a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+)*\.js")
DOCUMENTATION_PATHS = {
"/api/docs",
"/api/docs/oauth2-redirect",
Expand Down Expand Up @@ -71,6 +72,11 @@ def __init__(self, app):
async def dispatch(self, request: Request, call_next):
"""Process request, optionally enforce rate limiting, and log usage."""

# Loading the static ES module graph is a single viewer bootstrap. Its
# metadata and data requests still use the normal API quota.
if request.method in {"GET", "HEAD"} and VIEWER_MODULE_PATH_RE.fullmatch(request.url.path):
return await call_next(request)

# Skip rate limiting when test bypass flag is set, unless explicitly forced
if _bypass_rate_limit_for_tests() and not request.headers.get("X-Force-RateLimit"):
logger.debug("Rate limiting bypassed for tests (DISABLE_RATE_LIMIT_FOR_TESTS=true)")
Expand Down
74 changes: 46 additions & 28 deletions backend/app/services/download_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,34 +118,9 @@ def get_download_options(self) -> List[Dict]:
if not self.image_api_endpoint:
return []

# Remove /info.json from endpoint if present
base_url = self.image_api_endpoint.replace("/info.json", "")
from app.services.iiif_downloads import image_downloads

downloads = []

# Add standard size options
for size_name, dimensions in self.SIZES.items():
downloads.append(
{
"label": f"{size_name.title()} Image",
"url": (
f"{base_url}/full/{dimensions['width']},"
f"{dimensions['height']}/0/default.jpg"
),
"type": "image/jpeg",
}
)

# Add full size option
downloads.append(
{
"label": "Full Resolution Image",
"url": f"{base_url}/full/full/0/default.jpg",
"type": "image/jpeg",
}
)

return downloads
return image_downloads(self.image_api_endpoint)


class DownloadService:
Expand Down Expand Up @@ -359,7 +334,7 @@ def get_download_options(self) -> List[Dict]:
downloads = []

# Check for IIIF image API
iiif_image_url = self._first_url("http://iiif.io/api/image")
iiif_image_url = self._iiif_url("image")
if iiif_image_url:
iiif_service = IIIFDownloadService(iiif_image_url)
downloads.extend(iiif_service.get_download_options())
Expand All @@ -370,6 +345,49 @@ def get_download_options(self) -> List[Dict]:

return downloads

def _iiif_url(self, kind: str) -> Optional[str]:
return self._first_url(f"http://iiif.io/api/{kind}") or self._first_url(
f"https://iiif.io/api/{kind}"
)

async def resolve_iiif_downloads(self) -> List[Dict]:
"""Resolve remote IIIF only on the downloads endpoint, outside hot resource/search paths."""
from urllib.parse import urlsplit, urlunsplit

from app.services.iiif_downloads import (
http_url,
image_downloads,
manifest_downloads,
service_base,
)
from app.services.image_service import ImageService

manifest_url = self._iiif_url("presentation#manifest")
image_url = self._iiif_url("image")
if not manifest_url and not image_url:
return []
image_service = ImageService(self.document, distribution_context=self.distribution_context)
downloads = []
resolved = False
if http_url(manifest_url):
manifest = await asyncio.to_thread(image_service._get_manifest, manifest_url)
if isinstance(manifest, dict):
resolved = True
downloads.extend(manifest_downloads(manifest, manifest_url))
if http_url(image_url):
base = urlsplit(service_base(image_url))
info_url = urlunsplit(base._replace(path=f"{base.path}/info.json"))
info = await asyncio.to_thread(image_service._get_manifest, info_url)
if isinstance(info, dict):
resolved = True
downloads.extend(
{**item, "iiif_resource_url": image_url}
for item in image_downloads(image_url, info)
)
if resolved:
return downloads
raise ValueError("IIIF downloads are currently unavailable")

def get_generated_download_options(self) -> List[Dict]:
"""
Return generated download links that mirror GeoBlacklight behavior.
Expand Down
Loading
Loading