3 #=======================================================================
5 # File ID: e315d656-1cb0-11de-a0da-000475e441b9
6 # Create HTML page with collection of images
9 # ©opyleft 2004– Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later, see end of
11 # file for legal stuff.
12 #=======================================================================
36 $progname =~ s/^.*\/(.*?)$/$1/;
37 our $VERSION = "0.00";
39 my $Author = txt_to_xml
('Øyvind A. Holm <sunny@sunbase.org>'); # FIXME: Hardcoding
40 my $cmdline_str = txt_to_xml
(join(" ", @ARGV));
42 Getopt
::Long
::Configure
("bundling");
45 "debug" => \
$Opt{'debug'},
46 "generate|g" => \
$Opt{'generate'},
47 "help|h" => \
$Opt{'help'},
48 "language|l=s" => \
$Opt{'language'},
49 "output-file|o=s" => \
$Opt{'output-file'},
50 "title|t=s" => \
$Opt{'title'},
51 "verbose|v+" => \
$Opt{'verbose'},
52 "version" => \
$Opt{'version'},
54 ) || die("$progname: Option error. Use -h for help.\n");
56 $Opt{'debug'} && ($Debug = 1);
57 $Opt{'help'} && usage
(0);
58 if ($Opt{'version'}) {
63 my $Title = txt_to_xml
($Opt{'title'}) || die("$progname: -t/--title not specified\n");;
64 my $Outfile = txt_to_xml
($Opt{'output-file'}) || die("$progname: -o/--output-file not specified\n");;
65 scalar(@ARGV) || die("$progname: No filenames specified\n");
67 my $is_svn_wc = -d
".svn/." ?
1 : 0;
69 for my $Dir (qw{4288x2848
2144x1424
1072x712
536x356 thumbs
}) {
71 mkdir($Dir) || die("$progname: $Dir: mkdir() error: $!\n");
72 $is_svn_wc && mysyst
("svn", "add", $Dir);
74 if (!-e
"$Dir/.htaccess") {
75 open(OutFP
, ">$Dir/.htaccess") || die("$progname: $Dir/.htaccess: Cannot create file: $!\n");
76 chomp(my $file_id = `fileid -t htaccess $Dir/.htaccess`);
80 DirectoryIndex SpesialIndex.html
82 IndexOptions FancyIndexing NameWidth=* DescriptionWidth=*
83 AddType text/plain;charset=UTF-8 txt
84 AddType text/html;charset=UTF-8 html
85 AddDefaultCharset UTF-8
89 mysyst
("svn", "add", "$Dir/.htaccess");
90 mysyst
("keyw", "$Dir/.htaccess");
95 my @time_array = localtime(time);
96 my $Year = $time_array[5] + 1900;
100 my @files_found = ();
102 open(OutFP
, ">", $Outfile) || die("$progname: $Outfile: Cannot create file: $!\n");
107 chomp($smsum{$t} = `smsum <$t`);
108 $files_str .= sprintf("<file> <name>%s</name> <smsum>%s</smsum> </file> ", txt_to_xml
($t), $smsum{$t});
109 if ($Opt{'generate'}) {
110 mysyst
("cp -Lp $t 4288x2848/$t");
111 mysyst
("convert -resize 2144 4288x2848/$t 2144x1424/$t");
112 mysyst
("convert -resize 1072 2144x1424/$t 1072x712/$t");
113 mysyst
("convert -resize 536 1072x712/$t 536x356/$t");
114 mysyst
("convert -resize 160 536x356/$t thumbs/$t");
116 push(@files_found, $t);
118 warn("$progname: $t: Cannot open file for read: $!\n");
122 chomp(my $uuid = `suuid -t create_imgindex --raw -c "<c_create_imgindex> <cmdline>$cmdline_str</cmdline> <filename>$Outfile</filename> $files_str</c_create_imgindex>"`)
123 || die("$progname: suuid error");
125 my $ignorefile = ".$uuid.ignore.tmp";
127 if (open(TmpFP
, ">", $ignorefile)) {
128 printf(TmpFP
"%s\n", join("\n", @files_found));
132 if ($Opt{'generate'}) {
133 for my $dir (qw{4288x2848
2144x1424
1072x712
536x356 thumbs
}) {
137 mysyst
("svn add Files.smsum");
141 warn("$progname: $dir: Cannot chdir(), mkFiles not executed: $!\n");
143 $is_svn_wc && mysyst
("svn -F $ignorefile ps svn:ignore $dir");
146 $is_svn_wc && unlink($ignorefile);
149 <?xml version="1.0" encoding="UTF-8"?>
150 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
151 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="$Opt{'language'}" lang="$Opt{'language'}">
152 <!-- File ID: $uuid -->
154 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
155 <title>$Title</title>
156 <style type="text/css">
158 body { background-color: white; color: black; font-family: sans-serif; }
159 a:link { color: blue; background-color: white; }
160 a:visited { color: maroon; background-color: white; }
161 a:active { color: fuchsia; background-color: white; }
162 h1 { text-align: center; font-size: 200%; font-weight: bold; }
163 h2 { text-align: center; font-size: 120%; font-weight: bold; }
164 table.main { margin: 0 auto; }
165 td.head { text-align: center; vertical-align: middle; }
166 td.dirtxt { text-align: left; vertical-align: middle; }
167 td.dirs { text-align: center; vertical-align: middle; width: 25%; }
168 td.image { text-align: center; vertical-align: middle; }
169 td.text { text-align: center; vertical-align: top; font-size: 80%; }
170 td.lefticon { text-align: center; vertical-align: middle; font-size: 80%; }
171 td.righticon { text-align: center; vertical-align: middle; font-size: 80%; }
172 td.footer { text-align: center; vertical-align: top; width: 100%; font-size: 100%; }
175 <meta name="author" content="Øyvind A. Holm — sunny\@sunbase.org" />
176 <meta name="copyright" content="©$Year- Øyvind A. Holm" />
177 <link rev="made" href="mailto:sunny\@sunbase.org" />
180 <table class="main" cellpadding="10" cellspacing="0" border="1">
182 <td class="head" colspan="4">
186 <td colspan="4" class="dirtxt">
187 <h2>Directories:</h2>
192 <a href="4288x2848/">4288x2848/</a>
195 <a href="2144x1424/">2144x1424/</a>
198 <a href="1072x712/">1072x712/</a>
201 <a href="536x356/">536x356/</a>
209 my ($Count, $create_td) = (0, 0);
211 for my $Curr (@ARGV) {
213 print(OutFP
" <tr>\n");
217 <!-- $smsum{$Curr} -->
218 <table width="100%" cellpadding="2" cellspacing="0" border="0">
220 <td class="image" colspan="2">
221 <img src="thumbs/$Curr" width="160" alt="$Curr" />
226 [<a href="4288x2848/$Curr">4288x2848</a>]<br />
227 [<a href="1072x712/$Curr">1072x712</a>]
230 [<a href="2144x1424/$Curr">2144x1424</a>]<br />
231 [<a href="536x356/$Curr">536x356</a>]
235 <td class="text" colspan="2">
244 print(OutFP
" </tr>\n");
251 $create_td && printf(OutFP
" <td colspan=\"%u\">\n </td>\n", 4-$Count);
252 print(OutFP
" </tr>\n");
258 <table cellpadding="5" cellspacing="0" border="0">
260 <td class="lefticon">
261 <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10.png" alt="Valid XHTML 1.0" width="88" height="31" style="border: 0;" /></a>
263 <td class="footer" colspan="2">
264 ©opyleft $Year- Øyvind A. Holm <sunny\@sunbase.org><br />
266 <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-Share Alike 3.0 Unported</a>
268 <td class="righticon">
269 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img src="http://www.w3.org/Icons/valid-css.png" alt="Valid CSS" width="88" height="31" style="border: 0;" /></a>
285 my $system_txt = sprintf("system(\"%s\");", join("\", \"", @Args));
286 msg
(1, "Executing '$system_txt'...");
294 $Txt =~ s/&/&/gs;
302 # Print program version {{{
303 print("$progname v$VERSION\n");
308 # Send the help message to stdout {{{
311 if ($Opt{'verbose'}) {
317 Usage: $progname [options] -o OUTFILE -t TITLE [images ...]
322 Generate resized images in subdirectory tree. Needs convert(1) from
323 the ImageMagick package.
327 Use language code X. Default: "en".
328 -o X, --output-file X
329 Store output in file X.
331 Use title and header X.
333 Increase level of verbosity. Can be repeated.
335 Print version information.
337 Print debugging messages.
345 # Print a status message to stderr based on verbosity level {{{
346 my ($verbose_level, $Txt) = @_;
348 if ($Opt{'verbose'} >= $verbose_level) {
349 print(STDERR
"$progname: $Txt\n");
355 # Print a debugging message {{{
357 my @call_info = caller;
358 chomp(my $Txt = shift);
359 my $File = $call_info[1];
361 $File =~ s
#^.*/(.*?)$#$1#;
362 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
369 # Plain Old Documentation (POD) {{{
379 [options] [file [files [...]]]
389 =item B<-h>, B<--help>
391 Print a brief help summary.
393 =item B<-v>, B<--verbose>
395 Increase level of verbosity. Can be repeated.
399 Print version information.
403 Print debugging messages.
413 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
417 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
418 This is free software; see the file F<COPYING> for legalese stuff.
422 This program is free software: you can redistribute it and/or modify it
423 under the terms of the GNU General Public License as published by the
424 Free Software Foundation, either version 2 of the License, or (at your
425 option) any later version.
427 This program is distributed in the hope that it will be useful, but
428 WITHOUT ANY WARRANTY; without even the implied warranty of
429 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
430 See the GNU General Public License for more details.
432 You should have received a copy of the GNU General Public License along
434 If not, see L<http://www.gnu.org/licenses/>.
442 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :