This is an application called Markthrough (read: http://tools.wikimedia.de/~tim/pages/projects/markthrough) There are two versions of Markthrough: a version written in Python, and one in Perl. The two are essentially the same, except the Python version offers a new feature: an option to specify a custom title for each page (this assumes you know what Markthrough is, if not read the link above.) Review the source code below and decide which you think is better. Python (80 lines including extra blank lines; 68 lines removing extra blank linkes) #! /usr/sfw/bin/python # # MARKTHROUGH (PYTHON) 1.0 REV 062706 import sys, cgi, os, re, time # CONFIGURATION VARIABLES # page_dir = "/home/tim/pages" # the directory where your pages file are url_root = "/~tim" # the URL root of your website page_root = "%s/pages" % url_root # the publicly accessable URL of your markthrough pages index = "%s/home" % page_root # the index page of your markthrough installation # END CONFIGURATION VARIABLES formvars = cgi.FieldStorage() print "Content-Type: text/html; charset=UTF-8\n" # initial print if formvars.has_key('id'): id = formvars['id'].value.replace('/', '.') origid = formvars['id'].value else: print "No ID specified." sys.exit() source = False if id.find('src') != -1: source = True id = id.replace('.src', '') if source: execloc = 'cat %s/%s' % (page_dir, id) else: execloc = '/home/river/Markdown.pl %s/%s' % (page_dir, id) try: f = os.popen(execloc) if not source: title = re.match('
title = (.*)
', f.readline()).group(1) # the first line of the page must be the title else: title = "Source for %s" % id content = f.read() if source: content = "" + content + "" finally: f.close() if not source and id != 'home': bits = id.split('.') current = bits.pop() bitpath = page_root bit_output = "
< home" % index for bit in bits: bit_output = bit_output + ' | %s' % (bitpath, bit, bit) bitpath = bitpath + '/%s' % bit bit_output = bit_output + ' | %s
' % current print """"; print "< home"; my $nroot = $pageroot; foreach my $bit (@bits) { print " | $bit"; $nroot .= "/$bit"; } print " | $last"; print "
"; } print "" if $source; while (" if $source; unless ($source) { my @s = stat("$root/$name"); my $mtime = $s[9]; my $modified = scalar localtime $mtime; my $lastbit = $slashname; $slashname =~ s/^.*\/([^\/]*)$/$1/; print <<__EOF__; __EOF__ } else { print <<__EOF__; __EOF__ } print "\r\n";) { if ($source) { print CGI::escapeHTML($_); } else { print; } } close MARKDOWN; print "