/[pliva-si]/m/menu.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /m/menu.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (vendor branch)
Thu Jun 28 10:55:30 2001 UTC (22 years, 9 months ago) by ravilov
Branch: pliva
CVS Tags: r0
Changes since 1.1: +0 -0 lines
File MIME type: text/plain
initial import

1 ravilov 1.1 #! /usr/local/bin/perl -w
2    
3     use strict;
4     use DBI;
5     use Image::Magick;
6    
7     use constant TYPE_NONE => scalar 0;
8     use constant TYPE_BULLET => scalar 1;
9     use constant TYPE_LINE => scalar 2;
10    
11     sub dump_gif {
12     my ($text, $type, $file) = @_;
13     $type ||= TYPE_NONE;
14     $file ||= $text;
15     $file =~ s/[^a-zA-Z0-9\-]/_/g;
16     print "$text" unless ($file eq "-");
17     my $image = Image::Magick->new;
18     $image->Set('size' => '125x13');
19     $image->Read('xc:#283880');
20     if ($type == TYPE_BULLET) {
21     $image->Annotate('text' => $text, 'geometry' => '+17+1',
22     'font' => "\@arialbd.ttf", 'pointsize' => 11,
23     'pen' => '#FFFFFF', 'align' => 'left');
24     $image->Blur('radius' => 1);
25     $image->Draw('primitive' => 'rectangle', 'stroke' => '#00D000',
26     'fill' => '#00D000', 'antialias' => 1, 'points' =>
27     '7,4 10,7');
28     } else {
29     $image->Annotate('text' => $text, 'geometry' => '+3+0',
30     'font' => "\@arialbd.ttf", 'pointsize' => 11,
31     'pen' => '#FFFFFF', 'align' => 'left');
32     $image->Blur('radius' => 1);
33     if ($type == TYPE_LINE) {
34     $image->Draw('primitive' => 'line',
35     'stroke' => '#00FF00', 'fill' => '#00FF00',
36     'antialias' => 1, 'points' => '1,11 63,11');
37     my ($br, $bg, $bb) = (0x00, 0xFF, 0x00);
38     my ($er, $eg, $eb) = (0x28, 0x38, 0x80);
39     my $range = 125 - 64;
40     for (my $i = 0; $i < $range; $i++) {
41     my $j = $i + 64;
42     my $color = sprintf("#%02X%02X%02X",
43     $br + (($er - $br) / $range) * $i,
44     $bg + (($eg - $bg) / $range) * $i,
45     $bb + (($eb - $bb) / $range) * $i
46     );
47     $image->Draw('primitive' => 'point',
48     'stroke' => $color,
49     'antialias' => 1,
50     'points' => "$j,11");
51     }
52     }
53     }
54     # $image->Resize('geometry' => '125x15',
55     # 'filter' => 'Lanczos', 'blur' => '1.8');
56     #$image->Scale('geometry' => '50%');
57     # $image->Draw('stroke' => '#CCCCCC', 'primitive' => 'line',
58     # 'points' => '0,14 118,14', 'linewidth' => 1);
59     # $image->Draw('stroke' => '#cccccc', 'primitive' => 'line',
60     # 'points' => '118,14 118,7', 'linewidth' => 2);
61     print " -> " unless ($file eq "-");
62     $file .= ".gif" unless ($file eq "-");
63     $image->Write('filename' => "gif:$file", 'colors' => 256,
64     'interlace' => "none", 'compress' => 'lzw');
65     print "$file\n" unless ($file eq "-");
66     return "$file";
67     }
68    
69     print "Content-Type: image/gif\n\n";
70     dump_gif("NOVOSTI", TYPE_LINE, "-");
71     exit $?;
72    
73     my $dbh = DBI->connect("DBI:Pg:dbname=corp", "", "") ||
74     die $DBI::errstr;
75     my $sth = $dbh->prepare("SELECT section,item,url FROM menu") ||
76     die $dbh->errstr();
77     $sth->execute() || die $sth->errstr();
78     while (my @arr = $sth->fetchrow_array()) {
79     if (0) {
80     dump_gif($arr[1], TYPE_BULLET);
81     } else {
82     $dbh->do("UPDATE menu SET file='".dump_gif($arr[1], TYPE_BULLET).
83     "' WHERE item='$arr[1]'");
84     }
85     }
86     $sth->finish;
87     $dbh->disconnect;
88     exit $?;

  ViewVC Help
Powered by ViewVC 1.1.26