The script: MakeWebPageIndexUsingThumbnails #!/usr/bin/perl # Script: MakeWebPageIndexUsingThumbnails # Description: Create html to display all graphics on the system # # Author: Brant L. Pellett, with minor revisions by Dennis Carr # Version: 1.3.1 # Date: 09-Mar-2002 # Copyright: Copyright (C) 1997-2002 Brant Pellett, Dennis Carr # Permission granted to copy freely on a strictly cost-free basis\ . # Note - this revision expects you to have a file called ".index" in the # directory you run it in. This will contain something that will read as # " Image Archive" at the top of the page. If the file is not in the # directory, your page is simply titled "image archive". # # 1.3.1 implemented a minor change in tabling for the NextPrev routine, correct\ ing # some tabling issues that existed. # # Plans to make it default to the directory name for lack of a .index file # are dormant. # C O N F I G U R A T I O N S E C T I O N : $ImagesPerPage = 28 ; $TableWidth = "4" ; # C O N S T A N T S : #$TempFile="/tmp/MakeWebPageIndexUsingThumbnails-" . $$ ; $ThisDir=`cat ./.index` ; chop ($ThisDir) ; $DoubleQuote = '"' ; # Get list of files: open (IN,"find " . join(" ",@ARGV) . " -type d -o -print | sort |"); while ( $SomeFile = ) { # Ignore thumbnails: if ( $SomeFile =~ m/\// ) { @FileNameParts = split("/",$SomeFile) ; $SomeBasename = pop(@FileNameParts) ; } else { $SomeBasename = $SomeFile ; } ; if ( $SomeBasename =~ m/^tn_/ ) { next ; } ; chop($SomeFile); study($SomeFile); if ( ( $SomeFile =~ m/\.gif$/i ) || ( $SomeFile =~ m/\.jpg$/i ) || ( $SomeFile =~ m/\.jpeg$/i ) ) { if ( -f $SomeFile ) { push(@GraphicFiles, $SomeFile) ; dprint("Found:\t" . $SomeFile . "\n") ; }; } ; }; close(IN); $GraphicFileCount = scalar ( @GraphicFiles ) ; dprint("Total Graphic Files Found:\t" . $GraphicFileCount . "\n") ; while ( 0 != ($GraphicFileCount % $TableWidth ) ) { push(@GraphicFiles, " ") ; $GraphicFileCount = scalar ( @GraphicFiles ) ; } ; $GraphicFileCount = scalar ( @GraphicFiles ) ; #$EstimatedNumberOfPages = $GraphicFileCount / $ImagesPerPage ; $EstimatedNumberOfPages = int ($GraphicFileCount / $ImagesPerPage ) ; if ( $GraphicFileCount % $ImagesPerPage ) { $EstimatedNumberOfPages++ } ; if ( $EstimatedNumberOfPages < 100 ) { $PageNumberFormat = "%2.2d" ;\ } elsif ( $EstimatedNumberOfPages < 1000 ) { $PageNumberFormat = "%3.3d" ;\ } elsif ( $EstimatedNumberOfPages < 10000 ) { $PageNumberFormat = "%4.4d" ;\ } elsif ( $EstimatedNumberOfPages < 100000 ) { $PageNumberFormat = "%5.5d" ;\ } else { $PageNumberFormat = "%9.9d" ;\ } ; $PageCounter = 0 ; while ( $GraphicFileCount > 0 ) { $PageFileName = sprintf($PageNumberFormat,$PageCounter) . "-ImageIndex.\ html" ; open (OUT,">" . $PageFileName) || die("Out:" . $PageFileName) ; print (OUT "\n"); print (OUT "
\n") ; print (OUT "\n") ; print (OUT "\n") ; if ( $EstimatedNumberOfPages < 2 ) { print (OUT "\t\t\t" . $ThisDir . " Image Archive\n") ; } else { print (OUT "\t\t\t" . $ThisDir . " Image Archive, Page " . sprintf($PageNumberFormat,$PageCounter) . "\n") ; } ; print (OUT "\n") ; print (OUT "
\n") ; print (OUT "\n") ; print (OUT "

\n") ; print (OUT "
" . $ThisDir . " Image Archi\ ve, Page " . sprintf($PageNumberFormat,$PageCounter) . "\n ") ; print (OUT "
The northarc.com image archive\n") ; print (OUT "\n
\n") ; print (OUT "\n"); print (OUT "\n"); print (OUT "

\n"); print (OUT "
Sunset Grill: Home -> Anime Image Archives -> ".$ThisDir." page ".sprintf($PageN\ umberFormat,$PageCounter) . "\n"); print (OUT "
\n\n"); print (OUT "

\n") ; print (OUT "

\n"); print (OUT "\n"); print (OUT "\n"); $ColumnCount = "0" ; $FirstTime = "True" ; #foreach $aGraphicFile ( sort @GraphicFiles ) # foreach $aGraphicFile ( @GraphicFiles ) $ImageCounter = 0 ; # Keep going as long as both: 1) the page is not yet full, and 2) there a\ re more graphics: while ( ( $ImageCounter < $ImagesPerPage ) && ( scalar(@Graphic\ Files) > 0 ) ) { $aGraphicFile = shift( @GraphicFiles ) ; if ( -f $aGraphicFile ) { $ColumnCount++ ; if ( $ColumnCount > $TableWidth ) { print (OUT "\n"); print (OUT "\n"); $ColumnCount = "1" ; } ; $ThumbnailFileName = "tn_" . $aGraphicFile ; $ThumbnailFileName =~ s/tn_.\//.\/tn_/ ; if ( $TableWidth == 3 ) { $ThumbnailWidth = 240 ; $ThumbnailHeigth = 180 ; } elsif ( $TableWidth == 4 ) { $ThumbnailWidth = 120 ; $ThumbnailHeigth = 90 ; } elsif ( $TableWidth == 5 ) { $ThumbnailWidth = 150 ; $ThumbnailHeigth = 100 ; } else { $ThumbnailWidth = 150 ; $ThumbnailHeigth = 100 ; } ; print (OUT "\n"); }; $ImageCounter++ ; }; print (OUT "\n"); print (OUT "
\n"); print (OUT "\n"); print (OUT "
\n"); print (OUT "
\n"); &NextPrev; print (OUT "


This collection comp\ iled by Dennis Carr\n"); print (OUT "

\n"); # print (OUT "
\n") ; print (OUT "\n"); print (OUT "\n"); close(OUT); $PageCounter++ ; $GraphicFileCount = scalar ( @GraphicFiles ) ; }; # Debug printer - comment out print() to turn off debugging: sub dprint { print(join(" ",@_)) ; } ; # Next/Previous subroutine - inserts guides at the end of table sub NextPrev { $PrevFileName = sprintf($PageNumberFormat,$PageCounter-1) . "-ImageIndex.html" \ ; $NextFileName = sprintf($PageNumberFormat,$PageCounter+1) . "-ImageIndex.html" \ ; $LastPage = $EstimatedNumberOfPages-1; if ($EstimatedNumberOfPages > 1) { print (OUT "\n"); print (OUT "\n"); print (OUT "\n"); print (OUT ""); print (OUT "\n"); } print (OUT "
\n"); if ($PageCounter > 0) { print (OUT "
Previous\n"); } print (OUT "
\n \n"); if ($PageCounter < $LastPage) { print (OUT "
Next
\n"); print (OUT "
\n"); }} [EOF] Results of perl -V: Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration: Platform: osname=linux, osvers=2.4.21-1.1931.2.382.entsmp, archname=i386-linux-thread\ -multi uname='linux str' config_args='-des -Doptimize=-O2 -g -pipe -march=i386 -mcpu=i686 -Dmyhostna\ me=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dinstal\ lprefix=/usr -Dprefix=/usr -Darchname=i386-linux -Dvendorprefix=/usr -Dsitepref\ ix=/usr -Dotherlibdirs=/usr/lib/perl5/5.8.0 -Duseshrplib -Dusethreads -Duseithr\ eads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_s\ hadow -Di_syslog -Dman3ext=3pm -Duseperlio -Dinstallusrbinperl -Ubincompat5005 \ -Uversiononly -Dpager=/usr/bin/less -isr' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef' useithreads=define usemultiplicity= useperlio= d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=un uselongdouble= usemymalloc=, bincompat5005=undef Compiler: cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGG\ ING -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSE\ T_BITS=64 -I/usr/include/gdbm', optimize='', cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING -fno-s\ trict-aliasing -I/usr/local/include -I/usr/include/gdbm' ccversion='', gccversion='3.2.2 20030222 (Red Hat Linux 3.2.2-5)', gccosand\ vers='' gccversion='3.2.2 200302' intsize=r, longsize=r, ptrsize=5, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long' k', ivsize=4' ivtype='l, nvtype='double' o_nonbl', nvsize=, Off_t='', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='gcc' l', ldflags =' -L/u' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -lgdbm -ldb -ldl -lm -lpthread -lc -lcrypt -lutil perllibs= libc=/lib/libc-2.3.2.so, so=so, useshrplib=true, libperl=libper gnulibc_version='2.3.2' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so', d_dlsymun=undef, ccdlflags='-rdynamic -Wl,-r\ path,/usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE' cccdlflags='-fPIC' ccdlflags='-rdynamic -Wl,-rpath,/usr/lib/perl5', lddlflags='s Unicode/Normalize\ XS/A' Characteristics of this binary (from libperl): Compile-time options: DEBUGGING MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PER\ L_IMPLICIT_CONTEXT Locally applied patches: MAINT18379 Built under linux Compiled at Aug 13 2003 11:47:58 @INC: /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0