#! /usr/bin/env python # -*- coding: utf-8 -*- # Make a webpage for all pictures in the current directory. # # Author: R.F. Smith # Time-stamp: <2011-11-27 00:15:30 rsmith> # # To the extent possible under law, Roland Smith has waived all copyright and # related or neighboring rights to mkphotopage. This work is published from the # Netherlands. See http://creativecommons.org/publicdomain/zero/1.0/ import datetime import glob import zlib import base64 rootdir = "../../.." today = datetime.date.today() outfile = open('index.html', 'w') header = """ Roland's picture pages

Roland's picture pages

subtitle

My picture.

Creative
         Commons License
These photos are licensed under the Creative Commons Attribution 3.0 License.

The photos on this page have been taken during ...

""" outfile.write(header.format(today.year, today, rootdir, rootdir)) flist = glob.glob("*.jpg") flist.sort() twinned = [(flist[i], flist[i+1]) for i in range(0,len(flist)/2*2,2)] picline=""" \n""" cmtline=""" \n""" for p in twinned: outfile.write(picline.format(p[0], p[0], p[1], p[1])) outfile.write(cmtline.format(p[0], p[1])) if len(flist)%2 == 1: picline=""" \n""" cmtline=""" \n""" outfile.write(picline.format(flist[-1], flist[-1])) outfile.write(cmtline.format(flist[-1])) htmlfooter = """
{} {}
{} {}
{}
{}

""" outfile.write(htmlfooter.format(today.year, rootdir, rootdir, today)) # This footer is somewhat mangled, otherwise Emacs will pick it up. emacsfooter=''' ''' outfile.write(emacsfooter.format("Local Variables:")) outfile.close()