NSLU2-Linux
view · edit · print · history

Quick index.html generator for photo galleries

If you have tons of photos you want to show your friends but never have time to really put them all in a neat webpage, this is how you can create photo galleries on your thttpd server in five minutes.

Copy the following script text into a file index.sh

##########################cut here################################
# index.sh
# Author egor@kobylkin.com
# A quick way to create thumbnailed gallery index.html 
# With Microsoft Office Picture Manager I create thumbnails with the same name as the 
# pictures themself and put them into the subfolder "Thumbs".
# Then I'd just copy whole folder with the pictures and thumbnails to the /website 
# and run this script in there.

#!/bin/bash
cat <<EOF >./index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd"><html>
<head><title>`pwd|sed 's:/website/::'`</title>
<meta http-equiv="Content-Type" content="text/html">
</head>
<body>

`ls|sed 's/ /%20/g'|egrep -v "index.html|make_pic_index.sh|Thumbs|Thumbs.db"| \
  while read entry;
  do echo "<a href=$entry><img src=Thumbs/$entry></a>"; done;`

</body>
</html>
EOF

chmod a+r ./index.html
###########################cut here######################################

Put it where your pictures are (copy paste) and and make it executable

chmod a+x index.sh

If you will be copying when you are logged in as root you will have to change ownership to "website" afterwards.

chown website,website ./index.sh

Now run it

./index.sh

Check if everything looks OK

then delete it

rm ./index.sh
view · edit · print · history · Last edited by michaelebrown.
Originally by michaelebrown.
Page last modified on November 04, 2006, at 05:25 PM