--- /dev/null
+#!/usr/bin/perl
+# graphviz plugin for ikiwiki: render graphviz source as an image.
+# Josh Triplett
+package IkiWiki::Plugin::graphviz;
+
+use warnings;
+use strict;
+use IkiWiki;
+use IPC::Open2;
+
+sub import { #{{{
+ hook(type => "preprocess", id => "graph", call => \&graph);
+} # }}}
+
+my %graphviz_programs = (
+ "dot" => 1, "neato" => 1, "fdp" => 1, "twopi" => 1, "circo" => 1
+);
+
+sub render_graph (\%) { #{{{
+ my %params = %{(shift)};
+
+ my $src = "$params{type} g {\n";
+ $src .= "charset=\"utf-8\";\n";
+ $src .= "ratio=compress;\nsize=\"".($params{width}+0).", ".($params{height}+0)."\";\n"
+ if defined $params{width} and defined $params{height};
+ $src .= $params{src};
+ $src .= "}\n";
+
+ # Use the sha1 of the graphviz code as part of its filename.
+ eval q{use Digest::SHA1};
+ error($@) if $@;
+ my $dest=$params{page}."/graph-".
+ IkiWiki::possibly_foolish_untaint(Digest::SHA1::sha1_hex($src)).
+ ".png";
+ will_render($params{page}, $dest);
+
+ if (! -e "$config{destdir}/$dest") {
+ my $pid;
+ my $sigpipe=0;;
+ $SIG{PIPE}=sub { $sigpipe=1 };
+ $pid=open2(*IN, *OUT, "$params{prog} -Tpng");
+
+ # open2 doesn't respect "use open ':utf8'"
+ binmode (IN, ':utf8');
+ binmode (OUT, ':utf8');
+
+ print OUT $src;
+ close OUT;
+
+ my $png;
+ {
+ local $/ = undef;
+ $png = <IN>;
+ }
+ close IN;
+
+ waitpid $pid, 0;
+ $SIG{PIPE}="DEFAULT";
+ return "[[graph ".gettext("failed to run graphviz")."]]" if ($sigpipe);
+
+ if (! $params{preview}) {
+ writefile($dest, $config{destdir}, $png, 1);
+ }
+ else {
+ # can't write the file, so embed it in a data uri
+ eval q{use MIME::Base64};
+ error($@) if $@;
+ return "<img src=\"data:image/png;base64,".
+ encode_base64($png)."\" />";
+ }
+ }
+
+ return "<img src=\"".urlto($dest, $params{page})."\" />\n";
+} #}}}
+
+sub graph (@) { #{{{
+ my %params=@_;
+ $params{src} = "" unless defined $params{src};
+ $params{type} = "digraph" unless defined $params{type};
+ $params{prog} = "dot" unless defined $params{prog};
+ return "[[graph ".gettext("prog not a valid graphviz program")."]]" unless $graphviz_programs{$params{prog}};
+
+ return render_graph(%params);
+} # }}}
+
+1
+ikiwiki (1.50) UNRELEASED; urgency=low
+
+ [ Josh Triplett ]
+ * Add a graphviz plugin.
+ * Suggests: graphviz
+
+ -- Joey Hess <joeyh@debian.org> Mon, 09 Apr 2007 01:45:40 -0700
+
ikiwiki (1.49) unstable; urgency=low
[ Joey Hess ]
Architecture: all
Depends: ${perl:Depends}, libxml-simple-perl, markdown, libtimedate-perl, libhtml-template-perl, libhtml-scrubber-perl, libcgi-formbuilder-perl (>= 3.02.02), libtime-duration-perl, libcgi-session-perl (>= 4.14-1), libmail-sendmail-perl, gcc | c-compiler, libc6-dev | libc-dev, libhtml-parser-perl, liburi-perl
Recommends: subversion | git-core | tla | mercurial, hyperestraier, libnet-openid-consumer-perl
-Suggests: viewvc | viewcvs, librpc-xml-perl, libtext-wikiformat-perl, python-docutils, polygen, tidy, libxml-feed-perl, libmailtools-perl, perlmagick, libfile-mimeinfo-perl, libcrypt-ssleay-perl, liblocale-gettext-perl (>= 1.05-1)
+Suggests: viewvc | viewcvs, librpc-xml-perl, libtext-wikiformat-perl, python-docutils, polygen, tidy, libxml-feed-perl, libmailtools-perl, perlmagick, libfile-mimeinfo-perl, libcrypt-ssleay-perl, liblocale-gettext-perl (>= 1.05-1), graphviz
Description: a wiki compiler
ikiwiki converts a directory full of wiki pages into HTML pages suitable
for publishing on a website. Unlike many wikis, ikiwiki does not have its
--- /dev/null
+[[template id=plugin name=graphviz author="[[JoshTriplett]]"]]
+[[tag type/chrome type/format]]
+
+This plugin allows embedding [graphviz](http://www.graphviz.org/) graphs in a
+page. Example usage:
+
+ \[[graph src="a -> b -> c; a -> c;"]]
+
+Note that graphs will only show up in previews if your browser has
+[[wikipedia data: URI]] support, or if the same graph already exists on that
+page.
+
+Security implications: graphviz does not seem to have any syntax exploitable to
+perform file access or shell commands on the server. However, the graphviz
+plugin does make denial of service attacks somewhat easier: any user with edit
+privileges can use this plugin to create large files without the need to send
+large amounts of data, allowing them to more quickly fill the disk, run the
+server out of memory, or use up large amounts of bandwidth. Any user can
+already do these things with just the core of ikiwiki, but the graphviz plugin
+allows for an amplification attack, since users can send less data to use large
+amounts of processing time and disk usage.
+
+The `graph` directive supports the following parameters:
+
+- `src` - The graphviz source to render.
+- `type` - The type of graph to render: `graph` or `digraph`. Defaults to
+ `digraph`.
+- `prog` - The graphviz program to render with: `dot`, `neato`, `fdp`, `twopi`,
+ or `circo`. Defaults to `dot`.
+- `height`, `width` - Limit the size of the graph to a given height and width,
+ in inches. You must specify both to limit the size; otherwise, graphviz will
+ choose a size, without any limit.
+
+[[if test="enabled(graphviz)" then="""
+Some example graphs:
+
+[[graph src="a -> b -> c; a -> b;"]]
+[[graph src="a -- b -- c -- a;" prog="circo" type="graph"]]
+"""]]
> Editing graphviz files safely online might be tricky. Graphvis would need
> to be audited. --[[Joey]]
-[[tag soc]]
+>> I've added a [[graphviz_plugin|plugins/graphviz]] which adds a preprocessor
+>> directive to render inline graphviz graphs, addressing part of this todo
+>> item. It doesn't yet support graphviz files as a separate page type, image
+>> maps, or wikilinks.--[[JoshTriplett]]
msgstr ""
"Project-Id-Version: ikiwiki-bg\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-04-06 16:36-0400\n"
+"POT-Creation-Date: 2007-04-09 01:55-0700\n"
"PO-Revision-Date: 2007-01-12 01:19+0200\n"
"Last-Translator: Damyan Ivanov <dam@modsodtsys.com>\n"
"Language-Team: Bulgarian <dict@fsa-bg.org>\n"
msgid "failed to find url in html"
msgstr "приставката „googlecalendar” не намери URL в HTML-кода"
+#: ../IkiWiki/Plugin/graphviz.pm:59
+#, fuzzy
+msgid "failed to run graphviz"
+msgstr "приставката „linkmap”: грешка при изпълнение на „dot”"
+
+#: ../IkiWiki/Plugin/graphviz.pm:81
+msgid "prog not a valid graphviz program"
+msgstr ""
+
#: ../IkiWiki/Plugin/img.pm:36
#, fuzzy, perl-format
msgid "%s not found"
#. translators: preprocessor directive name,
#. translators: the second a page name, the
#. translators: third a number.
-#: ../IkiWiki.pm:614
+#: ../IkiWiki.pm:620
#, perl-format
msgid "%s preprocessing loop detected on %s at depth %i"
msgstr "открита е циклична завидимост при %s на „%s” на дълбочина %i"
msgstr ""
"Project-Id-Version: ikiwiki\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-04-06 16:36-0400\n"
+"POT-Creation-Date: 2007-04-09 01:55-0700\n"
"PO-Revision-Date: 2007-02-17 12:07+0100\n"
"Last-Translator: Miroslav Kure <kurem@debian.cz>\n"
"Language-Team: Czech <debian-l10n-czech@lists.debian.org>\n"
msgid "failed to find url in html"
msgstr "googlecalendar v html nenalezl url"
+#: ../IkiWiki/Plugin/graphviz.pm:59
+#, fuzzy
+msgid "failed to run graphviz"
+msgstr "linkmapu se nepodařilo spustit dot"
+
+#: ../IkiWiki/Plugin/graphviz.pm:81
+msgid "prog not a valid graphviz program"
+msgstr ""
+
#: ../IkiWiki/Plugin/img.pm:36
#, fuzzy, perl-format
msgid "%s not found"
#. translators: preprocessor directive name,
#. translators: the second a page name, the
#. translators: third a number.
-#: ../IkiWiki.pm:614
+#: ../IkiWiki.pm:620
#, perl-format
msgid "%s preprocessing loop detected on %s at depth %i"
msgstr "Byla rozpoznána smyčka direktivy %s na %s v hloubce %i"
msgstr ""
"Project-Id-Version: es\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-04-06 16:36-0400\n"
+"POT-Creation-Date: 2007-04-09 01:55-0700\n"
"PO-Revision-Date: 2007-02-12 10:31+0100\n"
"Last-Translator: Víctor Moral <victor@taquiones.net>\n"
"Language-Team: spanish <es@li.org>\n"
msgstr ""
"El complemento googlecalendar no ha encontrado un URL en el código HTML"
+#: ../IkiWiki/Plugin/graphviz.pm:59
+#, fuzzy
+msgid "failed to run graphviz"
+msgstr "El complemento linkmap no ha podido ejecutar el programa dot"
+
+#: ../IkiWiki/Plugin/graphviz.pm:81
+msgid "prog not a valid graphviz program"
+msgstr ""
+
#: ../IkiWiki/Plugin/img.pm:36
#, fuzzy, perl-format
msgid "%s not found"
#. translators: preprocessor directive name,
#. translators: the second a page name, the
#. translators: third a number.
-#: ../IkiWiki.pm:614
+#: ../IkiWiki.pm:620
#, perl-format
msgid "%s preprocessing loop detected on %s at depth %i"
msgstr ""
msgstr ""
"Project-Id-Version: ikiwiki\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-04-06 16:36-0400\n"
+"POT-Creation-Date: 2007-04-09 01:55-0700\n"
"PO-Revision-Date: 2007-04-01 21:03+0200\n"
"Last-Translator: Jean-Luc Coulon (f5ibh) <jean-luc.coulon@wanadoo.fr>\n"
"Language-Team: French <debian-l10n-french@lists.debian.org>\n"
msgid "failed to find url in html"
msgstr "Échec dans la recherche de l'url dans le code html"
+#: ../IkiWiki/Plugin/graphviz.pm:59
+#, fuzzy
+msgid "failed to run graphviz"
+msgstr "Échec de lancement de php"
+
+#: ../IkiWiki/Plugin/graphviz.pm:81
+msgid "prog not a valid graphviz program"
+msgstr ""
+
#: ../IkiWiki/Plugin/img.pm:36
#, perl-format
msgid "%s not found"
#. translators: preprocessor directive name,
#. translators: the second a page name, the
#. translators: third a number.
-#: ../IkiWiki.pm:614
+#: ../IkiWiki.pm:620
#, perl-format
msgid "%s preprocessing loop detected on %s at depth %i"
msgstr ""
msgstr ""
"Project-Id-Version: ikiwiki-gu\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-04-06 16:36-0400\n"
+"POT-Creation-Date: 2007-04-09 01:55-0700\n"
"PO-Revision-Date: 2007-01-11 16:05+0530\n"
"Last-Translator: Kartik Mistry <kartik.mistry@gmail.com>\n"
"Language-Team: Gujarati <team@utkarsh.org>\n"
msgid "failed to find url in html"
msgstr "ગુગલકેલેન્ડરને htmlમાં યુઆરએલ મળ્યું નહી"
+#: ../IkiWiki/Plugin/graphviz.pm:59
+#, fuzzy
+msgid "failed to run graphviz"
+msgstr "લીંકમેપ ડોટ ચલાવવામાં નિષ્ફળ"
+
+#: ../IkiWiki/Plugin/graphviz.pm:81
+msgid "prog not a valid graphviz program"
+msgstr ""
+
#: ../IkiWiki/Plugin/img.pm:36
#, fuzzy, perl-format
msgid "%s not found"
#. translators: preprocessor directive name,
#. translators: the second a page name, the
#. translators: third a number.
-#: ../IkiWiki.pm:614
+#: ../IkiWiki.pm:620
#, perl-format
msgid "%s preprocessing loop detected on %s at depth %i"
msgstr "%s પર શોધાયેલ લુપ %s પર ચલાવે છે %i ઉંડાણ પર"
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-04-08 16:20-0400\n"
+"POT-Creation-Date: 2007-04-09 01:55-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
msgid "failed to find url in html"
msgstr ""
+#: ../IkiWiki/Plugin/graphviz.pm:59
+msgid "failed to run graphviz"
+msgstr ""
+
+#: ../IkiWiki/Plugin/graphviz.pm:81
+msgid "prog not a valid graphviz program"
+msgstr ""
+
#: ../IkiWiki/Plugin/img.pm:36
#, perl-format
msgid "%s not found"
msgstr ""
"Project-Id-Version: ikiwiki 1.37\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-04-06 16:36-0400\n"
+"POT-Creation-Date: 2007-04-09 01:55-0700\n"
"PO-Revision-Date: 2007-01-05 16:33+100\n"
"Last-Translator: Paweł Tęcza <ptecza@net.icm.edu.pl>\n"
"Language-Team: Debian L10n Polish <debian-l10n-polish@lists.debian.org>\n"
"awaria wtyczki googlecalendar z powodu nieodnalezionego adresu URL na "
"stronie HTML"
+#: ../IkiWiki/Plugin/graphviz.pm:59
+#, fuzzy
+msgid "failed to run graphviz"
+msgstr "awaria wtyczki linkmap"
+
+#: ../IkiWiki/Plugin/graphviz.pm:81
+msgid "prog not a valid graphviz program"
+msgstr ""
+
#: ../IkiWiki/Plugin/img.pm:36
#, fuzzy, perl-format
msgid "%s not found"
#. translators: preprocessor directive name,
#. translators: the second a page name, the
#. translators: third a number.
-#: ../IkiWiki.pm:614
+#: ../IkiWiki.pm:620
#, perl-format
msgid "%s preprocessing loop detected on %s at depth %i"
msgstr "polecenie preprocesora %s wykryte w %s na głębokości %i"
msgstr ""
"Project-Id-Version: ikiwiki\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-04-06 16:36-0400\n"
+"POT-Creation-Date: 2007-04-09 01:55-0700\n"
"PO-Revision-Date: 2007-01-10 23:47+0100\n"
"Last-Translator: Daniel Nylander <po@danielnylander.se>\n"
"Language-Team: Swedish <tp-sv@listor.tp-sv.se>\n"
msgid "failed to find url in html"
msgstr "googlecalendar misslyckades med att hitta url i html"
+#: ../IkiWiki/Plugin/graphviz.pm:59
+#, fuzzy
+msgid "failed to run graphviz"
+msgstr "linkmap misslyckades att köra dot"
+
+#: ../IkiWiki/Plugin/graphviz.pm:81
+msgid "prog not a valid graphviz program"
+msgstr ""
+
#: ../IkiWiki/Plugin/img.pm:36
#, fuzzy, perl-format
msgid "%s not found"
#. translators: preprocessor directive name,
#. translators: the second a page name, the
#. translators: third a number.
-#: ../IkiWiki.pm:614
+#: ../IkiWiki.pm:620
#, perl-format
msgid "%s preprocessing loop detected on %s at depth %i"
msgstr "%s förbehandlingsslinga detekterades på %s, djup %i"
msgstr ""
"Project-Id-Version: ikiwiki\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-04-06 16:36-0400\n"
+"POT-Creation-Date: 2007-04-09 01:55-0700\n"
"PO-Revision-Date: 2007-01-13 15:31+1030\n"
"Last-Translator: Clytie Siddall <clytie@riverland.net.au>\n"
"Language-Team: Vietnamese <vi-VN@googlegroups.com>\n"
msgid "failed to find url in html"
msgstr "googlecalendar không tìm thấy địa chỉ URL trong mã HTML"
+#: ../IkiWiki/Plugin/graphviz.pm:59
+#, fuzzy
+msgid "failed to run graphviz"
+msgstr "linkmap không chạy dot được"
+
+#: ../IkiWiki/Plugin/graphviz.pm:81
+msgid "prog not a valid graphviz program"
+msgstr ""
+
#: ../IkiWiki/Plugin/img.pm:36
#, fuzzy, perl-format
msgid "%s not found"
#. translators: preprocessor directive name,
#. translators: the second a page name, the
#. translators: third a number.
-#: ../IkiWiki.pm:614
+#: ../IkiWiki.pm:620
#, perl-format
msgid "%s preprocessing loop detected on %s at depth %i"
msgstr "vòng lặp tiền xử lý %s được phát hiện trên %s ở độ sâu %i"