indeed not fixed, but patch needs improvement
[ikiwiki] / doc / bugs / Problems_with_graphviz.pm_plug-in.mdwn
1 The graphviz.pm plug-in currently attempts to read PNG data in UTF-8 mode, which sometimes fail with a message similar to the following (depending on the input):
2
3     utf8 "\x89" does not map to Unicode at /usr/local/lib/perl5/site_perl/5.8.8/IkiWiki/Plugin/graphviz.pm line 53, <IN> chunk 1.
4     Wide character in subroutine entry at /usr/local/lib/perl5/site_perl/5.8.8/IkiWiki/Plugin/graphviz.pm line 68.
5
6 > Ok, will remove the binmode IN then. done --[[Joey]]
7
8 >> Thanks --[[HenrikBrixAndersen]]
9
10 It also generates image URLs relative to the page being rendered, which means the URLs wont work when previewing a graph from the CGI script.
11
12 > You seem to be using an old version of ikiwiki, these preview isues have
13 > been fixed for some time, and the code doesn't look like what you patch
14 > in your second hunk. --[[Joey]]
15
16 >> I have just tested ikiwiki-2.5. The code in question still looks
17 >> the same, and the patch is still needed for making the graphviz
18 >> plug-in work in preview mode here.
19
20 >>> You're right, it doesn't preview properly. However, your patch doesn't
21 >>> really fix it, since it only makes it show any old files that are lying
22 >>> around, and not a current one updated for the current page. Fixing it
23 >>> really right calls for embedding the file in a data uri in the preview
24 >>> page, as the sparkline plugin does. --[[Joey]]
25
26 >> Here is an updated patch againt ikiwiki-2.5:
27
28
29     --- IkiWiki/Plugin/graphviz.pm.orig 2007-07-27 11:35:05.000000000 +0200
30     +++ IkiWiki/Plugin/graphviz.pm      2007-07-27 11:36:02.000000000 +0200
31     @@ -69,7 +69,12 @@ sub render_graph (\%) { #{{{
32                 }
33         }
34      
35     -   return "<img src=\"".urlto($dest, $params{page})."\" />\n";
36     +   if ($params{preview}) {
37     +           return "<img src=\"".urlto($dest, "")."\" />\n";
38     +   }
39     +   else {
40     +           return "<img src=\"".urlto($dest, $params{page})."\" />\n";
41     +   }
42      } #}}}
43      
44      sub graph (@) { #{{{
45
46
47 >> --[[HenrikBrixAndersen]]
48
49
50 The patch below fixes these two issues.
51
52     --- graphviz.pm.orig        Thu Jun  7 15:45:16 2007
53     +++ graphviz.pm     Fri Jun  8 12:03:38 2007
54     @@ -41,7 +41,6 @@ sub render_graph (\%) { #{{{
55                 $pid=open2(*IN, *OUT, "$params{prog} -Tpng");
56      
57                 # open2 doesn't respect "use open ':utf8'"
58     -           binmode (IN, ':utf8');
59                 binmode (OUT, ':utf8');
60      
61                 print OUT $src;
62     @@ -70,7 +69,12 @@ sub render_graph (\%) { #{{{
63                 }
64         }
65      
66     -   return "<img src=\"".urlto($dest, $params{page})."\" />\n";
67     +   if ($params{preview}) {
68     +           return "<img src=\"".urlto($dest, "")."\" />\n";
69     +   }
70     +   else {
71     +           return "<img src=\"".urlto($dest, $params{page})."\" />\n";
72     +   }
73      } #}}}
74      
75      sub graph (@) { #{{{