Class: Gollum::Filter::PlantUML
- Inherits:
-
Gollum::Filter
- Object
- Gollum::Filter
- Gollum::Filter::PlantUML
- Defined in:
- lib/gollum-lib/filter/plantuml.rb
Overview
PlantUML Diagrams
This filter replaces PlantUML blocks with HTML img tags. These img tags point to a PlantUML web service that converts the UML text blocks into nice diagrams.
For this to work you must have your own PlantUML server running somewhere. Just follow the instructions on the github page to run your own server:
https://github.com/plantuml/plantuml-server
Once you start you own plantuml server you need to configure this filter to point to it:
Gollum::Filter::PlantUML.configure do |config|
config.url = "http://localhost:8080/plantuml/png"
end
Then in your wiki pages simply add PlantUML blocks anywhere you want a diagram:
@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
Alice -> Bob: Another authentication Request
Alice <-- Bob: another authentication Response
@enduml
To learn more about how to create cool PlantUML diagrams check the examples at: plantuml.sourceforge.net/
Defined Under Namespace
Classes: Configuration
Constant Summary collapse
- DEFAULT_URL =
"http://localhost:8080/plantuml/png"
Constants inherited from Gollum::Filter
Class Attribute Summary collapse
Attributes inherited from Gollum::Filter
Class Method Summary collapse
Instance Method Summary collapse
-
#extract(data) ⇒ Object
Extract all sequence diagram blocks into the map and replace with placeholders.
-
#process(data) ⇒ Object
Process all diagrams from the map and replace the placeholders with the final HTML.
Methods inherited from Gollum::Filter
Methods included from Helpers
#path_to_link_text, #trim_leading_slashes
Constructor Details
This class inherits a constructor from Gollum::Filter
Class Attribute Details
.configuration ⇒ Object
61 62 63 |
# File 'lib/gollum-lib/filter/plantuml.rb', line 61 def self.configuration @configuration ||= Configuration.new end |
Class Method Details
.configure {|configuration| ... } ⇒ Object
65 66 67 |
# File 'lib/gollum-lib/filter/plantuml.rb', line 65 def self.configure yield(configuration) end |
Instance Method Details
#extract(data) ⇒ Object
Extract all sequence diagram blocks into the map and replace with placeholders.
71 72 73 74 75 76 77 |
# File 'lib/gollum-lib/filter/plantuml.rb', line 71 def extract(data) data.gsub(/(@start(uml|json|yaml|salt|mindmap|wbs|math|latex)\r?\n.+?\r?\n@end\2\r?$)/m) do id = "#{open_pattern}#{Digest::SHA1.hexdigest($1)}#{close_pattern}" @map[id] = { :code => $1 } id end end |
#process(data) ⇒ Object
Process all diagrams from the map and replace the placeholders with the final HTML.
81 82 83 84 85 86 87 88 |
# File 'lib/gollum-lib/filter/plantuml.rb', line 81 def process(data) @map.each do |id, spec| data.gsub!(id) do render_plantuml(id, spec[:code]) end end data end |