# 10-06-04

# the HTML templates used by Nanagram-CGI
# a CGI anagram creator by Fuzzyman
# See http://www.voidspace.org.uk/atlantibots/pythonutils.html

from time import strftime

######################################

versionstring = '1.0.2 10th June, 2004.'                            # edit this if you must..... :-(
scripturl = "http://www.voidspace.xennos.com/cgi-bin/Nanagram-CGI.py"   # This must be changed to the location of the main script


######################################

# pageout is the start of the page

pageout = """
<HTML>
<HEAD><TITLE>Nanagram - Sea-Gee-Eye - Jumbling Words for Fun</TITLE></HEAD>
<BODY bgcolor="#DCDCDC" link="#000099" vlink="#990099" alink="#000099">
<A NAME=abc></A>
<FONT COLOR=#424242 style="font-family:times;font-size:12pt;">
<CENTER>
<H1>The Nanagram - Sea-Gee-Eye</H1>
<B><I>By Fuzzyman</B></I><BR>
<H2>Jumbling Words for Fun and Profit</H2>
<BR><BR>
<H1>Output from Nanagram</H1>
<BR><BR>
</CENTER>""" + "<B>Version : " + versionstring + """
<BR>
Running on : """ + strftime('%I:%M %p, %A %d %B, %Y')+""".</B><BR>"""


######################################    


# entrytable is the form for getting the words etc. from the user.
# please leave the message and my links intact.

entrytable = """
<CENTER>
<BR>
<BR>
<HR WIDTH=50%>
<BR>
<BR>
<TABLE width=70% border=1>
<TR><form method=GET action=""" + scripturl + """>
<TD><FONT COLOR=#424242 style="font-family:times;font-size:12pt;">
    <P><B>Enter the words for me to jumble :</B></TD>
<TD align =right><input type=text name=words maxlength=25></TD>
<TR>
<TD><FONT COLOR=#424242 style="font-family:times;font-size:12pt;">
    <P><B>What word(s) Should the anagrams include ? :</B>
    <BR><B>(Optional)</B></TD>
<TD align =right><input type=text name=contain></TD>
<TR>
<TD><FONT COLOR=#424242 style="font-family:times;font-size:12pt;">
    <P><B>Minimum word length to include in the results ? :</B>
<BR><B>(Minimum number of letters, default is 4)</B></TD>
<TD align =right><input type=radio name=minlen value=1>1 
<input type=radio name=minlen value=2>2 
<input type=radio name=minlen value=3>3 
<input type=radio name=minlen value=4 CHECKED>4 
<input type=radio name=minlen value=5>5 </TD>
</TR>
<TR>
<TD><FONT COLOR=#424242 style="font-family:times;font-size:12pt;">
<B><A HREF=http://www.voidspace.org.uk/atlantibots/pythonutils.html target=_blank>Nanagram</A>
the word jumbler</B> is written and maintained by <I><A HREF=http://www.voidspace.org.uk target=_blank>Fuzzyman</A></I>,
using <B><A HREF=http://www.python.org target=_blank>Python</A></B>.
</TD>
<TD align=center valign=middle><input type=submit value='Go Nanagram'></TD>
</form></TR></TABLE>
<BR>
<BR>
<HR WIDTH=50%>
<BR>
<BR>
</CENTER>
"""

######################################

# pageout1 to pageout4 are the various messages used to display the information to the user.
# Note the <CENTER> in pageout4 used to format the anagrams.....
# This could easily be removed if you wanted.
# (It is also in blankout and uncontained).
# the %s in pageout1-3 represent values that will be substituted in later.....

pageout1 = """
<BR>
We are looking for anagrams of : \'%s\'.<BR><BR>"""

pageout2 = """
Containing the following words : \'%s\'.<BR><BR>"""

pageout3 = """
Only using words with minimum length of  : %s letters.<BR><BR>"""

pageout4 ="""
<BR>
Here they are :<BR>
<CENTER>
<BR><BR>"""


######################################

# uncontained is the message displayed when the user sks you to display impossible anagrams -
# e.g. anagrams of 'fish face' containing the word 'ugly'.....

uncontained = """
<BR>
Sorry the word(s) you have said must be contained in the anagrams, can't be made from the words you have given us.<BR>
Please try again.
<BR><BR>
<CENTER>
"""

######################################

# blankout is the message displayed when the user hits submit without any words.
# *or* if it is called with no parameters.
# It can be used as the basic page - just displays the entry table and then a welcome message below.

blankout = """
<BR>
<BR>
<BR>
<CENTER>

<TABLE width=60%>
<TR>
<TD>
<FONT COLOR=#424242 style="font-family:times;font-size:12pt;">
Nanagram is a <B><A HREF=http://www.python.org.uk target=_blank>Python</A></B> script that finds anagrams of words.<BR>
It uses a 'built-in' dictionary of 17890 words. The main 'loop' that finds the anagrams is only 23 lines of code !! There is also a desktop version of Nanagram (Nanagram - Gooey) that has a much larger dictionary included with it.<BR>
<B><A HREF=http://www.voidspace.org.uk/atlantibots/nanagram.html target=_blank>Nanagram-GUI Download</A></B><BR>
(This page also includes an explantion of how Nanagram works - in actual fact Nanagram-CGI is slightly simpler than Nanagram-GUI !!).<BR>
<BR> 
The source code of <B>Nanagram-CGI</B> is available for use on your own website (including dictionaries and the HTML template). Visit <B><A HREF=http://www.voidspace.org.uk/atlantibots/pythonutils.html target=_blank>Python-Utils Home Page</A></B> which also has various other python 'snippets' of mine.<BR>
<BR>
The dictionary of words that <B>Nanagram</B> uses is an 'open-source' wordlist from <B><A HREF=http://wordlist.sourceforge.net target=_blank>wordlist.sourceforge.net</A></B>. The appropriate license is included in all downloads that include it.<BR>
<BR>
For those of you who wonder about such things - The CGI in Nanagram <B>Sea-Gee-Eye</B> refers to the 'Common Gateway Interface' and is the way that web-browsers and servers communicate with programs like Nanagram.<BR>
<BR>
Anyway - I hope you enjoy Nanagram, if you do then you'll probably enjoy the desktop version even more.<BR>
<I>Fuzzyman</I> 


</TD>
</TR>
</TABLE>
<BR>
<BR>
"""


######################################

# pageend is the rest of the page below the results.
# If you have deleted the <CENTER> tag in pageout4, uncontained and blankout then you might want to
# add one at the start of here.


pageend = """
<BR>
<BR>
<HR width=50%>
<BR>
<BR>
email : michael AT foord DOT me DOT uk<BR>


<FONT COLOR=#424242 style="font-family:times;font-size:12pt;">
<BR>
Nanagram CGI (and it's <B><A HREF=http://www.python.org target=_blank>Python</A></B> source code) is available for non-commercial use by anyone who might want it, without fee. No warranty as to it's correctness, fitness for purpose or anything else is made - use at your own risk :-)<BR>
The home page for this program - where news/updates can be found -  is <B><A HREF=http://www.voidspace.org.uk/atlantibots/pythonutils.html target=_blank>Python-Utils Home Page</A></B>. If you want to be kept up to date about changes and improvements to Nanagram-CGI then send me an e-mail, alternatively if you have any questions or comments (or bug reports) feel free to contact me - <I>Michael Foord</I>.<BR>
<SMALL>(If you let me know any places you use my scripts I can include a link back to you as examples).</SMALL><BR><BR>

<BR>
<BR>
<A HREF=#abc>Back To Top</A>
<BR>
<BR>
</CENTER>

</BODY>
</HTML>
"""

######################################


