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"
151 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
152 <html xmlns="http://www.w3.org/1999/xhtml"
153 xml:lang="$Opt{'language'}" lang="$Opt{'language'}">
154 <!-- File ID: $uuid -->
156 <meta http-equiv="Content-Type"
157 content="text/html; charset=UTF-8" />
158 <title>$Title</title>
159 <style type="text/css">
162 background-color: white;
164 font-family: sans-serif;
166 a:link { color: blue; background-color: white; }
167 a:visited { color: maroon; background-color: white; }
168 a:active { color: fuchsia; background-color: white; }
169 h1 { text-align: center; font-size: 200%; font-weight: bold; }
170 h2 { text-align: center; font-size: 120%; font-weight: bold; }
171 table.main { margin: 0 auto; }
172 td.head { text-align: center; vertical-align: middle; }
173 td.dirtxt { text-align: left; vertical-align: middle; }
176 vertical-align: middle;
179 td.image { text-align: center; vertical-align: middle; }
187 vertical-align: middle;
192 vertical-align: middle;
203 <meta name="author" content="Øyvind A. Holm — sunny\@sunbase.org" />
204 <meta name="copyright" content="©$Year- Øyvind A. Holm" />
207 <table class="main" cellpadding="10" cellspacing="0" border="1">
209 <td class="head" colspan="4">
213 <td colspan="4" class="dirtxt">
214 <h2>Directories:</h2>
219 <a href="4288x2848/">4288x2848/</a>
222 <a href="2144x1424/">2144x1424/</a>
225 <a href="1072x712/">1072x712/</a>
228 <a href="536x356/">536x356/</a>
236 my ($Count, $create_td) = (0, 0);
238 for my $Curr (@ARGV) {
240 print(OutFP
" <tr>\n");
244 <!-- $smsum{$Curr} -->
245 <table width="100%" cellpadding="2" cellspacing="0" border="0">
247 <td class="image" colspan="2">
248 <img src="thumbs/$Curr" width="160" alt="$Curr" />
253 [<a href="4288x2848/$Curr">4288x2848</a>]<br />
254 [<a href="1072x712/$Curr">1072x712</a>]
257 [<a href="2144x1424/$Curr">2144x1424</a>]<br />
258 [<a href="536x356/$Curr">536x356</a>]
262 <td class="text" colspan="2">
271 print(OutFP
" </tr>\n");
278 $create_td && printf(OutFP
" <td colspan=\"%u\">\n </td>\n", 4-$Count);
279 print(OutFP
" </tr>\n");
285 <table cellpadding="5" cellspacing="0" border="0">
287 <td class="lefticon">
288 <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>
290 <td class="footer" colspan="2">
291 ©opyleft $Year- Øyvind A. Holm <sunny\@sunbase.org><br />
293 <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-Share Alike 3.0 Unported</a>
295 <td class="righticon">
296 <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>
312 my $system_txt = sprintf("system(\"%s\");", join("\", \"", @Args));
313 msg
(1, "Executing '$system_txt'...");
321 $Txt =~ s/&/&/gs;
329 # Print program version {{{
330 print("$progname v$VERSION\n");
335 # Send the help message to stdout {{{
338 if ($Opt{'verbose'}) {
344 Usage: $progname [options] -o OUTFILE -t TITLE [images ...]
349 Generate resized images in subdirectory tree. Needs convert(1) from
350 the ImageMagick package.
354 Use language code X. Default: "en".
355 -o X, --output-file X
356 Store output in file X.
358 Use title and header X.
360 Increase level of verbosity. Can be repeated.
362 Print version information.
364 Print debugging messages.
372 # Print a status message to stderr based on verbosity level {{{
373 my ($verbose_level, $Txt) = @_;
375 if ($Opt{'verbose'} >= $verbose_level) {
376 print(STDERR
"$progname: $Txt\n");
382 # Print a debugging message {{{
384 my @call_info = caller;
385 chomp(my $Txt = shift);
386 my $File = $call_info[1];
388 $File =~ s
#^.*/(.*?)$#$1#;
389 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
396 # Plain Old Documentation (POD) {{{
406 [options] [file [files [...]]]
416 =item B<-h>, B<--help>
418 Print a brief help summary.
420 =item B<-v>, B<--verbose>
422 Increase level of verbosity. Can be repeated.
426 Print version information.
430 Print debugging messages.
440 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
444 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
445 This is free software; see the file F<COPYING> for legalese stuff.
449 This program is free software: you can redistribute it and/or modify it
450 under the terms of the GNU General Public License as published by the
451 Free Software Foundation, either version 2 of the License, or (at your
452 option) any later version.
454 This program is distributed in the hope that it will be useful, but
455 WITHOUT ANY WARRANTY; without even the implied warranty of
456 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
457 See the GNU General Public License for more details.
459 You should have received a copy of the GNU General Public License along
461 If not, see L<http://www.gnu.org/licenses/>.
469 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :