Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow serving catalog from a path relative to server root #478

Merged
merged 2 commits into from
Jun 12, 2024
Merged

Conversation

jsheunis
Copy link
Member

@jsheunis jsheunis commented Jun 11, 2024

This aims to address #443

This change across several files allows to serve a catalog e.g. from http://localhost:8000/subdir/mycatalog with the mycatalog directory containing all necessary components of the catalog, such as assets, metadata, etc. The changes involved:

  • using the <base> html tag in the index.html file and assigning its href property dynamically based on window.location.path
  • changing all paths of assets and scripts, previously all absolute (starting with /) to relative paths, that will now be interpreted as relative to the <base> tag href property
  • changing the router base property to also be assigned dynamically from window.location.path
  • updating the catalog-serve command and Webcatalog.serve() method to accept an optional base argument which allows a local server to serve the base path as root, and then use the relative portion of the catalog location relative to the base path in order to set the correct redirect configuration. Previously, the redirect rule from /dataset to /index.html basically assumed that the base path and catalog location were the same. Now the redirect rule uses the relative portion to redirect from /{relpath}/dataset to /{relpath}/index.html.

The last point implies that any server using a catalog location that is different from and relative to the base path will have to change their redirect rules to accommodate the relative portion.

Lastly, some metadata that was found to be faulty during testing was updated.

This change across several files allows to serve a catalog e.g. from
http://localhost:8000/subdir/mycatalog with the 'mycatalog' directory
containing all necessary components of the catalog, such as assets,
metadata, etc. The changes involved:
- using the 'base' html tag in the index.html file and assigning its
  href property dynamically based on window.location.path
- changing all paths of assets and scripts, previously all absolute
  (starting with '/') to relative paths, that will now be interpreted
  as relative to the base tag href property
- changing the router 'base' property to also be assigned dynamically
  from window.location.path
- updating the 'catalog-serve' command and 'Webcatalog.serve()' method
  to accept an optional 'base' argument which allows a local server to
  serve the base path as root, and then use the relative portion of the
  catalog location relative to the base path in order to set the correct
  redirect configuration. Previously, the redirect rule from '/dataset'
  to '/index.html' basically assumed that the base path and catalog
  location were the same. Now the redirect rule uses the relative portion
  to redirect from '/{relpath}/dataset' to '/{relpath}/index.html'.

The last point implies that any server using a catalog location that is
different from and relative to the base path will have to change their
redirect rules to accommodate the relative portion.

Lastly, some metadata that was found to be faulty during testing was
updated.
Copy link

netlify bot commented Jun 11, 2024

Deploy Preview for datalad-catalog canceled.

Name Link
🔨 Latest commit a19a631
🔍 Latest deploy log https://app.netlify.com/sites/datalad-catalog/deploys/6668bd77cfc91a00087a8470

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.

1 participant