#!/home3/zenmagic/python/bin/python
import cgi
import cgitb; cgitb.enable()
import urllib
import re
import os
import glob
import sys
themarkdhtml="default"
doit=1
s=""
if (doit == 1) :
f=''
f = urllib.urlopen("http://zenmagiclove.com/zml/markd/mobi/markd.html")
if f != '' :
themarkdhtml = f.read()
f.close()
s=s.replace("
","")
gp=s.split("{{")
if (gp[0] == "") : gp[0]="hello world92}}"
print 'Content-type: text/html\n\n'
#wherestop=0
#for x in range(0,len(gp)) :
# wherestop=gp[x].find("}}")
# if (wherestop > -1) :
# print str(x).zfill(3)+" -- "+gp[x][0:wherestop]+" "
gpagenumfield="1"
gpagenamefield="1"
gpagenum=1
gpagename="1"
gpagenums="1"
thedirectory="jvine"
form=cgi.FieldStorage()
if 'gpagenumfield' in form :
gpagenums=str(form['gpagenumfield'].value)
if 'gpagenamefield' in form :
gpagename=str(form['gpagenamefield'].value)
gpagenum=int(gpagenums)
action="none"
if 'next' in form:
gpagenum=gpagenum+1
action="next"
if 'prev' in form:
gpagenum=gpagenum-1
action="prev"
if 'toggle' in form:
action="toggle"
if 'nextg' in form:
gpagenum=gpagenum+1
action="next"
if 'prevg' in form:
gpagenum=gpagenum-1
action="prev"
if 'toggleg' in form:
action="toggle"
if 'plusone' in form:
gpagenum=gpagenum+1
action="plusone"
if 'minusone' in form:
gpagenum=gpagenum-1
action="minusone"
if 'tohome' in form:
gpagenum=1
action="tohome"
if 'toend' in form:
gpagenum=len(gp)-1
action="toend"
if (gpagenum > len(gp)-1) : gpagenum=1
if (gpagenum <= 0) : gpagenum=len(gp)-1
s="hi"
if (s != "hi") :
s=re.sub('\r\n','\n',s)
s=re.sub('\r\n','\n',s)
s=re.sub('\r','\n',s)
s=re.sub('\r','\n',s)
s=re.sub(' \n','\n',s)
s=re.sub(' \n','\n',s)
s=re.sub(' \n','\n',s)
s=re.sub(' \n','\n',s)
s=re.sub(' \n','\n',s)
html5="""
viewer19.py
"""
#s=s.strip('\n')
#s=s.rstrip()
#s='\n\n\n\n\n'+s
#
#s=re.sub('\n\n\n\n\n\n\n\n\n\n','\n\n\n\n\n',s)
#s=re.sub('\n\n\n\n\n\n\n\n\n','\n\n\n\n\n',s)
#s=re.sub('\n\n\n\n\n\n\n\n','\n\n\n\n\n',s)
#s=re.sub('\n\n\n\n\n\n\n','\n\n\n\n\n',s)
#s=re.sub('\n\n\n\n\n\n','\n\n\n\n\n',s)
print html5
# print theform
thebody="""
help text goes here...1
help text goes here...2
help text goes here...3
help text goes here...4
help text goes here...5
help text goes here...6
help text goes here...7
help text goes here...8
help text goes here...9
help text goes here...10
help text goes here...11
help text goes here...12
"""
theform="""
"""
gpagenums=str(gpagenum)
if (int(gpagenums) < 1) :
gpagenums="1"
gpagenum=1
if (int(gpagenums) > len(gp)-1) :
gpagenums=str(len(gp)-1)
gpagenum=len(gp)-1
theform=theform.replace("11111",str(gpagenums))
theform=theform.replace("22222",str(gpagename))
thebody=thebody.replace("themarkdhtml",themarkdhtml)
theform=theform.replace("themarkdhtml",themarkdhtml)
print thebody
print theform
thejavascript="""
"""
print thejavascript
for x in range(gpagenum,gpagenum+1) : ## in range(1,len(gp)-1) :
sx=str(x).strip()
wherestop=gp[x].find("}")
print '
'+gp[x]+'
'
print ''
print ''
print ''
print ''
mouseturd="""
<form> Defines an HTML form for user input
<input> Defines an input control
<textarea> Defines a multiline input control (text area)
<label> Defines a label for an element
<fieldset> Groups related elements in a form
<legend> Defines a caption for a