Index: webmagick.in =================================================================== RCS file: /cvsroot/webmagick/WebMagick/webmagick.in,v retrieving revision 1.117 retrieving revision 1.129 diff -u -r1.117 -r1.129 --- webmagick.in 23 Oct 2002 16:14:47 -0000 1.117 +++ webmagick.in 21 Feb 2004 02:27:24 -0000 1.129 @@ -1,6 +1,6 @@ #! @PERL@ # -# $Id: webmagick.in,v 1.117 2002/10/23 16:14:47 clindell Exp $ +# $Id: webmagick.in,v 1.129 2004/02/21 02:27:24 ache Exp $ # # You are looking at the main PERL script for WebMagick, a package to # intelligently create HTML and JavaScript index files and imagemaps @@ -167,6 +167,7 @@ %opt_icons, $opt_ignore, $opt_ignorefp, + $opt_indexinfo, $opt_imgindexname, $opt_indexname, $opt_javascript, @@ -212,6 +213,9 @@ $opt_srcdir, $opt_stylesheet, # URL to a CSS to use $opt_tables, + $opt_tables_bottom, + $opt_tables_params, + $opt_tables_top, $opt_thumbbackground, $opt_thumbbordercolor, $opt_thumbborderwidth, @@ -237,8 +241,11 @@ $opt_webmagickrc, # Per-directory WebMagick rc file name $opt_zoomfilter, $opt_pichtml, + $opt_pichtmlaltend, + $opt_pichtmlaltstart, $opt_pichtmlbottom, $opt_pichtmlext, + $opt_pichtmllink, $opt_pichtmlnav, $opt_pichtmlputtitle, $opt_pichtmltarget, @@ -368,6 +375,7 @@ $opt_ignore = 0; # Do not webmagick this directory # but still recurse into sub-directories $opt_ignorefp = 1; # ignore _* special FrontPage directories (on) +$opt_indexinfo = 1; # Put "Index of files" $opt_srcdir = '.'; # Source directory path (current directory) $opt_verbose = 0; # Verbose flag (default off) $opt_forcecache = 0; # Force update of cached thumbnails @@ -386,13 +394,19 @@ $opt_readmevisible = 0; # Make README.html be first page. $opt_title = ''; # Page title (blank provides default title) $opt_tables = 0; # disable tables +$opt_tables_bottom = ''; # HTML after table contents +$opt_tables_params = 'WIDTH="90%"'; # table HTML parameters +$opt_tables_top = ''; # HTML before table contents $opt_address = ''; # Additonal address info for bottom of # imagemap page $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_pichtmllink = ''; # Where to link pic $opt_pichtmlnav = 0; # Write navigation into pic's HTML $opt_pichtmlputtitle = 1; # Write picture title above it $opt_pichtmltarget = ''; @@ -492,7 +506,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 +610,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 +629,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 +652,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 +675,15 @@ # | | | # ------------- $opt_framefmt{4}= -' +' - + - -'; + '; $opt_framefmt_frames{4}=3; # Number of frames expressed by this frame format # @@ -793,7 +803,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, @@ -803,6 +813,7 @@ 'iconbase=s' => \$opt_iconbase, 'iconpath=s' => \$opt_iconpath, 'ignorefp!' => \$opt_ignorefp, + 'indexinfo!' => \$opt_indexinfo, 'imgindexname=s' => \$opt_imgindexname, 'indexname=s' => \$opt_indexname, 'javascript!' => \$opt_javascript, @@ -828,8 +839,11 @@ '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, + 'pichtmllink=s' => \$opt_pichtmllink, 'pichtmlnav!' => \$opt_pichtmlnav, 'pichtmlputtitle!' => \$opt_pichtmlputtitle, 'pichtmltarget=s' => \$opt_pichtmltarget, @@ -846,6 +860,9 @@ 'srcdir=s' => \$opt_srcdir, 'stylesheet=s' => \$opt_stylesheet, 'tables!' => \$opt_tables, + 'tables_bottom=s' => \$opt_tables_bottom, + 'tables_params=s' => \$opt_tables_params, + 'tables_top=s' => \$opt_tables_top, 'thumbtexture=s' => \$opt_thumbtexture, 'thumbbackground=s' => \$opt_thumbbackground, 'thumbborderwidth=i' => \$opt_thumbborderwidth, @@ -1353,9 +1370,11 @@ if( !defined(%dirTitles) || ( compareHash(\%dirTitles,\%tmp_dirTitles) ) ) { %dirTitles = %tmp_dirTitles; - print( STDERR "Directory titles have changed, must re-do HTML indexes\n" ) - if $opt_debug; - ++$doIndexHtml; + if ($opt_frames) { + print( STDERR "Directory titles have changed, must re-do HTML indexes\n" ) + if $opt_debug; + ++$doIndexHtml; + } } } @@ -1576,7 +1595,7 @@ $tmp_montageParameters .= "mattecolor=>\'$opt_thumbframecolor\',\n " if $opt_thumbframecolor ne 'false'; $tmp_montageParameters .= "label=>\'$opt_thumblabel\',\n " - if $opt_thumblabel ne 'false'; + if ($opt_thumblabel && $opt_thumblabel ne 'false'); $tmp_montageParameters .= "labelwidth=>\'$opt_thumblabelwidth\',\n "; $tmp_montageParameters .= "\Lzoomfilter=>\'$opt_zoomfilter\'"; if( !defined($montageParameters) || ($tmp_montageParameters ne $montageParameters)) { @@ -1619,7 +1638,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, @@ -1627,6 +1646,7 @@ 'htmlext' => !$opt_frames ? "" : $opt_htmlext, 'iconbase' => $opt_iconbase, 'imgindexname' => $opt_imgindexname, + 'indexinfo' => $opt_indexinfo, 'indexname' => $opt_indexname, 'javascript' => $opt_javascript, 'jsdirindex' => !$opt_javascript ? "" : $fileNames{'jsDirIndex'}, @@ -1647,8 +1667,8 @@ 'msg_directory_navigator' => !$opt_frames ? "" : $opt_msg_directory_navigator, 'msg_images' => !$opt_frames ? "" : $opt_msg_images, 'msg_index_of_directory' => $opt_msg_index_of_directory, - 'msg_index_of_files' => $opt_msg_index_of_files, - 'msg_index_through' => $opt_msg_index_through, + 'msg_index_of_files' => !$opt_indexinfo ? "" : $opt_msg_index_of_files, + 'msg_index_through' => !$opt_indexinfo ? "" : $opt_msg_index_through, 'msg_next' => $opt_msg_next, 'msg_pause' => $opt_msg_pause, 'msg_page_navigator' => !$opt_frames ? "" : $opt_msg_page_navigator, @@ -1659,8 +1679,11 @@ '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, + 'pichtmllink' => !$opt_pichtml ? '' : $opt_pichtmllink, 'pichtmlnav' => !$opt_pichtml ? 0 : $opt_pichtmlnav, 'pichtmlputtitle' => !$opt_pichtml ? 0 : $opt_pichtmlputtitle, 'pichtmltarget' => (!$opt_pichtml || !$opt_frames) ? "" : $opt_pichtmltarget, @@ -1676,6 +1699,9 @@ 'stylesheet' => $opt_stylesheet, 'subdirectories' => !$opt_frames ? "" : join(' ',@dirNames), 'tables' => $opt_tables, + 'tables_bottom' => !$opt_tables ? "" : $opt_tables_bottom, + 'tables_params' => !$opt_tables ? "" : $opt_tables_params, + 'tables_top' => !$opt_tables ? "" : $opt_tables_top, 'title' => $pageTitle, 'version' => $opt_anonymous ? "" : $webmagickInfo{'version'}, ); @@ -2135,7 +2161,8 @@ print( INDEX " ${pageTitle}\n" ); # Meta tags - print( INDEX " \n" ); + print( INDEX " \n" ) + if (!$opt_anonymous); print( INDEX " \n" ) if( "$opt_metaauthor" ne '' ); print( INDEX " \n" ) @@ -2173,20 +2200,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 ); @@ -2224,7 +2248,8 @@ print( INDEX " \n" ); # Meta tags - print( INDEX " \n" ); + print( INDEX " \n" ) + if (!$opt_anonymous); print( INDEX " \n" ) if( "$opt_metaauthor" ne '' ); print( INDEX " \n" ) @@ -2242,17 +2267,14 @@ print( INDEX "\n" ); print( INDEX "\n"); print( INDEX $pagedirhtml ); print( INDEX "\n" ); @@ -2361,7 +2383,8 @@ if ($opt_frames); # Meta tags - print( INDEX " \n" ); + print( INDEX " \n" ) + if (!$opt_anonymous); print( INDEX " \n" ) if( "$opt_metaauthor" ne '' ); print( INDEX " \n" ) @@ -2379,16 +2402,13 @@ print( INDEX "\n" ); print( INDEX "\n"); print( INDEX "${opt_header}\n" ) if ("$opt_header" ne ''); @@ -2397,14 +2417,21 @@ 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" ) + if ($opt_indexinfo); } print( INDEX "$indexbar
\n" ); if ($opt_tables) { - print INDEX ""; + print INDEX "
"; + print INDEX "${opt_tables_top}" + if ($opt_tables_top ne ''); } else { @@ -2433,25 +2460,34 @@ 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" ); + print( PICHTML " \n" ) + if (!$opt_anonymous); print( PICHTML " \n" ) if( "$opt_metaauthor" ne '' ); print( PICHTML " \n" ) @@ -2469,28 +2505,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 +2553,9 @@ } else { print ( PICHTML "
"); } - if ( $pic =~ /\.(jpg|jpeg?|gif|xbm|png)$/i ) { - print( PICHTML "\"\"" ); + if ($pic =~ /\.(jpg|jpeg?|gif|xbm|png)$/i) { + print( PICHTML "") + if ($opt_pichtmllink ne ''); + print( PICHTML "\"${altlabel}\"" ); + print( PICHTML "") + if ($opt_pichtmllink ne ''); } else { - print( PICHTML "$pic ", fsize($pic), "" ); + print( PICHTML "", escapehtml($pic), " ", fsize($pic), "" ); } print( PICHTML "$opt_pichtmlbottom\n") if ("$opt_pichtmlbottom" ne ''); @@ -2601,12 +2632,19 @@ # 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 ""); + print (INDEX "
", + $tableImageLabels{$imageNames[$pageNumber - 1][$imageNum]}, + "") + if ($opt_thumblabel && $opt_thumblabel ne 'false'); + print (INDEX "\n"); if ($imageNum%$opt_columns == ($opt_columns - 1)) { @@ -2622,6 +2660,8 @@ { print INDEX ""; } + print INDEX "${opt_tables_bottom}" + if ($opt_tables_bottom ne ''); print (INDEX "
\n") } else {print( INDEX "\n" );} } @@ -3868,7 +3908,7 @@ # Set image label # my $label = ''; - if( $opt_thumblabel ne 'false' ) { + if( $opt_thumblabel && $opt_thumblabel ne 'false' ) { if( defined( $imageLabels{$imagename} ) ) { # Set image specific label $label = $imageLabels{$imagename}; @@ -3922,7 +3962,7 @@ # put our label into the table image hash - $tableImageLabels{$imagename} = $label; + $tableImageLabels{$imagename} = escapehtml($label); $tableImageLabels{$imagename} =~ s/\n/
/g; print( STDERR "Applying image label: \"${label}\"\n" ) @@ -4073,6 +4113,7 @@ --[no]forcehtml Force HTML files to be generated (default off) --[no]forcemontage Force montage (default off) --[no]ignorefp Ignore directories with names like _vti (FrontPage directories) (default on) + --[no]indexinfo Put "Index of files" (default on) --[no]help Display usage message (default off) --[no]recurse Recurse directory tree (default off) --srcdir Image directory to process @@ -4156,25 +4197,33 @@ --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) + --tables_params Table HTML parameters + --tables_top HTML before table contents + --tables_bottom HTML after table contents + --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) + --pichtmllink Per-image HTML link (default "") --[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 +4345,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( $_ ); }