diff options
author | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2007-03-07 07:41:07 +0000 |
---|---|---|
committer | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2007-03-07 07:41:07 +0000 |
commit | 4cbb1095d62b9b2ded9546040e4bc5f5b0faef67 (patch) | |
tree | 6566313d4f07ee0757d9b39efccbf360e2f6d1de /IkiWiki | |
parent | 7ae2deacdf5ebf7274da8c77daf42b43aca985c0 (diff) | |
download | ikiwiki-4cbb1095d62b9b2ded9546040e4bc5f5b0faef67.tar ikiwiki-4cbb1095d62b9b2ded9546040e4bc5f5b0faef67.tar.gz |
support previewing of sparklines: embed in data uris for preview
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Plugin/sparkline.pm | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/IkiWiki/Plugin/sparkline.pm b/IkiWiki/Plugin/sparkline.pm index a44e06252..63c2cf943 100644 --- a/IkiWiki/Plugin/sparkline.pm +++ b/IkiWiki/Plugin/sparkline.pm @@ -108,10 +108,6 @@ sub preprocess (@) { #{{{ $php.=qq{\$sparkline->RenderResampled($width, $height);\n}; } - if ($params{preview}) { - return "[[".gettext("sparkline previewing not implemented")."]]"; - } - $php.=qq{\$sparkline->Output();\n?>\n}; # Use the sha1 of the php code that generates the sparkline as @@ -148,7 +144,16 @@ sub preprocess (@) { #{{{ return "[[".gettext("sparkline failed to run php")."]]"; } - writefile($fn, $config{destdir}, $png, 1); + if (! $params{preview}) { + writefile($fn, $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="'. |