File: logo.src

package info (click to toggle)
wml 2.32.0~ds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, trixie
  • size: 1,812 kB
  • sloc: perl: 6,963; ansic: 747; yacc: 154; makefile: 107; sh: 25
file content (195 lines) | stat: -rw-r--r-- 5,706 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
##
##  wml::std::logo - Logo Insertion
##  Copyright (c) 1997-2001 Ralf S. Engelschall, All Rights Reserved.
##

#  The <preserve>/<restore> tags with multiple arguments require WML 2.0.3
#use wml::mod::version
<require 2.0.3 />

#use wml::std::tags

#
#  Insert a Logo image
#
<define-tag logo>
<preserve name base file format target notag />
<set-var notag=* />
<set-var %attributes />
<defvar name wml />
<defvar base <or <get-var LOGO_BASE /> <get-var IMAGE_BASE /> /> />
<defvar format <or <get-var IMAGE_FORMAT /> png /> />
<perl>
    my $name   = '<get-var name />';
    my $ext    = '<get-var format />';
    my $base   = '<get-var base />';
    my $file   = '<get-var file />';
    my $target = '<get-var target />';
    my $notag  = (qq|<get-var notag />| eq '' ? 1 : 0);

    my $dir = "$(WML_LOC_DATADIR)/data/logos";
    my $imgfile  = "$dir/logo-$name.$ext";
    my $infofile = "$dir/logo-$name.info";

    #   make sure the logo exists
    if (! -f $imgfile or ! -f $infofile) {
        print STDERR "Error: No such logo named '$name'.\n";
        exit(1);
    }

    #   create the output filename
    if ($file eq '') {
        if ($base ne '' && $base !~ m|/$|) {
            if (-d $base) {
                $base .= '/';
            }
            else {
                $base .= '.';
            }
        }
        $file = sprintf("%slogo-%s.%s", $base, $name, $ext);
    }

    open(FH_LOGO, "<$infofile");
    my $alt  = <*FH_LOGO>; $alt  =~ s|^\s+||; $alt  =~ s|\n$||; $alt  =~ s|\s+$||;
    my $hint = <*FH_LOGO>; $hint =~ s|^\s+||; $hint =~ s|\n$||; $hint =~ s|\s+$||;
    my $url  = <*FH_LOGO>; $url  =~ s|^\s+||; $url  =~ s|\n$||; $url  =~ s|\s+$||;
    close(FH_LOGO);

    #   create the logo image copy
    my $error = `cp $imgfile $file`;
    if ($? >> 8) {
        print STDERR "** wml::std::logo:\n$error";
        exit(1);
    }

    #   insert the markup code
    if (not $notag) {
        <perl:print>\
           <*a href="$url" \
              onmouseover="self.status='$hint';return true" \
              onmouseout="self.status='';return true" \
              onfocus="self.status='$hint';return true" \
              onblur="self.status='';return true"\
        </perl:print>
        if ($target ne '') {
          <perl:print> target="$target"</perl:print>
        }
        <perl:print>\
           ><img src="$file" alt="$alt" border=0 /><*/a>\
        </perl:print>
    }
</perl>
<restore  name base file format target notag />
</define-tag>

##EOF##
__END__

=head1 NAME

wml::std::logo - Logo Insertion

=head1 SYNOPSIS

 #use wml::std::logo

 <logo [attributes]>

=head1 DESCRIPTION

This include file provides the C<E<lt>logoE<gt>> tag to insert logo images.
The logo is selected via attribute C<name>. The following logos are available:

  Name      Inserted Hint                  Inserted URL
  --------  ------------------------------ ----------------------------
  apache    Apache Webserver Project       http://www.apache.org/
  freebsd   FreeBSD Operating System       http://www.freebsd.org/
  gimp      GNU Image Manipulation Program http://www.gimp.org/
  linux     Linux Operating System         http://www.linux.org/
  netbsd    NetBSD Operating System        http://www.netbsd.org/
  openbsd   OpenBSD Operating System       http://www.openbsd.org/
  php       PHP Hypertext Preprocessor     http://www.php.net/
  vim       Vi Improved Editor             http://www.vim.org/
  wml       Website META Language          https://www.shlomifish.org/open-source/projects/website-meta-language/

=head1 ATTRIBUTES

=over 4

=item C<name>

The C<name> attribute selects which logo is wanted. The table above lists
valid names, and I<wml> is used by default.

=item C<base>

Usually the logos are copied into F<logo-xxxxxx.png> where C<xxxxxx> is
the name of the logo.  When you use a C<base=foo> attribute, then the
resulting files are named F<foo.logo-xxxxxx.png>.  Actually you can even
use a complete filename including a directory prefix, i.e. when you use
C<base=../../common/foo> attribute, then the images are created as
F<../../common/foo.logo-xxxxxx.png>.

And for most flexibility when no base is specified and the variable
C<LOGO_BASE> is defined (usually from within a F<.wmlrc> file via
C<-LOGO_BASE~path/to/logo/dir/base>) it is used.  Use this feature to
copy the logos to a particular directory.

You may also use the variable C<IMAGE_BASE> which defines in a single line
all base names for images generated by WML.

=item C<format>

Logos are available in PNG or GIF formats. This attribute is the
filename extension of the desired format, i.e. respectively C<png> and C<gif>.
Default is C<png> extension ; this default can be changed via the C<IMAGE_FORMAT>
variable.

=item C<file>

This attribute defines the logo filename. It overrides all other computed
values.

=item C<target>

If the C<target> attribute is used, it refers to a target frame or window
where the hyperlink is redirected to.

=item C<notag>

This forces C<E<lt>logoE<gt>> to expand to nothing, i.e. no resulting
C<E<lt>imgE<gt>> tag. The image itself is still generated. In combination with
the above C<file> attribute this can be used to generate images to particular
files which can be used at other positions, for instance inside
C<E<lt>rolloverE<gt>> (see wml::des::rollover(3)) tags.

=back

=head1 EXAMPLE

This example only copy the vim logo to C<$(IMAGES)/logo-vim.png> without
any output:

 <logo name=vim format=png base="$(IMAGES)/logo" notag>

=head1 AUTHORS

 Ralf S. Engelschall
 rse@engelschall.com
 www.engelschall.com

 Denis Barbier
 barbier@engelschall.com

=head1 REQUIRES

 Internal: P1, P2, P3
 External: --

=head1 SEE ALSO

wml(1)

=cut