datalad / datalad-catalog

Create a user-friendly data catalog from structured metadata
https://datalad-catalog.netlify.app
MIT License
15 stars 11 forks source link

Add support for --server-prefix for catalog-create to deploy catalog not in the root of the website #443

Open yarikoptic opened 6 months ago

yarikoptic commented 6 months ago

After migration to https://router.vuejs.org/guide/essentials/history-mode.html some changes required to have /assets and /artwork to be placed at / since while navigating into "/sub/folders" in the new mode it would also append those if they were relative. For datalad-registry we need to deploy catalog under some /catalog/ prefix or alike, so then we cannot serve them from the /.

jsheunis commented 6 months ago

@yarikoptic I was thinking about this again, was there a specific reason why having relative URLs wouldn't be sufficient and why something like a base url would be specifically necessary?

I've started working on this locally and made all URLs relative, and ended up with the same error that we stopped at previously. So there seems to be an issue with all-relative URLs, but I still need to figure out what exactly.

yarikoptic commented 6 months ago

I think it was the fact that whenever you go to some /prefix/something/redirected/to/indexabove.html then any relative links (e.g. to assets/blah) within /prefix/index.html become relative to the path of that page i.e. /prefix/something/redirected/to/assets/blah. That is why we wanted them absolute to be /prefix/assets/blah.

jsheunis commented 6 months ago

Ok so redirection is the cause.

jsheunis commented 6 months ago

The use of the <base> html tag in the index page meta seems to be useful. If I make all URLs relative and include <base href="/"> inside the page metadata, the page renders correctly, and navigation also works correctly. This is when the app is served from root, e.g. http://localost:8000.

If I change the root so that the app is served from e.g. http://localost:8000/datalad_catalog/catalog, and also change the base tag to <base href="/datalad_catalog/catalog/">, then the page also renders correctly. But when I then navigate to a specific dataset url, e.g. http://localhost:8000/dataset/deabeb9b-7a37-4062-a1e0-8fcef7909609/6d7fb68264f9b9951ae141fc830712a8744e3293, I get a standard 404 (not the app-specific 404 page). I think the required redirection setup that takes care of the VueJS single-page-app history mode shortcoming is to blame for this, since I didn't update that redirection url to account for the changed base url. I must still test this though. A challenge that I see here and that I'm not sure how to fix would be that the server redirection setup is not (necessarily?) dynamic, so how would one specify a dynamic base url/prefix to a static server setup...

yarikoptic commented 6 months ago

http://localhost:8000/dataset/deabeb9b-7a37-4062-a1e0-8fcef7909609/6d7fb68264f9b9951ae141fc830712a8744e3293, I get a standard 404 (not the app-specific 404 page)

why it is not http://localost:8000/datalad_catalog/dataset/... ?

so adding that /datalad_catalog/ prefix explicitly to those locations to reach /assets/ and /artwork/ isn't enough?

jsheunis commented 5 months ago

@yarikoptic https://github.com/datalad/datalad-catalog/pull/478 should address the issues we had with relative/absolute locations of assets. Here, one wouldn't need to pass a flag specifying the server prefix to catalog-create. You can create the catalog at any location relative to the server root in the standard way. The import thing to update is the server's redirect rule, which should take the location of the catalog relative to the server root into account.