galaxyproject / galaxy-hub

Galaxy Community Hub
https://galaxyproject.org/
Other
99 stars 277 forks source link

Fix linking to local files #943

Open NickSto opened 3 years ago

NickSto commented 3 years ago

It seems that when a hyperlink points to a local file (not in a static directory), Gridsome usually moves the file to the /assets/ directory and rewrites the href to point to the file. This can lead to issues.

One known scenario is when the file is actually a symlink placed there by our build system (preprocessor.mjs). In that case, Gridsome copies the symlink itself, not the target file. Because our symlinks are relative, if you put them in a different filesystem location, they break. Even if they didn't break, I'd want to verify that the AWS uploader would be able to access the target file (since it's in a totally different directory).

The bottom line is this makes linking to a local file (one in the same directory) unreliable. We'd ideally like to support that.

There are several factors that affect whether Gridsome takes action and performs the rewriting, and if so, how it does it:

  1. The type of link: It seems to only rewrite relative urls that point to files in the same directory as the Markdown file.
  2. The file extension: It seems to have a list of known extensions and treats the file differently if it's an image, another known extension, or an unknown one.
  3. Whether you're running the development server or doing a full build (yarn develop vs yarn build).
  4. Whether the page is being handled by vue-remark or just source-filesystem.

This page has details on the effects of each factor.

NickSto commented 3 years ago

FYI, a search (grep -ER '[^!]\[.+\]\(\./[^)]+\.[^)]+\)') through the build directory shows that currently there aren't actually many links directly to files.

The only clear one is the link to PoweredByGalaxy.xcf on /outreach/powered-by-galaxy/.

I feel like there were other examples but I've checked my regex a few times and it should be catching them.

tnabtaf commented 3 years ago

Nick, we can kill that xcf file. I bet it has never been used

NickSto commented 3 years ago

@tnabtaf Good to know. We can also easily just move it to a static directory (content/media/), FYI. That'll still work.

tnabtaf commented 3 years ago

That .xcf file will be deleted in PR #954.