-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Tags support sprites (incl. img support), technology and custom legend text #173
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
Tags support sprites (incl. img support), technology and custom legend text #173
Conversation
…XxxxxxxStyle() with specific default colors)
|
Fixed OpenIconic errors and add image support to $sprite="..." (via img:....). This enables diagrams like @startuml
!include https://raw.githubusercontent.com/kirchsth/C4-PlantUML/extended/C4_Container.puml
!define osaPuml https://raw.githubusercontent.com/Crashedmind/PlantUML-opensecurityarchitecture2-icons/master
!include osaPuml/Common.puml
!include osaPuml/User/all.puml
!include osaPuml/Server/all.puml
!include <office/Servers/database_server>
!include <office/Servers/file_server>
!include <office/Servers/application_server>
!include <office/Concepts/service_application>
!include <office/Concepts/firewall>
AddExternalPersonTag("anonymous_ext", $sprite="osa_user_black_hat", $legendText="anonymous user")
AddPersonTag("customer", $sprite="osa_user_large_group", $legendText="aggregated user")
AddPersonTag("admin", $sprite="osa_user_audit,color=red", $legendSprite="osa_user_audit,scale=0.25,color=red", $legendText="administration user")
AddContainerTag("webApp", $sprite="application_server", $legendText="web application")
AddContainerTag("db", $sprite="database_server", $legendText="database container")
AddContainerTag("files", $sprite="file_server", $legendText="file server container")
AddContainerTag("conApp", $sprite="img:http://plantuml.com/logo3.png{scale=0.3}", $legendSprite="img:http://plantuml.com/logo3.png{scale=0.1}", $legendText="console application")
UpdateElementStyle("external_system", $bgColor=$EXTERNAL_SYSTEM_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$EXTERNAL_SYSTEM_BORDER_COLOR, $sprite = "osa_server", , $legendText="external system")
AddRelTag("firewall", $textColor="$ARROW_COLOR", $lineColor="$ARROW_COLOR", $sprite="&envelope-closed", $legendText="firewall")
AddRelTag("plantuml", $textColor="$ARROW_COLOR", $lineColor="$ARROW_COLOR", $sprite="img:http://plantuml.com/logo3.png{scale=0.1}", $legendText="console triggered")
Person_Ext(anonymous_user, "Bob", $tags="anonymous_ext")
Person(aggregated_user, "Sam, Ivone", $tags="customer")
Person(administration_user, "Bernd", $tags="admin")
System_Boundary(c1, "techtribes.js"){
Container(web_app, "Web Application", "Java, Spring MVC, Tomcat 7.x", "Allows users to view people, tribes, content, events, jobs, etc. from the local tech, digital and IT sector", $tags="webApp")
ContainerDb(rel_db, "Relational Database", "MySQL 5.5.x", "Stores people, tribes, tribe membership, talks, events, jobs, badges, GitHub repos, etc.", $tags="db")
Container(filesystem, "File System", "FAT32", "Stores search indexes", $tags="files")
ContainerDb(nosql, "NoSQL Data Store", "MongoDB 2.2.x", "Stores from RSS/Atom feeds (blog posts) and tweets", $tags="db")
Container(updater, "Updater", "Java 7 Console App", "Updates profiles, tweets, GitHub repos and content on a scheduled basis", $tags="conApp")
}
System_Ext(twitter, "Twitter")
System_Ext(github, "GitHub")
System_Ext(blogs, "Blogs")
Rel(anonymous_user, web_app, "Uses", "HTTPS", $tags="firewall")
Rel(aggregated_user, web_app, "Uses", "HTTPS", $tags="firewall")
Rel(administration_user, web_app, "Uses", "HTTPS", $tags="firewall")
Rel(web_app, rel_db, "Reads from and writes to", "SQL/JDBC, port 3306")
Rel(web_app, filesystem, "Reads from")
Rel(web_app, nosql, "Reads from", "MongoDB wire protocol, port 27017")
Rel_U(updater, rel_db, "Reads from and writes data to", "SQL/JDBC, port 3306")
Rel_U(updater, filesystem, "Writes to")
Rel_U(updater, nosql, "Reads from and writes to", "MongoDB wire protocol, port 27017")
Rel(updater, twitter, "Gets profile information and tweets from", "HTTPS", $tags="plantuml")
Rel(updater, github, "Gets information about public code repositories from", "HTTPS", $tags="plantuml")
Rel(updater, blogs, "Gets content using RSS and Atom feeds from", "HTTP", $tags="plantuml")
Lay_R(rel_db, filesystem)
SHOW_LEGEND()
@endumlBR Helmut |
|
At first glance this looks good, I'll try to do an actual review soon. 👍 |
|
@Potherca: I have a branch that tags supports tech/type properties too (branch kirchsth/feature/TagsSupportsTechn or my extended merged kirchsth/extended_tag_techn) should I add the extensions to this branch too? This extension enables shorter diagram source without additional $techn properties but we would start to mix $techn./$type with $tags. BR Helmut @startuml
' !!!! only extended_tag_techn supports tags with $techn !!!!
!include https://raw.githubusercontent.com/kirchsth/C4-PlantUML/extended_tag_techn/C4_Component.puml
!define osaPuml https://raw.githubusercontent.com/Crashedmind/PlantUML-opensecurityarchitecture2-icons/master
!include osaPuml/Common.puml
!include osaPuml/User/all.puml
!include osaPuml/Server/all.puml
!include <office/Servers/database_server>
!include <office/Servers/file_server>
!include <office/Servers/application_server>
!include <office/Concepts/service_application>
!include <office/Concepts/firewall>
!include <tupadr3/common>
!include <tupadr3/devicons2/mysql>
!include <tupadr3/devicons2/mongodb>
AddExternalPersonTag("anonymous_ext", $sprite="osa_user_black_hat", $legendText="anonymous user")
AddPersonTag("customer", $sprite="osa_user_large_group", $legendText="aggregated user")
AddPersonTag("admin", $sprite="osa_user_audit,color=red", $legendSprite="osa_user_audit,scale=0.25,color=red", $legendText="administration user")
AddContainerTag("webApp", $sprite="application_server", $legendText="web application")
AddContainerTag("mongo_db", $techn="MongoDB 2.2.x", $sprite="mongodb", $legendText="MongoDB container")
AddContainerTag("mysql_db", $techn="MySQL 5.5.x", $sprite="mysql", $legendText="MySQL container")
AddContainerTag("files", $sprite="file_server", $legendText="file server container")
AddContainerTag("conApp", $sprite="img:http://plantuml.com/logo3.png{scale=0.3}", $legendSprite="img:http://plantuml.com/logo3.png{scale=0.1}", $legendText="console application")
UpdateElementStyle("external_system", $bgColor=$EXTERNAL_SYSTEM_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$EXTERNAL_SYSTEM_BORDER_COLOR, $sprite = "osa_server", , $legendText="external system")
AddRelTag("firewall", $textColor="$ARROW_COLOR", $lineColor="$ARROW_COLOR", $techn="HTTPS", $sprite="firewall,scale=0.3,color=red", $legendText="firewall")
AddRelTag("plantuml", $textColor="$ARROW_COLOR", $lineColor="$ARROW_COLOR", $techn="HTTPS", $sprite="img:http://plantuml.com/logo3.png{scale=0.1}", $legendText="console triggered")
LAYOUT_LEFT_RIGHT()
' LAYOUT_LANDSCAPE()
Person_Ext(anonymous_user, "Bob", $tags="anonymous_ext")
Person(aggregated_user, "Sam, Ivone", $tags="customer")
Person(administration_user, "Bernd", $tags="admin")
System_Boundary(c1, "techtribes.js"){
' $techn not part of $tags
Container(web_app, "Web Application", "Java, Spring MVC, Tomcat 7.x", $tags="webApp")
' $techn part of $tags
ContainerDb(rel_db, "Relational Database", $tags="mysql_db", $descr="DESCRIPTION")
' $techn not part of $tags
Container(filesystem, "File System", "FAT32", "DESCRIPTION", $tags="files")
' $techn part of $tags
ContainerDb(nosql, "NoSQL Data Store", $tags="mongo_db", $descr="DESCRIPTION")
Container(updater, "Updater", "Java 7 Console App", $tags="conApp")
}
System_Ext(twitter, "Twitter")
System_Ext(github, "GitHub")
System_Ext(blogs, "Blogs")
' $techn part of $tags
Rel(anonymous_user, web_app, "Uses", $tags="firewall")
Rel(aggregated_user, web_app, "Uses", $tags="firewall")
Rel(administration_user, web_app, "Uses", $tags="firewall")
Rel(web_app, rel_db, "Reads from and writes to", "SQL/JDBC, port 3306")
Rel(web_app, filesystem, "Reads from")
Rel(web_app, nosql, "Reads from", "MongoDB wire protocol, port 27017")
Rel_U(updater, rel_db, "Reads from and writes data to", "SQL/JDBC, port 3306")
Rel_U(updater, filesystem, "Writes to")
Rel_U(updater, nosql, "Reads from and writes to", "MongoDB wire protocol, port 27017")
Rel(updater, twitter, "Gets profile information and tweets from", $tags="plantuml")
Rel(updater, github, "Gets information about public code repositories from", $tags="plantuml")
' don't use the default techn. "HTTPS" which is defined via tags, define techn "HTTP" too
Rel(updater, blogs, "Gets content using RSS and Atom feeds from", "HTTP", $tags="plantuml")
' Lay_R(rel_db, filesystem)
' HIDE_STEREOTYPE()
SHOW_LEGEND()
@enduml |
|
@Potherca: I added the missing tech/type support to this branch too, that the tags supports all properties (and we avoid an additional review cycle) |
C4.puml
Outdated
| !while ($brPos >= 0) | ||
| !$tag = %substr($tags, 0, $brPos) | ||
| !$newSprite = %get_variable_value("$" + $tag + "RelTagSprite") | ||
| !if ($newSprite>"") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For readability, I would suggest adding whitespace around the >:
!if ($newSprite > "")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
I finally got around to reviewing this. Other than some minor nitpicks, it looks good! I just noticed that, by merging the other MRs first, I create a conflict here. I probably should have done that in the reversed order. 😞 |
|
thank you for the review; no problem I will resolve the MRs. |
…(resolve conflicts, fix PR findings)
AddElementTag(), AddRelTag() and UpdateElementStyle() is extended with ?sprite, ?legendText and ?legendSprite
that
The extended calls are:
AddElementTag(tagStereo, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?sprite, ?legendText, ?legendSprite):AddRelTag(tagStereo, ?textColor, ?lineColor, ?lineStyle, ?sprite, ?legendText, ?legendSprite):UpdateElementStyle(elementName, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?sprite, ?legendText, ?legendSprite):Element specific tags with element specific default colors are added:
AddPersonTag(tagStereo, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?sprite, ?legendText, ?legendSprite)AddExternalPersonTag(tagStereo, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?sprite, ?legendText, ?legendSprite)AddSystemTag(tagStereo, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?sprite, ?legendText, ?legendSprite)AddExternalSystemTag(tagStereo, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?sprite, ?legendText, ?legendSprite)AddComponentTag(tagStereo, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?sprite, ?legendText, ?legendSprite)AddExternalComponentTag(tagStereo, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?sprite, ?legendText, ?legendSprite)AddContainerTag(tagStereo, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?sprite, ?legendText, ?legendSprite)AddExternalContainerTag(tagStereo, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?sprite, ?legendText, ?legendSprite)AddNodeTag(tagStereo, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?sprite, ?legendText, ?legendSprite)it enables diagrams like Sample with tag dependent sprites and custom legend text
It can be tested with my extended branch
BR Helmut
@Potherca: based on Github docu (I followed the in the languages YAML file link) supports it plantuml syntax highlighting, but I couldn't get it working (it highlights only @startuml)