aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki/Plugin/graphviz.pm86
-rw-r--r--debian/changelog8
-rw-r--r--debian/control2
-rw-r--r--doc/plugins/graphviz.mdwn39
-rw-r--r--doc/todo/graphviz.mdwn5
-rw-r--r--po/bg.po13
-rw-r--r--po/cs.po13
-rw-r--r--po/es.po13
-rw-r--r--po/fr.po13
-rw-r--r--po/gu.po13
-rw-r--r--po/ikiwiki.pot10
-rw-r--r--po/pl.po13
-rw-r--r--po/sv.po13
-rw-r--r--po/vi.po13
14 files changed, 235 insertions, 19 deletions
diff --git a/IkiWiki/Plugin/graphviz.pm b/IkiWiki/Plugin/graphviz.pm
new file mode 100644
index 000000000..48f520c4f
--- /dev/null
+++ b/IkiWiki/Plugin/graphviz.pm
@@ -0,0 +1,86 @@
+#!/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
diff --git a/debian/changelog b/debian/changelog
index 227770ee0..b7957b0c5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+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 ]
diff --git a/debian/control b/debian/control
index 35e6d0eac..f4d4a0742 100644
--- a/debian/control
+++ b/debian/control
@@ -12,7 +12,7 @@ Package: ikiwiki
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
diff --git a/doc/plugins/graphviz.mdwn b/doc/plugins/graphviz.mdwn
new file mode 100644
index 000000000..c8844d0d6
--- /dev/null
+++ b/doc/plugins/graphviz.mdwn
@@ -0,0 +1,39 @@
+[[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"]]
+"""]]
diff --git a/doc/todo/graphviz.mdwn b/doc/todo/graphviz.mdwn
index 4c70250a3..31d5787ae 100644
--- a/doc/todo/graphviz.mdwn
+++ b/doc/todo/graphviz.mdwn
@@ -5,4 +5,7 @@ To complement this, ikiwiki could support creating and editing graphviz files th
> 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]]
diff --git a/po/bg.po b/po/bg.po
index 783d391b3..25ec7da86 100644
--- a/po/bg.po
+++ b/po/bg.po
@@ -7,7 +7,7 @@ msgid ""
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"
@@ -123,6 +123,15 @@ msgstr "грешшка в приставката „fortune”"
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"
@@ -566,7 +575,7 @@ msgstr "Грешка"
#. 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"
diff --git a/po/cs.po b/po/cs.po
index 59486b266..259b256af 100644
--- a/po/cs.po
+++ b/po/cs.po
@@ -7,7 +7,7 @@ msgid ""
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"
@@ -122,6 +122,15 @@ msgstr "fortune selhal"
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"
@@ -559,7 +568,7 @@ msgstr "Chyba"
#. 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"
diff --git a/po/es.po b/po/es.po
index 75b9b56de..9ee628afc 100644
--- a/po/es.po
+++ b/po/es.po
@@ -7,7 +7,7 @@ msgid ""
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"
@@ -126,6 +126,15 @@ msgid "failed to find url in html"
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"
@@ -571,7 +580,7 @@ msgstr "Error"
#. 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 ""
diff --git a/po/fr.po b/po/fr.po
index 669c356e2..4aa7cd99e 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -7,7 +7,7 @@ msgid ""
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"
@@ -124,6 +124,15 @@ msgstr "Échec de « fortune »"
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"
@@ -558,7 +567,7 @@ msgstr "Erreur"
#. 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 ""
diff --git a/po/gu.po b/po/gu.po
index fb8830e4e..2899b62ad 100644
--- a/po/gu.po
+++ b/po/gu.po
@@ -7,7 +7,7 @@ msgid ""
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"
@@ -122,6 +122,15 @@ msgstr "ભવિષ્ય નિષ્ફળ"
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"
@@ -556,7 +565,7 @@ msgstr "ક્ષતિ"
#. 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 ઉંડાણ પર"
diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot
index 40ac2637e..1986963c0 100644
--- a/po/ikiwiki.pot
+++ b/po/ikiwiki.pot
@@ -8,7 +8,7 @@ msgid ""
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"
@@ -122,6 +122,14 @@ msgstr ""
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"
diff --git a/po/pl.po b/po/pl.po
index 9c46d4ed2..029733d3c 100644
--- a/po/pl.po
+++ b/po/pl.po
@@ -8,7 +8,7 @@ msgid ""
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"
@@ -125,6 +125,15 @@ msgstr ""
"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"
@@ -570,7 +579,7 @@ msgstr "Błąd"
#. 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"
diff --git a/po/sv.po b/po/sv.po
index 6428edd87..3caf2e850 100644
--- a/po/sv.po
+++ b/po/sv.po
@@ -7,7 +7,7 @@ msgid ""
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"
@@ -122,6 +122,15 @@ msgstr "fortune misslyckades"
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"
@@ -560,7 +569,7 @@ msgstr "Fel"
#. 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"
diff --git a/po/vi.po b/po/vi.po
index 240c5dbb7..628a60d22 100644
--- a/po/vi.po
+++ b/po/vi.po
@@ -6,7 +6,7 @@ msgid ""
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"
@@ -123,6 +123,15 @@ msgstr "fortune bị lỗi"
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"
@@ -561,7 +570,7 @@ msgstr "Lỗi"
#. 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"