Skip to content

Allow for custom css sheet overrides for reports#1573

Merged
ewels merged 14 commits intoMultiQC:masterfrom
jchorl:jchorl/customcss
Nov 7, 2021
Merged

Allow for custom css sheet overrides for reports#1573
ewels merged 14 commits intoMultiQC:masterfrom
jchorl:jchorl/customcss

Conversation

@jchorl
Copy link
Copy Markdown
Contributor

@jchorl jchorl commented Nov 2, 2021

Adds the ability to specify CSS overrides. I know it's possible to add css to custom modules, but we'd like to do it for the simple/default reports, without specifying entirely new modules.

For example, I'd like to add css rules for the css print media query. I will merge these with upstream. But for the short term, it's useful to just specify a bunch of overrides, and then get them merged. This will allow for e.g. beautiful print exports of multiqc reports (currently e.g. background colours don't show up). Let me know what you think!

  • This comment contains a description of changes (with reason)
  • CHANGELOG.md has been updated

I tried this out with a few configurations:

$ cat sample.css 
.side-nav {
  width: 800px;
}
$ cat other_sample.css 
.side-nav h1 img {
  height: 200px;
}
$ cat multiqc_config.yaml 
custom_css_files:
  - sample.css
  - other_sample.css

Screenshot 2021-11-02 at 03-45-51 MultiQC Report

You can see the logo and sidebar are huge here.

Then I built/ran with cli flags:

$ docker run -it --rm -v $(pwd):/work -w /work jchorl/multiqc --custom-css-files sample.css --custom-css-files other_sample.css .

  /// MultiQC 🔍 | v1.12.dev0

|           multiqc | Search path : /work
|         searching | ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 3/3  
|    custom_content | plasmid_table: Found 2 samples (table)
|           multiqc | Compressing plot data
|           multiqc | Report      : multiqc_report.html
|           multiqc | Data        : multiqc_data
|           multiqc | MultiQC complete
 j@bike  ~/third-party/MultiQC/testdata   jchorl/customcss ±  ls multiqc_config.yaml
ls: cannot access 'multiqc_config.yaml': No such file or directory

Screenshot 2021-11-02 at 03-48-03 MultiQC Report

Finally, I removed the flags and config file:
Screenshot 2021-11-02 at 03-49-47 MultiQC Report

We're back to normal looking reports.

@jchorl
Copy link
Copy Markdown
Contributor Author

jchorl commented Nov 6, 2021

@ewels any chance I could get you to take a look at this? Happy to revise as you see helpful.

Copy link
Copy Markdown
Member

@ewels ewels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sorry - I've been on paternity leave and now working 50% so I'm very behind on MultiQC maintenance work.

Love the idea of this PR though, have done a quick read on my phone with one or two minor comments but happy to merge once resolved 👍🏻

Thanks for this!

{{ include_file('assets/css/jquery.toast.css') }}
</style>
{% for css_href in config.custom_css_files %}
<style type="text/css">{{ include_file(css_href, None) }}</style>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forget, what is the second argument for? Is it needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    def include_file(name, fdir=tmp_dir, b64=False):
        try:
            if fdir is None:
                fdir = ""
            if b64:
                with io.open(os.path.join(fdir, name), "rb") as f:
                    return base64.b64encode(f.read()).decode("utf-8")
            else:
                with io.open(os.path.join(fdir, name), "r", encoding="utf-8") as f:
                    return f.read()

It's the root dir, looks like. I suspect we can actually omit it. I just copy/pasta'd from right above it.

Comment thread multiqc/multiqc.py Outdated
config.exclude_modules = exclude
if profile_runtime:
config.profile_runtime = True
if custom_css_files is not None and len(custom_css_files) > 0:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a feeling that if a click argument accepts multiple, it returns an empty list of not specified. So you can probably ditch this line if that's true.

But worth checking as this is off the top of my head 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will test!

Comment thread multiqc/multiqc.py Outdated
@click.option("--profile-runtime", is_flag=True, help="Add analysis of how long MultiQC takes to run to the report")
@click.option("--no-ansi", is_flag=True, help="Disable coloured log output")
@click.option(
"--custom-css-files",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that you need this twice..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're probably right. Above:

@click.option(
    "--cl-config", "--cl_config", type=str, multiple=True, help="Specify MultiQC config YAML on the command line"
)

But lemme try taking it out :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, past-me probably didn't know better. Only needed when doing short form + long form if I remember correctly.

Comment thread multiqc/multiqc.py Outdated
Comment thread CHANGELOG.md Outdated
Comment thread docs/config.md Outdated
Comment thread docs/config.md Outdated
Comment thread docs/config.md Outdated
Comment thread docs/config.md Outdated
jchorl and others added 8 commits November 6, 2021 23:08
Co-authored-by: Phil Ewels <phil.ewels@scilifelab.se>
Co-authored-by: Phil Ewels <phil.ewels@scilifelab.se>
Co-authored-by: Phil Ewels <phil.ewels@scilifelab.se>
Co-authored-by: Phil Ewels <phil.ewels@scilifelab.se>
Co-authored-by: Phil Ewels <phil.ewels@scilifelab.se>
Co-authored-by: Phil Ewels <phil.ewels@scilifelab.se>
@jchorl
Copy link
Copy Markdown
Contributor Author

jchorl commented Nov 6, 2021

Congrats on the pat leave :)

I implemented your suggestions. Thanks for working through.

If you have any additional cycles, I cut another 3 PRs. These 2 should be a slam dunk:

And this one's a tad hairier:

@ewels
Copy link
Copy Markdown
Member

ewels commented Nov 7, 2021

Nice, thanks! Ready to merge apart from the failing CI tests that are due to changing CSPs. I never completely wrapped my head around this stuff. Are you ok to look into it and try to get the tests passing?

@ewels
Copy link
Copy Markdown
Member

ewels commented Nov 7, 2021

Ah crap, looks like that test is failing on all PRs. Ok may need some thought, I'd be nice to have some green ticks before merging if possible..

@jchorl
Copy link
Copy Markdown
Contributor Author

jchorl commented Nov 7, 2021

Hey @ewels I actually fixed CI in #1578

Let's merge that, and then I can rebase the other PRs, get CI green, $$$?

@ewels
Copy link
Copy Markdown
Member

ewels commented Nov 7, 2021

Ah you're a hero! No need to rebase, can just rerun actions.

@jchorl
Copy link
Copy Markdown
Contributor Author

jchorl commented Nov 7, 2021

Seems like actions run at the current sha, not rebasing on master. Should I just rebase and push?

@ewels
Copy link
Copy Markdown
Member

ewels commented Nov 7, 2021

Ok fab, thanks!

@ewels ewels merged commit 297fd88 into MultiQC:master Nov 7, 2021
@ewels
Copy link
Copy Markdown
Member

ewels commented Nov 7, 2021

It's none of my business, but how come an engineer from Stripe is running MultiQC? Do you have some bioinformatics side project or are you using MultiQC for something totally different?

@jchorl
Copy link
Copy Markdown
Contributor Author

jchorl commented Nov 7, 2021

It's none of my business, but how come an engineer from Stripe is running MultiQC? Do you have some bioinformatics side project or are you using MultiQC for something totally different?

Nothing employer/work related - just nerding out on weekends, trying to learn :P

@ewels
Copy link
Copy Markdown
Member

ewels commented Nov 7, 2021

Awesome. Happy to have you here 😀

ewels added a commit to jchorl/MultiQC that referenced this pull request Nov 9, 2021
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.

2 participants