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

Fix gilbarbara sprite set url #266

Merged
merged 1 commit into from
Dec 4, 2024
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
20 changes: 12 additions & 8 deletions scripts/gilbarbaraImageSpriteParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@
import json
import urllib.request

GILBARBARA_ICON_URL = "https://raw.githubusercontent.com/plantuml-stdlib/gilbarbara-plantuml-sprites/v1.1"
SPRITE_FILE_URL = "https://raw.githubusercontent.com/rabelenda/gilbarbara-plantuml-sprites/refs/heads/master/sprites-list.md"
BASE_PATH = (
"https://raw.githubusercontent.com/plantuml-stdlib/gilbarbara-plantuml-sprites"
)
GILBARBARA_ICON_URL = BASE_PATH + "/v1.1"
SPRITE_FILE_URL = BASE_PATH + "/refs/heads/master/sprites-list.md"
OUTPUT_FILE_JSON = "../src/main/resources/sprites/gilbarbara_image_sprites.json"
URL_VAR_NAME = "GILBARBARA_PNG_URL"
ADDITIOANL_DEFINITIONS = [URL_VAR_NAME + " " + GILBARBARA_ICON_URL+"/pngs"]
ADDITIOANL_DEFINITIONS = [URL_VAR_NAME + " " + GILBARBARA_ICON_URL + "/pngs"]


def icon_names_to_path():
sprite_defs = urllib.request.urlopen(SPRITE_FILE_URL).readlines()
index_to_start = sprite_defs.index(b"|--------|------|\n") + 1
icon_name_to_path = {}
for sprite_def in sprite_defs[5:]:
sprite_values = sprite_def.decode("utf-8").split("|")
name = sprite_values[1] + "-img"
icon = sprite_values[2]
icon_path = re.search(r"\((.+)\)", icon).group(1).replace("pngs","")
for sprite_def in sprite_defs[index_to_start:]:
sprite_values = sprite_def.decode("utf-8").replace("🧟", "").split("|")
name = sprite_values[1].strip() + "-img"
icon = sprite_values[2].strip()
icon_path = re.search(r"\((.+)\)", icon).group(1).replace("pngs", "")
icon_path = "img:" + GILBARBARA_ICON_URL + icon_path
icon_name_to_path[name] = icon_path
return icon_name_to_path
Expand Down
37 changes: 17 additions & 20 deletions scripts/standardLibSpriteParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@
import glob

STANDARD_LIB_FOLDER = "../../plantuml-stdlib/stdlib"
STANDARD_LIB_FOLDER_URL = "https://github.com/plantuml/plantuml-stdlib/tree/master/stdlib"
STANDARD_LIB_FOLDER_URL = (
"https://github.com/plantuml/plantuml-stdlib/tree/master/stdlib"
)

AWS_STANDARD_LIB_FOLDER = "/awslib14/"
AWS_STANDARD_LIB_FOLDER = "/awslib14/"
AWS_OUTPUT_FILE_PATH = "../src/main/resources/sprites/aws_stdlib_sprites.json"

AZURE_STANDARD_LIB_FOLDER = "/azure/"
AZURE_STANDARD_LIB_FOLDER = "/azure/"
AZURE_OUTPUT_FILE_PATH = "../src/main/resources/sprites/azure_stdlib_sprites.json"

ELASTIC_STANDARD_LIB_FOLDER = "/elastic/"
ELASTIC_STANDARD_LIB_FOLDER = "/elastic/"
ELASTIC_OUTPUT_FILE_PATH = "../src/main/resources/sprites/elastic_stdlib_sprites.json"

GCP_STANDARD_LIB_FOLDER = "/gcp/"
GCP_STANDARD_LIB_FOLDER = "/gcp/"
GCP_OUTPUT_FILE_PATH = "../src/main/resources/sprites/gcp_stdlib_sprites.json"

K8S_STANDARD_LIB_FOLDER = "/k8s/"
K8S_STANDARD_LIB_FOLDER = "/k8s/"
K8S_OUTPUT_FILE_PATH = "../src/main/resources/sprites/k8s_stdlib_sprites.json"

CLOUDINSIGHT_STANDARD_LIB_FOLDER = "/cloudinsight/"
Expand All @@ -30,16 +32,16 @@
MATERIAL_STANDARD_LIB_FOLDER = "/material/"
MATERIAL_OUTPUT_FILE_PATH = "../src/main/resources/sprites/material_stdlib_sprites.json"

LOGOS_STANDARD_LIB_FOLDER = "/logos/"
LOGOS_STANDARD_LIB_FOLDER = "/logos/"
LOGOS_OUTPUT_FILE_PATH = "../src/main/resources/sprites/logos_stdlib_sprites.json"

OFFICE_STANDARD_LIB_FOLDER = "/office/"
OFFICE_OUTPUT_FILE_PATH = "../src/main/resources/sprites/office_stdlib_sprites.json"

OSA_STANDARD_LIB_FOLDER = "/osa/"
OSA_STANDARD_LIB_FOLDER = "/osa/"
OSA_OUTPUT_FILE_PATH = "../src/main/resources/sprites/osa_stdlib_sprites.json"

TUPADR3_STANDARD_LIB_FOLDER = "/tupadr3/"
TUPADR3_STANDARD_LIB_FOLDER = "/tupadr3/"
TUPADR3_OUTPUT_FILE_PATH = "../src/main/resources/sprites/tupadr3_stdlib_sprites.json"

# violet
Expand Down Expand Up @@ -128,12 +130,7 @@ def write_sprite_set(
f.write(json.dumps(sprite_set))


def create_sprites(
paths,
color_function,
name_function,
reference_function
):
def create_sprites(paths, color_function, name_function, reference_function):
json_sprites = []
for path in paths:
category = path.split("/")[1]
Expand Down Expand Up @@ -169,19 +166,19 @@ def process_sprite_folder(
additional_includes=None,
color_function=None,
name_function=default_name_function,
reference_function=None
reference_function=None,
):
paths = parse_paths(STANDARD_LIB_FOLDER+sprite_source_folder, sprite_fileending)
paths = parse_paths(STANDARD_LIB_FOLDER + sprite_source_folder, sprite_fileending)
json_sprites = create_sprites(
paths=paths,
color_function=color_function,
name_function=name_function,
reference_function=reference_function
reference_function=reference_function,
)
write_sprite_set(
output_file=output_file,
sprite_set_name=sprite_set_name,
sprite_set_source=STANDARD_LIB_FOLDER_URL+sprite_source_folder,
sprite_set_source=STANDARD_LIB_FOLDER_URL + sprite_source_folder,
json_sprites=json_sprites,
additional_includes=additional_includes,
)
Expand Down Expand Up @@ -242,7 +239,7 @@ def process_sprite_folder(
sprite_source_folder=MATERIAL_STANDARD_LIB_FOLDER,
output_file=MATERIAL_OUTPUT_FILE_PATH,
sprite_set_name="Google Material plantuml-stdlib Sprites",
reference_function=lambda path: "ma_"+path.split("/")[-1]
reference_function=lambda path: "ma_" + path.split("/")[-1],
)

process_sprite_folder(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.chriskn.structurizrextension.api.view

import com.github.chriskn.structurizrextension.api.view.layout.C4PlantUmlLayout
import com.github.chriskn.structurizrextension.api.view.layout.LayoutRegistry
import com.github.chriskn.structurizrextension.internal.view.layout.LayoutRegistry
import com.structurizr.model.Container
import com.structurizr.model.SoftwareSystem
import com.structurizr.view.ComponentView
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.github.chriskn.structurizrextension.internal.export

import com.github.chriskn.structurizrextension.api.view.layout.LayoutRegistry
import com.github.chriskn.structurizrextension.internal.export.view.ComponentViewExporter
import com.github.chriskn.structurizrextension.internal.export.view.ContainerViewExporter
import com.github.chriskn.structurizrextension.internal.export.view.DeploymentViewExporter
Expand All @@ -13,6 +12,7 @@ import com.github.chriskn.structurizrextension.internal.export.writer.HeaderWrit
import com.github.chriskn.structurizrextension.internal.export.writer.PropertyWriter
import com.github.chriskn.structurizrextension.internal.export.writer.StyleWriter
import com.github.chriskn.structurizrextension.internal.export.writer.relationship.RelationshipWriter
import com.github.chriskn.structurizrextension.internal.view.layout.LayoutRegistry
import com.structurizr.export.AbstractDiagramExporter
import com.structurizr.export.Diagram
import com.structurizr.export.IndentingWriter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.github.chriskn.structurizrextension.internal.export.writer

import com.github.chriskn.structurizrextension.api.view.layout.C4PlantUmlLayout
import com.github.chriskn.structurizrextension.api.view.layout.LayoutRegistry
import com.github.chriskn.structurizrextension.api.view.layout.Legend
import com.github.chriskn.structurizrextension.internal.view.layout.LayoutRegistry
import com.structurizr.export.IndentingWriter
import com.structurizr.view.ModelView

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import com.github.chriskn.structurizrextension.api.icons.IconRegistry
import com.github.chriskn.structurizrextension.api.model.icon
import com.github.chriskn.structurizrextension.api.model.sprite
import com.github.chriskn.structurizrextension.api.view.dynamic.renderAsSequenceDiagram
import com.github.chriskn.structurizrextension.api.view.layout.LayoutRegistry
import com.github.chriskn.structurizrextension.api.view.sprite.sprites.PlantUmlSprite
import com.github.chriskn.structurizrextension.api.view.style.styles.BoundaryStyle
import com.github.chriskn.structurizrextension.api.view.style.styles.DependencyStyle
import com.github.chriskn.structurizrextension.api.view.style.styles.ElementStyle
import com.github.chriskn.structurizrextension.api.view.style.styles.PersonStyle
import com.github.chriskn.structurizrextension.internal.view.layout.LayoutRegistry
import com.structurizr.export.IndentingWriter
import com.structurizr.model.DeploymentNode
import com.structurizr.model.ModelItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package com.github.chriskn.structurizrextension.internal.export.writer.relations
import com.github.chriskn.structurizrextension.api.model.link
import com.github.chriskn.structurizrextension.api.view.dynamic.renderAsSequenceDiagram
import com.github.chriskn.structurizrextension.api.view.layout.DependencyConfiguration
import com.github.chriskn.structurizrextension.api.view.layout.LayoutRegistry
import com.github.chriskn.structurizrextension.api.view.layout.Mode
import com.github.chriskn.structurizrextension.internal.export.idOf
import com.github.chriskn.structurizrextension.internal.export.writer.PropertyWriter
import com.github.chriskn.structurizrextension.internal.export.writer.getUsedIconOrSprite
import com.github.chriskn.structurizrextension.internal.export.writer.linkString
import com.github.chriskn.structurizrextension.internal.view.layout.LayoutRegistry
import com.structurizr.export.IndentingWriter
import com.structurizr.model.InteractionStyle
import com.structurizr.model.Relationship
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.github.chriskn.structurizrextension.api.view.layout
package com.github.chriskn.structurizrextension.internal.view.layout

object LayoutRegistry {
import com.github.chriskn.structurizrextension.api.view.layout.C4PlantUmlLayout

internal object LayoutRegistry {

private val keyToLayout = mutableMapOf<String, C4PlantUmlLayout>()

Expand Down
Loading
Loading