Index: webmagick.in =================================================================== RCS file: /cvsroot/webmagick/WebMagick/webmagick.in,v retrieving revision 1.117 retrieving revision 1.125 diff -u -r1.117 -r1.125 --- webmagick.in 23 Oct 2002 16:14:47 -0000 1.117 +++ webmagick.in 18 Jul 2003 00:27:35 -0000 1.125 @@ -1,6 +1,6 @@ #! @PERL@ # -# $Id: webmagick.in,v 1.117 2002/10/23 16:14:47 clindell Exp $ +# $Id: webmagick.in,v 1.125 2003/07/18 00:27:35 ache Exp $ # # You are looking at the main PERL script for WebMagick, a package to # intelligently create HTML and JavaScript index files and imagemaps @@ -237,6 +237,8 @@ $opt_webmagickrc, # Per-directory WebMagick rc file name $opt_zoomfilter, $opt_pichtml, + $opt_pichtmlaltend, + $opt_pichtmlaltstart, $opt_pichtmlbottom, $opt_pichtmlext, $opt_pichtmlnav, @@ -391,6 +393,8 @@ $opt_date = 1; # Output updates date $opt_pichtml = 0; # Write separate HTML for each picture +$opt_pichtmlaltend = ''; # Some words to append to ALT +$opt_pichtmlaltstart = ''; # Some words to prepend to ALT $opt_pichtmlbottom = ''; $opt_pichtmlext = '.html'; # Use .shtml for SSI $opt_pichtmlnav = 0; # Write navigation into pic's HTML @@ -492,7 +496,7 @@ $opt_framemarginwidth = 1; # Pixels allocated to frame margin in horizontal direction $opt_framemarginheight = 1; # Pixels allocated to frame margin in vertical direction $opt_framebordersize = 3 ; # Pixels allocated to frame border -$opt_frameborder = 'YES'; # Enable (YES) or disable (NO) decorative frame borders +$opt_frameborder = 1; # Enable (1) or disable (0) decorative frame borders $opt_framestyle = 1; # Frame style to use (out of those available) # @@ -596,12 +600,11 @@ # | | | # ------------- $opt_framefmt{1}= -' +' -'; + MARGINWIDTH=${opt_framemarginwidth} MARGINHEIGHT=${opt_framemarginheight}>'; $opt_framefmt_frames{1}=2; # Number of frames expressed by this frame format # Three frame screen with directories listed in top-left frame, @@ -616,16 +619,15 @@ # | | | # ------------- $opt_framefmt{2}= -' - +' + -'; + MARGINWIDTH=${opt_framemarginwidth} MARGINHEIGHT=${opt_framemarginheight}>'; $opt_framefmt_frames{2}=3; # Number of frames expressed by this frame format # Three frame screen with directories listed in left frame, @@ -640,16 +642,15 @@ # | | | # ------------- $opt_framefmt{3}= -' +' - + - -'; + '; $opt_framefmt_frames{3}=3; # Number of frames expressed by this frame format # Three frame screen with directories listed in lower-left frame, @@ -664,16 +665,15 @@ # | | | # ------------- $opt_framefmt{4}= -' +' - + - -'; + '; $opt_framefmt_frames{4}=3; # Number of frames expressed by this frame format # @@ -793,7 +793,7 @@ 'framemarginwidth=i' => \$opt_framemarginwidth, 'framemarginheight=i' => \$opt_framemarginheight, 'framebordersize=i' => \$opt_framebordersize, - 'frameborder=s' => \$opt_frameborder, + 'frameborder=i' => \$opt_frameborder, 'frames!' => \$opt_frames, 'framestyle=i' => \$opt_framestyle, 'header=s' => \$opt_header, @@ -828,6 +828,8 @@ 'msg_up=s' => \$opt_msg_up, 'pageindexname=s' => \$opt_pageindexname, 'pichtml!' => \$opt_pichtml, + 'pichtmlaltend=s' => \$opt_pichtmlaltend, + 'pichtmlaltstart=s' => \$opt_pichtmlaltstart, 'pichtmlbottom=s' => \$opt_pichtmlbottom, 'pichtmlext=s' => \$opt_pichtmlext, 'pichtmlnav!' => \$opt_pichtmlnav, @@ -1619,7 +1621,7 @@ 'framemarginwidth' => !$opt_frames ? 0 : $opt_framemarginwidth, 'framemarginheight' => !$opt_frames ? 0 : $opt_framemarginheight, 'framebordersize' => !$opt_frames ? 0 : $opt_framebordersize, - 'frameborder' => !$opt_frames ? "" : $opt_frameborder, + 'frameborder' => !$opt_frames ? 0 : $opt_frameborder, 'frames' => $opt_frames, 'framestyle' => !$opt_frames ? 1 : $opt_framestyle, 'header' => $opt_header, @@ -1659,6 +1661,8 @@ 'numpages' => $numPages, 'pageindexname' => $opt_pageindexname, 'pichtml' => $opt_pichtml, + 'pichtmlaltend' => !$opt_pichtml ? "" : $opt_pichtmlaltend, + 'pichtmlaltstart' => !$opt_pichtml ? "" : $opt_pichtmlaltstart, 'pichtmlbottom' => !$opt_pichtml ? "" : $opt_pichtmlbottom, 'pichtmlext' => !$opt_pichtml ? "" : $opt_pichtmlext, 'pichtmlnav' => !$opt_pichtml ? 0 : $opt_pichtmlnav, @@ -2173,20 +2177,17 @@ print( INDEX $framespechtml ); print( INDEX "\n" ); print( INDEX "<BODY\n" ); - unless ("$opt_stylesheet" ne '') - { - print( INDEX " TEXT=\"${opt_colorfore}\"\n" ); - print( INDEX " BGCOLOR=\"${opt_colorback}\"\n" ) - if $opt_colorback ne 'false'; - print( INDEX " BACKGROUND=\"$iconImageUrls{background}\"\n" ) - if defined $iconImageUrls{background}; - print( INDEX " LINK=\"${opt_colorlink}\"\n" ); - print( INDEX " VLINK=\"${opt_colorvlink}\"\n" ); - print( INDEX " ALINK=\"${opt_coloralink}\""); - } + print( INDEX " TEXT=\"${opt_colorfore}\"\n" ); + print( INDEX " BGCOLOR=\"${opt_colorback}\"\n" ) + if $opt_colorback ne 'false'; + print( INDEX " BACKGROUND=\"$iconImageUrls{background}\"\n" ) + if defined $iconImageUrls{background}; + print( INDEX " LINK=\"${opt_colorlink}\"\n" ); + print( INDEX " VLINK=\"${opt_colorvlink}\"\n" ); + print( INDEX " ALINK=\"${opt_coloralink}\""); print( INDEX ">\n" ); print( INDEX $indexhtml ); - print( INDEX "</BODY>\n\n" ); + print( INDEX "\n\n\n" ); close( INDEX ); @@ -2242,17 +2243,14 @@ print( INDEX "\n" ); print( INDEX "\n"); print( INDEX $pagedirhtml ); print( INDEX "\n" ); @@ -2379,16 +2377,13 @@ print( INDEX "\n" ); print( INDEX "\n"); print( INDEX "${opt_header}\n" ) if ("$opt_header" ne ''); @@ -2397,8 +2392,12 @@ if( $numimages > 0 ) { # Total HACK!!! if( !$opt_frames || $opt_framestyle == 1 ) { - print( INDEX "

${opt_msg_index_of_files}\"$imageNames[$pageNumber - 1][0]\" ${opt_msg_index_through}", - " \"$imageNames[$pageNumber - 1][$numimages-1]\"

\n" ); + print( INDEX "

${opt_msg_index_of_files}\"", + escapehtml($imageNames[$pageNumber - 1][0]), + "\" ${opt_msg_index_through}", + " \"", + escapehtml($imageNames[$pageNumber - 1][$numimages-1]), + "\"

\n" ); } print( INDEX "$indexbar
\n" ); @@ -2433,22 +2432,30 @@ my $pic = $imageNames[$pageNumber - 1][$imageNum]; my $pichtml; + my $altlabel; my $target = ''; + if ($opt_pichtml && $opt_frames && "$opt_pichtmltarget" ne '') { $target = " TARGET=\"${opt_pichtmltarget}\""; } + if (defined($imageLabels{$pic})) { + $altlabel = $imageLabels{$pic}; + } else { + ($altlabel = $pic) =~ s/(.*)\.\w+$/$1/i; + $altlabel =~ y/_/ /; # Usual space replacement in file name + } + $altlabel = escapehtml($opt_pichtmlaltstart . $altlabel . $opt_pichtmlaltend); if ( $opt_pichtml ) { $pichtml = $pic . $opt_pichtmlext; - open( PICHTML, ">$pichtml") || die("$0: Failed to open file $pichtml for output\n$@\n"); print( PICHTML "\n\n" ); # Charset is better before title print( PICHTML " \n" ) if( "$opt_metacharset" ne '' ); - print( PICHTML " $pic\n" ); + print( PICHTML " ${altlabel}\n" ); # Meta tags print( PICHTML " \n" ); @@ -2469,28 +2476,19 @@ print( PICHTML "\n" ); print( PICHTML "\n" ); print( PICHTML "$opt_pichtmltop") if ("$opt_pichtmltop" ne ''); if ($opt_pichtmlputtitle) { - print ( PICHTML "${opt_pichtmltitlestart}"); - if (defined( $imageLabels{$pic})) { - print( PICHTML "$imageLabels{$pic}"); - } else { - print( PICHTML "$pic"); - } - print ( PICHTML "${opt_pichtmltitleend}"); + print ( PICHTML "${opt_pichtmltitlestart}${altlabel}${opt_pichtmltitleend}"); } if ($opt_pichtmlnav) { @@ -2526,9 +2524,9 @@ } else { print ( PICHTML "
"); } - if ( $pic =~ /\.(jpg|jpeg?|gif|xbm|png)$/i ) { - print( PICHTML "\"\"" ); + if ($pic =~ /\.(jpg|jpeg?|gif|xbm|png)$/i) { + print( PICHTML "\"${altlabel}\"" ); } else { - print( PICHTML "$pic ", fsize($pic), "" ); + print( PICHTML "", escapehtml($pic), " ", fsize($pic), "" ); } print( PICHTML "$opt_pichtmlbottom\n") if ("$opt_pichtmlbottom" ne ''); @@ -2601,12 +2599,16 @@ # TODO: make sure the thumbnails are created, and get some image sizes # TODO: save the labels in a new array, maybe same with sizes if ( $thumbImageSizes{$pic}) { - print (INDEX ""); + print (INDEX "\"${altlabel}\""); } else { - print (INDEX ""); + print (INDEX "\"${altlabel}\""); } - print (INDEX "
" . $tableImageLabels{$imageNames[$pageNumber - 1][$imageNum]} . "\n"); + print (INDEX "
", + escapehtml($tableImageLabels{$imageNames[$pageNumber - 1][$imageNum]}), + "\n"); if ($imageNum%$opt_columns == ($opt_columns - 1)) { @@ -4156,25 +4158,29 @@ --footer Page footer (imagemap frame) (default to ) --header Page header (imagemap frame) (default to
) --[no]javascript Enable JavaScript output (default off) + --[no]readmevisible Show README.html on first page rather than just linking (default off) + --[no]tables Use HTML tables instead of imagemaps for thumbnails (default off) + --title Page title + +Per-image HTML options: --[no]pichtml Per-image HTML file generation (default off) - --pichtmlext Per-image HTML file extension (default .html) + --pichtmlaltend Some words to append to ALT= (default "") + --pichtmlaltstart Some words to prepend to ALT= (default "") --pichtmlbottom Per-image HTML, extra HTML to display below image (default to
) + --pichtmlext Per-image HTML file extension (default .html) --[no]pichtmlnav Per-image HTML, show navigation buttons (default off) --[no]pichtmlputtitle Put per-image HTML picture title (default on) --pichtmltarget Per-image HTML default frame target --pichtmltitleend End tags for per-image HTML picture title (default

) --pichtmltitlestart Start tags for per-image HTML picture title (default

) --pichtmltop Per-image HTML, extra HTML to display above image (default to

) - --[no]readmevisible Show README.html on first page rather than just linking (default off) - --[no]tables Use HTML tables instead of imagemaps for thumbnails (default off) - --title Page title Frame Options: --[no]frames Use frames, if no - single directory collection assumed (default on) --framemarginwidth Pixels allocated to frame margin in horizontal direction --framemarginheight Pixels allocated to frame margin in vertical direction --framebordersize Pixels allocated to frame border - --frameborder Enable (YES) or disable (NO) decorative frame borders + --frameborder Enable (1) or disable (0) decorative frame borders --framestyle Frame style to use (out of those available) --[no]allowconfig Allow user to configure framestyle, columns and rows (requires javascript and tables) (default off) @@ -4296,6 +4302,7 @@ s/&/&/g; s/>/>/g; s//%3E/g; # > - s/\[/%5B/g; # [ - #s/\\/%5C/g; # \ - s/\]/%5D/g; # ] - s/\^/%5E/g; # ^ - s/\`/%60/g; # ` - s/\{/%7B/g; # { - s/\|/%7C/g; # | - s/\}/%7D/g; # } - s/\~/%7E/g; # ~ - s/ /%20/g; # " " + # ' is here because some bots (Google) goes crazy on "xxx'xxx" + s/([][\x00-\x20"#%'<>^`{|}~\x7F-\xFF])/sprintf("%%%02x", ord($1))/eg; s:\\:/:g; # replace \ with / for better URLs return( $_ ); }