diff --git a/.github/workflows/blockdiag-ci.yaml b/.github/workflows/blockdiag-ci.yaml deleted file mode 100644 index 726f1c84a..000000000 --- a/.github/workflows/blockdiag-ci.yaml +++ /dev/null @@ -1,29 +0,0 @@ -name: BlockDiag CI - -on: - push: - paths: - - 'blockdiag/**' - branches: - - main - pull_request: - paths: - - 'blockdiag/**' - branches: - - '*' - -jobs: - blockdiag-ci: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: '3.11' - cache: 'pip' # caching pip dependencies - - name: Install BlockDiag - run: make install - working-directory: blockdiag - - name: Test BlockDiag - run: make test - working-directory: blockdiag diff --git a/.github/workflows/cve-scan.yml b/.github/workflows/cve-scan.yml index d9d3caccd..0f6c5c061 100644 --- a/.github/workflows/cve-scan.yml +++ b/.github/workflows/cve-scan.yml @@ -10,7 +10,7 @@ jobs: continue-on-error: true strategy: matrix: - image: [ kroki, kroki-mermaid, kroki-bpmn, kroki-excalidraw, kroki-blockdiag, kroki-diagramsnet, kroki-wireviz ] + image: [ kroki, kroki-mermaid, kroki-bpmn, kroki-excalidraw, kroki-diagramsnet, kroki-wireviz ] tag: [ latest ] steps: - name: Run Trivy vulnerability scanner diff --git a/.github/workflows/dockerhub-description.yml b/.github/workflows/dockerhub-description.yml index d6c06ee7a..c1dda1b69 100644 --- a/.github/workflows/dockerhub-description.yml +++ b/.github/workflows/dockerhub-description.yml @@ -47,15 +47,6 @@ jobs: short-description: Companion server for Kroki that provides Mermaid readme-filepath: ./DOCKERHUB-COMPANION.md - - name: Docker Hub Description - blockdiag - uses: peter-evans/dockerhub-description@v3.4.2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - repository: yuzutech/kroki-blockdiag - short-description: Companion server for Kroki that provides BlockDiag, SeqDiag, ActDiag, NwDiag, PacketDiag and RackDiag - readme-filepath: ./DOCKERHUB-COMPANION.md - - name: Docker Hub Description - diagramsnet uses: peter-evans/dockerhub-description@v3.4.2 with: diff --git a/DOCKERHUB.md b/DOCKERHUB.md index e99240717..6ac3d88da 100644 --- a/DOCKERHUB.md +++ b/DOCKERHUB.md @@ -29,24 +29,19 @@ This image includes `EXPOSE 8000` (the kroki port), so standard container linkin #### connect with companion containers We recommend using docker-composer to connect with companion containers, such as -[kroki-bpmn](https://hub.docker.com/r/yuzutech/kroki-bpmn), [kroki-blockdiag](https://hub.docker.com/r/yuzutech/kroki-blockdiag), [kroki-excalidraw](https://hub.docker.com/r/yuzutech/kroki-excalidraw) and [kroki-mermaid](https://hub.docker.com/r/yuzutech/kroki-mermaid) +[kroki-bpmn](https://hub.docker.com/r/yuzutech/kroki-bpmn), [kroki-excalidraw](https://hub.docker.com/r/yuzutech/kroki-excalidraw) and [kroki-mermaid](https://hub.docker.com/r/yuzutech/kroki-mermaid) ``` version: "3" services: core: image: yuzutech/kroki environment: - - KROKI_BLOCKDIAG_HOST=blockdiag - KROKI_MERMAID_HOST=mermaid - KROKI_BPMN_HOST=bpmn - KROKI_EXCALIDRAW_HOST=excalidraw - KROKI_WIREVIZ_HOST=wireviz ports: - "8000:8000" - blockdiag: - image: yuzutech/kroki-blockdiag - ports: - - "8001:8001" mermaid: image: yuzutech/kroki-mermaid ports: @@ -69,7 +64,6 @@ If you don't want to use `docker-compose`, you can configure the host and port f | Container | Host | Port | |--------------------|-------------------------|-------------------------| -| `kroki-blockdiag` | `KROKI_BLOCKDIAG_HOST` | `KROKI_BLOCKDIAG_PORT` | | `kroki-mermaid` | `KROKI_MERMAID_HOST` | `KROKI_MERMAID_PORT` | | `kroki-bpmn` | `KROKI_BPMN_HOST` | `KROKI_BPMN_PORT` | | `kroki-excalidraw` | `KROKI_EXCALIDRAW_HOST` | `KROKI_EXCALIDRAW_PORT` | diff --git a/README.adoc b/README.adoc index 62804be3d..5400d9e06 100644 --- a/README.adoc +++ b/README.adoc @@ -87,9 +87,6 @@ A Node.js CLI on top of the _Nomnoml_ diagram library. vega:: A Node.js CLI on top of the _vega_ diagram library. Also supports Vega-Lite concise grammar. -blockdiag:: -A companion web server written in Python (powered by _Flask_ and _Gunicorn_) that provides _BlockDiag_, _SeqDiag_, _ActDiag_, _NwDiag_, _PacketDiag_ and _RackDiag_ diagrams libraries. - mermaid:: A companion web server written in JavaScript (powered by _micro_) that provides _Mermaid_ diagram library. @@ -137,9 +134,6 @@ Once the Docker images are built, you can run Kroki using `docker`: If you want to use one of the following diagram libraries then you will also need to start the corresponding companion container: -yuzutech/kroki-blockdiag:: -BlockDiag, ActDiag, NwDiag, SeqDiag, PacketDiag, RackDiag - yuzutech/kroki-mermaid:: Mermaid @@ -165,17 +159,12 @@ services: core: image: yuzutech/kroki environment: - - KROKI_BLOCKDIAG_HOST=blockdiag - KROKI_MERMAID_HOST=mermaid - KROKI_BPMN_HOST=bpmn - KROKI_EXCALIDRAW_HOST=excalidraw - KROKI_WIREVIZ_HOST=wireviz ports: - "8000:8000" - blockdiag: - image: yuzutech/kroki-blockdiag - expose: - - "8001" mermaid: image: yuzutech/kroki-mermaid expose: diff --git a/blockdiag/.dockerignore b/blockdiag/.dockerignore deleted file mode 100644 index 9379563cb..000000000 --- a/blockdiag/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -venv-py*/ -test/ -.idea/ diff --git a/blockdiag/.editorconfig b/blockdiag/.editorconfig deleted file mode 100644 index 25ac5ff12..000000000 --- a/blockdiag/.editorconfig +++ /dev/null @@ -1,14 +0,0 @@ -root = true - -[*] -end_of_line = lf -insert_final_newline = true -charset = utf-8 -indent_style = space - -[*.py] -indent_size = 4 - - -[*.svg] -indent_size = 2 \ No newline at end of file diff --git a/blockdiag/.gitignore b/blockdiag/.gitignore deleted file mode 100644 index dfeb86fe5..000000000 --- a/blockdiag/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -venv-*/ -*.pyc diff --git a/blockdiag/Dockerfile b/blockdiag/Dockerfile deleted file mode 100644 index b96f3802d..000000000 --- a/blockdiag/Dockerfile +++ /dev/null @@ -1,25 +0,0 @@ -FROM python:3.11.4-alpine3.18 - -RUN addgroup -g 1000 kroki && adduser -D -G kroki -u 1000 kroki - -# add runtime dependency -RUN apk --update --no-cache add jpeg zlib fontconfig ttf-dejavu - -ENV LIBRARY_PATH=/lib:/usr/lib - -WORKDIR /usr/local/kroki - -COPY --chown=kroki:kroki requirements.txt . - -# build -RUN apk --update --no-cache add --virtual build-dependencies build-base python3-dev jpeg-dev zlib-dev freetype-dev \ - && pip install --no-cache-dir -r requirements.txt \ - && apk del build-dependencies - -COPY --chown=kroki:kroki src . - -EXPOSE 8001 - -USER kroki - -CMD ["gunicorn", "--preload", "--bind", "0.0.0.0:8001", "wsgi"] diff --git a/blockdiag/Makefile b/blockdiag/Makefile deleted file mode 100644 index 07d947ade..000000000 --- a/blockdiag/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -.PHONY: test showExamples - -default: test - -install: requirements.txt - python -m pip install -r requirements.txt - -test: - python -m unittest test/test_diag.py - -showExamples: - $(PYTHON) blockdiag/examples.py diff --git a/blockdiag/README.adoc b/blockdiag/README.adoc deleted file mode 100644 index ad8f8270e..000000000 --- a/blockdiag/README.adoc +++ /dev/null @@ -1,35 +0,0 @@ -= BlockDiag (BlockDiag, SeqDiag, ActDiag, NwDiag, PacketDiag and RackDiag) -:uri-py-venv: https://docs.python.org/3/library/venv.html -:uri-py-releases: https://www.python.org/downloads/releases - -Kroki companion server for diagrams libraries written in Python. - -[NOTE] -==== -The server accepts `POST` requests with the diagram sent as plain text. -It should only be used behind the Kroki gateway. -==== - -== Package - -To get you started quickly, you can build a Docker image: - - $ sudo make package - -Then you can run the server using the following command: - - $ sudo docker run --publish=8001:8001 yuzutech/kroki-blockdiag:latest - -NOTE: We are using the `--publish` option to expose the container's port 8001 on the host's port 8001. - -The server should be running and available at: http://localhost:8001/ - -== Local development - -You will need to install {uri-py-releases}[Python 3.8+] on your machine. -We recommend {uri-py-venv}[creating a virtual environment] to install all the dependencies: - - $ python3.8 -m venv venv-py38 - - $ venv-py38/bin/pip install -r requirements.txt - $ venv-py38/bin/python src/server.py diff --git a/blockdiag/examples.py b/blockdiag/examples.py deleted file mode 100644 index b637afdb0..000000000 --- a/blockdiag/examples.py +++ /dev/null @@ -1,1048 +0,0 @@ -# coding: utf-8 -import base64 -import zlib - - -def encode(source): - return base64.urlsafe_b64encode(zlib.compress(source.encode('utf-8'), 9)).decode('utf-8') - - -def section(title): - print('') - print('') - print('== ' + title) - - -def sample(service, source): - print('\n```' + source + '```') - print('/' + service + '/svg/' + encode(source)) - - -print('= Examples') - -# Svgbob -section('Svgbob') -ascii_art = """ - _____ - / O__] -/ ___] -\ \ - | | - | | - / / - \ \\ - / / -""" -sample('svgbob', ascii_art) - -svgbob_sample = """ -.-------------------------. -| | -| .---.-. .-----. .-----. | -| | .-. | +--> | | <--| | -| | '-' | | <--| +--> | | -| '---'-' '-----' '-----' | -| ascii 2 svg | -| | -'-------------------------' -""" -sample('svgbob', svgbob_sample) - -ascii_internet = """ - .-,( ),-. - ___ _ .-( )-. - [___]|=| -->( ) __________ - /::/ |_| '-( ).-' --->[_...__...°] - '-.( ).-' - \ ____ __ - '--->| | |==| - |____| | | - /::::/ |__| -""" -sample('svgbob', ascii_internet) - -# PlantUML -section('PlantUML') -plantuml_bob_alice = """ -@startuml -Bob -> Alice : hello -@enduml -""" -sample('plantuml', plantuml_bob_alice) - -plantuml_checkout = """ -left to right direction -skinparam packageStyle rectangle -skinparam monochrome true -actor customer -actor clerk -rectangle checkout { - customer -- (checkout) - (checkout) .> (payment) : include - (help) .> (checkout) : extends - (checkout) -- clerk -} -""" -sample('plantuml', plantuml_checkout) - -# RackDiag -section('RackDiag') -rackdiag_sample = """ -rackdiag { - 16U; - 1: UPS [2U]; - 3: DB Server; - 4: Web Server; - 5: Web Server; - 6: Web Server; - 7: Load Balancer; - 8: L3 Switch; -} -""" -sample('rackdiag', rackdiag_sample) - -# PacketDiag -section('PacketDiag') -packetdiag_sample = """ -packetdiag { - colwidth = 32; - node_height = 72; - - 0-15: Source Port; - 16-31: Destination Port; - 32-63: Sequence Number; - 64-95: Acknowledgment Number; - 96-99: Data Offset; - 100-105: Reserved; - 106: URG [rotate = 270]; - 107: ACK [rotate = 270]; - 108: PSH [rotate = 270]; - 109: RST [rotate = 270]; - 110: SYN [rotate = 270]; - 111: FIN [rotate = 270]; - 112-127: Window; - 128-143: Checksum; - 144-159: Urgent Pointer; - 160-191: (Options and Padding); - 192-223: data [colheight = 3]; -} -""" -sample('packetdiag', packetdiag_sample) - -# BlockDiag -section('BlockDiag') -blockdiag_sample = """ -blockdiag { - blockdiag -> generates -> "block-diagrams"; - blockdiag -> is -> "very easy!"; - - blockdiag [color = "greenyellow"]; - "block-diagrams" [color = "pink"]; - "very easy!" [color = "orange"]; -} -""" -sample('blockdiag', blockdiag_sample) - -# SeqDia -section('SeqDiag') -seqdiag_sample = """ -seqdiag { - browser -> webserver [label = "GET /index.html"]; - browser <-- webserver; - browser -> webserver [label = "POST /blog/comment"]; - webserver -> database [label = "INSERT comment"]; - webserver <-- database; - browser <-- webserver; -} -""" -sample('seqdiag', seqdiag_sample) - -# ActDiag -section('ActDiag') -actdiag_sample = """ -{ - write -> convert -> image - - lane user { - label = "User" - write [label = "Writing reST"]; - image [label = "Get diagram IMAGE"]; - } - lane actdiag { - convert [label = "Convert reST to Image"]; - } -} -""" -sample('actdiag', actdiag_sample) - -# NwDiag -section('NwDiag') -nwdiag_sample = """ -nwdiag { - network dmz { - address = "210.x.x.x/24" - - web01 [address = "210.x.x.1"]; - web02 [address = "210.x.x.2"]; - } - network internal { - address = "172.x.x.x/24"; - - web01 [address = "172.x.x.1"]; - web02 [address = "172.x.x.2"]; - db01; - db02; - } -} -""" -sample('nwdiag', nwdiag_sample) - - -# GraphViz -section('GraphViz') -graphviz_clusters = """ -digraph G { - - subgraph cluster_0 { - style=filled; - color=lightgrey; - node [style=filled,color=white]; - a0 -> a1 -> a2 -> a3; - label = "process #1"; - } - - subgraph cluster_1 { - node [style=filled]; - b0 -> b1 -> b2 -> b3; - label = "process #2"; - color=blue - } - start -> a0; - start -> b0; - a1 -> b3; - b2 -> a3; - a3 -> a0; - a3 -> end; - b3 -> end; - - start [shape=Mdiamond]; - end [shape=Msquare]; -} -""" -sample('graphviz', graphviz_clusters) - -graphviz_unix = """ -digraph "unix" { - graph [ fontname = "Helvetica-Oblique", - fontsize = 36, - label = "\n\n\n\nObject Oriented Graphs\nStephen North, 3/19/93", - size = "6,6" ]; - node [ shape = polygon, - sides = 4, - distortion = "0.0", - orientation = "0.0", - skew = "0.0", - color = white, - style = filled, - fontname = "Helvetica-Outline" ]; - "5th Edition" [sides=9, distortion="0.936354", orientation=28, skew="-0.126818", color=salmon2]; - "6th Edition" [sides=5, distortion="0.238792", orientation=11, skew="0.995935", color=deepskyblue]; - "PWB 1.0" [sides=8, distortion="0.019636", orientation=79, skew="-0.440424", color=goldenrod2]; - LSX [sides=9, distortion="-0.698271", orientation=22, skew="-0.195492", color=burlywood2]; - "1 BSD" [sides=7, distortion="0.265084", orientation=26, skew="0.403659", color=gold1]; - "Mini Unix" [distortion="0.039386", orientation=2, skew="-0.461120", color=greenyellow]; - Wollongong [sides=5, distortion="0.228564", orientation=63, skew="-0.062846", color=darkseagreen]; - Interdata [distortion="0.624013", orientation=56, skew="0.101396", color=dodgerblue1]; - "Unix/TS 3.0" [sides=8, distortion="0.731383", orientation=43, skew="-0.824612", color=thistle2]; - "PWB 2.0" [sides=6, distortion="0.592100", orientation=34, skew="-0.719269", color=darkolivegreen3]; - "7th Edition" [sides=10, distortion="0.298417", orientation=65, skew="0.310367", color=chocolate]; - "8th Edition" [distortion="-0.997093", orientation=50, skew="-0.061117", color=turquoise3]; - "32V" [sides=7, distortion="0.878516", orientation=19, skew="0.592905", color=steelblue3]; - V7M [sides=10, distortion="-0.960249", orientation=32, skew="0.460424", color=navy]; - "Ultrix-11" [sides=10, distortion="-0.633186", orientation=10, skew="0.333125", color=darkseagreen4]; - Xenix [sides=8, distortion="-0.337997", orientation=52, skew="-0.760726", color=coral]; - "UniPlus+" [sides=7, distortion="0.788483", orientation=39, skew="-0.526284", color=darkolivegreen3]; - "9th Edition" [sides=7, distortion="0.138690", orientation=55, skew="0.554049", color=coral3]; - "2 BSD" [sides=7, distortion="-0.010661", orientation=84, skew="0.179249", color=blanchedalmond]; - "2.8 BSD" [distortion="-0.239422", orientation=44, skew="0.053841", color=lightskyblue1]; - "2.9 BSD" [distortion="-0.843381", orientation=70, skew="-0.601395", color=aquamarine2]; - "3 BSD" [sides=10, distortion="0.251820", orientation=18, skew="-0.530618", color=lemonchiffon]; - "4 BSD" [sides=5, distortion="-0.772300", orientation=24, skew="-0.028475", color=darkorange1]; - "4.1 BSD" [distortion="-0.226170", orientation=38, skew="0.504053", color=lightyellow1]; - "4.2 BSD" [sides=10, distortion="-0.807349", orientation=50, skew="-0.908842", color=darkorchid4]; - "4.3 BSD" [sides=10, distortion="-0.030619", orientation=76, skew="0.985021", color=lemonchiffon2]; - "Ultrix-32" [distortion="-0.644209", orientation=21, skew="0.307836", color=goldenrod3]; - "PWB 1.2" [sides=7, distortion="0.640971", orientation=84, skew="-0.768455", color=cyan]; - "USG 1.0" [distortion="0.758942", orientation=42, skew="0.039886", color=blue]; - "CB Unix 1" [sides=9, distortion="-0.348692", orientation=42, skew="0.767058", color=firebrick]; - "USG 2.0" [distortion="0.748625", orientation=74, skew="-0.647656", color=chartreuse4]; - "CB Unix 2" [sides=10, distortion="0.851818", orientation=32, skew="-0.020120", color=greenyellow]; - "CB Unix 3" [sides=10, distortion="0.992237", orientation=29, skew="0.256102", color=bisque4]; - "Unix/TS++" [sides=6, distortion="0.545461", orientation=16, skew="0.313589", color=mistyrose2]; - "PDP-11 Sys V" [sides=9, distortion="-0.267769", orientation=40, skew="0.271226", color=cadetblue1]; - "USG 3.0" [distortion="-0.848455", orientation=44, skew="0.267152", color=bisque2]; - "Unix/TS 1.0" [distortion="0.305594", orientation=75, skew="0.070516", color=orangered]; - "TS 4.0" [sides=10, distortion="-0.641701", orientation=50, skew="-0.952502", color=crimson]; - "System V.0" [sides=9, distortion="0.021556", orientation=26, skew="-0.729938", color=darkorange1]; - "System V.2" [sides=6, distortion="0.985153", orientation=33, skew="-0.399752", color=darkolivegreen4]; - "System V.3" [sides=7, distortion="-0.687574", orientation=58, skew="-0.180116", color=lightsteelblue1]; - "5th Edition" -> "6th Edition"; - "5th Edition" -> "PWB 1.0"; - "6th Edition" -> LSX; - "6th Edition" -> "1 BSD"; - "6th Edition" -> "Mini Unix"; - "6th Edition" -> Wollongong; - "6th Edition" -> Interdata; - Interdata -> "Unix/TS 3.0"; - Interdata -> "PWB 2.0"; - Interdata -> "7th Edition"; - "7th Edition" -> "8th Edition"; - "7th Edition" -> "32V"; - "7th Edition" -> V7M; - "7th Edition" -> "Ultrix-11"; - "7th Edition" -> Xenix; - "7th Edition" -> "UniPlus+"; - V7M -> "Ultrix-11"; - "8th Edition" -> "9th Edition"; - "1 BSD" -> "2 BSD"; - "2 BSD" -> "2.8 BSD"; - "2.8 BSD" -> "Ultrix-11"; - "2.8 BSD" -> "2.9 BSD"; - "32V" -> "3 BSD"; - "3 BSD" -> "4 BSD"; - "4 BSD" -> "4.1 BSD"; - "4.1 BSD" -> "4.2 BSD"; - "4.1 BSD" -> "2.8 BSD"; - "4.1 BSD" -> "8th Edition"; - "4.2 BSD" -> "4.3 BSD"; - "4.2 BSD" -> "Ultrix-32"; - "PWB 1.0" -> "PWB 1.2"; - "PWB 1.0" -> "USG 1.0"; - "PWB 1.2" -> "PWB 2.0"; - "USG 1.0" -> "CB Unix 1"; - "USG 1.0" -> "USG 2.0"; - "CB Unix 1" -> "CB Unix 2"; - "CB Unix 2" -> "CB Unix 3"; - "CB Unix 3" -> "Unix/TS++"; - "CB Unix 3" -> "PDP-11 Sys V"; - "USG 2.0" -> "USG 3.0"; - "USG 3.0" -> "Unix/TS 3.0"; - "PWB 2.0" -> "Unix/TS 3.0"; - "Unix/TS 1.0" -> "Unix/TS 3.0"; - "Unix/TS 3.0" -> "TS 4.0"; - "Unix/TS++" -> "TS 4.0"; - "CB Unix 3" -> "TS 4.0"; - "TS 4.0" -> "System V.0"; - "System V.0" -> "System V.2"; - "System V.2" -> "System V.3"; -} -""" - -sample('graphviz', graphviz_unix) - -graphviz_hello = """digraph G {Hello->World}""" -sample('graphviz', graphviz_hello) - -# Erd -section('Erd') -erd_person = """ -[Person] -*name -height -weight -+birth_location_id - -[Location] -*id -city -state -country - -Person *--1 Location -""" -sample('erd', erd_person) - -# Ditaa -section('Ditaa') -ditaa = """ - +-------------+ - | | - | Exponential | - | | - +-------------+ - | - lambda | - v -+-------------+ +-------------+ +-------------+ -| | tau | | lambda | | -| Lognormal |---------->| Gamma |<----------| Poisson | -| | | |---+ | | -+-------------+ +-------------+ | +-------------+ - | ^ ^ | beta - | tau | | | - | tau | +---------+ - | +-------------+ - +------------------>| | - | Normal | - | |----+ - +-------------+ | - ^ | mu - | | - +-------+ -""" - -sample('ditaa', ditaa) - -# Symbolator -section('Symbolator') -symbolator = """ -module demo_device #( - //# {{}} - parameter SIZE = 8, - parameter RESET_ACTIVE_LEVEL = 1 -) ( - //# {{clocks|Clocking}} - input wire clock, - //# {{control|Control signals}} - input wire reset, - input wire enable, - //# {{data|Data ports}} - input wire [SIZE-1:0] data_in, - output wire [SIZE-1:0] data_out -); - // ... -endmodule -""" - -sample('symbolator', symbolator) - -section('C4 PlantUML') -context_bigbank = """ -@startuml -!include C4_Context.puml - -LAYOUT_WITH_LEGEND - -title System Context diagram for Internet Banking System - -Person(customer, "Personal Banking Customer", "A customer of the bank, with personal bank accounts.") -System(banking_system, "Internet Banking System", "Allows customers to view information about their bank accounts, and make payments.") - -System_Ext(mail_system, "E-mail system", "The internal Microsoft Exchange e-mail system.") -System_Ext(mainframe, "Mainframe Banking System", "Stores all of the core banking information about customers, accounts, transactions, etc.") - -Rel(customer, banking_system, "Uses") -Rel_Back(customer, mail_system, "Sends e-mails to") -Rel_Neighbor(banking_system, mail_system, "Sends e-mails", "SMTP") -Rel(banking_system, mainframe, "Uses") -@enduml -""" -print('\n=== C4 Context') -sample('c4plantuml', context_bigbank) - -container_bigbank = """ -@startuml -!includeurl https://raw.githubusercontent.com/RicardoNiepel/C4-PlantUML/master/C4_Container.puml - -LAYOUT_TOP_DOWN -'LAYOUT_AS_SKETCH -LAYOUT_WITH_LEGEND - -title Container diagram for Internet Banking System - -Person(customer, Customer, "A customer of the bank, with personal bank accounts") - -System_Boundary(c1, "Internet Banking") { - Container(web_app, "Web Application", "Java, Spring MVC", "Delivers the static content and the Internet banking SPA") - Container(spa, "Single-Page App", "JavaScript, Angular", "Provides all the Internet banking functionality to cutomers via their web browser") - Container(mobile_app, "Mobile App", "C#, Xamarin", "Provides a limited subset of the Internet banking functionality to customers via their mobile device") - ContainerDb(database, "Database", "SQL Database", "Stores user registraion information, hased auth credentials, access logs, etc.") - Container(backend_api, "API Application", "Java, Docker Container", "Provides Internet banking functionality via API") -} - -System_Ext(email_system, "E-Mail System", "The internal Microsoft Exchange system") -System_Ext(banking_system, "Mainframe Banking System", "Stores all of the core banking information about customers, accounts, transactions, etc.") - -Rel(customer, web_app, "Uses", "HTTPS") -Rel(customer, spa, "Uses", "HTTPS") -Rel(customer, mobile_app, "Uses") - -Rel_Neighbor(web_app, spa, "Delivers") -Rel(spa, backend_api, "Uses", "async, JSON/HTTPS") -Rel(mobile_app, backend_api, "Uses", "async, JSON/HTTPS") -Rel_Back_Neighbor(database, backend_api, "Reads from and writes to", "sync, JDBC") - -Rel_Back(customer, email_system, "Sends e-mails to") -Rel_Back(email_system, backend_api, "Sends e-mails using", "sync, SMTP") -Rel_Neighbor(backend_api, banking_system, "Uses", "sync/async, XML/HTTPS") -@enduml -""" -print('\n=== C4 Container') -sample('c4plantuml', container_bigbank) - -comp_bigbank = """ -@startuml -!include c4_component.puml - -LAYOUT_WITH_LEGEND - -title Component diagram for Internet Banking System - API Application - -Container(spa, "Single Page Application", "javascript and angular", "Provides all the internet banking functionality to customers via their web browser.") -Container(ma, "Mobile App", "Xamarin", "Provides a limited subset ot the internet banking functionality to customers via their mobile mobile device.") -ContainerDb(db, "Database", "Relational Database Schema", "Stores user registration information, hashed authentication credentials, access logs, etc.") -System_Ext(mbs, "Mainframe Banking System", "Stores all of the core banking information about customers, accounts, transactions, etc.") - -Container_Boundary(api, "API Application") { - Component(sign, "Sign In Controller", "MVC Rest Controlle", "Allows users to sign in to the internet banking system") - Component(accounts, "Accounts Summary Controller", "MVC Rest Controlle", "Provides customers with a summory of their bank accounts") - Component(security, "Security Component", "Spring Bean", "Provides functionality related to singing in, changing passwords, etc.") - Component(mbsfacade, "Mainframe Banking System Facade", "Spring Bean", "A facade onto the mainframe banking system.") - - Rel(sign, security, "Uses") - Rel(accounts, mbsfacade, "Uses") - Rel(security, db, "Read & write to", "JDBC") - Rel(mbsfacade, mbs, "Uses", "XML/HTTPS") -} - -Rel(spa, sign, "Uses", "JSON/HTTPS") -Rel(spa, accounts, "Uses", "JSON/HTTPS") - -Rel(ma, sign, "Uses", "JSON/HTTPS") -Rel(ma, accounts, "Uses", "JSON/HTTPS") -@enduml -""" -print('\n=== C4 Component') -sample('c4plantuml', comp_bigbank) - -# Nomnoml -section('Nomnoml') -nomnoml_sample=""" -[Pirate|eyeCount: Int|raid();pillage()| - [beard]--[parrot] - [beard]-:>[foul mouth] -] - -[Marauder]<:--[Pirate] -[Pirate]- 0..7[mischief] -[jollyness]->[Pirate] -[jollyness]->[rum] -[jollyness]->[singing] -[Pirate]-> *[rum|tastiness: Int|swig()] -[Pirate]->[singing] -[singing]<->[rum] - -[st]->[plunder] -[plunder]->[more loot] -[more loot]->[st] -[more loot] no ->[e] - -[Sailor] - [shiver me;timbers] -""" -sample('nomnoml', nomnoml_sample) - -# Mermaid -section('Mermaid') -mermaid_flowchart_sample=""" -graph TD; - A-->B; - A-->C; - B-->D; - C-->D; -""" -sample('mermaid', mermaid_flowchart_sample) - -mermaid_seqdiag_sample=""" -sequenceDiagram - participant Alice - participant Bob - Alice->John: Hello John, how are you? - loop Healthcheck - John->John: Fight against hypochondria - end - Note right of John: Rational thoughts
prevail... - John-->Alice: Great! - John->Bob: How about you? - Bob-->John: Jolly good! -""" -sample('mermaid', mermaid_seqdiag_sample) - -mermaid_gant_sample=""" -gantt - dateFormat YYYY-MM-DD - title Adding GANTT diagram functionality to mermaid - section A section - Completed task :done, des1, 2014-01-06,2014-01-08 - Active task :active, des2, 2014-01-09, 3d - Future task : des3, after des2, 5d - Future task2 : des4, after des3, 5d - section Critical tasks - Completed task in the critical line :crit, done, 2014-01-06,24h - Implement parser and jison :crit, done, after des1, 2d - Create tests for parser :crit, active, 3d - Future task in critical line :crit, 5d - Create tests for renderer :2d - Add to mermaid :1d -""" -sample('mermaid', mermaid_gant_sample) - -# UMlet -section('UMlet') -umlet_analysis = """ -com.umlet.element.base.Relation39016090120lt=-70;100;20;20com.umlet.element.base.Relation3902409080lt=-70;20;20;60com.umlet.element.custom.ThreeWayRelation4602503020transparentSelection=falsecom.umlet.element.base.Relation4702409040lt=-70;20;20;20com.umlet.element.base.Relation36016040160lt=<- -r1=to20;140;20;20com.umlet.element.base.Class31030010030AirporttransparentSelection=falsecom.umlet.element.base.Relation32016040160lt=<- - -r1=from20;140;20;20com.umlet.element.base.Class030010030MilesAccounttransparentSelection=falsecom.umlet.element.base.Relation40015018040lt=- -m1=1 -r2=fh -m2=*20;20;160;20com.umlet.element.base.Relation8014026040lt=- -r1=passagengers -m1=* -r2=flights -m2=*20;20;240;20com.umlet.element.base.Class015010030PassengertransparentSelection=falsecom.umlet.element.base.Relation2202057160lt=. -r1=booking28;20;28;140com.umlet.element.base.Relation35060184114lt=- -<connectingFlights -m1=*20;84;20;34;100;34;100;74;70;94com.umlet.element.base.Class56015011030FlightHandlingtransparentSelection=falsecom.umlet.element.base.Class54024010030AirlinetransparentSelection=falsecom.umlet.element.base.Class32015010030FlighttransparentSelection=falsecom.umlet.element.base.Class2001010030BookingtransparentSelection=falsecom.umlet.element.base.Relation3016040160lt=<- -m1=0..1 -r1=mk20;140;20;20 -""" - -print('\n=== Analysis') -print('/umlet/svg/' + encode(umlet_analysis)) - -umlet_object = """ -com.umlet.element.base.Class350290160110_tp2:TravelPart_ --- -dep=2003-09-23 -arr=2003-09-23 -...com.umlet.element.base.Class70290160110_cp2: ConnPart_ --- -von="LHR" -nach="LA" -flNr="NZ4550V"com.umlet.element.base.Class670290240110_tp2: TravelPart_ --- -gate="A55" -...com.umlet.element.base.Class670160240110_tp1: TravelPart_ --- -gate="D12" -...com.umlet.element.base.Class57010180110_th4711: TravelHandling_ --- -numOfBags=2com.umlet.element.base.Relation49036020040lt=>- -r2=_travel_180;20;20;20com.umlet.element.base.Relation49021020040lt=>- -r2=_travel_180;20;20;20com.umlet.element.base.Relation4303016040lt=>- -r2=_travel_140;20;20;20com.umlet.element.base.Class350160160110_tp1: TravelPart_ --- -dep=2003-09-23 -arr=2003-09-23 -...com.umlet.element.base.Relation21036016040lt=>- -r2=_conn_140;20;20;20com.umlet.element.base.Relation21022016040lt=>- -r2=_conn_140;20;20;20com.umlet.element.base.Class29010160110_t42: Travel_ --- -dep=2003-09-23 -arr=2003-09-24 -class="Economy"com.umlet.element.base.Class70160160110_cp1: ConnPart_ --- -from="MUC" -to="LHR" -flNr="LH4754"com.umlet.element.base.Relation1503016040lt=>- -r2=_conn_140;20;20;20com.umlet.element.base.Class1010160110_c42: Connection_ --- -from="MUC" -to="AKL" -dep=07:45 -arr=06:30 (+24) -status="planned"com.umlet.element.base.Relation580100110270lt=<<<<-20;20;20;250;90;250com.umlet.element.base.Relation580100110110lt=<<<<-20;20;20;90;90;90com.umlet.element.base.Relation29010080120lt=<<<<-20;20;20;100;60;100com.umlet.element.base.Relation29010080280lt=<<<<-20;20;20;260;60;260com.umlet.element.base.Relation1010084290lt=<<<<-20;20;20;270;64;270com.umlet.element.base.Relation1010080120lt=<<<<-20;20;20;100;60;100 -""" - -print('\n=== Object') -print('/umlet/svg/' + encode(umlet_object)) - -umlet_struct = """ -com.umlet.element.base.Relation50340200160lt=<[GUI]180;140;20;20com.umlet.element.base.Relation52036040100lt=<[=][SQL]>20;20;20;80com.umlet.element.base.Relation580180130110lt=<[GUI]20;20;110;90com.umlet.element.base.Relation5030190190lt=<[GUI]170;170;20;20com.umlet.element.base.Class220150380230Albatros Air AutopilottransparentSelection=falsecom.umlet.element.base.Actor10320107120ground stafftransparentSelection=falsecom.umlet.element.base.Actor2017085120passengertransparentSelection=falsecom.umlet.element.base.Actor1020105120sales partnertransparentSelection=falsecom.umlet.element.base.Actor65024096120bonus partnertransparentSelection=falsecom.umlet.element.base.Class230440380100Air Partner SystemtransparentSelection=falsecom.umlet.element.base.Relation5018019040lt=<[GUI]170;20;20;20com.umlet.element.base.Relation50180190190lt=<[GUI]170;20;110;170;20;170com.umlet.element.base.Actor62090151120partner airlinetransparentSelection=falsecom.umlet.element.base.Relation580110130110lt=<[GUI]20;90;110;20 -""" - -print('\n=== Struct') -print('/umlet/svg/' + encode(umlet_struct)) - -umlet_seq = """ -com.umlet.element.base.SequenceDiagram1010202140Client|Server -1->>>2:call(self,param) -2.>1:number -2->1:receive(num) - -""" - -print('\n=== Sequence') -print('/umlet/svg/' + encode(umlet_seq)) - -umlet_state = """ - - - - com.umlet.element.base.Relation - - 739 - 16 - 232 - 264 - - lt=<- -when(spidersensor="rotate") -/block spider - - 161;244;161;34;71;34;71;74 - - - com.umlet.element.custom.FinalState - - 890 - 260 - 20 - 20 - - - transparentSelection=false - - - com.umlet.element.base.Relation - - 750 - 170 - 160 - 137 - - lt=<- -after (10s) -/ block spider - - 140;100;66;100;66;20 - - - com.umlet.element.custom.State - - 340 - 420 - 100 - 40 - - wait - transparentSelection=false - - - com.umlet.element.custom.HistoryState - - 230 - 440 - 20 - 20 - - - transparentSelection=false - - - com.umlet.element.base.Relation - - 230 - 416 - 130 - 54 - - lt=<- -restart - - 20;34;110;34 - - - com.umlet.element.base.Relation - - 270 - 396 - 90 - 54 - - lt=<- -pause - - 70;34;20;34 - - - com.umlet.element.custom.FinalState - - 90 - 400 - 20 - 20 - - - transparentSelection=false - - - com.umlet.element.base.Relation - - 46 - 256 - 114 - 164 - - lt=<- -after (10s) -/timeout - - 54;144;54;34;94;34 - - - com.umlet.element.base.Relation - - 230 - 110 - 190 - 170 - - lt=<- -timeout - - 20;150;110;150;110;20;170;20 - - - com.umlet.element.custom.State - - 700 - 90 - 180 - 100 - - accept -boarding pass --- -entry/ release card -do/release spider - - transparentSelection=true - - - com.umlet.element.base.Relation - - 540 - 140 - 205 - 100 - - lt=<- -[passenger booked] - - 160;20;120;80;20;80 - - - com.umlet.element.base.Relation - - 450 - 210 - 239 - 190 - - lt=<- -[passenger not booked] - - 219;170;99;170;99;20 - - - com.umlet.element.custom.State - - 670 - 350 - 120 - 50 - - reject -boarding pass - - transparentSelection=false - - - com.umlet.element.base.Relation - - 480 - 130 - 142 - 100 - - lt=<- -result of search - - 71;80;71;20 - - - com.umlet.element.base.Relation - - 270 - 70 - 150 - 40 - - lt=<- - 130;20;20;20 - - - com.umlet.element.custom.ThreeWayRelation - - 540 - 210 - 20 - 20 - - - transparentSelection=false - - - com.umlet.element.custom.State - - 140 - 60 - 150 - 420 - - read boarding pass --- - - transparentSelection=true - - - com.umlet.element.custom.State - - 400 - 60 - 180 - 90 - - check passenger --- -entry/start search -do/blink lamp - - transparentSelection=true - - - com.umlet.element.custom.FinalState - - 170 - 410 - 20 - 20 - - - transparentSelection=false - - - com.umlet.element.custom.State - - 150 - 240 - 100 - 40 - - read -passenger ID - - transparentSelection=false - - - com.umlet.element.custom.State - - 150 - 330 - 100 - 40 - - identify -passenger - - transparentSelection=false - - - com.umlet.element.base.Relation - - 160 - 260 - 40 - 90 - - lt=<- - 20;70;20;20 - - - com.umlet.element.base.Relation - - 160 - 100 - 40 - 70 - - lt=<- - 20;50;20;20 - - - com.umlet.element.base.Relation - - 160 - 350 - 40 - 80 - - lt=<- - 20;60;20;20 - - - com.umlet.element.base.Relation - - 140 - 170 - 78 - 90 - - lt=<- -[valid] - - 39;70;39;20 - - - com.umlet.element.custom.State - - 150 - 150 - 100 - 40 - - check -validity - - transparentSelection=false - - - com.umlet.element.custom.InitialState - - 170 - 100 - 20 - 20 - - - transparentSelection=false - - -""" - -print('\n=== State') -print('/umlet/svg/' + encode(umlet_state)) - -umlet_state_simple = """ -com.umlet.element.base.Relation43190258110lt=< -handle() -passenger.addMiles(flight.miles)129;90;129;20com.umlet.element.base.Relation294623294lt=<- -transfer [Class <> Economy]96;74;116;74;116;34;66;34;66;64com.umlet.element.base.Relation28090297110lt=<- -r2=cancel()277;90;27;90;27;20com.umlet.element.base.Relation7090507110lt=<- -r2=cancel()487;90;27;90;27;20com.umlet.element.custom.State807010040reservedtransparentSelection=falsecom.umlet.element.base.Relation1606015054lt=<- -pay()130;34;20;34com.umlet.element.custom.SeqDestroyMark5501702020transparentSelection=falsecom.umlet.element.custom.State2907010040bookedtransparentSelection=falsecom.umlet.element.base.Relation3706015054lt=<- -start()130;34;20;34com.umlet.element.custom.State5007010040startedtransparentSelection=false""" - -print('\n=== Simple state') -print('/umlet/svg/' + encode(umlet_state_simple)) diff --git a/blockdiag/requirements.txt b/blockdiag/requirements.txt deleted file mode 100644 index c87b42b7b..000000000 --- a/blockdiag/requirements.txt +++ /dev/null @@ -1,15 +0,0 @@ -actdiag==3.0.0 -blockdiag==3.0.0 -Click==8.1.6 -Flask==2.3.2 -funcparserlib==1.0.1 -gunicorn==20.1.0 -itsdangerous==2.1.2 -Jinja2==3.1.2 -MarkupSafe==2.1.3 -nwdiag==3.0.0 -Pillow==9.5.0 -reportlab==3.6.13 -seqdiag==3.0.0 -webcolors==1.13 -Werkzeug==2.3.6 diff --git a/blockdiag/src/backend/__init__.py b/blockdiag/src/backend/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/blockdiag/src/backend/diag.py b/blockdiag/src/backend/diag.py deleted file mode 100644 index 6a08e4a0c..000000000 --- a/blockdiag/src/backend/diag.py +++ /dev/null @@ -1,103 +0,0 @@ -from blockdiag.utils.bootstrap import create_fontmap -from blockdiag.parser import ParseException -from backend.error import GenerateError -import re - -SVG_PREAMBLE_REGEX = re.compile(r'\A.*?(?=]*>') -WIDTH_REGEX = re.compile(r'width="(?P\d+(?:\.\d+)?)(?P[a-zA-Z]+)?"') -HEIGHT_REGEX = re.compile(r'height="(?P\d+(?:\.\d+)?)(?P[a-zA-Z]+)?"') -VIEWBOX_REGEX = re.compile(r'viewBox="\d+(?:\.\d+)? \d+(?:\.\d+)? (?P\d+(?:\.\d+)?) (?P\d+(?:\.\d+)?)"') - - -def set_dimension_attributes(data): - svg_preamble_match = SVG_PREAMBLE_REGEX.match(data) - if svg_preamble_match: - svg_preamble = svg_preamble_match.group(0) - svg = re.sub(SVG_PREAMBLE_REGEX, '', data) - start_tag_match = START_TAG_REGEX.match(svg) - if start_tag_match: - start_tag = start_tag_match.group(0) - width_found = WIDTH_REGEX.search(start_tag) - height_found = HEIGHT_REGEX.search(start_tag) - if height_found and width_found: - # width and height are already present! - return data - - viewbox_found = VIEWBOX_REGEX.search(start_tag) - if viewbox_found: - width = viewbox_found.group('width') - height = viewbox_found.group('height') - new_start_tag = start_tag[:-1] + f' width=\"{width}px\" height=\"{height}px\">' - return svg_preamble + new_start_tag + f'{svg[len(start_tag):-1]}' - - # svg does not match the expected format! - return data - - -def generate_diag(app, diagram_type, output_format, source, options): - output_format = output_format.lower() - cli_options = ['-T' + output_format] - antialias = options.get('antialias') - if antialias is not None: - cli_options.append('--antialias') - - no_transparency = options.get('no-transparency') - if no_transparency is not None and output_format == 'png': - cli_options.append('--no-transparency') - - size = options.get('size') - if size is not None: - cli_options.append('--size=' + size) - - no_doctype = options.get('no-doctype') - if no_doctype is not None and output_format == 'svg': - cli_options.append('--nodoctype') - - cli_options.append('file') - app.parse_options(cli_options) - - app.options.font = [ - '/usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf', - '/usr/share/fonts/dejavu/DejaVuSerif.ttf', - ] - - app.fontmap = create_fontmap(app.options) - app.setup() - - app.code = source - try: - tree = app.module.parser.parse_string(app.code) - try: - diagram = app.module.builder.ScreenNodeBuilder.build(tree, app.options) - except TypeError: - diagram = app.module.builder.ScreenNodeBuilder.build(tree) # old interface - - drawer = app.module.drawer.DiagramDraw(app.options.type, diagram, - None, - fontmap=app.fontmap, - code=app.code, - antialias=app.options.antialias, - nodoctype=app.options.nodoctype, - transparency=app.options.transparency) - drawer.draw() - if output_format == 'png': - png_image = drawer.drawer.save(None, None, drawer.format) - return png_image - elif output_format == 'pdf': - pdf_drawer = drawer.drawer.target - pdf_drawer.canvas.showPage() - binary_pdf = pdf_drawer.canvas.getpdfdata() - return binary_pdf - elif output_format == 'svg': - xml_text = drawer.drawer.save(None, None, drawer.format) - return set_dimension_attributes(xml_text) - except (ParseException, Exception) as err: - raise GenerateError('Unable to generate the ' + diagram_type + ' diagram from source', - status_code=400, - payload={ - 'source': source, - 'output_format': output_format, - 'diagram_type': diagram_type, - 'error': str(err) - }) diff --git a/blockdiag/src/backend/error.py b/blockdiag/src/backend/error.py deleted file mode 100644 index 28ad7c78e..000000000 --- a/blockdiag/src/backend/error.py +++ /dev/null @@ -1,14 +0,0 @@ -class GenerateError(Exception): - status_code = 400 - - def __init__(self, message, status_code=None, payload=None): - Exception.__init__(self) - self.message = message - if status_code is not None: - self.status_code = status_code - self.payload = payload - - def to_dict(self): - rv = dict(self.payload or ()) - rv['message'] = self.message - return rv diff --git a/blockdiag/src/server.py b/blockdiag/src/server.py deleted file mode 100644 index 34ebafc98..000000000 --- a/blockdiag/src/server.py +++ /dev/null @@ -1,181 +0,0 @@ -import io -from flask import Flask, send_file, make_response, jsonify -from rackdiag.command import RackdiagApp -from packetdiag.command import PacketdiagApp -from blockdiag.command import BlockdiagApp -from seqdiag.command import SeqdiagApp -from nwdiag.command import NwdiagApp -from actdiag.command import ActdiagApp -from backend.diag import generate_diag -from backend.error import GenerateError -from flask import request -from rackdiag import __version__ as rackdiag_version -from packetdiag import __version__ as packetdiag_version -from blockdiag import __version__ as blockdiag_version -from actdiag import __version__ as actdiag_version -from nwdiag import __version__ as nwdiag_version -from seqdiag import __version__ as seqdiag_version -from werkzeug.exceptions import default_exceptions -from werkzeug.exceptions import HTTPException - - -def make_json_app(import_name, **kwargs): - """ - Creates a JSON-oriented Flask app. - All error responses that you don't specifically - manage yourself will have application/json content - type, and will contain JSON like this (just an example): - { "message": "405: Method Not Allowed" } - """ - def make_json_error(ex): - response = jsonify({"error": str(ex.description)}) - response.status_code = (ex.code - if isinstance(ex, HTTPException) - else 500) - return response - - app = Flask(import_name, **kwargs) - - for code in iter(default_exceptions.keys()): - app.errorhandler(code)(make_json_error) - - return app - - -application = make_json_app(__name__) - - -class InvalidUsage(Exception): - status_code = 400 - - def __init__(self, error, status_code=None, payload=None): - Exception.__init__(self) - self.error = error - if status_code is not None: - self.status_code = status_code - self.payload = payload - - def to_dict(self): - rv = dict(self.payload or ()) - rv['error'] = self.error - return rv - - -def _generate_diagram(app, diagram_type, output_format, source, options): - try: - output_format = output_format.lower() - if output_format == 'png': - result = generate_diag(app, diagram_type, output_format, source, options) - response = send_file(io.BytesIO(result), - download_name='result.png', - mimetype='image/png') - return response - elif output_format == 'pdf': - result = generate_diag(app, diagram_type, output_format, source, options) - response = make_response(result) - response.headers['Content-Type'] = 'application/pdf' - response.headers['Content-Disposition'] = 'inline; filename=result.pdf' - return response - elif output_format == 'svg': - result = generate_diag(app, diagram_type, output_format, source, options) - response = make_response(result) - response.headers["Content-Type"] = "image/svg+xml; charset=utf-8" - return response - else: - raise InvalidUsage('Unsupported output format: %s. Must be one of: png, svg or pdf.' % output_format, - status_code=400) - except GenerateError as err: - raise err - except Exception as err: - raise GenerateError('Unexpected error', - status_code=500, - payload={ - 'source': source, - 'output_format': output_format, - 'diagram_type': diagram_type, - 'error': str(err) - }) - - -@application.route('/_status', methods=['GET']) -def status(): - return jsonify( - name='blockdiag', - version={ - 'blockdiag': blockdiag_version, - 'actdiag': actdiag_version, - 'nwdiag': nwdiag_version, - 'rackdiag': rackdiag_version, - 'packetdiag': packetdiag_version, - 'seqdiag': seqdiag_version - } - ) - - -@application.route('/rackdiag/', methods=['POST']) -def rackdiag(output_format, source=None): - return _generate_diagram(RackdiagApp(), 'block', output_format, source or request.get_data(as_text=True), request.args) - - -@application.route('/packetdiag/', methods=['POST']) -def packetdiag(output_format, source=None): - return _generate_diagram(PacketdiagApp(), 'block', output_format, source or request.get_data(as_text=True), request.args) - - -@application.route('/blockdiag/', methods=['POST']) -def blockdiag(output_format, source=None): - return _generate_diagram(BlockdiagApp(), 'block', output_format, source or request.get_data(as_text=True), request.args) - - -@application.route('/seqdiag/', methods=['POST']) -def seqdiag(output_format, source=None): - return _generate_diagram(SeqdiagApp(), 'sequence', output_format, source or request.get_data(as_text=True), request.args) - - -@application.route('/actdiag/', methods=['POST']) -def actdiag(output_format, source=None): - return _generate_diagram(ActdiagApp(), 'activity', output_format, source or request.get_data(as_text=True), request.args) - - -@application.route('/nwdiag/', methods=['POST']) -def nwdiag(output_format, source=None): - return _generate_diagram(NwdiagApp(), 'network', output_format, source or request.get_data(as_text=True), request.args) - - -@application.route('/', methods=['POST']) -def diag(output_format): - source = request.get_data(as_text=True) - if source.startswith('blockdiag'): - return blockdiag(output_format, source) - elif source.startswith('seqdiag'): - return seqdiag(output_format, source) - elif source.startswith('actdiag'): - return actdiag(output_format, source) - elif source.startswith('nwdiag'): - return nwdiag(output_format, source) - elif source.startswith('rackdiag'): - return rackdiag(output_format, source) - elif source.startswith('packetdiag'): - return packetdiag(output_format, source) - else: - raise InvalidUsage('Diagram source must begin with one of the following: ' - 'blockdiag, seqdiag, actdiag, nwdiag, packetdiag or rackdiag', - status_code=400) - - -@application.errorhandler(GenerateError) -def handle_generate_error(error): - response = jsonify(error.to_dict()) - response.status_code = error.status_code - return response - - -@application.errorhandler(InvalidUsage) -def handle_invalid_usage(error): - response = jsonify(error.to_dict()) - response.status_code = error.status_code - return response - - -if __name__ == '__main__': - application.run(debug=True, host='0.0.0.0', port=8001) diff --git a/blockdiag/src/wsgi.py b/blockdiag/src/wsgi.py deleted file mode 100644 index b5d6763bc..000000000 --- a/blockdiag/src/wsgi.py +++ /dev/null @@ -1,5 +0,0 @@ -from server import application - -if __name__ == "__main__": - application.run() - diff --git a/blockdiag/test/__init__.py b/blockdiag/test/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/blockdiag/test/fixtures/actdiag_expected.svg b/blockdiag/test/fixtures/actdiag_expected.svg deleted file mode 100644 index 992fa981b..000000000 --- a/blockdiag/test/fixtures/actdiag_expected.svg +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - -blockdiag -{ -write -> convert -> image - -lane user { -label = "User" -write [label = "Writing reST"]; -image [label = "Get diagram IMAGE"]; -} -lane actdiag { -convert [label = "Convert reST to Image"]; -} -} - - - - - -User - -actdiag - - - - -Writing reST - -Convert reST to Image - -Get diagram IMAGE - - - - - - - - - \ No newline at end of file diff --git a/blockdiag/test/fixtures/actdiag_source.txt b/blockdiag/test/fixtures/actdiag_source.txt deleted file mode 100644 index 84cd3f93f..000000000 --- a/blockdiag/test/fixtures/actdiag_source.txt +++ /dev/null @@ -1,12 +0,0 @@ -{ - write -> convert -> image - - lane user { - label = "User" - write [label = "Writing reST"]; - image [label = "Get diagram IMAGE"]; - } - lane actdiag { - convert [label = "Convert reST to Image"]; - } -} diff --git a/blockdiag/test/fixtures/blockdiag_expected.svg b/blockdiag/test/fixtures/blockdiag_expected.svg deleted file mode 100644 index 72fe68273..000000000 --- a/blockdiag/test/fixtures/blockdiag_expected.svg +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - -blockdiag -blockdiag { -blockdiag -> generates -> "block-diagrams"; -blockdiag -> is -> "very easy!"; - -blockdiag [color = "greenyellow"]; -"block-diagrams" [color = "pink"]; -"very easy!" [color = "orange"]; -} - - - - - - - -blockdiag - -generates - -is - -block-diagrams - -very easy! - - - - - - - - - - - \ No newline at end of file diff --git a/blockdiag/test/fixtures/blockdiag_options_expected.svg b/blockdiag/test/fixtures/blockdiag_options_expected.svg deleted file mode 100644 index cac11e1f8..000000000 --- a/blockdiag/test/fixtures/blockdiag_options_expected.svg +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - -blockdiag -blockdiag { -blockdiag -> generates -> "block-diagrams"; -blockdiag -> is -> "very easy!"; - -blockdiag [color = "greenyellow"]; -"block-diagrams" [color = "pink"]; -"very easy!" [color = "orange"]; -} - - - - - - - -blockdiag - -generates - -is - -block-diagrams - -very easy! - - - - - - - - - - - \ No newline at end of file diff --git a/blockdiag/test/fixtures/blockdiag_options_source.txt b/blockdiag/test/fixtures/blockdiag_options_source.txt deleted file mode 100644 index d967efd8c..000000000 --- a/blockdiag/test/fixtures/blockdiag_options_source.txt +++ /dev/null @@ -1,8 +0,0 @@ -blockdiag { - blockdiag -> generates -> "block-diagrams"; - blockdiag -> is -> "very easy!"; - - blockdiag [color = "greenyellow"]; - "block-diagrams" [color = "pink"]; - "very easy!" [color = "orange"]; -} diff --git a/blockdiag/test/fixtures/blockdiag_source.txt b/blockdiag/test/fixtures/blockdiag_source.txt deleted file mode 100644 index d967efd8c..000000000 --- a/blockdiag/test/fixtures/blockdiag_source.txt +++ /dev/null @@ -1,8 +0,0 @@ -blockdiag { - blockdiag -> generates -> "block-diagrams"; - blockdiag -> is -> "very easy!"; - - blockdiag [color = "greenyellow"]; - "block-diagrams" [color = "pink"]; - "very easy!" [color = "orange"]; -} diff --git a/blockdiag/test/fixtures/blockdiag_utf8_expected.svg b/blockdiag/test/fixtures/blockdiag_utf8_expected.svg deleted file mode 100644 index 72b5cf5f6..000000000 --- a/blockdiag/test/fixtures/blockdiag_utf8_expected.svg +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - -blockdiag -blockdiag admin { -// Set M17N text using label property. -A [label = "起"]; -B [label = "承"]; -C [label = "転"]; -D [label = "結"]; - -A -> B -> C -> D; - -// Use M17N text directly (need to quote). -春 -> 夏 -> 秋 -> 冬; - -// Use M17N text including symbol characters (need to quote). -"春は 曙" -> "夏 = 夜" -> "秋.夕暮れ" -> "冬 & つとめて"; -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -春は 曙 - -夏 = 夜 - -秋.夕暮れ - -冬 & つとめて - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/blockdiag/test/fixtures/blockdiag_utf8_source.txt b/blockdiag/test/fixtures/blockdiag_utf8_source.txt deleted file mode 100644 index a90fb7d8a..000000000 --- a/blockdiag/test/fixtures/blockdiag_utf8_source.txt +++ /dev/null @@ -1,15 +0,0 @@ -blockdiag admin { - // Set M17N text using label property. - A [label = "起"]; - B [label = "承"]; - C [label = "転"]; - D [label = "結"]; - - A -> B -> C -> D; - - // Use M17N text directly (need to quote). - 春 -> 夏 -> 秋 -> 冬; - - // Use M17N text including symbol characters (need to quote). - "春は 曙" -> "夏 = 夜" -> "秋.夕暮れ" -> "冬 & つとめて"; -} diff --git a/blockdiag/test/fixtures/nwdiag_expected.svg b/blockdiag/test/fixtures/nwdiag_expected.svg deleted file mode 100644 index 54ad66c15..000000000 --- a/blockdiag/test/fixtures/nwdiag_expected.svg +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - -blockdiag -nwdiag { -network dmz { -address = "210.x.x.x/24" - -web01 [address = "210.x.x.1"]; -web02 [address = "210.x.x.2"]; -} -network internal { -address = "172.x.x.x/24"; - -web01 [address = "172.x.x.1"]; -web02 [address = "172.x.x.2"]; -db01; -db02; -} -} - - - - - - - - - - - - - - -dmz -210.x.x.x/24 -internal -172.x.x.x/24 - -210.x.x.1 - -172.x.x.1 - -web01 - -210.x.x.2 - -172.x.x.2 - -web02 - - -db01 - - -db02 - \ No newline at end of file diff --git a/blockdiag/test/fixtures/nwdiag_source.txt b/blockdiag/test/fixtures/nwdiag_source.txt deleted file mode 100644 index 998b9310e..000000000 --- a/blockdiag/test/fixtures/nwdiag_source.txt +++ /dev/null @@ -1,16 +0,0 @@ -nwdiag { - network dmz { - address = "210.x.x.x/24" - - web01 [address = "210.x.x.1"]; - web02 [address = "210.x.x.2"]; - } - network internal { - address = "172.x.x.x/24"; - - web01 [address = "172.x.x.1"]; - web02 [address = "172.x.x.2"]; - db01; - db02; - } -} diff --git a/blockdiag/test/fixtures/packetdiag_expected.svg b/blockdiag/test/fixtures/packetdiag_expected.svg deleted file mode 100644 index 07130dfc3..000000000 --- a/blockdiag/test/fixtures/packetdiag_expected.svg +++ /dev/null @@ -1,183 +0,0 @@ - - - - - - - - -blockdiag -packetdiag { -colwidth = 32; -node_height = 72; - -0-15: Source Port; -16-31: Destination Port; -32-63: Sequence Number; -64-95: Acknowledgment Number; -96-99: Data Offset; -100-105: Reserved; -106: URG [rotate = 270]; -107: ACK [rotate = 270]; -108: PSH [rotate = 270]; -109: RST [rotate = 270]; -110: SYN [rotate = 270]; -111: FIN [rotate = 270]; -112-127: Window; -128-143: Checksum; -144-159: Urgent Pointer; -160-191: (Options and Padding); -192-223: data [colheight = 3]; -} - - -0 - - - - - - - - - - - - - - - - -16 - - - - - - - - - - - - - - - - -32 - - - - - -Source Port - - - - - -Destination Port - - - - - -Sequence Number - - - - - -Acknowledgment Number - - - - - -Data Offset - - - - - -Reserved - - - - - - -URG - - - - - - - -ACK - - - - - - - -PSH - - - - - - - -RST - - - - - - - -SYN - - - - - - - -FIN - - - - - - -Window - - - - - -Checksum - - - - - -Urgent Pointer - - - - - -(Options and Padding) - - - - - -data - \ No newline at end of file diff --git a/blockdiag/test/fixtures/packetdiag_source.txt b/blockdiag/test/fixtures/packetdiag_source.txt deleted file mode 100644 index 4dd4a228d..000000000 --- a/blockdiag/test/fixtures/packetdiag_source.txt +++ /dev/null @@ -1,22 +0,0 @@ -packetdiag { - colwidth = 32; - node_height = 72; - - 0-15: Source Port; - 16-31: Destination Port; - 32-63: Sequence Number; - 64-95: Acknowledgment Number; - 96-99: Data Offset; - 100-105: Reserved; - 106: URG [rotate = 270]; - 107: ACK [rotate = 270]; - 108: PSH [rotate = 270]; - 109: RST [rotate = 270]; - 110: SYN [rotate = 270]; - 111: FIN [rotate = 270]; - 112-127: Window; - 128-143: Checksum; - 144-159: Urgent Pointer; - 160-191: (Options and Padding); - 192-223: data [colheight = 3]; -} diff --git a/blockdiag/test/fixtures/rackdiag_expected.svg b/blockdiag/test/fixtures/rackdiag_expected.svg deleted file mode 100644 index bd9471efd..000000000 --- a/blockdiag/test/fixtures/rackdiag_expected.svg +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - -blockdiag -rackdiag { -16U; -1: UPS [2U]; -3: DB Server; -4: Web Server; -5: Web Server; -6: Web Server; -7: Load Balancer; -8: L3 Switch; -} - - - -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 - -UPS -[2U] - -DB Server - -Web Server - -Web Server - -Web Server - -Load Balancer - -L3 Switch - \ No newline at end of file diff --git a/blockdiag/test/fixtures/rackdiag_source.txt b/blockdiag/test/fixtures/rackdiag_source.txt deleted file mode 100644 index a91cae8e0..000000000 --- a/blockdiag/test/fixtures/rackdiag_source.txt +++ /dev/null @@ -1,10 +0,0 @@ -rackdiag { - 16U; - 1: UPS [2U]; - 3: DB Server; - 4: Web Server; - 5: Web Server; - 6: Web Server; - 7: Load Balancer; - 8: L3 Switch; -} diff --git a/blockdiag/test/fixtures/seqdiag_expected.svg b/blockdiag/test/fixtures/seqdiag_expected.svg deleted file mode 100644 index 7c4adaed2..000000000 --- a/blockdiag/test/fixtures/seqdiag_expected.svg +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - -blockdiag -seqdiag { -browser -> webserver [label = "GET /index.html"]; -browser <-- webserver; -browser -> webserver [label = "POST /blog/comment"]; -webserver -> database [label = "INSERT comment"]; -webserver <-- database; -browser <-- webserver; -} - - - - - - - - - - - - - - - - -browser - -webserver - -database - - - - - - - - - - - - -GET /index.html -POST /blog/comment -INSERT comment - \ No newline at end of file diff --git a/blockdiag/test/fixtures/seqdiag_issue_134_expected.svg b/blockdiag/test/fixtures/seqdiag_issue_134_expected.svg deleted file mode 100644 index 790023712..000000000 --- a/blockdiag/test/fixtures/seqdiag_issue_134_expected.svg +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - -blockdiag -seqdiag { -start [label = "Contract"] -start [label = "End"] -start -> stage1 [label = "1st"]; -stage1 -> stage2 [label = "2st"]; -} - - - - - - - - - - - - - - -End - -stage1 - -stage2 - - - - -1st -2st - \ No newline at end of file diff --git a/blockdiag/test/fixtures/seqdiag_issue_134_source.txt b/blockdiag/test/fixtures/seqdiag_issue_134_source.txt deleted file mode 100644 index ab66971b0..000000000 --- a/blockdiag/test/fixtures/seqdiag_issue_134_source.txt +++ /dev/null @@ -1,6 +0,0 @@ -seqdiag { - start [label = "Contract"] - start [label = "End"] - start -> stage1 [label = "1st"]; - stage1 -> stage2 [label = "2st"]; -} diff --git a/blockdiag/test/fixtures/seqdiag_source.txt b/blockdiag/test/fixtures/seqdiag_source.txt deleted file mode 100644 index 1a4667054..000000000 --- a/blockdiag/test/fixtures/seqdiag_source.txt +++ /dev/null @@ -1,8 +0,0 @@ -seqdiag { - browser -> webserver [label = "GET /index.html"]; - browser <-- webserver; - browser -> webserver [label = "POST /blog/comment"]; - webserver -> database [label = "INSERT comment"]; - webserver <-- database; - browser <-- webserver; -} diff --git a/blockdiag/test/test_diag.py b/blockdiag/test/test_diag.py deleted file mode 100644 index 1b5e3ea5d..000000000 --- a/blockdiag/test/test_diag.py +++ /dev/null @@ -1,97 +0,0 @@ -import unittest -import sys - -from rackdiag.command import RackdiagApp -from packetdiag.command import PacketdiagApp -from blockdiag.command import BlockdiagApp -from seqdiag.command import SeqdiagApp -from nwdiag.command import NwdiagApp -from actdiag.command import ActdiagApp -from werkzeug.datastructures import MultiDict - -sys.path.append('src') -from backend.diag import generate_diag -from server import InvalidUsage - - -class TestDiag(unittest.TestCase): - - def _generate(self, filename, diagram_type=None, options=None): - if options is None: - options = MultiDict() - with open('test/fixtures/' + filename + '_source.txt', 'r') as file: - source = file.read() - with open('test/fixtures/' + filename + '_expected.svg', 'r') as file: - lines = file.readlines() - expected = '\n'.join([item.strip() for item in lines]) - - if diagram_type is None: - diagram_type = filename - - if diagram_type == 'nwdiag': - app, name = NwdiagApp(), 'network' - elif diagram_type == 'blockdiag': - app, name = BlockdiagApp(), 'block' - elif diagram_type == 'seqdiag': - app, name = SeqdiagApp(), 'sequence' - elif diagram_type == 'actdiag': - app, name = ActdiagApp(), 'activity' - elif diagram_type == 'packetdiag': - app, name = PacketdiagApp(), 'packet' - elif diagram_type == 'rackdiag': - app, name = RackdiagApp(), 'rack' - else: - raise InvalidUsage('Unknown diagram type: ' + diagram_type) - result = generate_diag(app, name, 'svg', source, options) - actual = '\n'.join([item.strip() for item in result.split('\n')]) - return actual, expected - - def test_nwdiag(self): - actual, expected = self._generate('nwdiag') - self.maxDiff = None - self.assertEqual(actual, expected) - - def test_blockdiag(self): - actual, expected = self._generate('blockdiag') - self.maxDiff = None - self.assertEqual(actual, expected) - - def test_seqdiag(self): - actual, expected = self._generate('seqdiag') - self.maxDiff = None - self.assertEqual(actual, expected) - - def test_seqdiag_issue_134(self): - actual, expected = self._generate('seqdiag_issue_134', 'seqdiag') - self.maxDiff = None - self.assertEqual(actual, expected) - - def test_actdiag(self): - actual, expected = self._generate('actdiag') - self.maxDiff = None - self.assertEqual(actual, expected) - - def test_packetdiag(self): - actual, expected = self._generate('packetdiag') - self.maxDiff = None - self.assertEqual(actual, expected) - - def test_rackdiag(self): - actual, expected = self._generate('rackdiag') - self.maxDiff = None - self.assertEqual(actual, expected) - - def test_blockdiag_with_options(self): - actual, expected = self._generate('blockdiag_options', 'blockdiag', options=MultiDict([ - ('no-doctype', '') - ])) - self.maxDiff = None - self.assertEqual(actual, expected) - - def test_blockdiag_utf8(self): - actual, expected = self._generate('blockdiag_utf8', 'blockdiag') - self.maxDiff = None - self.assertEqual(actual, expected) - -if __name__ == '__main__': - unittest.main() diff --git a/ci/tasks/update-versions.js b/ci/tasks/update-versions.js index b96798da8..c2bb53ce8 100755 --- a/ci/tasks/update-versions.js +++ b/ci/tasks/update-versions.js @@ -6,7 +6,6 @@ import ospath from 'node:path' import { createRequire } from 'node:module' import { spawn } from 'node:child_process' -const KROKI_UBUNTU_VERSION = 'jammy' const require = createRequire(import.meta.url) const __dirname = url.fileURLToPath(new URL('.', import.meta.url)) const rootDir = ospath.join(__dirname, '..', '..') @@ -127,23 +126,6 @@ const diagramLibraryNames = [ ] try { - // GET CURRENT VERSION - const blockdiagRequirementsContent = await fs.readFile(ospath.join(rootDir, 'blockdiag', 'requirements.txt'), 'utf8') - for (const line of blockdiagRequirementsContent.split('\n')) { - const found = line.match(/^(?[a-zA-Z]+)==(?.*)$/) - if (found) { - const { name, version } = found.groups - if (diagramLibraryNames.includes(name)) { - if (name === 'nwdiag') { - // this package also includes rackdiag and packetdiag - diagramLibraryVersions.rackdiag = version - diagramLibraryVersions.packetdiag = version - } - diagramLibraryVersions[name] = version - } - } - } - const wirevizRequirementsContent = await fs.readFile(ospath.join(rootDir, 'wireviz', 'requirements.txt'), 'utf8') for (const line of wirevizRequirementsContent.split('\n')) { const found = line.match(/^(?[a-zA-Z]+)==(?.*)$/) @@ -204,6 +186,7 @@ try { if (plantumlVersionFound) { const { version } = plantumlVersionFound.groups diagramLibraryVersions.plantuml = version + diagramLibraryVersions.c4plantuml = version } const graphvizVersionFound = line.match(/^ARG GRAPHVIZ_VERSION="(?.+)"$/) if (graphvizVersionFound) { @@ -215,6 +198,17 @@ try { const { version } = ditaaVersionFound.groups diagramLibraryVersions.ditaa = version } + const blockdiagVersionFound = line.match(/^ARG BLOCKDIAG_VERSION="(?.+)"$/) + if (blockdiagVersionFound) { + const { version } = blockdiagVersionFound.groups + diagramLibraryVersions.blockdiag = version + diagramLibraryVersions.actdiag = version + diagramLibraryVersions.seqdiag = version + diagramLibraryVersions.rackdiag = version + diagramLibraryVersions.packetdiag = version + diagramLibraryVersions.nwdiag = version + diagramLibraryVersions.nwdiag = version + } } const svgbobCargoContent = await fs.readFile(ospath.join(rootDir, 'server', 'ops', 'docker', 'Cargo.toml'), 'utf8') diff --git a/ci/tests/docker-compose.yaml b/ci/tests/docker-compose.yaml index d41308843..7f357260c 100644 --- a/ci/tests/docker-compose.yaml +++ b/ci/tests/docker-compose.yaml @@ -4,12 +4,10 @@ services: kroki: image: yuzutech/kroki:smoketests depends_on: - - blockdiag - mermaid - bpmn - excalidraw environment: - - KROKI_BLOCKDIAG_HOST=blockdiag - KROKI_MERMAID_HOST=mermaid - KROKI_BPMN_HOST=bpmn - KROKI_EXCALIDRAW_HOST=excalidraw @@ -18,11 +16,6 @@ services: ports: - "8000:8000" - blockdiag: - image: yuzutech/kroki-blockdiag:smoketests - expose: - - "8001" - mermaid: image: yuzutech/kroki-mermaid:smoketests expose: diff --git a/docker-bake-release.hcl b/docker-bake-release.hcl index 672583d73..c6640074d 100644 --- a/docker-bake-release.hcl +++ b/docker-bake-release.hcl @@ -5,10 +5,6 @@ target "kroki" { tags = ["yuzutech/kroki:${RELEASE_VERSION}", "yuzutech/kroki:latest"] } -target "kroki-blockdiag" { - tags = ["yuzutech/kroki-blockdiag:${RELEASE_VERSION}", "yuzutech/kroki-blockdiag:latest"] -} - target "kroki-mermaid" { tags = ["yuzutech/kroki-mermaid:${RELEASE_VERSION}", "yuzutech/kroki-mermaid:latest"] } diff --git a/docker-bake.hcl b/docker-bake.hcl index 02c199268..19f397baa 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -3,7 +3,7 @@ variable "TAG" { } group "companion-images" { - targets = ["kroki-blockdiag", "kroki-mermaid", "kroki-bpmn", "kroki-excalidraw", "kroki-diagramsnet", "kroki-wireviz"] + targets = ["kroki-mermaid", "kroki-bpmn", "kroki-excalidraw", "kroki-diagramsnet", "kroki-wireviz"] } target "kroki" { @@ -20,11 +20,6 @@ target "kroki" { tags = ["yuzutech/kroki:${TAG}"] } -target "kroki-blockdiag" { - context = "blockdiag" - tags = ["yuzutech/kroki-blockdiag:${TAG}"] -} - target "kroki-mermaid" { context = "mermaid" tags = ["yuzutech/kroki-mermaid:${TAG}"] diff --git a/docs/antora.yml b/docs/antora.yml index d2178c5f5..23ade272e 100644 --- a/docs/antora.yml +++ b/docs/antora.yml @@ -3,11 +3,11 @@ title: Kroki version: master asciidoc: attributes: - actdiag-version: 3.0.0 - blockdiag-version: 3.0.0 + actdiag-version: 3.1.0 + blockdiag-version: 3.1.0 bpmn-version: 13.2.0 bytefield-version: 1.8.0 - c4plantuml-version: undefined + c4plantuml-version: 1.2023.7 d2-version: 0.5.1 dbml-version: 1.0.26 diagramsnet-version: 16.2.4 @@ -17,13 +17,13 @@ asciidoc: graphviz-version: 8.0.5 mermaid-version: 10.2.3 nomnoml-version: 1.6.1 - nwdiag-version: 3.0.0 - packetdiag-version: 3.0.0 + nwdiag-version: 3.1.0 + packetdiag-version: 3.1.0 pikchr-version: '7269f78c4a' plantuml-version: 1.2023.7 - rackdiag-version: 3.0.0 - seqdiag-version: 3.0.0 - structurizr-version: 1.30.1 + rackdiag-version: 3.1.0 + seqdiag-version: 3.1.0 + structurizr-version: 1.32.0 svgbob-version: 0.7.0 symbolator-version: 1.2.2 umlet-version: 15.1 diff --git a/docs/modules/ROOT/pages/architecture.adoc b/docs/modules/ROOT/pages/architecture.adoc index cfedfb10f..ad783322e 100644 --- a/docs/modules/ROOT/pages/architecture.adoc +++ b/docs/modules/ROOT/pages/architecture.adoc @@ -6,9 +6,6 @@ Gateway Server:: This component is the entry point of Kroki. The server is using _Vert.x_ and will route the request to different services. -Blockdiag:: -A companion web server written in Python (powered by _Flask_ and _Gunicorn_) that provides _BlockDiag_, _SeqDiag_, _ActDiag_ and _NwDiag_ diagrams libraries. - Mermaid:: A companion web server written in JavaScript (powered by _micro_) that provides _Mermaid_ diagram library. @@ -31,6 +28,12 @@ The `yuzutech/kroki` Docker image contains the following diagrams libraries out- [options="header",cols="1,1m"] |=== |Diagram Type | Version +|https://github.com/blockdiag/actdiag[ActDiag] +|{actdiag-version} + +|https://github.com/blockdiag/blockdiag[BlockDiag] +|{blockdiag-version} + |https://github.com/Deep-Symmetry/bytefield-svg[Bytefield] |{bytefield-version} @@ -54,6 +57,12 @@ The `yuzutech/kroki` Docker image contains the following diagrams libraries out- |{nomnoml-version} //|Binary `/node/bin/nomnoml` +|https://github.com/blockdiag/nwdiag[NwDiag] +|{nwdiag-version} + +|https://github.com/blockdiag/nwdiag/tree/master/src/packetdiag[PacketDiag] +|{packetdiag-version} + |https://github.com/drhsqlite/pikchr[Pikchr] |{pikchr-version} @@ -61,6 +70,12 @@ The `yuzutech/kroki` Docker image contains the following diagrams libraries out- |{plantuml-version} //|Java library (depends on GraphViz) +|https://github.com/blockdiag/nwdiag/tree/master/src/rackdiag[RackDiag] +|{rackdiag-version} + +|https://github.com/blockdiag/seqdiag[SeqDiag] +|{seqdiag-version} + |https://github.com/structurizr/dsl[Structurizr] |{structurizr-version} //|Java library/DSL @@ -88,35 +103,6 @@ The `yuzutech/kroki` Docker image contains the following diagrams libraries out- |https://github.com/wavedrom/wavedrom[WaveDrom] |{wavedrom-version} //|Binary `/node/bin/wavedrom` - -|=== - -== Companion Servers - -=== BlockDiag - -The `yuzutech/kroki-blockdiag` Docker image contains the following diagrams libraries out-of-the-box: - -[options="header",cols="1,1m"] -|=== -|Diagram Type | Version -|https://github.com/blockdiag/actdiag[ActDiag] -|{actdiag-version} - -|https://github.com/blockdiag/blockdiag[BlockDiag] -|{blockdiag-version} - -|https://github.com/blockdiag/nwdiag[NwDiag] -|{nwdiag-version} - -|https://github.com/blockdiag/nwdiag/tree/master/src/packetdiag[PacketDiag] -|{packetdiag-version} - -|https://github.com/blockdiag/nwdiag/tree/master/src/rackdiag[RackDiag] -|{rackdiag-version} - -|https://github.com/blockdiag/seqdiag[SeqDiag] -|{seqdiag-version} |=== === Mermaid diff --git a/docs/modules/setup/pages/configuration.adoc b/docs/modules/setup/pages/configuration.adoc index ccb138eab..a4efc07fe 100644 --- a/docs/modules/setup/pages/configuration.adoc +++ b/docs/modules/setup/pages/configuration.adoc @@ -196,8 +196,6 @@ In other words, diagram library timeouts (for instance, `KROKI_PLANTUML_CONVERT_ You can configure the host and port on which every companion container will be listening: -KROKI_BLOCKDIAG_HOST:: Host of the BlockDiag container (default: `127.0.0.1`). -KROKI_BLOCKDIAG_PORT:: Port of the BlockDiag container (default: `8001`). KROKI_MERMAID_HOST:: Host of the Mermaid container (default: `127.0.0.1`). KROKI_MERMAID_PORT:: Port of the Mermaid container (default: `8002`). KROKI_BPMN_HOST:: Host of the BPMN container (default: `127.0.0.1`). diff --git a/docs/modules/setup/pages/install.adoc b/docs/modules/setup/pages/install.adoc index 77f712448..83d647565 100644 --- a/docs/modules/setup/pages/install.adoc +++ b/docs/modules/setup/pages/install.adoc @@ -1,7 +1,6 @@ = Install Kroki // Docker Hub URIs of Kroki container images :uri-docker-kroki-image: https://hub.docker.com/r/yuzutech/kroki -:uri-docker-kroki-blockdiag-image: https://hub.docker.com/r/yuzutech/kroki-blockdiag :uri-docker-kroki-mermaid-image: https://hub.docker.com/r/yuzutech/kroki-mermaid :uri-docker-kroki-bpmn-image: https://hub.docker.com/r/yuzutech/kroki-bpmn :uri-docker-kroki-excalidraw-image: https://hub.docker.com/r/yuzutech/kroki-excalidraw @@ -93,6 +92,8 @@ In other words, the following endpoints will be available: [literal] .... +/actdiag +/blockdiag /bytefield /c4plantuml /d2 @@ -101,8 +102,12 @@ In other words, the following endpoints will be available: /graphviz /dot /nomnoml +/nwdiag +/packetdiag /pikchr /plantuml +/rackdiag +/seqdiag /structurizr /svgbob /symbolator @@ -112,27 +117,16 @@ In other words, the following endpoints will be available: /wavedrom .... -If you want to use additional diagram libraries (such as _BlockDiag_, _BPMN_, _Excalidraw_ or _Mermaid_), then you will also need to start their companion containers: +If you want to use additional diagram libraries (such as _BPMN_, _Excalidraw_ or _Mermaid_), then you will also need to start their companion containers: == Companion containers These optional companion containers provide additional diagrams and require the gateway server -// * <> // * <> // * <> // * <> // * <> -[#yuzutech-kroki-blockdiag] -{uri-docker-kroki-blockdiag-image}[yuzutech/kroki-blockdiag^]:: -Provides block, sequence, activity, network, packet & equipment rack diagrams for Kroki using respectively the -{uri-blockdiag}[BlockDiag^], -{uri-seqdiag}[SeqDiag^], -{uri-actdiag}[ActDiag^], -{uri-nwdiag}[NwDiag^] -{uri-packetdiag}[PacketDiag^], -and {uri-rackdiag}[RackDiag^] libraries. - [#yuzutech-kroki-bpmn] {uri-docker-kroki-bpmn-image}[yuzutech/kroki-bpmn^]:: Provides BPMN diagrams for Kroki using the {uri-bpmn}[bpmn-js^] library. diff --git a/docs/modules/setup/pages/use-kubernetes.adoc b/docs/modules/setup/pages/use-kubernetes.adoc index f6154e4ef..04c03abe7 100644 --- a/docs/modules/setup/pages/use-kubernetes.adoc +++ b/docs/modules/setup/pages/use-kubernetes.adoc @@ -68,13 +68,6 @@ Alternatively they can be applied individually. To install them individually from GitHub, open a terminal and type commands indicated for each service: -.Add BlockDiag service -[source,cli,subs=+attributes] ----- -kubectl apply -f {uri-k8s-kroki-examples}/blockdiag-deployment.yaml -kubectl apply -f {uri-k8s-kroki-examples}/blockdiag-service.yaml ----- - .Add Mermaid service [source,cli,subs=+attributes] ---- @@ -129,7 +122,6 @@ If the installation is successful a list of running pods is shown that includes + .... NAME READY STATUS RESTARTS AGE -blockdiag-7bd6c989b7-zhvj8 1/1 Running 0 24s bpmn-6cfccf9bc4-6w4px 1/1 Running 0 24s excalidraw-5b84995fcb-dh57t 1/1 Running 0 24s kroki-6b49bcb7c4-x2ksc 1/1 Running 0 23s @@ -179,4 +171,4 @@ unzip kroki-k8s-singlepod.zip -d kroki-k8s You can then create the Kubernetes objects as a batch or individually, similar to what was shown previously. -Validation and uninstall/removal of Kubernetes objects can be followed using the exact same commands as shown previously too. \ No newline at end of file +Validation and uninstall/removal of Kubernetes objects can be followed using the exact same commands as shown previously too. diff --git a/server/ops/docker/jdk11-jammy/Dockerfile b/server/ops/docker/jdk11-jammy/Dockerfile index 55849fe96..7f126b02e 100644 --- a/server/ops/docker/jdk11-jammy/Dockerfile +++ b/server/ops/docker/jdk11-jammy/Dockerfile @@ -239,6 +239,7 @@ ARG PLANTUML_VERSION="1.2023.7" ARG UMLET_VERSION="2023-03-20_UMLet_v15.1" ARG GRAPHVIZ_VERSION="8.0.5" ARG DITAA_VERSION="1.0.3" +ARG BLOCKDIAG_VERSION="3.1.0" ARG TARGETARCH LABEL \ @@ -294,6 +295,9 @@ RUN wget "https://github.com/ggrossetie/plantuml/releases/download/v${PLANTUML_V RUN wget "https://github.com/yuzutech/umlet/releases/download/${UMLET_VERSION}/umlet-linux-${TARGETARCH}" -O /usr/bin/umlet && \ chmod +x /usr/bin/umlet +RUN wget "https://github.com/yuzutech/blockdiag/releases/download/v${BLOCKDIAG_VERSION}/blockdiag-bundle-linux-${TARGETARCH}.bin" -O /usr/bin/blockdiag && \ + chmod +x /usr/bin/blockdiag + COPY --from=kroki-builder-static-svgbob /usr/local/cargo/bin/svgbob_cli /usr/bin/svgbob COPY --from=kroki-builder-static-erd /root/.local/bin/erd /usr/bin/erd COPY --from=kroki-builder-static-pikchr /build/pikchr /usr/bin/pikchr @@ -325,6 +329,7 @@ ENV KROKI_PLANTUML_BIN_PATH=/usr/bin/plantuml ENV KROKI_TIKZ2SVG_BIN_PATH=/usr/bin/tikz2svg ENV KROKI_DITAA_BIN_PATH=/usr/bin/ditaa ENV KROKI_SYMBOLATOR_BIN_PATH=/usr/bin/symbolator +ENV KROKI_BLOCKDIAG_BIN_PATH=/usr/bin/blockdiag ENV JAVA_OPTS="-Dlogback.configurationFile=/etc/kroki/logback.xml -Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory" COPY --chown=kroki:kroki target/kroki-server.jar /usr/local/kroki/kroki-server.jar diff --git a/server/src/main/java/io/kroki/server/Server.java b/server/src/main/java/io/kroki/server/Server.java index 51e234517..f22ee4010 100644 --- a/server/src/main/java/io/kroki/server/Server.java +++ b/server/src/main/java/io/kroki/server/Server.java @@ -123,7 +123,7 @@ static void start(Vertx vertx, JsonObject config, Handler SUPPORTED_FORMATS = Arrays.asList(FileFormat.PNG, FileFormat.SVG, FileFormat.PDF); - private final WebClient client; + private final Vertx vertx; + private final String binPath; private final SourceDecoder sourceDecoder; - private final String host; - private final int port; + private final Commander commander; - public Blockdiag(Vertx vertx, JsonObject config) { - this.client = WebClient.create(vertx); + public Blockdiag(Vertx vertx, JsonObject config, Commander commander) { + this.vertx = vertx; + this.binPath = config.getString("KROKI_BLOCKDIAG_BIN_PATH", "blockdiag"); this.sourceDecoder = new SourceDecoder() { @Override public String decode(String encoded) throws DecodeException { return DiagramSource.decode(encoded); } }; - this.host = config.getString("KROKI_BLOCKDIAG_HOST", "127.0.0.1"); - this.port = config.getInteger("KROKI_BLOCKDIAG_PORT", 8001); + this.commander = commander; } @Override @@ -49,13 +49,44 @@ public SourceDecoder getSourceDecoder() { @Override public String getVersion() { - return "3.0.0"; + return "3.1.0"; } @Override public void convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, Handler> handler) { - String requestURI = "/" + serviceName + "/" + fileFormat.getName(); - Handler>> responseHandler = Delegator.createHandler(host, port, requestURI, handler); - Delegator.delegate(client, host, port, requestURI, sourceDecoded, options, responseHandler); + vertx.executeBlocking(future -> { + try { + byte[] result = bin(sourceDecoded.getBytes(), serviceName, fileFormat, options); + future.complete(result); + } catch (IOException | InterruptedException | IllegalStateException e) { + future.fail(e); + } + }, res -> handler.handle(res.map(o -> Buffer.buffer((byte[]) o)))); + } + + private byte[] bin(byte[] source, String serviceName, FileFormat fileFormat, JsonObject options) throws IOException, InterruptedException, IllegalStateException { + List commands = new ArrayList<>(); + commands.add(binPath); + commands.add("--module=" + serviceName); + commands.add("--font=/usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf"); + commands.add("-T" + fileFormat.getName()); + String antialiasValue = options.getString("antialias"); + if (antialiasValue != null) { + commands.add("--antialias"); + } + String noTransparencyValue = options.getString("no-transparency"); + if (fileFormat == FileFormat.PNG && noTransparencyValue != null) { + commands.add("--no-transparency"); + } + String sizeValue = options.getString("size"); + if (sizeValue != null) { + commands.add("--size=" + sizeValue); + } + String noDoctypeValue = options.getString("no-doctype"); + if (fileFormat == FileFormat.SVG && noDoctypeValue != null) { + commands.add("--nodoctype"); + } + commands.add("-"); // read from stdin + return commander.execute(source, commands.toArray(new String[0])); } } diff --git a/server/src/main/java/io/kroki/server/service/Structurizr.java b/server/src/main/java/io/kroki/server/service/Structurizr.java index f189b8414..cb0b05c60 100644 --- a/server/src/main/java/io/kroki/server/service/Structurizr.java +++ b/server/src/main/java/io/kroki/server/service/Structurizr.java @@ -70,7 +70,7 @@ public SourceDecoder getSourceDecoder() { @Override public String getVersion() { - return "1.30.1"; + return "1.32.0"; } @Override diff --git a/server/src/test/java/io/kroki/server/action/DelegatorTest.java b/server/src/test/java/io/kroki/server/action/DelegatorTest.java index fcf3835c4..0b54ec2e2 100644 --- a/server/src/test/java/io/kroki/server/action/DelegatorTest.java +++ b/server/src/test/java/io/kroki/server/action/DelegatorTest.java @@ -47,10 +47,11 @@ void should_propagate_options_when_delegating_work(Vertx vertx, VertxTestContext server.listen(port, "localhost", handler -> { WebClient webClient = WebClient.create(vertx); HashMap options = new HashMap<>(); - options.put("no-transparency", ""); - Delegator.delegate(webClient, "localhost", port, "/blockdiag/png", "blockdiag { Kroki -> is -> great; }", new JsonObject(options), testContext.succeeding(bufferHttpResponse -> { + options.put("theme", "forest"); + Delegator.delegate(webClient, "localhost", port, "/mermaid/png", "sequenceDiagram\n" + + " Alice->>John: Hello John, how are you?", new JsonObject(options), testContext.succeeding(bufferHttpResponse -> { String response = bufferHttpResponse.bodyAsString(); - assertThat(response).isEqualTo("uri=/blockdiag/png?no-transparency=\n;body=blockdiag { Kroki -> is -> great; }"); + assertThat(response).isEqualTo("uri=/mermaid/png?theme=forest\n;body=sequenceDiagram\n Alice->>John: Hello John, how are you?"); testContext.completeNow(); })); });