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

Rename and document customization options #206

Merged
merged 4 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* [Generate a website from a Git repository](#generate-a-website-from-a-git-repository)
* [Start a development web server around the generated website](#start-a-development-web-server-around-the-generated-website)
* [For those taking the Docker approach](#for-those-taking-the-docker-approach-1)
* [Customizing the generated website](#customizing-the-generated-website)
* [Contributing](#contributing)
* [Background](#background)
<!-- TOC -->
Expand Down Expand Up @@ -227,6 +228,29 @@ Generatr container. So
is needed to expose the container's port 8080 to the host (web browser). In the example above, the
`-p 8080:8080` argument tells Docker to bind the local machine / host's port 8080 to the container's port 8080.

## Customizing the generated website

The site generator use the
[C4PlantUmlExporter](https://github.com/structurizr/export/tree/main/src/main/java/com/structurizr/export/plantuml#c4plantumlexporter)
to generate the diagrams. All properties available for the C4PlantUMLExporter, e.g. `c4plantuml.tags`, can be applied
and affect the diagrams in the generate site. See also
[Diagram notation](https://github.com/structurizr/export/tree/main#diagram-notation) for an overview of supported
features and limitations for this exporter.

The look and feel of the generated site can be customized with several additionally view properties in the C4
architecture model:

| Property name | Description | Default | Example |
|-----------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------|--------------------|
| `generatr.style.colors.primary` | Primary site color, used for header bar background and active menu background. | `#333333` | `#485fc7` |
| `generatr.style.colors.secondary` | Secondary site color, used for font color in header bar and for active menu. | `#cccccc` | `#ffffff` |
| `generatr.style.faviconPath` | Site logo location relative to the configured `assets` folder. When configured, the logo image will be place on the left side in the header bar. This requires the `--assets-dir` switch when generating the site and the corresponding file to be available in the `assets` folder. | | `site/favicon.ico` |
| `generatr.style.logoPath` | Site favicon location relative to the configured `assets` folder. When configured, the favicon will be set for all generated pages. This requires the `--assets-dir` switch when generating the site and the corresponding file to be available in the `assets` folder. | | `site/logo.png` |
| `generatr.search.language` | Indexing/stemming language for the search index. See [Lunr language support](https://github.com/olivernn/lunr-languages) | `en` | `nl` |

See the included example for usage of some those properties in the
[C4 architecture model example](https://github.com/avisi-cloud/structurizr-site-generatr/blob/main/docs/example/workspace.dsl#L159).

## Contributing

We welcome contributions! Please refer to [CONTRIBUTING.md](CONTRIBUTING.md) for more information on how you can help.
Expand Down
8 changes: 4 additions & 4 deletions docs/example/workspace.dsl
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ workspace "Big Bank plc" "This is an example workspace to illustrate the key fea
views {
properties {
"c4plantuml.elementProperties" "true"
"structurizr.style.colors.primary" "#485fc7"
"structurizr.style.colors.secondary" "#ffffff"
"structurizr.style.favicon.path" "site/favicon.ico"
"structurizr.style.logo.path" "site/logo.png"
"generatr.style.colors.primary" "#485fc7"
"generatr.style.colors.secondary" "#ffffff"
"generatr.style.faviconPath" "site/favicon.ico"
"generatr.style.logoPath" "site/logo.png"
}

systemlandscape "SystemLandscape" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ private fun copyAssets(assetsDir: File, exportDir: File) {

private fun generateStyle(context: GeneratorContext, exportDir: File) {
val configuration = context.workspace.views.configuration.properties
val primary = configuration.getOrDefault("structurizr.style.colors.primary", "#333333")
val secondary = configuration.getOrDefault("structurizr.style.colors.secondary", "#cccccc")
val primary = configuration.getOrDefault("generatr.style.colors.primary", "#333333")
val secondary = configuration.getOrDefault("generatr.style.colors.secondary", "#cccccc")

val file = File(exportDir, "style-branding.css")
val content = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class FaviconViewModel(generatorContext: GeneratorContext, pageViewModel: PageVi
private fun faviconPath(generatorContext: GeneratorContext) =
generatorContext.workspace.views.configuration.properties
.getOrDefault(
"structurizr.style.favicon.path",
"generatr.style.faviconPath",
null
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class HeaderBarViewModel(pageViewModel: PageViewModel, generatorContext: Generat
private fun logoPath(generatorContext: GeneratorContext) =
generatorContext.workspace.views.configuration.properties
.getOrDefault(
"structurizr.style.logo.path",
"generatr.style.logoPath",
null
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SearchViewModel(generatorContext: GeneratorContext) : PageViewModel(genera
override val url = url()

val language: String = generatorContext.workspace.views
.configuration.properties.getOrDefault("structurizr.style.search.language", "")
.configuration.properties.getOrDefault("generatr.search.language", "")

val documents = buildList {
add(home(generatorContext.workspace.documentation, this@SearchViewModel))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class FaviconViewModelTest : ViewModelTest() {
@Test
fun favicon() {
generatorContext.workspace.views.configuration.addProperty(
"structurizr.style.favicon.path",
"generatr.style.faviconPath",
"site/favicon.png"
)
val faviconViewModel = faviconViewModel()
Expand All @@ -28,7 +28,7 @@ class FaviconViewModelTest : ViewModelTest() {
@Test
fun `invalid favicon`() {
generatorContext.workspace.views.configuration.addProperty(
"structurizr.style.favicon.path",
"generatr.style.faviconPath",
"favicon"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class HeaderBarViewModelTest : ViewModelTest() {
@Test
fun logo() {
generatorContext.workspace.views.configuration.addProperty(
"structurizr.style.logo.path",
"generatr.style.logoPath",
"site/logo.png"
)
val viewModel = HeaderBarViewModel(pageViewModel, generatorContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SearchViewModelTest : ViewModelTest() {
@Test
fun `index language configured`() {
val generatorContext = generatorContext().apply {
workspace.views.configuration.addProperty("structurizr.style.search.language", "nl")
workspace.views.configuration.addProperty("generatr.search.language", "nl")
}
val viewModel = SearchViewModel(generatorContext)

Expand Down