Module Webby::Helpers::GraphvizHelper
In: lib/webby/helpers/graphviz_helper.rb

Methods

Public Class methods

Check the temporary error file to see if it contains any error messages from the graphviz program. If it is not empty, then read the contents and log an error message and raise an exception.

Public Instance methods

The graphviz method processes DOT scripts in a webpage and replaces them with generated image files. The page sections to be processed are given as blocks of text to the graphviz method.

Options can be passed to the Graphviz program using attributes in the graphviz method.

    <% graphviz( :path => "images", :type => "gif", cmd => "dot" ) do %>
    digraph graph_1 {
      graph [URL="default.html"]
      a [URL="a.html"]
      b [URL="b.html"]
      c [URL="c.html"]
      a -> b -> c
      a -> c
    }
    <% end %>

If the DOT script contains URL or href attributes on any of the nodes or edges, then an image map will be generated and the image will be "clikcable" in the webpage. If URL or href attributes do not appear in the DOT script, then a regular image will be inserted into the webpage.

The image is inserted into the page using an HTML <img /> tag. A corresponding <map>…</map> element will be inserted if needed.

The supported Graphviz options are the following:

   :path     : where generated images will be stored
               [default is "/"]
   :type     : the type of image to generate (png, jpeg, gif)
               [default is png]
   :cmd      : the Graphviz command to use when generating images
               (dot, neato, twopi, circo, fdp) [default is dot]

   the following options are passed as-is to the generated <img /> tag
   :style    : CSS styles to apply to the <img />
   :class    : CSS class to apply to the <img />
   :id       : HTML identifier
   :alt      : alternate text for the <img />

[Validate]