Index: webmagick.in =================================================================== RCS file: /cvsroot/webmagick/WebMagick/webmagick.in,v retrieving revision 1.117 retrieving revision 1.150 diff -u -r1.117 -r1.150 --- webmagick.in 23 Oct 2002 16:14:47 -0000 1.117 +++ webmagick.in 20 Nov 2004 05:22:55 -0000 1.150 @@ -1,6 +1,6 @@ #! @PERL@ # -# $Id: webmagick.in,v 1.117 2002/10/23 16:14:47 clindell Exp $ +# $Id: webmagick.in,v 1.150 2004/11/20 05:22:55 ache Exp $ # # You are looking at the main PERL script for WebMagick, a package to # intelligently create HTML and JavaScript index files and imagemaps @@ -99,7 +99,8 @@ @imageThumbCoords, # Thumbnail imagemap coordinates $imageFrameLink, # URL to use as source for image frame %imageLabels, # Labels to use for images (if specified) - %tableImageLabels, # labels to use in tables + %imageCaptions, # Captions for perimage HTML + %tableImageLabels, # labels to use in tables %imageOrder, # Order that images occur in imgindex file $inChild, # Set to true if this process is a child $currentDate, @@ -117,6 +118,7 @@ $opt_cacheformat, $opt_cachegeom, $opt_cachemin, + $opt_centerfooter, $opt_lowres, $opt_lowresdir, $opt_lowresformat, @@ -144,12 +146,13 @@ $opt_forcejpeg, $opt_forcehtml, $opt_forcemontage, + $opt_forcenouplink, + $opt_forceuplink, $opt_frame_name_dirview, $opt_frame_name_imageview, $opt_frame_name_thumbview, $opt_frame_name_top, $opt_frameborder, - $opt_framebordersize, $opt_frameddirfmt, %opt_framefmt, %opt_framefmt_frames, @@ -167,6 +170,7 @@ %opt_icons, $opt_ignore, $opt_ignorefp, + $opt_indexinfo, $opt_imgindexname, $opt_indexname, $opt_javascript, @@ -212,6 +216,12 @@ $opt_srcdir, $opt_stylesheet, # URL to a CSS to use $opt_tables, + $opt_tablebackcolor, + $opt_fancytables, + $opt_fancytableheight, + $opt_tables_bottom, + $opt_tables_params, + $opt_tables_top, $opt_thumbbackground, $opt_thumbbordercolor, $opt_thumbborderwidth, @@ -237,14 +247,20 @@ $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_pichtmlupfirst, $opt_pichtmlputtitle, + $opt_pichtmltitletop, $opt_pichtmltarget, $opt_pichtmltitleend, $opt_pichtmltitlestart, $opt_pichtmltop, + $opt_edgelinksindex, $pageStatusTime, # Time status file last modified $pageNumber, # Current page number $pathSep, # OS-specific path separator @@ -368,6 +384,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 @@ -376,6 +393,9 @@ $opt_forcemontage = 0; # Force montage (default off) $opt_forcegif = 0; # Force GIF imagemaps (default off) $opt_forcejpeg = 0; # Force JPEG imagemaps (default off) +$opt_forcenouplink = 0; # Force there to be no uplink in directory index list +$opt_forceuplink = 0; # Force there to be an uplink in directory index list + # (i.e. even if we didn't generate ../index.html) $opt_jpegquality = 70; # Quality for JPEG imagemaps $opt_help = 0; # Display usage message $opt_version = 0; # Display version info @@ -386,15 +406,28 @@ $opt_readmevisible = 0; # Make README.html be first page. $opt_title = ''; # Page title (blank provides default title) $opt_tables = 0; # disable tables +$opt_tablebackcolor = '#000000'; # table background color +$opt_fancytables = 0; # use a fancier table for index pages +$opt_fancytableheight = 28; # the height of the fancy table border +$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_centerfooter = 0; # Center the footer text $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_pichtmlupfirst = 1; # Put up button before next/prev +$opt_edgelinksindex = 0; # End links link back to index +$opt_pichtmlputtitle = 1; # Write picture title +$opt_pichtmltitletop = 1; # Put picture title at top $opt_pichtmltarget = ''; $opt_pichtmltitleend = '

'; # End tags for picture title $opt_pichtmltitlestart = '

'; # Start tags for picture title @@ -491,8 +524,7 @@ $opt_frames = 1; # Use frames $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) # @@ -539,6 +571,7 @@ $opt_icons{'next_gray'} = 'gray_next.gif'; # Next (grayed out) $opt_icons{'up'} = 'blue_up.gif'; # Up $opt_icons{'help'} = 'blue_readme.gif'; # Help Readme File +# $opt_icons{'ft_top'} = 'ft_top.gif'; # Fancy table top # $opt_icons{'help'} = 'blue_help.gif'; # Help Alternative (Question) # $opt_icons{'dir'} = 'blue_dir.gif'; # Directory List Icon (See below) # $opt_icons{'ball'} = 'blue_ball.gif'; # A ball matching other icons @@ -596,12 +629,11 @@ # | | | # ------------- $opt_framefmt{1}= -' - + - -'; + '; $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 +648,15 @@ # | | | # ------------- $opt_framefmt{2}= -' - - + + - - -'; + '; $opt_framefmt_frames{2}=3; # Number of frames expressed by this frame format # Three frame screen with directories listed in left frame, @@ -640,16 +671,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 +694,15 @@ # | | | # ------------- $opt_framefmt{4}= -' - + - - + - - -'; + '; $opt_framefmt_frames{4}=3; # Number of frames expressed by this frame format # @@ -756,6 +785,7 @@ use Getopt::Long; if ( ! GetOptions( 'address=s' => \$opt_address, + 'centerfooter!' => \$opt_centerfooter, 'anonymous!' => \$opt_anonymous, 'cache!' => \$opt_cache, 'cachedir=s' => \$opt_cachedir, @@ -790,10 +820,11 @@ 'forcehtml!' => \$opt_forcehtml, 'forcejpeg!' => \$opt_forcejpeg, 'forcemontage!' => \$opt_forcemontage, + 'forceuplink!' => \$opt_forceuplink, + 'forcenouplink!' => \$opt_forcenouplink, '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 +834,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,14 +860,20 @@ '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, + 'pichtmlupfirst!' => \$opt_pichtmlupfirst, 'pichtmlputtitle!' => \$opt_pichtmlputtitle, + 'pichtmltitletop!' => \$opt_pichtmltitletop, 'pichtmltarget=s' => \$opt_pichtmltarget, 'pichtmltitleend=s' => \$opt_pichtmltitleend, 'pichtmltitlestart=s' => \$opt_pichtmltitlestart, 'pichtmltop=s' => \$opt_pichtmltop, + 'edgelinksindex!' => \$opt_edgelinksindex, 'prefixpath=s' => \$opt_prefixpath, 'readme=s' => \$opt_readme, 'readmevisible!' => \$opt_readmevisible, @@ -846,6 +884,12 @@ 'srcdir=s' => \$opt_srcdir, 'stylesheet=s' => \$opt_stylesheet, 'tables!' => \$opt_tables, + 'tablebackcolor=s' => \$opt_tablebackcolor, + 'fancytables!' => \$opt_fancytables, + 'fancytableheight=i' => \$opt_fancytableheight, + '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, @@ -1187,7 +1231,6 @@ evaluateRcFiles(); - # Decide if we want to process this directory or not based on the # value of $opt_ignore. If not, then just return. @@ -1329,7 +1372,6 @@ $pageStatusTime=fmtime($fileNames{'pageStatus'}); } - # Handle a directory name to title index file. Store alternative # names in %dirTitles. { @@ -1346,34 +1388,50 @@ $tmp_dirTitles{$dirname} = escapehtml($dirtitle); $dirOrder{$dirname} = $pos; $pos++; + } elsif( defined($dirname) ) { + $dirOrder{$dirname} = $pos; + $pos++; } } close( DIRINDEX ); } - if( !defined(%dirTitles) || ( compareHash(\%dirTitles,\%tmp_dirTitles) ) ) { + if( compareHash(\%dirTitles,\%tmp_dirTitles) ) { %dirTitles = %tmp_dirTitles; - print( STDERR "Directory titles have changed, must re-do HTML indexes\n" ) + if ($opt_frames) { + print( STDERR "Directory titles have changed, must re-do HTML indexes\n" ) + if $opt_debug; + ++$doIndexHtml; + } + } else { + print( STDERR "Directory titles not needed or unchanged from last run.\n") if $opt_debug; - ++$doIndexHtml; - } + } } # - # Handle a image name to thumbnail label index file + # Handle an image name to thumbnail label index file # Store alternative names in %imageLabels # { my $pos = 0; my %tmp_imageLabels; + undef( %tmp_imageLabels ); + my %tmp_imageCaptions; + undef( %tmp_imageCaptions ); if ( -f $opt_imgindexname ) { open( IMGINDEX, "<$opt_imgindexname" ); while( ) { chop; - my ( $imgname, $imgtitle); - ( $imgname, $imgtitle) = split( /[ \t]+/, $_, 2); + my ( $imgname, $imgtitle, $imgcaption, $tmpstr); + ( $imgname, $tmpstr) = split( /[ \t]+/, $_, 2); + ( $imgtitle, $imgcaption ) = split( /,+/, $tmpstr, 2); if(defined($imgname) && defined($imgtitle)) { $tmp_imageLabels{$imgname} = $imgtitle; + $tmp_imageCaptions{$imgname} = $imgcaption; + $imageOrder{$imgname} = $pos; + $pos++; + } elsif( defined($imgname) ) { $imageOrder{$imgname} = $pos; $pos++; } @@ -1383,11 +1441,25 @@ # # This code is totally BOGUS since decision should be made on a per-page basis!! # - if( !defined(%imageLabels) || ( compareHash(\%imageLabels,\%tmp_imageLabels) ) ) { + if( compareHash(\%imageLabels,\%tmp_imageLabels) ) { %imageLabels = %tmp_imageLabels; print( STDERR "Image labels have changed, must re-do montages\n" ) if $opt_debug; $opt_forcemontage=1; + } else { + print( STDERR "Image labels not needed or unchanged from last run.\n") if $opt_debug; + } + + #BRAD: Added to record per image captions for perimage html page + if( $opt_pichtml && + compareHash(\%imageCaptions,\%tmp_imageCaptions) ) { + %imageCaptions = %tmp_imageCaptions; + print( STDERR "Image captions have changed, must re-do perpage html\n" ) + if $opt_debug; + $opt_forcehtml=1; + } else { + print( STDERR "Image captions not needed or unchanged from last run.\n") + if $opt_debug; } } @@ -1396,6 +1468,7 @@ # { my %tmp_iconImageUrls; + undef (%tmp_iconImageUrls); print( "Icon URLs:\n" ) if $opt_debug; my $icon; for $icon ( keys %opt_icons ) { @@ -1405,11 +1478,14 @@ if $opt_debug; } } - if( !defined(%iconImageUrls) || ( compareHash(\%iconImageUrls,\%tmp_iconImageUrls) ) ) { + if( compareHash(\%iconImageUrls,\%tmp_iconImageUrls) ) { %iconImageUrls = %tmp_iconImageUrls; print( STDERR "Icon URLs have changed, must re-do all HTML\n" ) if $opt_debug; $opt_forcehtml = 1;; + } else { + print( STDERR "Icon URLs not needed or unchanged from last run.\n") + if $opt_debug; } } @@ -1431,6 +1507,7 @@ # Build list of image files # @allImageFiles = sort( sortImages grep( /$includeRegex/io, @allFiles)); + print( STDERR " numfiles=", scalar(@allImageFiles), "\n") if $opt_debug; # Find subdirectory names (if any) ignoring hidden directories and # directories without index files. Directories should have index @@ -1446,10 +1523,9 @@ if ($opt_frames) { grep($tarray{$_}++, @allImageFiles); foreach $_ ( grep(! $tarray{$_},@allFiles) ) { - #if( -f "${_}/${opt_indexname}" ) { # If directory & index file - # exists then add to list if( -d "${_}" ) { # If directory exists - unless ($opt_ignorefp && /^_[a-z]/) { # and we shouldn't ignore it + unless (get_rc_var(${_}, 'opt_ignore', 0) eq 1) { # and dir not ignored + unless ($opt_ignorefp && /^_[a-z]/) { # and we shouldn't ignore it push(@dirfiles, $_); # then add it to the list if ($opt_javascript) { # Check which index file to use for JavaScript @@ -1461,6 +1537,7 @@ $dirJsLink{"$_"} = ''; } } + } } } } @@ -1510,9 +1587,7 @@ if( $numimages > 0 ) { $haveImages = 1; } - - - + # # Determine page title # @@ -1520,10 +1595,18 @@ $pageTitle = $opt_title; } else { my $dirname=basename($sourceDirectory); - $pageTitle = "${opt_msg_index_of_directory} \"$dirname\""; + #BRAD: if cwd or pageTitle in imageLabels, use that for directory name + if( $imageLabels{$dirname} ne '') { + $pageTitle = $imageLabels{$dirname}; + $imageLabels{'pageTitle'} = $imageLabels{$dirname}; + $imageCaptions{'pageTitle'} = $imageLabels{$dirname}; + } elsif ( $imageLabels{'pageTitle'} ne '') { + $pageTitle = $imageLabels{'pageTitle'}; + } else { + $pageTitle = "${opt_msg_index_of_directory} \"$dirname\""; + } } - # # Put the PerlMagick Montage options together # @@ -1576,7 +1659,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)) { @@ -1597,6 +1680,7 @@ 'backgroundimg' => $opt_icons{'background'}, 'cachedir' => !$opt_tables ? "" : $opt_cachedir, 'cacheformat' => !$opt_tables ? "" : $opt_cacheformat, + 'centerfooter' => $opt_centerfooter, 'coloralink' => $opt_coloralink, 'colorback' => $opt_colorback, 'colorfore' => $opt_colorfore, @@ -1615,11 +1699,12 @@ 'dirhtmlext' => !$opt_frames ? "" : $opt_dirhtmlext, 'dirindexname' => !$opt_frames ? "" : $opt_dirindexname, 'footer' => $opt_footer, + 'forceuplink' => $opt_forceuplink, + 'forcenouplink' => $opt_forcenouplink, 'frameddirfmt' => !$opt_frames ? "" : $opt_frameddirfmt, '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 +1712,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 +1733,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,14 +1745,20 @@ '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, + 'pichtmlupfirst' => $opt_pichtmlupfirst, 'pichtmlputtitle' => !$opt_pichtml ? 0 : $opt_pichtmlputtitle, + 'pichtmltitletop' => (!$opt_pichtml || !$opt_pichtmlputtitle) ? 0 : $opt_pichtmltitletop, 'pichtmltarget' => (!$opt_pichtml || !$opt_frames) ? "" : $opt_pichtmltarget, 'pichtmltitleend' => !$opt_pichtml ? "" : $opt_pichtmltitleend, 'pichtmltitlestart' => !$opt_pichtml ? "" : $opt_pichtmltitlestart, 'pichtmltop' => !$opt_pichtml ? "" : $opt_pichtmltop, + 'edgelinksindex' => $opt_edgelinksindex, 'prefixpath' => $opt_prefixpath, 'readme' => !$haveReadme ? "" : $opt_readme, 'readmepresent' => $haveReadme, @@ -1676,6 +1768,12 @@ 'stylesheet' => $opt_stylesheet, 'subdirectories' => !$opt_frames ? "" : join(' ',@dirNames), 'tables' => $opt_tables, + 'tablebackcolor' => !$opt_tables ? "" : $opt_tablebackcolor, + 'fancytables' => !$opt_tables ? 0 : $opt_fancytables, + 'fancytableheight' => !$opt_tables ? 0 : $opt_fancytableheight, + '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'}, ); @@ -1763,7 +1861,7 @@ if( ! $opt_tables && (! -f $fileNames{'pageStatus'} || ( ! -f $fileNames{'montageGIF'} && ! -f $fileNames{'montageJPEG'} ))) { # If key file is missing then do montage - print(STDERR "\nMust do montage because a required output", + print(STDERR "Must do montage because a required output", " file is missing\n") if $opt_debug; ++$doMontage; @@ -1975,7 +2073,8 @@ # get indexname of parent directory my $upindexname = get_rc_var('..', 'opt_indexname', "$opt_indexname"); - unless ( "$upindexname" eq 'NOLINK' ) { + + unless ( "$upindexname" eq 'NOLINK' || "$opt_forcenouplink" || ( cwd() eq "$opt_rootpath" && ! "$opt_forceuplink" ) ) { $uphtml = "" . " ${opt_msg_up}
\n"; @@ -2023,20 +2122,19 @@ } else { $dirtitle=$subdir; } - + # get indexname for sub-directory (default as this directory) my $subindexname = get_rc_var($subdir, 'opt_indexname', "$opt_indexname"); unless ( "$subindexname" eq 'NOLINK' ) { my $url = escapeurl("$subdir/${subindexname}"); - $dirhtml .= ''; # If a bullet icon is defined, then use it # otherwise use plain text only if( defined( $iconImageUrls{'ball'} ) ) { $dirhtml .= "\"*\""; } - $dirhtml .= "$dirtitle
\n"; + $dirhtml .= "$dirtitle
\n"; } } } @@ -2128,14 +2226,15 @@ # open( INDEX, ">${opt_indexname}") || die("$0: Failed to open file ${opt_indexname} for output\n$@\n"); - print( INDEX "\n\n" ); + print( INDEX "\n\n\n" ); # Charset is better before title print( INDEX " \n" ) if( "$opt_metacharset" ne '' ); 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" ) @@ -2154,7 +2253,7 @@ # If in JavaScript mode, output code to switch to JavaScript pages # Currently knows about certain browsers. if( $opt_javascript ) { - print( INDEX '\n" ); } @@ -2173,20 +2272,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 ); @@ -2195,12 +2291,11 @@ if( $opt_javascript ) { open( INDEX, ">$fileNames{'jsDirIndex'}") || die("$0: Failed to open file $fileNames{'jsDirIndex'} for output\n$@\n"); - print( INDEX "\n" ); - print( INDEX "\n" ); + print( INDEX "\n\n\n" ); print( INDEX "\n" ); - print( INDEX q/! . "\n" ); - print( INDEX q/! . "\n" ); - print( INDEX "! . "\n" ); + print( INDEX q/! . "\n" ); + print( INDEX "\n" ); @@ -2214,7 +2309,7 @@ open( INDEX, ">${opt_pageindexname}dir${opt_dirhtmlext}") || die("$0: Failed to open file \"${opt_pageindexname}dir${opt_dirhtmlext}\"", " for output\n$@\n"); - print( INDEX "\n\n" ); + print( INDEX "\n\n\n" ); # Charset is better before title print( INDEX " \n" ) if( "$opt_metacharset" ne '' ); @@ -2224,7 +2319,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 +2338,14 @@ print( INDEX "\n" ); print( INDEX "\n"); print( INDEX $pagedirhtml ); print( INDEX "\n" ); @@ -2279,7 +2372,7 @@ # Calculate page index bar # No link for current page # Nothing at all when there is only one page. - $indexbar = ""; + $indexbar = ""; # Must be visible at each page, if no frames if (!$opt_frames) { @@ -2329,8 +2422,6 @@ } } - $indexbar .= ""; - # --- page links --- if( $numPages > 1 ) { my $page; @@ -2352,7 +2443,7 @@ open( INDEX, ">$fileNames{'htmlCurrentIndex'}") || die("$0: Failed to open file $fileNames{'htmlCurrentIndex'} for output\n$@\n"); - print( INDEX "\n\n" ); + print( INDEX "\n\n\n" ); # Charset is better before title print( INDEX " \n" ) if( "$opt_metacharset" ne '' ); @@ -2361,7 +2452,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,32 +2471,65 @@ print( INDEX "\n" ); print( INDEX "\n"); print( INDEX "${opt_header}\n" ) if ("$opt_header" ne ''); # Leave page blank unless there is something to show 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" ); + #BRAD: Added directory description + if( $imageCaptions{'pageTitle'} ne '') { + print( INDEX "

$imageCaptions{'pageTitle'}

\n"); + print( STDERR "Using custom PageDescription\n") if $opt_debug; + } else { + print( INDEX "

\n" ); } print( INDEX "$indexbar
\n" ); + if( $imageCaptions{'pageTitle'} eq '' && + $opt_indexinfo && (!$opt_frames || $opt_framestyle == 1) ) { + my $desc1 = ''; + my $desc2 = ''; + if (defined($imageCaptions{$imageNames[$pageNumber -1][0]})) { + $desc1=escapehtml($imageCaptions{$imageNames[$pageNumber -1][0]}); + } elsif (defined($imageLabels{$imageNames[$pageNumber -1][0]})) { + $desc1=escapehtml($imageLabels{$imageNames[$pageNumber -1][0]}); + } else { + $desc1=escapehtml($imageNames[$pageNumber - 1][0]); + } + if (defined($imageCaptions{$imageNames[$pageNumber -1][$numimages-1]})) { + $desc2=escapehtml($imageCaptions{$imageNames[$pageNumber -1][$numimages-1]}); + } elsif (defined($imageLabels{$imageNames[$pageNumber -1][$numimages-1]})) { + $desc2=escapehtml($imageLabels{$imageNames[$pageNumber -1][$numimages-1]}); + } else { + $desc2=escapehtml($imageNames[$pageNumber - 1][$numimages-1]); + } + print( INDEX "${opt_msg_index_of_files}\"", + $desc1, "\" ${opt_msg_index_through}", " \"", $desc2, + "\"
\n" ); + } + if ($opt_tables) { - print INDEX ""; + if ( !$opt_fancytables ) { + print INDEX "
"; + print INDEX "${opt_tables_top}" + if ($opt_tables_top ne ''); + } else { + #BRAD added fancy tables based entirely on the Igal program + #This section prints the top of the table + my $cols = $opt_columns; + if ( $numimages < $cols) { $cols=$numimages; } + print INDEX "
\n"; + print INDEX ""; + } } else { @@ -2423,35 +2548,46 @@ } print( INDEX "" ); + " USEMAP=\"#${mapname}\" BORDER=0 ISMAP ALT=\"${mapname}\">" ); print( INDEX "" ) if ($opt_serversidemap); print( INDEX "\n\n" ); } # unless ( $opt_tables ) my $imageNum; - for( $imageNum = 0; $imageNum <= $#{$imageNames[$pageNumber - 1]}; ++$imageNum ) { + my $maxNum = $#{$imageNames[$pageNumber-1]}; + + for( $imageNum = 0; $imageNum <= ${maxNum}; ++$imageNum ) { 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" ); + print( PICHTML "\n\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,32 +2605,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}"); - } - if ($opt_pichtmlnav) { - print ( PICHTML "

"); + print ( PICHTML "

"); # Must be visible at each page, if no frames if (!$opt_frames) { @@ -2507,7 +2630,7 @@ } # up - if (!$opt_frames || $opt_framestyle == 1) { + if ( (!$opt_frames || $opt_framestyle == 1) && $opt_pichtmlupfirst ) { if ($opt_frames) { print ( PICHTML "\n"); + #BRAD: Added edgelinks link back to index + if ( $opt_edgelinksindex ) { + if ($opt_frames) { + print ( PICHTML ""); + } else { + print ( PICHTML ""); + } + } + print ( PICHTML "\n"); + if ( $opt_edgelinksindex ) { + print ( PICHTML ""); + } } else { print ( PICHTML "\"${opt_msg_prev}\"\n"); } - + + # up if in middle (added by BRAD) + if ( (!$opt_frames || $opt_framestyle == 1) && !$opt_pichtmlupfirst ) { + if ($opt_frames) { + print ( PICHTML "\"${opt_msg_up}\"\n"); + + } + #next if (($pageNumber == $numPages) && ($imageNum == $#{$imageNames[$pageNumber - 1]})) { - print ( PICHTML "\n"); + #BRAD: Added edge links back to index + if ( $opt_edgelinksindex ) { + if ($opt_frames) { + print ( PICHTML ""); + } else { + print ( PICHTML ""); + } + } + print ( PICHTML "\n"); + if ( $opt_edgelinksindex ) { + print ( PICHTML ""); + } } else { print ( PICHTML "\"${opt_msg_next}\"\n"); } - - print ( PICHTML "
"); } - if ( $pic =~ /\.(jpg|jpeg?|gif|xbm|png)$/i ) { - print( PICHTML "\"\"" ); + if ($opt_pichtmlputtitle && $opt_pichtmltitletop) { + print ( PICHTML "${opt_pichtmltitlestart}${altlabel}${opt_pichtmltitleend}"); + } elsif ($opt_pichtmlnav) { + 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), "" ); + } + + if ($opt_pichtmlputtitle && !$opt_pichtmltitletop) { + print ( PICHTML "${opt_pichtmltitlestart}${altlabel}${opt_pichtmltitleend}"); } print( PICHTML "$opt_pichtmlbottom\n") if ("$opt_pichtmlbottom" ne ''); @@ -2570,14 +2742,14 @@ unless ($opt_tables) { - print( INDEX " \n" ); } } else { unless ($opt_tables) { - print( INDEX " \"${altlabel}\"\n" ); } } @@ -2590,7 +2762,7 @@ print INDEX "

"; } - print INDEX "\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)) { print INDEX ""; - } + #BRAD: Middle lines in a fancy tables + if ( $opt_fancytables && $imageNum != $maxNum) { + my $cols = $opt_columns; + if ( $maxNum - $imageNum < $opt_columns ) { + $cols = $maxNum%$opt_columns+1; + } + print INDEX "", + "", + "" ; + } + } } # if ($opt_tables) } # for each picture @@ -2622,6 +2811,13 @@ { print INDEX ""; } + #BRAD:The bottom of a fancy table + if ( $opt_fancytables ) { + my $cols = $maxNum%$opt_columns+1; + print INDEX ""; + } + print INDEX "${opt_tables_bottom}" + if ($opt_tables_bottom ne ''); print (INDEX "
 
"; + print INDEX ""; if ($opt_pichtml) { print (INDEX ""); @@ -2601,17 +2773,34 @@ # 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") } else {print( INDEX "\n" );} } @@ -2630,6 +2826,9 @@ # Print Copyright info on non-blank pages. if( $numimages > 0 ) { + if( $opt_centerfooter ) { + print( INDEX "

\n" ); + } if( "${opt_address}" ne '' ) { print( INDEX "
${opt_address}
\n" ); } @@ -2642,13 +2841,17 @@ # If anonymous, don't show copyright and address info if( ! $opt_anonymous ) { print( INDEX "
\n${opt_msg_produced_by} " ); - print( INDEX "WebMagick" ); - print( INDEX " $webmagickInfo{version}, ${opt_msg_copyright}© Bob Friesenhahn\n" ); + print( INDEX " $webmagickInfo{version}, ${opt_msg_copyright}© Bob Friesenhahn\n" ); } if( "$htmlOpts{'dateText'}" ne '' || !$opt_anonymous) { print( INDEX "\n" ); } + if( $opt_centerfooter ) { + print( INDEX "
\n"); + } + } print( INDEX "\n" ); @@ -2674,13 +2877,12 @@ open( JSINDEX, ">$fileNames{'jsPageIndex'}") || die("$0: Failed to open file $fileNames{'jsPageIndex'} for output\n$@\n"); - print( JSINDEX "\n"); - print( JSINDEX "\n"); - print( JSINDEX "\n"); - print( JSINDEX "\n"); + print( JSINDEX "\n\n\n" ); + print( JSINDEX "\n"); + print( JSINDEX "\n"); print( JSINDEX "\n"); print( JSINDEX "\n"); - print( JSINDEX "\n"); print( JSINDEX "\n"); @@ -2714,6 +2916,8 @@ # Image labels print( JSVARS "\n// image titles\n", jsHash( 'imageLabels', \%imageLabels ) ); + # Image captions + print( JSVARS "\n// image captions\n", jsHash( 'imageCaptions', \%imageCaptions ) ); # Image labels #print( JSVARS "\n// table image titles\n", jsHash( 'tableImageLabels', \%tableImageLabels ) ); @@ -2803,6 +3007,8 @@ # Image labels print( PERLVARS "\n# image titles\n", plHash( 'imageLabels', \%imageLabels ) ); + # Image captions + print( PERLVARS "\n# image captions\n", plHash( 'imageCaptions', \%imageCaptions ) ); # Table image labels print( PERLVARS "\n# table image titles\n", plHash( 'tableImageLabels', \%tableImageLabels ) ); @@ -3465,6 +3671,10 @@ sub sortDir { if(defined($dirOrder{$a}) && defined($dirOrder{$b})) { $dirOrder{$a} <=> $dirOrder{$b} + } elsif(defined($dirOrder{$a})) { + return -1; + } elsif(defined($dirOrder{$b})) { + return 1; } else { lc($a) cmp lc($b); } @@ -3476,7 +3686,11 @@ sub sortImages { if(defined($imageOrder{$a}) && defined($imageOrder{$b})) { $imageOrder{$a} <=> $imageOrder{$b} - } else { + } elsif(defined($imageOrder{$a})) { + return -1; + } elsif(defined($imageOrder{$b})) { + return 1; + } else { lc($a) cmp lc($b); } } @@ -3533,6 +3747,9 @@ sub compareHash { my( $hash1, $hash2) = @_; + if (defined(%$hash1) != defined(%$hash2)) { + return( 1 ); + } if(scalar(keys(%$hash1)) != scalar(keys(%$hash2))) { return( 1 ); # different length } @@ -3868,7 +4085,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 +4139,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 +4290,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 @@ -4093,6 +4311,8 @@ Filenames: --dirindexname Directory-name to title cross-reference file name --imgindexname Image-name to thumbnail label cross-reference file name + Line Format: [, ] + or: pageTitle [, ] --indexname Name of master index files (default server index) --pageindexname Base name of page-related index files --readme Name of directory info file @@ -4138,6 +4358,7 @@ HTML Colors & Appearance: --address Optional user address info + --[no]centerfooter Center the footer text (default no) --[no]anonymous Don't show WebMagick address and copyright info on pages (default off) --coloralink Link (active) color --colorback Background color (also applied to JPEG montage background) @@ -4150,31 +4371,44 @@ --dircolorlink Link (unvisited) color (directory frame) --dircolorvlink Link (visited) color (directory frame) --dirhtmlext Extension for directory frame + --forceuplink Force there to be a link to "../index.html" in directory list even if we didn't generate the file + --forcenouplink Force there to be no linke to "../index.hml" in directory list even if we did generate the file --stylesheet URL to stylesheet (overrides other color options) --[no]date Output updates date (default on) --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) + --[no]pichtmlupfirst Put Up icon before prev, next icons (default on) --[no]pichtmlputtitle Put per-image HTML picture title (default on) + --[no]pichtmltitletop Put per-image picture title above image (default on) + --[no]edgelinksindex Edge-links on per-image HTML link back to index (default off) --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 + --[no]fancytables Use a fancier HTML table (default off). Caution, the default + colors do not look good with this option. 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 + --framemarginwidth Pixels allocated to frame margin in horizontal direction (default 1) + --framemarginheight Pixels allocated to frame margin in vertical direction (default 1) + --frameborder Enable (1, default) 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 +4530,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( $_ ); } @@ -4387,7 +4610,6 @@ my $rc; foreach $rc (@_) { next if ( ! -r $rc || ! -f $rc ); - print( "Sourcing ${rc}\n" ) if $opt_debug; eval ( get_rc($rc) ); if( $@ ) { print( STDERR "Bad Eval for file \"${rc}\"...\n$@\n" ); @@ -4468,7 +4690,7 @@ my $path=$top; $direlem=''; do { - # Certain values must only be vaild in the last + # Certain values must only be valid in the last # current directory webmagickrc file. $opt_ignore=0; # Ignore -- do not process this directory