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

Relative image paths in HTML #17

Closed
ewels opened this issue Jan 21, 2021 · 0 comments
Closed

Relative image paths in HTML #17

ewels opened this issue Jan 21, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@ewels
Copy link

ewels commented Jan 21, 2021

Hi there,

Many thanks for this tool! We use it in the @nf-core / viralrecon pipeline. I'm new to this type of analysis and am just poking around my first proper run of the pipeline.

I noticed that in the HTML report, the image embeds aren't working for me. When I look at the HTML source, the <img> src is an absolute file path back to the location that the pipeline ran on the server. The above pipeline is written in Nextflow which executes each sub-task in its own directory before copying final results to a folder. So even if I hadn't moved the report from my cluster that would still break each report.

I wonder if the HTML report could instead use relative image paths instead of absolute? If I edit in the browser from this:

<a href="file:///cluster/path/analysis/work/0a/7489264fc24b66e4ef634ad280a2303/NO_GROUP/P1234_567/images/P1234_567_REF.png" target="_blank">
<img src="file:///cluster/path/analysis/work/0a/7489264fc24b66e4ef634ad280a2303/NO_GROUP/P1234_567/images/P1234_567_REF.png" alt="REF">
</a>

to this:

<a href="images/P1234_567_REF.png" target="_blank">
<img src="images/P1234_567_REF.png" alt="REF">
</a>

..then the report can be moved around and the images load properly.

A very quick poke around the package source code (it's late here) makes me think that it's probably the following line that needs to be tweaked:

return 'file://' + os.path.join(root, name)

I guess that using a relative path here will propagate through to the HTML report? e.g. something like this:

return os.path.relpath(os.path.join(root, name), sample_folder)

However as I've only looked at the code for about 5 minutes, I'm not sure if this will affect functionality elsewhere and break stuff..

Anyway, let me know what you think! Happy to prepare a PR for this change next week if you like (or please go ahead if you'd rather as it's such a small change).

Phil

@saramonzon saramonzon added the bug Something isn't working label Feb 26, 2021
saramonzon added a commit that referenced this issue Mar 19, 2021
saramonzon added a commit that referenced this issue Mar 20, 2021
- Migrated tests to github actions
- Updated environment.yml for conda.
- Fixed issues #12,#14,#15,#17. Cases with no plasmids or too many. Relative paths in html images.
saramonzon added a commit that referenced this issue Mar 20, 2021
- Updated Dockerfile
- Migrated tests to github actions
- Updated environment.yml for conda.
- Fixed issues #12,#14,#15,#17. Cases with no plasmids or too many. Relative paths in html images.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants