Skip to content

Fold ohm-inspector into ohm-website (issue #1058)#402

Closed
jeffreyameyer wants to merge 1 commit into
stagingfrom
1058-Inspector-deployment-as-NPM
Closed

Fold ohm-inspector into ohm-website (issue #1058)#402
jeffreyameyer wants to merge 1 commit into
stagingfrom
1058-Inspector-deployment-as-NPM

Conversation

@jeffreyameyer
Copy link
Copy Markdown
Member

Summary

Closes the request in openhistoricalmap/issues#1058 by replacing the GitHub-Pages-hosted ohm-inspector bundle with an in-tree implementation.

The feature inspector panel is now rendered server-side as a Rails partial, with client-side JS only for SimpleLightbox initialization, Wikipedia excerpt fetching, and (future) Wikidata lookup. SimpleLightbox is consumed from npm rather than vendored.

⚠️ Needs much more testing

This PR has only been verified via the new automated tests; it has not been exercised end-to-end in a running dev environment yet (local Docker setup hit several environmental issues during this work). Before merging, please:

  • Bring up locally per DEVELOPMENT.md and verify /node/<id>, /way/<id>, /relation/<id> pages render the new panel for features that have any of image:N, start_date/end_date, wikipedia, wikidata, more_info:N tags.
  • Confirm SimpleLightbox JS + CSS load (no 404s in DevTools Network tab; clicking a slideshow image opens the lightbox).
  • Confirm asset compilation succeeds in CI; the lockfile may need an npm install commit if asset compile fails on simplelightbox.
  • Test on features that previously rendered well in the CDN inspector to make sure nothing regressed.

What's included

New files (OHM-only, no upstream merge risk):

  • app/views/browse/_ohm_details.html.erb — server-side panel: image slideshow, date range, Wikipedia/Wikidata excerpt placeholder, more-info links. All strings localized via t(\".key\").
  • app/assets/javascripts/index/ohm_inspector.jsaddOpenHistoricalMapInspector(map): SimpleLightbox init, slideshow nav, Wikipedia excerpt fetch, Wikidata→Wikipedia fallback.
  • app/helpers/ohm_inspector_helper.rbohm_inspector_wikipedia_url and ohm_inspector_date_range.
  • app/assets/stylesheets/_ohm_inspector.scss — panel styles.
  • app/assets/stylesheets/ohm-inspector-all.scss — Sprockets manifest pulling in SimpleLightbox CSS from npm.
  • app/assets/images/ohm-inspector-chevron-{left,right}.svg — slideshow nav icons.
  • test/helpers/ohm_inspector_helper_test.rb — 15 unit tests.
  • test/controllers/ohm_inspector_test.rb — 15 integration tests.

Upstream files touched (kept minimal for merge maintainability):

  • app/views/layouts/_head.html.erb — removed two CDN tags, added one stylesheet_link_tag.
  • app/views/elements/show.html.erb — added one render call.
  • app/assets/javascripts/index.js — added two //= require lines.
  • app/assets/javascripts/index/element.js — replaced inline addOpenHistoricalMapInspector body with a call to the new global function.
  • app/assets/stylesheets/common.scss — added @import \"ohm_inspector\".
  • config/locales/en.yml — added browse.ohm_details.* and javascripts.ohm_inspector.* keys.
  • package.json — added simplelightbox ^2.1.0.

Bugs fixed in passing

  • openhistoricalmap/issues#859 — non-English Wikipedia articles. The new helper detects lang:Title prefix correctly instead of always using en.
  • openhistoricalmap/issues#7471000001 BCE and 1000000 CE were treated as null dates. The new server-side path uses the existing DateRange class which has no such special-casing.
  • openhistoricalmap/issues#584 — partial: when a feature has wikidata but no wikipedia tag, the JS now looks up the Wikipedia article via the Wikidata API.

Intentionally not ported

  • followed_by:name / followed_by tag display — per openhistoricalmap/issues#748, this was practically unused (zero followed_by URLs in the wild) and should be replaced with chronology-relation lookup instead. Stub for that future feature is left in ohm_inspector.js.
  • Feature name and bottom Wikipedia/Wikidata/LoC links — redundant with the existing sidebar <h2> title and the tag table's format_value linkification.
  • The two-DOM-structure injection polyfill from the old inspector — moot once we render server-side.

Deferred for follow-up issues

Test plan

  • Boot the dev environment per DEVELOPMENT.md on this branch and confirm Puma starts cleanly.
  • Confirm CI asset compile passes; if not, run npm install locally, commit the resulting lockfile.
  • Confirm CI test suite passes (15 helper + 15 controller tests added).
  • Browse to /node/<id> for a node with image:1 tags — slideshow renders, prev/next buttons appear if multiple images, clicking an image opens SimpleLightbox.
  • Browse to a node with start_date/end_date — date range renders correctly, including BCE features and very-large-year features (regression check for OpenStreetMap Map key is not working in STANDARD LAYER openstreetmap/openstreetmap-website#747).
  • Browse to a node with wikipedia=pt:Article — Portuguese Wikipedia excerpt loads (regression check for Update geocoder.search_osm_nominatim.prefix.aerialway openstreetmap/openstreetmap-website#859).
  • Browse to a node with wikidata=Q… and no wikipedia tag — Wikipedia excerpt loads via Wikidata sitelink (Obtain changeset comment for /api/[node|way|relation](/history) openstreetmap/openstreetmap-website#584).
  • Browse to a feature with more_info:1 tags — links render under "More info" with appropriate fallback when name is missing.
  • Browse to an invisible/deleted feature — no inspector panel renders.
  • Confirm no span.translation_missing markers appear on any of the above.
  • Confirm pages without any of the relevant tags don't render an empty .ohm-inspector-panel wrapper.
  • Visual / layout review (not addressed in this PR).

🤖 Generated with Claude Code

… ohm-website

Replaces the GitHub Pages-hosted ohm-inspector bundle with an in-tree
implementation. The feature panel is now rendered server-side as a Rails
partial with client-side JS only for SimpleLightbox initialization,
Wikipedia excerpt fetching, and (future) Wikidata lookup. SimpleLightbox
is consumed from npm rather than vendored.

Changes:
- app/views/browse/_ohm_details.html.erb: server-side panel (image
  slideshow, date range, Wikipedia/Wikidata excerpt placeholder,
  more-info links). All strings localized via t(".key").
- app/assets/javascripts/index/ohm_inspector.js: SimpleLightbox init,
  slideshow nav, async Wikipedia excerpt fetch, Wikidata->Wikipedia
  fallback (openstreetmap#584). Replaces the CDN-loaded bundle.
- app/helpers/ohm_inspector_helper.rb: ohm_inspector_wikipedia_url and
  ohm_inspector_date_range. Wikipedia URL helper detects lang:Title
  prefix correctly (openstreetmap#859). Date range uses existing DateRange class
  which has no 1000000/-1000000 special-casing (openstreetmap#747).
- app/assets/stylesheets/_ohm_inspector.scss: panel styles.
- app/assets/stylesheets/ohm-inspector-all.scss: Sprockets manifest
  for SimpleLightbox CSS from npm.
- config/locales/en.yml: browse.ohm_details.* and
  javascripts.ohm_inspector.* keys.
- package.json: simplelightbox ^2.1.0 (run npm install to update
  the lockfile).

Upstream files touched (kept minimal for merge maintainability):
- app/views/layouts/_head.html.erb: removed two CDN tags, added one
  stylesheet_link_tag.
- app/views/elements/show.html.erb: render the new partial.
- app/assets/javascripts/index.js: two new //= require lines.
- app/assets/javascripts/index/element.js: replaced inline
  addOpenHistoricalMapInspector body with a call to the new global
  function, passing map for future openstreetmap#1323 use.
- app/assets/stylesheets/common.scss: @import "ohm_inspector".

Tests:
- test/helpers/ohm_inspector_helper_test.rb: 15 unit tests including
  regression coverage for openstreetmap#859 and openstreetmap#747.
- test/controllers/ohm_inspector_test.rb: 15 integration tests
  exercising the partial via the nodes controller.

Intentionally not ported:
- followed_by:name / followed_by tag display: per openstreetmap#748, this should
  consult the chronology relation rather than these undocumented tags.
- Feature name and bottom Wikipedia/Wikidata/LoC links: redundant with
  the existing sidebar header and tag table.
- The two-DOM-structure injection polyfill from the old inspector.

Layout/visual design and remaining inspector-labeled issues are
deferred per the project plan.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jeffreyameyer
Copy link
Copy Markdown
Member Author

Closing — opened prematurely. The branch 1058-Inspector-deployment-as-NPM remains pushed; reopening can wait until additional testing is done.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

1 Warning
⚠️ Number of updated lines of code is too large to be in one PR. Perhaps it should be separated into two or more?

Generated by 🚫 Danger

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants