/[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

Diff of /m/menu.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by dpavlin, Fri Jun 29 08:33:59 2001 UTC revision 1.7 by dpavlin, Mon Nov 5 10:47:10 2001 UTC
# Line 7  use Image::Magick; Line 7  use Image::Magick;
7  use constant TYPE_NONE => scalar 2;  use constant TYPE_NONE => scalar 2;
8  use constant TYPE_BULLET => scalar 3;  use constant TYPE_BULLET => scalar 3;
9  use constant TYPE_LINE => scalar 1;  use constant TYPE_LINE => scalar 1;
10    use constant TYPE_BLUEDOT => scalar 4;
11    
12  # size of menu image  # size of menu image
13  my $w=125;  my $w=125;
14  my $h_base=13;  my $h_base=13;
15  my $h;  my $h;
16    
17    my %iso2utf_tab = (
18    '¹' => 0x0161, 'ð' => 0x0111, 'è' => 0x010d, 'æ' => 0x0107, '¾' => 0x017e,
19    '©' => 0x0160, 'Ð' => 0x0110, 'È' => 0x010c, 'Æ' => 0x0106, '®' => 0x017d
20    );
21    
22    sub iso2utf {
23            local($_)=@_;
24    
25            sub utf8 {
26                    local($_)=@_;
27                    return $_ < 0x80 ? chr($_) :
28                     $_ < 0x800 ? chr($_>>6&0x3F|0xC0) . chr($_&0x3F|0x80) :
29                      chr($_>>12&0x0F|0xE0).chr($_>>6&0x3F|0x80).chr($_&0x3F|0x80);
30            }
31            s/([¹ðè澩ÐÈÆ®])/utf8($iso2utf_tab{$1})/ge;
32            return $_;
33    }
34    
35  sub dump_gif {  sub dump_gif {
36          my ($text, $type, $file) = @_;          my ($text, $type, $file) = @_;
37          $type ||= TYPE_NONE;          $type ||= TYPE_NONE;
38          $file ||= $text;          $file ||= "$text-$type";
39          $file =~ s/[^a-zA-Z0-9\-]/_/g;          $file =~ s/[^a-zA-Z0-9\-]/_/g;
40            $file = lc($file);
41          print "$text" unless ($file eq "-");          print "$text" unless ($file eq "-");
42          my $tmp=$text;          my $tmp=$text;
43          my $nl=1;          my $nl=1;
# Line 26  sub dump_gif { Line 46  sub dump_gif {
46          my $image = Image::Magick->new;          my $image = Image::Magick->new;
47          $image->Set('size' => "${w}x${h}");          $image->Set('size' => "${w}x${h}");
48          $image->Read('xc:#283880');          $image->Read('xc:#283880');
49            $text=~tr/šðžèæŠÐŽÈÆ/¹ð¾èæ©Ð®ÈÆ/;       # 1250 -> iso8859-2
50            $text=iso2utf($text);
51          if ($type == TYPE_BULLET) {          if ($type == TYPE_BULLET) {
52                  $image->Annotate('text' => $text, 'geometry' => '+17+10',                  $image->Annotate('text' => $text, 'geometry' => '+17+10',
53                          'font' => "\@arialbd.ttf", 'pointsize' => 11,                          'font' => "\@arialbd.ttf", 'pointsize' => 11,
# Line 37  sub dump_gif { Line 59  sub dump_gif {
59                  $image->Draw('primitive' => 'rectangle', 'stroke' => '#00D000',                  $image->Draw('primitive' => 'rectangle', 'stroke' => '#00D000',
60                          'fill' => '#00D000', 'antialias' => 1, 'points' =>                          'fill' => '#00D000', 'antialias' => 1, 'points' =>
61                          '7,4 10,7');                          '7,4 10,7');
62            } elsif ($type == TYPE_BLUEDOT) {
63                    $image->Annotate('text' => $text, 'geometry' => '+17+10',
64                            'font' => "\@arialbd.ttf", 'pointsize' => 11,
65                            'fill' => '#ffffff', 'align' => 'left');
66                    $image->Draw('primitive' => 'rectangle', 'stroke' => '#00b2dc',
67                            'fill' => '#00b2dc', 'antialias' => 1, 'points' =>
68                            '7,4 10,7');
69          } else {          } else {
70                  if ($type == TYPE_LINE) {                  if ($type == TYPE_LINE) {
71                          $image->Draw('primitive' => 'line',                          $image->Draw('primitive' => 'line',
# Line 76  sub dump_gif { Line 105  sub dump_gif {
105  #dump_gif("NOVOSTI", TYPE_LINE, "-");  #dump_gif("NOVOSTI", TYPE_LINE, "-");
106  #exit $?;  #exit $?;
107    
108    #
109  my $dbh = DBI->connect("DBI:Pg:dbname=plivasi", "", "") ||  my $dbh = DBI->connect("DBI:Pg:dbname=plivasi", "", "") ||
110          die $DBI::errstr;          die $DBI::errstr;
111  my $sth = $dbh->prepare("SELECT section,item,url,level,num FROM menu") ||  my $sth = $dbh->prepare("SELECT section,item,url,level,num FROM menu") ||

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.7

  ViewVC Help
Powered by ViewVC 1.1.26