Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use local file as theme #331

Closed
Lenormju opened this issue Aug 27, 2024 · 2 comments
Closed

Use local file as theme #331

Lenormju opened this issue Aug 27, 2024 · 2 comments

Comments

@Lenormju
Copy link

Description

Add support for providing theme by a file.

The !include keyword allows for 3 different types of resources : !include <file|directory|url>
While the theme keyword allows for only 1 type of resource : theme <default|url> (default being a shorthand for an hardcoded URL).

I was uncertain between the Priority "no rush" and "willing to open a PR". I think I can solve this issue myself, but I'd like to know if you are okay with the goal before to start working on it.

Priority

I'm willing to add this feature myself and raise a PR (please confirm approach first)

More information

I don't want to have to store my own theme file on a file server somewhere, to be picked up by Structurizr, while it can already use local files for all kinds of purposes.
I had to use Docker Compose with a Python Simple HTTP Server to be able to have a self-contained build step :

name: build-structurizr
services:
  serve-theme:
    image: "python:3.10.8-slim-bullseye"
    working_dir: /www/data/
    command: "python -m http.server 8000"
    ports:
      - 8000:8000
    volumes:
      - type: bind
        source: ./docs/theme/
        target: /www/data/
        read_only: true

  build-docs:
    image: ghcr.io/avisi-cloud/structurizr-site-generatr:latest
    command: generate-site -w workspace.dsl
    volumes:
      - type: bind
        source: ./docs/
        target: /var/model/
        read_only: false
    depends_on:
      - serve-theme

which made possible to provide the theme as an URL :

        theme http://serve-theme:8000/theme.json
@simonbrowndotje
Copy link
Contributor

The browser-based Structurizr UI loads themes via an XHR request, which is why they need to be URLs. Since you're using Site Generatr, this restriction doesn't apply, so I've added the ability to specify a theme file, relative to the DSL file; for example:

theme theme.json

This will inline all styles defined in theme.json and override any styles that already exist in your workspace.

@Lenormju
Copy link
Author

I just pulled ghcr.io/avisi-cloud/structurizr-site-generatr:1.5.0 and it has the change. I have simplified my build thanks to that, thank you.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants