#!/usr/bin/env python
# -*- python-mode -*-
# -*- coding: UTF-8 -*-
###########################################################################
######################## Eureka latin hexameters #########################
###########################################################################
##
## o author: Richard Everson (R.M.Everson@exeter.ac.uk)
## o created: 2011-04-14 22:08:17+00:40
## o license: 

from random import choice
from string import upper, capitalize, join

drums = [
    [ 'fervida', 'trucida', 'invida', 'martia', 'turpia', 'lurida', 'pessima', 'aspera',
      'ignea', 'altera', 'barbara', 'impia', 'horrida', 'sontia', 'bellica' ], 

    [ 'tela', 'nota', 'castra', 'signa', 'regna', 'jura', 'facta', 'templa', 'ferra',
      'damna', 'verba', 'froena', 'vincla', 'sacra', 'pila', 'sponsa' ],

    [ 'foris', 'suis', 'sequa', 'puto', 'feris', 'patet', 'fere', 'reis', 'bonis',
      'modis', 'palam', 'domi', 'quidem', 'malis', 'cito', 'tuis' ],

    [ 'promulgant', 'depromunt', 'portendunt', 'confirmant', 'praemonstrant', 'conjungant',
      'progignunt', 'decidunt', 'proritant', 'praenarrant', 'producunt', 'declarant',
      'conquirant', 'monstrabunt', 'profundunt', 'corradunt', 'promittunt', 'casuabunt' ], 

    [ 'vulnera', 'nomina', 'munera', 'tristia', 'tempora', 'agmina', 'crimina', 'lumina',
      'prelia', 'carmina', 'vincula', 'spicula', 'nubila', 'verbera', 'foedera', 'jurgia',
      'fulgura', 'somina', 'organa' ],

    ['saeva', 'senta', 'cara', 'firma', 'dira', 'moesta', 'torva', 'mira', 'mala',
     'nigra', 'rara', 'multa', 'letha', 'quaedam', 'nequam', 'dura', 'densa', 'crebra',
     'fursca', 'prava' ]
    ]



h = " ".join([ choice(drum) for drum in drums ]).upper().capitalize()

print """Content-Type: text/html



<html>
<head>
<title>Eureka: John Clark's Latin Hexameters</title>
</head>
<body>

<h2>Eureka: John Clark's Latin Hexameters</h2>

<table width="100%%" border=0 cellspacing=0 cellpadding=20
bgcolor="#ffffff">
<tr>
<td>

 <font size="5" color="blue"> %s <font color="black" size="3">
<p>
&nbsp;
</p>

 <table width="70%%" border=0 cellspacing=0 cellpadding=0>
 <tr>
 <td>
 <p>
 This is a randomly generated latin hexameter generated using the component words from John Clark's Eureka machine built completed in 1845.   There are over 26 million possible hexameters.
</p>

<p>
Reload the page to get another one.
</p>
</td>
</tr>
</table>
 </td>
 
 <td>
 <img src="eureka1.jpg" border="0" alt="Eureka machine">
 </td>
 </tr>
</table>

""" % h

print """

<p> The vocabulary of words is taken from those listed by D.W. Blandford in
his article <a href="http://www.jstor.org/stable/642797">The 'Eureka'<a>
(<it>Greece and Rome,</it> Second Series, Vol 10, No. 1, March 1963, pp
71-78). No attempt has been made to remedy the errors Blandford points out:
"three words (<i>trucida, sequa,
casuabunt</i>) are non-existent, three (<i>puto, cito, mala</i>) have false quantities,
two (<i>nota, tristia</i>) are in the wrong column, one (<i>somina = somnia</i>) is
misspelt, one (<i>foris</i>) is repeated, and at least one other (<i>letha</i>) has
something wrong."
</p>

</html> """

