Normalize gen.py scripts across directories

This commit is contained in:
Steven Grimm 2013-12-26 12:49:33 -08:00
parent 79cf402d86
commit 0ead233940
13 changed files with 160 additions and 336 deletions

2
.gitignore vendored
View File

@ -1,7 +1,7 @@
background/[0-9]*.shtml background/[0-9]*.shtml
comic/[0-9]*.html comic/[0-9]*.html
credits/[0-9]*.html credits/[0-9]*.html
guide/#* */#*
guide/[0-9]*.html guide/[0-9]*.html
synops/[0-9]*.html synops/[0-9]*.html
novels/[0-9]*.html novels/[0-9]*.html

View File

@ -26,21 +26,11 @@ for epnum in sys.argv[1:]:
input = open('story.html', 'r') input = open('story.html', 'r')
output = open(cureplong + '.shtml', 'w') output = open(cureplong + '.shtml', 'w')
output.write("""<html> page_name = 'Background: "' + epname + '"'
<head> output.write(otros.head(page_name))
<title>Background: """ + '"' + epname + '"' + """</title> output.write("<body>\n")
<link rev=made href="mailto:koreth@midwinter.com"> output.write(otros.pageheader(curepno, 'background', 1))
<link rel=parent href="../guide/""" + cureplong + """.html"> output.write("\n<pre>\n\n</pre>\n")
</head>
<body>
""" + otros.pageheader(curepno, 'background', 1) + """
<pre>
</pre>
""")
printing = 1 printing = 1

View File

@ -1,85 +0,0 @@
#!/usr/bin/python
import sys,string,time,os
sys.path.append('../internal')
import otros
months = [ '', 'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December']
for epnum in sys.argv[1:]:
curep = string.atoi(epnum[:3])
pix = open('../internal/comicnames', 'r')
for i in range(0, curep + 1):
epname = pix.readline()[:-1]
pix.close()
if epname == '':
epname = 'XXX'
cureplong = '%03d' % curep
which = 'comic'
input = open(epnum, 'r')
mtime = time.localtime(os.stat(epnum)[8]);
mtime_str = '%s %d, %d' % (months[mtime[1]], mtime[2], mtime[0])
output = open(epnum + '.html', 'w')
output.write("""<html>
<head>
<title>Comic: """ + '"' + epname + '"')
if which == 'extra':
output.write(' (scene in detail)')
output.write("""</title>
<link rev=made href="mailto:koreth@midwinter.com">
<link rel=parent href="../eplist.html">
</head>
<body>
""" + otros.pageheader(curep, which))
if which == 'guide':
output.write("""
<p>
<b>Contents:</b>
<a href="#OV">Overview</a> -
<a href="#BP">Backplot</a> -
<a href="#UQ">Questions</a> -
<a href="#AN">Analysis</a> -
<a href="#NO">Notes</a> -
<a href="#JS">JMS</a>
<p>
<hr>
""")
else:
output.write("""
<pre>
</pre>
""")
output.write(input.read())
output.write('<pre>\n\n</pre>\n' + otros.pagefooter(curep) + """
<h5>
Last update:
""" + mtime_str + """
</h5>
</body>
</html>
""")
input.close()
output.close()
print epnum

1
comic/gen.py Symbolic link
View File

@ -0,0 +1 @@
../guide/gen.py

29
comic/perdir.py Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/python
#
# Per-directory values for /lurk/comic
#
def get_type():
return 'comic'
def get_episode_names_file():
return '../internal/comicnames'
def get_page_name_prefix():
return 'Comic'
def get_table_of_contents():
return """
<p>
<b>Contents:</b>
<a href="#OV">Overview</a> -
<a href="#BP">Backplot</a> -
<a href="#UQ">Questions</a> -
<a href="#AN">Analysis</a> -
<a href="#NO">Notes</a> -
<a href="#JS">JMS</a>
"""
def get_do_jpeg():
return 0

View File

@ -1,69 +0,0 @@
#!/usr/bin/python
import sys,string,time,os
sys.path.append('../internal')
import otros
months = [ '', 'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December']
for epnum in sys.argv[1:]:
curep = string.atoi(epnum[:3])
pix = open('../internal/epnames', 'r')
for i in range(0, curep + 1):
epname = pix.readline()[:-1]
pix.close()
if epname == '':
epname = 'XXX'
if len(epnum) > 3:
cureplong = epnum
else:
cureplong = '%03d' % curep
input = open(cureplong, 'r')
output = open(cureplong + '.html', 'w')
mtime = time.localtime(os.stat(cureplong)[8]);
mtime_str = '%s %d, %d' % (months[mtime[1]], mtime[2], mtime[0])
output.write("""<html>
<head>
<title>Credits: """ + '"' + epname + '"' + """</title>
<link rev=made href="mailto:koreth@midwinter.com">
<link rel=parent href="../guide/""" + cureplong + """.html">
</head>
<body>
""" + otros.pageheader(curep, 'credits', 1) + '</p>\n\n')
try:
special = open(cureplong + '-head', 'r')
output.write(special.read())
special.close()
except:
pass
output.write('<pre>\n\n')
output.write(input.read())
output.write("""
</pre>
""" + otros.pagefooter(curep) + """
<h5>
Last update:
""" + mtime_str + """
</h5>
</body>
</html>
""")
input.close()
output.close()
print epnum

1
credits/gen.py Symbolic link
View File

@ -0,0 +1 @@
../guide/gen.py

View File

@ -3,17 +3,19 @@
import sys,string,time,os import sys,string,time,os
sys.path.append('../internal') sys.path.append('../internal')
import otros import otros
sys.path.insert(0, '.')
import perdir
months = [ '', 'January', 'February', 'March', 'April', 'May', 'June', 'July', months = [ '', 'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December'] 'August', 'September', 'October', 'November', 'December']
do_jpeg = 1 do_jpeg = perdir.get_do_jpeg()
args = sys.argv args = sys.argv
for epnum in args[1:]: for epnum in args[1:]:
curep = string.atoi(epnum[:3]) curep = string.atoi(epnum[:3])
pix = open('../internal/epnames', 'r') pix = open(perdir.get_episode_names_file(), 'r')
for i in range(0, curep + 1): for i in range(0, curep + 1):
epname = pix.readline()[:-1] epname = pix.readline()[:-1]
pix.close() pix.close()
@ -23,7 +25,7 @@ for epnum in args[1:]:
cureplong = '%03d' % curep cureplong = '%03d' % curep
if len(epnum) == 3: if len(epnum) == 3:
which = 'guide' which = perdir.get_type()
else: else:
which = 'extra' which = 'extra'
@ -42,44 +44,37 @@ for epnum in args[1:]:
output = open(epnum + '.html', 'w') output = open(epnum + '.html', 'w')
output.write("""<html> page_name = perdir.get_page_name_prefix() + ': "' + epname + '"'
<head>
<title>Guide page: """ + '"' + epname + '"')
if which == 'extra': if which == 'extra':
output.write(' (scene in detail)') page_name = page_name + ' (scene in detail)'
output.write("""</title>
<link rev=made href="mailto:koreth@midwinter.com">
<link rel=parent href="../eplist.html">
</head>
<body> output.write(otros.head(page_name))
""" + otros.pageheader(curep, which, do_jpeg)) output.write("<body>\n")
if which == 'guide': try:
output.write(""" special = open(epnum + '-head', 'r')
output.write(special.read())
special.close()
except:
pass
<p> output.write(otros.pageheader(curep, which, do_jpeg))
<b>Contents:</b>
<a href="#OV">Overview</a> -
<a href="#BP">Backplot</a> -
<a href="#UQ">Questions</a> -
<a href="#AN">Analysis</a> -
<a href="#NO">Notes</a> -
<a href="#JS">JMS</a>
<p>
<hr>
""") if which == 'extra':
else:
output.write(""" output.write("""
<pre> <pre>
</pre> </pre>
""") """)
elif perdir.get_type() == 'credits':
output.write("\n<pre>\n")
else:
toc = perdir.get_table_of_contents()
if len(toc) > 0:
output.write(toc)
output.write("\n<p>\n<hr>\n")
wholefile = input.read() wholefile = input.read()
input.close() input.close()
@ -126,6 +121,10 @@ for epnum in args[1:]:
if do_jpeg: if do_jpeg:
final = otros.mungeimages(final, do_jpeg) final = otros.mungeimages(final, do_jpeg)
output.write(final) output.write(final)
if perdir.get_type() == 'credits':
output.write("</pre>\n")
output.write('<pre>\n\n</pre>\n' + otros.pagefooter(curep) + """ output.write('<pre>\n\n</pre>\n' + otros.pagefooter(curep) + """
<h5> <h5>

View File

@ -1,2 +1,2 @@
#!/bin/csh #!/bin/csh
gen.py `/bin/ls [012]* | fgrep -v .html` gen.py `/bin/ls [012345]* | fgrep -v .html`

28
guide/perdir.py Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/python
#
# Per-directory values for /lurk/guide
#
def get_type():
return 'guide'
def get_episode_names_file():
return '../internal/epnames'
def get_page_name_prefix():
return 'Guide Page'
def get_table_of_contents():
return """
<p>
<b>Contents:</b>
<a href="#OV">Overview</a> -
<a href="#BP">Backplot</a> -
<a href="#UQ">Questions</a> -
<a href="#AN">Analysis</a> -
<a href="#NO">Notes</a> -
<a href="#JS">JMS</a>
"""
def get_do_jpeg():
return 1

View File

@ -288,8 +288,11 @@ align=bottom
# Given an image path, generate the full path to the corresponding file. # Given an image path, generate the full path to the corresponding file.
# #
def normalize_path(path): def normalize_path(path):
if path[0:4] == '/lurk/': if path[0:6] == '/lurk/':
path = '/home/koreth/lurk' + path[5:] curdir = os.getcwd()
if (not os.path.exists(curdir + '/lurker.html')):
curdir = curdir + '/..'
path = os.path.abspath(curdir) + path[5:]
elif path[0] == '/': elif path[0] == '/':
path = '/home/midwinter/docroot' + path path = '/home/midwinter/docroot' + path
return path return path
@ -326,3 +329,15 @@ def mungeimages(text, do_jpeg):
return result return result
#
# Returns the <head> section for a page, including image maps.
#
def head(title):
result = "<html><head>\n<title>" + title + "</title>\n"
mapsfile = open('../maps/maps.html', 'r')
result = result + mapsfile.read()
mapsfile.close()
result = result + "</head>\n"
return result

View File

@ -1,70 +0,0 @@
#!/usr/bin/python
import sys,string,time,os
sys.path.append('../internal')
import otros
months = [ '', 'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December']
for epnum in sys.argv[1:]:
curep = string.atoi(epnum[:3])
pix = open('../internal/novelnames', 'r')
for i in range(0, curep + 1):
epname = pix.readline()[:-1]
pix.close()
if epname == '':
epname = 'XXX'
cureplong = '%03d' % curep
which = 'novels'
input = open(epnum, 'r')
mtime = time.localtime(os.stat(epnum)[8]);
mtime_str = '%s %d, %d' % (months[mtime[1]], mtime[2], mtime[0])
output = open(epnum + '.html', 'w')
page_name = 'Novel: "' + epname + '"'
if which == 'extra':
page_name = page_name + ' (scene in detail)'
output.write(otros.head(page_name))
output.write("<body>\n")
output.write(otros.pageheader(curep, which))
output.write("""
<p>
<b>Contents:</b>
<a href="#BC">Back Cover</a> -
<a href="#SY">Synopsis</a> -
<a href="#UQ">Questions</a> -
<a href="#AN">Analysis</a> -
<a href="#NO">Notes</a> -
<a href="#JS">Author</a>
<p>
<hr>
""")
output.write(input.read())
output.write('<pre>\n\n</pre>\n' + otros.pagefooter(curep) + """
<h5>
Last update:
""" + mtime_str + """
</h5>
</body>
</html>
""")
input.close()
output.close()
print epnum

1
novels/gen.py Symbolic link
View File

@ -0,0 +1 @@
../guide/gen.py

29
novels/perdir.py Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/python
#
# Per-directory values for /lurk/novels
#
def get_type():
return 'novels'
def get_episode_names_file():
return '../internal/novelnames'
def get_page_name_prefix():
return 'Novel'
def get_table_of_contents():
return """
<p>
<b>Contents:</b>
<a href="#BC">Back Cover</a> -
<a href="#SY">Synopsis</a> -
<a href="#UQ">Questions</a> -
<a href="#AN">Analysis</a> -
<a href="#NO">Notes</a> -
<a href="#JS">Author</a>
"""
def get_do_jpeg():
return 0

View File

@ -1,64 +0,0 @@
#!/usr/bin/python
import sys,string,time,os
sys.path.append('../internal')
import otros
months = [ '', 'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December']
for epnum in sys.argv[1:]:
curep = string.atoi(epnum[:3])
pix = open('../internal/epnames', 'r')
for i in range(0, curep + 1):
epname = pix.readline()[:-1]
pix.close()
if epname == '':
epname = 'XXX'
cureplong = '%03d' % curep
which = 'synopsis'
input = open(epnum, 'r')
mtime = time.localtime(os.stat(epnum)[8]);
mtime_str = '%s %d, %d' % (months[mtime[1]], mtime[2], mtime[0])
output = open(epnum + '.html', 'w')
output.write("""<html>
<head>
<title>Synopsis: """ + '"' + epname + '"' + """</title>
<link rev=made href="mailto:koreth@midwinter.com">
<link rel=parent href="../eplist.html">
</head>
<body>
""" + otros.pageheader(curep, which, 1) + """
<pre>
</pre>
""")
output.write(otros.mungeimages(input.read(), 1))
output.write('\n<pre>\n\n</pre>' +
otros.pagefooter(curep, 'synopsis') + """
<h5>
<a href="/lurk/lastmod.html">Last update:</a>
""" + mtime_str + """
</h5>
</body>
</html>
""")
input.close()
output.close()
print epnum

1
synops/gen.py Symbolic link
View File

@ -0,0 +1 @@
../guide/gen.py

18
synops/perdir.py Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/python
#
# Per-directory values for /lurk/synops
#
def get_type():
return 'synopsis'
def get_episode_names_file():
return '../internal/epnames'
def get_page_name_prefix():
return 'Synopsis'
def get_table_of_contents():
return ''
def get_do_jpeg():
return 1