This commit is contained in:
Tim Sharpe
2010-10-01 16:18:09 +10:00
parent 5fc3c298c1
commit 4cad535baa
2 changed files with 25 additions and 0 deletions
+12
View File
@@ -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)
data.gsub(/^\{\{\{ ?(.+?)\r?\n(.+?)\r?\n\}\}\}\r?$/m) do
id = Digest::SHA1.hexdigest($2)
@@ -389,6 +395,12 @@ module Gollum
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)
@wsdmap.each do |id, spec|
style = spec[:style]
+13
View File
@@ -5,6 +5,12 @@ require 'open-uri'
class Gollum::WebSequenceDiagram
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)
@code = code
@style = style
@@ -13,6 +19,10 @@ class Gollum::WebSequenceDiagram
render
end
# Render the sequence diagram on the remote server and store the url to
# the rendered image.
#
# Returns nil.
def render
response = Net::HTTP.post_form(URI.parse(WSD_URL), 'style' => @style, 'message' => @code)
if response.body =~ /img: "(.+)"/
@@ -24,6 +34,9 @@ class Gollum::WebSequenceDiagram
end
end
# Gets the HTML IMG tag for the sequence diagram.
#
# Returns a String containing the IMG tag.
def to_tag
@tag
end