#!/net/u/1/f/fdc/kermit/wermit # # Run this script to create the Bronx images photo gallery, # or to update it when new images are added. # # Source images are not in the current (gallery) directory, but # in the superior (home) directory with Javascript-friendly names: # # bronx1.jpg, bronx2.jpg, ..., bronx10.jpg, bronx11.jpg, ..., bronx100.jpg,... # # This allows the number of images to grow by orders of magnitude without # getting into "ASCII order" sorting difficulties (where bronx100.jpg comes # before bronx2.jpg), or having to pad the numeric part of the filename # out to some fixed number of digits that might one day be exceeded. # cd ~/web/bronx if fail exit 1 .\%n := \ffiles(../bronx[1-9]*.{jpg,gif},&f) # List of source files for gallery echo Images: \%n # Since the image files are in the superior directory, their names # look like this: # \&f[]: Dimension = 1000 # 0. 1000 # 1. ../bronx1.jpg # 2. ../bronx10.jpg # 3. ../bronx100.jpg # 4. ../bronx1000.jpg # dcl \&t[\%n] # Parallel array for desired order for i 1 \%n 1 { # Go through list .num := \&f[i] # Extract number from filename .num := \s(num[9:]) # Number part starts here .num := \fword(\m(num),1) # continuing to the end of the "word" .\&t[num] := \&f[i] # Use number as index to result array } fopen /write \%o IMAGES # Create (or replace) the IMAGES file if fail exit for i \%n 1 -1 { if not def \&t[i] { echo WARNING: bronx\m(i).jpg seems to be missing continue } fwrite /line \%o \&t[i] if fail exit } fclose \%o chmod 664 IMAGES # run photogallery # Update the gallery exit