Skip to content

Embed logos as base64 data URIs instead of remote URLs - #255

Merged
karlnyr merged 26 commits into
masterfrom
rc5.0.1
Aug 21, 2026
Merged

Embed logos as base64 data URIs instead of remote URLs#255
karlnyr merged 26 commits into
masterfrom
rc5.0.1

Conversation

@karlnyr

@karlnyr karlnyr commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Description

Previously, the MicroSALT and Swedac logos in generated reports were loaded via remote GitHub URLs (raw=true links). This means reports required an active internet connection to display the logos, and would silently break if GitHub was unreachable or if the artwork paths changed.

This PR embeds both logos as base64-encoded inline data URIs at render time, reading the image files directly from the installed package. Reports are now fully self-contained.

Additionally, this PR includes a few dependabot alerts.

Primary function of PR

  • Hot-fix
  • Patch
  • Minor functionality improvement
  • New type of analysis
  • Backward-breaking functionality improvement
  • This change requires internal documents to be updated
  • This change requires another repository to be updated

Changes:

  • New microSALT/server/utils.py with read_jpg() (base64 encoder) and pre-resolved paths MICROSALT_LOGO_PATH / SWEDAC_LOGO_PATH pointing into the installed package's artwork/ directory.
  • views.py injects these as Jinja2 globals so all templates can use them.
  • typing_page.html, alignment_page.html, and STtracker_page.html updated to call read_jpg(file_path=...) instead of hardcoded remote src URLs.

Testing

  • bash /home/proj/production/servers/resources/hasta.scilifelab.se/install-microsalt-stage.sh BRANCHNAME
  • us
  • conda activate S_microSALT
  • microSALT analyse --input /path/to/fastq/ SAMPLEINFO_FILE

Quick local verification (no deployment needed):

from pathlib import Path
from datetime import datetime
from jinja2 import Environment, FileSystemLoader
from microSALT.server.utils import MICROSALT_LOGO_PATH, SWEDAC_LOGO_PATH, read_jpg

env = Environment(loader=FileSystemLoader("microSALT/server/templates"))
env.globals.update(read_jpg=read_jpg, microsalt_logo_path=MICROSALT_LOGO_PATH, swedac_logo_path=SWEDAC_LOGO_PATH)
rendered = env.get_template("typing_page.html").render(...)
assert "data:image/jpeg;base64," in rendered

Test results

Verified locally: rendered typing_page.html contains data:image/jpeg;base64,... inline data URIs for both logos. Opening the output HTML in a browser shows logos without any network requests.

Sign-offs

  • Approved to run at Clinical-Genomics by @karlnyr or @Clinical-Genomics/micro

dependabot Bot and others added 11 commits May 11, 2026 07:11
Bumps [pygments](https://github.com/pygments/pygments) from 2.19.2 to 2.20.0.
- [Release notes](https://github.com/pygments/pygments/releases)
- [Changelog](https://github.com/pygments/pygments/blob/master/CHANGES)
- [Commits](pygments/pygments@2.19.2...2.20.0)

---
updated-dependencies:
- dependency-name: pygments
  dependency-version: 2.20.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [requests](https://github.com/psf/requests) from 2.32.5 to 2.33.0.
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md)
- [Commits](psf/requests@v2.32.5...v2.33.0)

---
updated-dependencies:
- dependency-name: requests
  dependency-version: 2.33.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [mako](https://github.com/sqlalchemy/mako) from 1.3.11 to 1.3.12.
- [Release notes](https://github.com/sqlalchemy/mako/releases)
- [Changelog](https://github.com/sqlalchemy/mako/blob/main/CHANGES)
- [Commits](https://github.com/sqlalchemy/mako/commits)

---
updated-dependencies:
- dependency-name: mako
  dependency-version: 1.3.12
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [pytest](https://github.com/pytest-dev/pytest) from 9.0.2 to 9.0.3.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst)
- [Commits](pytest-dev/pytest@9.0.2...9.0.3)

---
updated-dependencies:
- dependency-name: pytest
  dependency-version: 9.0.3
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [black](https://github.com/psf/black) from 26.1.0 to 26.3.1.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](psf/black@26.1.0...26.3.1)

---
updated-dependencies:
- dependency-name: black
  dependency-version: 26.3.1
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.6.3 to 2.7.0.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](urllib3/urllib3@2.6.3...2.7.0)

---
updated-dependencies:
- dependency-name: urllib3
  dependency-version: 2.7.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [idna](https://github.com/kjd/idna) from 3.11 to 3.15.
- [Release notes](https://github.com/kjd/idna/releases)
- [Changelog](https://github.com/kjd/idna/blob/master/HISTORY.md)
- [Commits](kjd/idna@v3.11...v3.15)

---
updated-dependencies:
- dependency-name: idna
  dependency-version: '3.15'
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [soupsieve](https://github.com/facelessuser/soupsieve) from 2.8.3 to 2.8.4.
- [Release notes](https://github.com/facelessuser/soupsieve/releases)
- [Commits](facelessuser/soupsieve@2.8.3...2.8.4)

---
updated-dependencies:
- dependency-name: soupsieve
  dependency-version: 2.8.4
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
@karlnyr
karlnyr requested a review from a team as a code owner August 17, 2026 11:35
@karlnyr
karlnyr requested a lite review from Copilot August 17, 2026 11:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR makes generated MicroSALT HTML reports fully self-contained by embedding the MicroSALT and Swedac logos as inline data:image/jpeg;base64,... URIs instead of loading them from remote GitHub URLs.

Changes:

  • Added microSALT/server/utils.py with logo resource paths and a read_jpg() helper to build JPEG data URIs.
  • Injected read_jpg and the logo paths into the Jinja2 environment as globals from microSALT/server/views.py.
  • Updated report templates to use read_jpg(...) rather than hardcoded remote raw=true image URLs.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
microSALT/server/views.py Adds Jinja globals for logo embedding and minor formatting cleanups.
microSALT/server/utils.py Introduces helper + constants for resolving and base64-encoding logo assets.
microSALT/server/templates/typing_page.html Switches logo <img src> to embedded data URIs (including conditional Swedac logo).
microSALT/server/templates/STtracker_page.html Switches MicroSALT logo <img src> to embedded data URI.
microSALT/server/templates/alignment_page.html Switches MicroSALT logo <img src> to embedded data URI.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread microSALT/server/utils.py Outdated
@karlnyr

karlnyr commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

Zenodo badge working in branch:

image

@karlnyr

karlnyr commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Reports before:

Typing:

image

QC:

Note

This is an old version of the QC reports where the Swedac logo was included. It was later removed, meaning we should not expect this in new versions of the QC reports.

image

Reports after:

Typing:

image

QC:

image

@jemten jemten left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A couple of questions but otherwise it looks good.

Comment thread artwork/microsalt.emf Outdated
Comment thread microSALT/server/templates/STtracker_page.html Outdated

@jemten jemten left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good!

@karlnyr
karlnyr merged commit bed25d4 into master Aug 21, 2026
1 check passed
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.

3 participants