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)
|
||||
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]
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user