Skip to content

ufal/dspace-angular#184 Interpolate ${...} placeholders on the Terms of Service page - #185

Open
amadulhaxxani wants to merge 1 commit into
clarin-v7from
fix/tos-interpolation-184
Open

amadulhaxxani wants to merge 1 commit into
clarin-v7from
fix/tos-interpolation-184

Conversation

@amadulhaxxani

Copy link
Copy Markdown

Problem description

The static Terms of Service page (/static/terms-of-service) shows ${dspace.name}, ${lr.description.institution}, ${lr.description.location}, ${lr.description.city} and ${lr.description.country} literally instead of values. The old XMLUI substituted these at runtime; the 2023 move to Angular (commit 216209b7f1) copied the HTML without the substitution. Fixes #184.

Analysis

  • New optional config section staticPage.variables (StaticPageConfig), with defaults in default-app-config.ts. A deployment can override single keys in config.yml; the other defaults are kept.
  • New interpolateVariables() in StaticPageComponent, called right after the existing OAI link rewrite. It runs in SSR and in the browser.
    • Values are HTML-escaped (lodash/escape).
    • Uses a function replacer and own-property lookup.
    • A missing, non-string, or empty value leaves ${key} in place and logs one warning.
  • Added staticPage to the publicConfig whitelist in config.server.ts. Without it, assets/config.json had no values for the browser-only path (yarn start:dev, SSR-error fallback).
  • terms-of-service.html is unchanged.
  • Verified: yarn lint --quiet passes; 33 unit tests pass; yarn run build:prod exit 0.

Problems

  • LINDAT values ship as code defaults. Other deployments must override them in config.yml.
  • The frontend dspace.name ("LINDAT/CLARIAH-CZ Repository") is a display name for this page only. It is not synced with the backend dspace.name from REST.
  • The publicConfig whitelist has no unit test. Karma cannot load config.server.ts, because it imports fs. Verified at runtime: the generated config.json contains staticPage.variables.

Copilot review

  • Requested review from Copilot

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused interpolation change includes configuration propagation and relevant tests, with no unresolved review findings.

0 open findings

What changed in this PR

Fixes #184 by resolving configurable placeholders on static pages, including Terms of Service, during server-side and browser rendering.

Changes:

  • Adds configurable placeholder values with LINDAT defaults and deployment overrides.
  • HTML-escapes substitutions and preserves unresolved placeholders with a warning.
  • Adds interpolation and configuration-merge tests.
File Description
src/​config/​static-page-config.interface.ts Defines static-page variable configuration.
src/​config/​default-app-config.ts Supplies default placeholder values.
src/​config/​config.util.spec.ts Tests partial overrides preserving defaults.
src/​config/​config.server.ts Exposes static-page configuration to browsers.
src/​config/​app-config.interface.ts Adds optional static-page configuration.
src/​app/​static-page/​static-page.component.ts Implements escaped placeholder substitution.
src/​app/​static-page/​static-page.component.spec.ts Tests interpolation and edge cases.
config/​config.example.yml Documents configuration and overrides.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Static Terms of Service page renders raw ${...} placeholders to users

2 participants