Skip to content
Snippets Groups Projects

Enable producing fully standalone html file

Merged Paul Gessinger requested to merge pagessin/dcube:standalone into master
All threads resolved!

This optionally inlines all the plot images as data-uris. For SVG it tries to be smart and encode it directly as ascii SVG (SVG being natively ASCII) to save some space.

Note: this always inlines the layout images etc into the HTML file. I think this is fine to do as it only negligibly increases the HTML file size as opposed to inlining the plots. In principle, this can also be made optionally.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Very nice! I have a couple of suggestions for improvement:

    1. add a title attribute (or maybe it's something else) to make sure Save Image As gives a unique filename. For compatibility, this could be the .png filename. Even nicer, would be to use something like resolution_vs_eta_d0.png - based on plot name.
    2. remove or don't copy all the other files that aren't needed when everything is in dcube.html. Well, maybe still want dcube.log and dcube.xml. And maybe only do this if --web-display=html (no PHP). Would also be good to use a temporary directory for the plots files, which could be much much faster.

    I could probably take a look at either or both of these if you like. In any case, they can probably wait for a separate MR.

    Edited by Tim Adye
  • Thanks @adye

    1. I don't think this is possible. Data URI does not have a way to communicate a file name, and you can only specify the recommended download filename on a. I think this is just going to have to be a limitation of the standalone format (and hence why it's good to have it optional). Anyway, as a workaround I at an a labeled "Download" that does this with the original filename. This doesn't work with a link to an image file that's actually an HTTP url, so the link is only shown in inline mode.
    2. For the server files this is easy enough. For the temp dir: there's no great way to communicate a common temporary directory. What I do now is always attaching a temporary directory to self.opts because that's passed to all the objects, and always deleted at the end of the job. If --inline-plots is given, the plot directory is rerouted there, otherwise it stays empty.
  • Paul Gessinger added 7 commits

    added 7 commits

    • 4bb08c44...bbc54af7 - 2 commits from branch art:master
    • 1d6ea2a0 - use absolute path for server
    • 6c1b15f9 - add .icon_h1
    • 5c4da8a8 - Merge remote-tracking branch 'origin/master' into standalone
    • 88885075 - use temp dir for plots in inline mode
    • 7fbc7e49 - aadd download link to plots in inline mode

    Compare with previous version

  • Paul Gessinger resolved all threads

    resolved all threads

  • I'm still looking through the code changes in detail, but it looks good so far. My testing shows:

    1. The PHP mode works without --inline-plots, but the Normal View button image is missing. This isn't serious - you can still select the text - but would be good to fix.
    2. As expected, PHP mode doesn't show any plots with --inline-plots. Can we disable the PHP output in this case? That way we don't even have the link from the .html file, and don't need to generate the .php files. That can be done by forcing --web-display=html if --inline-plots is specified.
    3. With --inline-plots, I guess we don't need to copy anything to DCubeServer. Ah, I see this is properly dropped with --web-display=html :smile:
  • Tim Adye
  • Tim Adye added 1 commit

    added 1 commit

    • 3673e505 - remove some now-unused variables

    Compare with previous version

  • I committed a few small changes to remove now-unused variables. It seems in this repo, I have the power! :grin: I hope that's OK.

    Edited by Tim Adye
  • Tim Adye added 1 commit

    added 1 commit

    • 229009a6 - fix tab bar for php. Remove remaining references to deleted sel_tp_left/title/right CSS classes

    Compare with previous version

  • I found why the Normal View button image was missing and committed the fix.

  • Tim Adye added 1 commit

    added 1 commit

    • eee943cf - --inline-plots forces --web-display=html

    Compare with previous version

  • With that last commit, I think the only outstanding issue is in the unresolved thread above, which I'll leave to @pagessin.

    In the meantime, I looked through the rest of the code changes and it all looks good. So I can merge as soon as the dl is null issue is fixed.

  • Paul Gessinger added 1 commit

    added 1 commit

    • 3098c27d - conditionally set href on the download links

    Compare with previous version

  • Tim Adye added 1 commit

    added 1 commit

    • f1c6323e - remove more unneeded vars. Use self.css and self.js

    Compare with previous version

  • Tim Adye resolved all threads

    resolved all threads

  • Tim Adye mentioned in commit 314d0927

    mentioned in commit 314d0927

  • merged

  • Please register or sign in to reply
    Loading