#!/usr/bin/env python import cgitb cgitb.enable() import glob png = glob.glob('mini/*.png') jpg = glob.glob('mini/*.jpg') images = list(filename[5:-4] for filename in (png + jpg)) p = len(images) / 5 first = images[:p] second = images[p:p*2] third = images[p*2:p*3] fourth = images[p*3:p*4] fifth = images[p*4:] print 'Content-Type: text/html; charset=utf-8' print print """\ <!DOCTYPE html> <title>Lluniau Amrywiol (Miscellaneous Images)</title> <style type="text/css"> body { margin: 3em } h1 { font: 1.7em Georgia; font-weight: normal; margin: 1em; font-variant: small-caps; letter-spacing: 0.1ex } h1, p { text-align: center } p { margin: 0 0 2.5em 0 } table { margin: 0 auto; text-align: center } td { width: 20%; vertical-align: top; padding: 0 1em; text-align: center; font: 0.9em/1.3em Georgia } a img { border: 0 solid #fff } </style> <h1>Lluniau Amrywiol</h1> <p><a href="/list/stuff/images/">directory</a> · <a href="/inside/stuff/images/">source</a></p> <table> <tr> """ for part in (first, second, third, fourth, fifth): print '<td>' for image in part: print '<p><a href="%s" title="%s"><img ' % (image, image) print 'src="mini/%s" alt="[%s]"></a><br>%s</p>' % (image, image, image) print '</td>' print """\ </tr> </table> <hr> <address> <a href="http://inamidst.com/sbp/">Sean B. Palmer</a>, inamidst.com </address> """ # EOF