Code

Initial revision
[rrdtool-all.git] / website / .wml / tobis.inc
1 #use wml::des::space
2 #use wml::std::tags
3 #use wml::fmt::url
4 #use wml::std::box
6 <define-container TITLE>
7 ..TITLE>>%body<<..
8 </define-container>
10 <define-container LI>
11 <LI*>%body</LI*><DIV><vspace 7></DIV>
12 </define-container>
14 <define-container MAGICK>
15 # <MAGICK ButtonSmall|ButtonLarge|Title|Section  optfilename>
16 <perl>
17 BEGIN{unshift @INC, "/usr/pack/imagemagick-4.2.9-to/solaris/perl/"};
18 use Image::Magick;
19 my $type = lc("%0");
20 my $text = <<'sdosidufgtjseflsdj';
21 %body
22 sdosidufgtjseflsdj
23 $text =~ s/%/%%/g;
25 my $fontpath = "/home/oetiker/data/projects/AABN-rrdtool/website/.ttf";
26 my %props = (
27         "buttonsmall" =>["trebuc","20","250x34",  "+40+0"],
28         "buttonlarge" =>["trebuc","21","250x38",  "+24+3"],
29         "title" =>      ["trebucbd","50","940x400", "+0+1"],
30         "section" =>    ["trebucbd","32","940x60",  "+0+1"]
31 );
33 my %color = ( "back" => "#6c9bcd",
34                "fore" => "#14195d",
35                "activ" =>   "#fdfbcc",
36                "marker" =>  "#14195d",
37                "tfore" =>   "#14195d",
38                "tactiv" => "#5786bf",
39                "tback" =>   "#ffffff",         
40 );
42 my $file = $text;
43 $file =~ s/\s+|\/|<|>|"|\?/_/g;
44 $file = "%1" if "%1";
46 if ($type =~ /^button/) {
47       @filetask = ("$file-sel","$file-std","$file-ovr");
48 } else {
49       @filetask = ($file);
50 }
51 foreach $file (@filetask){
52        next if -e "$(ROOT)/.img/$file.gif";
53        my ($q);
54         
55        $q=Image::Magick->new;     
56        $q->Set(size=>$props{$type}[2]);
57        if ($type =~ /^title/ ||$type =~ /^section/ ){
58         $q->ReadImage("xc:$color{tback}");
59         $col=$color{tfore};
60        } else {
61         $q->ReadImage("xc:$color{back}");
62         $col=$color{fore};
63        }
64        $border=0;
66        if ($type =~ /^title/){
67         $q->Annotate(text=>$text,
68                geometry=>"+3+3",
69                font=>"\@${fontpath}/$props{$type}[0].ttf",
70                pointsize=>$props{$type}[1],
71                pen=>$color{tactiv},
72                align=>'left');
73         $q->Blur(factor=>99);
74         $q->Blur(factor=>99);
75         $q->Blur(factor=>99);
76         $q->Blur(factor=>99);
77         $q->Blur(factor=>99);
78         $q->Blur(factor=>99);
79         $q->Blur(factor=>99);
80         $q->Blur(factor=>99);
81         $q->Blur(factor=>99);
82         $q->Blur(factor=>99);
83         $q->Blur(factor=>99);
84         $q->Blur(factor=>99);
85         $q->Blur(factor=>99);
86         $q->Blur(factor=>99);
87         $q->Blur(factor=>99);
88        }
90        if ($type =~ /^button/) {
91        SWITCH: for ($file) {
92             /-sel$/ && do { $col = $color{activ}; $border=1; last;};
93             /-ovr$/ && do { $col = $color{activ};
94                 if ($type =~ /small$/) {
95                             $q->Draw(primitive=>'FillPolygon',
96                                      pen=>$color{marker},
97                                      points => "10,4 24,14 10,24");
98                 } else {
99                             $q->Draw(primitive=>'FillPolygon',
100                                      pen=>$color{marker},
101                                      points => "0,10 14,20 0,30");
102                 }
103                             last;};
104             /-std$/ && do { $col = $color{fore}; last;};
105           }
106         }
109         $q->Annotate(text=>$text,
110                geometry=>$props{$type}[3],
111                font=>"\@${fontpath}/$props{$type}[0].ttf",
112                pointsize=>$props{$type}[1],
113                pen=>$col,
114                align=>'left');
116        $q->Scale(geometry=>"50%");
117        $q->Crop(geometry=>"0x0+1+1") unless $type =~ /^button/;
118        $q->Sharpen(factor=>"30%") if $type =~ /^button/;
119        $q->Quantize(colors=>15,olorspace=>"RGB", dither=>"true");       
120        $q->Write(filename=>"gif:$(ROOT)/.img/$file.gif", 
121                  colors=>16,                                                     
122                  interlace=>"line",
123                  compress=>'lzw');
126 print "$(ROOT)/.img/$file.gif" unless "%1";
128 </perl>
129 </define-container>
131 <define-container H1>
132 ..!H1>>
133 <H1*><IMG SRC="<MAGICK Title>%body</MAGICK>" ALT="<: print qq{%body} :> "></H1*>
134 <<..
135 ..!TITLE>><: print qq{%body} :><<..
136 </define-container>
138 <define-container H2>
139 <DIV><vspace 6><BR><IMG SRC="<MAGICK Section>%body</MAGICK>" ALT="%body"><BR><vspace 5></DIV>
140 </define-container>
142 #<define-container P>
143 #<DIV>%body<BR><vspace 4></DIV>
144 #</define-container>
146 <define-container DD>
147 <DD*>%BODY</DD*><P*>
148 </define-container>
150 <define-container DT>
151 <DT*><B>%BODY</B></DT*>
152 </define-container>