Tomdoc'd
This commit is contained in:
@@ -381,6 +381,12 @@ module Gollum
|
|||||||
#
|
#
|
||||||
#########################################################################
|
#########################################################################
|
||||||
|
|
||||||
|
# Extract all sequence diagram blocks into the wsdmap and replace with
|
||||||
|
# placeholders.
|
||||||
|
#
|
||||||
|
# data - The raw String data.
|
||||||
|
#
|
||||||
|
# Returns the placeholder'd String data.
|
||||||
def extract_wsd(data)
|
def extract_wsd(data)
|
||||||
data.gsub(/^\{\{\{ ?(.+?)\r?\n(.+?)\r?\n\}\}\}\r?$/m) do
|
data.gsub(/^\{\{\{ ?(.+?)\r?\n(.+?)\r?\n\}\}\}\r?$/m) do
|
||||||
id = Digest::SHA1.hexdigest($2)
|
id = Digest::SHA1.hexdigest($2)
|
||||||
@@ -389,6 +395,12 @@ module Gollum
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Process all diagrams from the wsdmap and replace the placeholders with
|
||||||
|
# the final HTML.
|
||||||
|
#
|
||||||
|
# data - The String data (with placeholders).
|
||||||
|
#
|
||||||
|
# Returns the marked up String data.
|
||||||
def process_wsd(data)
|
def process_wsd(data)
|
||||||
@wsdmap.each do |id, spec|
|
@wsdmap.each do |id, spec|
|
||||||
style = spec[:style]
|
style = spec[:style]
|
||||||
|
|||||||
@@ -5,6 +5,12 @@ require 'open-uri'
|
|||||||
class Gollum::WebSequenceDiagram
|
class Gollum::WebSequenceDiagram
|
||||||
WSD_URL = "http://www.websequencediagrams.com/index.php"
|
WSD_URL = "http://www.websequencediagrams.com/index.php"
|
||||||
|
|
||||||
|
# Initialize a new WebSequenceDiagram object.
|
||||||
|
#
|
||||||
|
# code - The String containing the sequence diagram markup.
|
||||||
|
# style - The String containing the rendering style.
|
||||||
|
#
|
||||||
|
# Returns a new Gollum::WebSequenceDiagram object
|
||||||
def initialize(code, style)
|
def initialize(code, style)
|
||||||
@code = code
|
@code = code
|
||||||
@style = style
|
@style = style
|
||||||
@@ -13,6 +19,10 @@ class Gollum::WebSequenceDiagram
|
|||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Render the sequence diagram on the remote server and store the url to
|
||||||
|
# the rendered image.
|
||||||
|
#
|
||||||
|
# Returns nil.
|
||||||
def render
|
def render
|
||||||
response = Net::HTTP.post_form(URI.parse(WSD_URL), 'style' => @style, 'message' => @code)
|
response = Net::HTTP.post_form(URI.parse(WSD_URL), 'style' => @style, 'message' => @code)
|
||||||
if response.body =~ /img: "(.+)"/
|
if response.body =~ /img: "(.+)"/
|
||||||
@@ -24,6 +34,9 @@ class Gollum::WebSequenceDiagram
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Gets the HTML IMG tag for the sequence diagram.
|
||||||
|
#
|
||||||
|
# Returns a String containing the IMG tag.
|
||||||
def to_tag
|
def to_tag
|
||||||
@tag
|
@tag
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user