Browse Source

Normalize gen.py scripts across directories

Steven Grimm 5 years ago
parent
commit
0ead233940
17 changed files with 160 additions and 336 deletions
  1. 1
    1
      .gitignore
  2. 5
    15
      background/gen.py
  3. 0
    85
      comic/gen.py
  4. 1
    0
      comic/gen.py
  5. 29
    0
      comic/perdir.py
  6. 0
    69
      credits/gen.py
  7. 1
    0
      credits/gen.py
  8. 28
    29
      guide/gen.py
  9. 1
    1
      guide/genall.csh
  10. 28
    0
      guide/perdir.py
  11. 17
    2
      internal/otros.py
  12. 0
    70
      novels/gen.py
  13. 1
    0
      novels/gen.py
  14. 29
    0
      novels/perdir.py
  15. 0
    64
      synops/gen.py
  16. 1
    0
      synops/gen.py
  17. 18
    0
      synops/perdir.py

+ 1
- 1
.gitignore View File

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

+ 5
- 15
background/gen.py View File

@@ -26,21 +26,11 @@ for epnum in sys.argv[1:]:
26 26
 	input = open('story.html', 'r')
27 27
 	output = open(cureplong + '.shtml', 'w')
28 28
 
29
-	output.write("""<html>
30
-<head>
31
-<title>Background: """ + '"' + epname + '"' + """</title>
32
-<link rev=made href="mailto:koreth@midwinter.com">
33
-<link rel=parent href="../guide/""" + cureplong + """.html">
34
-</head>
35
-
36
-<body>
37
-
38
-""" + otros.pageheader(curepno, 'background', 1) + """
39
-
40
-<pre>
41
-
42
-</pre>
43
-""")
29
+	page_name = 'Background: "' + epname + '"'
30
+	output.write(otros.head(page_name))
31
+	output.write("<body>\n")
32
+	output.write(otros.pageheader(curepno, 'background', 1))
33
+	output.write("\n<pre>\n\n</pre>\n")
44 34
 
45 35
 	printing = 1
46 36
 

+ 0
- 85
comic/gen.py View File

@@ -1,85 +0,0 @@
1
-#!/usr/bin/python
2
-
3
-import sys,string,time,os
4
-sys.path.append('../internal')
5
-import otros
6
-
7
-months = [ '', 'January', 'February', 'March', 'April', 'May', 'June', 'July',
8
-		'August', 'September', 'October', 'November', 'December']
9
-
10
-for epnum in sys.argv[1:]:
11
-	curep = string.atoi(epnum[:3])
12
-
13
-	pix = open('../internal/comicnames', 'r')
14
-	for i in range(0, curep + 1):
15
-		epname = pix.readline()[:-1]
16
-	pix.close()
17
-	if epname == '':
18
-		epname = 'XXX'
19
-
20
-	cureplong = '%03d' % curep
21
-
22
-	which = 'comic'
23
-
24
-	input = open(epnum, 'r')
25
-	mtime = time.localtime(os.stat(epnum)[8]);
26
-	mtime_str = '%s %d, %d' % (months[mtime[1]], mtime[2], mtime[0])
27
-
28
-	output = open(epnum + '.html', 'w')
29
-
30
-	output.write("""<html>
31
-<head>
32
-<title>Comic: """ + '"' + epname + '"')
33
-	if which == 'extra':
34
-		output.write(' (scene in detail)')
35
-	
36
-	output.write("""</title>
37
-<link rev=made href="mailto:koreth@midwinter.com">
38
-<link rel=parent href="../eplist.html">
39
-</head>
40
-
41
-<body>
42
-
43
-""" + otros.pageheader(curep, which))
44
-
45
-	if which == 'guide':
46
-		output.write("""
47
-
48
-<p>
49
-<b>Contents:</b>
50
-<a href="#OV">Overview</a> -
51
-<a href="#BP">Backplot</a> -
52
-<a href="#UQ">Questions</a> -
53
-<a href="#AN">Analysis</a> -
54
-<a href="#NO">Notes</a> -
55
-<a href="#JS">JMS</a>
56
- 
57
-<p>
58
-<hr>
59
-
60
-""")
61
-	else:
62
-		output.write("""
63
-<pre>
64
-
65
-</pre>
66
-
67
-""")
68
-
69
-	output.write(input.read())
70
-
71
-	output.write('<pre>\n\n</pre>\n' + otros.pagefooter(curep) + """
72
-
73
-<h5>
74
-Last update:
75
-""" + mtime_str + """
76
-
77
-</h5>
78
-</body>
79
-</html>
80
-""")
81
-
82
-	input.close()
83
-	output.close()
84
-
85
-	print epnum

+ 1
- 0
comic/gen.py View File

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

+ 29
- 0
comic/perdir.py View File

@@ -0,0 +1,29 @@
1
+#!/usr/bin/python
2
+#
3
+# Per-directory values for /lurk/comic
4
+#
5
+def get_type():
6
+	return 'comic'
7
+
8
+def get_episode_names_file():
9
+	return '../internal/comicnames'
10
+
11
+def get_page_name_prefix():
12
+	return 'Comic'
13
+
14
+def get_table_of_contents():
15
+	return """
16
+
17
+<p>
18
+<b>Contents:</b>
19
+<a href="#OV">Overview</a> -
20
+<a href="#BP">Backplot</a> -
21
+<a href="#UQ">Questions</a> -
22
+<a href="#AN">Analysis</a> -
23
+<a href="#NO">Notes</a> -
24
+<a href="#JS">JMS</a>
25
+
26
+"""
27
+
28
+def get_do_jpeg():
29
+	return 0

+ 0
- 69
credits/gen.py View File

@@ -1,69 +0,0 @@
1
-#!/usr/bin/python
2
-
3
-import sys,string,time,os
4
-sys.path.append('../internal')
5
-import otros
6
-
7
-months = [ '', 'January', 'February', 'March', 'April', 'May', 'June', 'July',
8
-		'August', 'September', 'October', 'November', 'December']
9
-
10
-for epnum in sys.argv[1:]:
11
-	curep = string.atoi(epnum[:3])
12
-
13
-	pix = open('../internal/epnames', 'r')
14
-	for i in range(0, curep + 1):
15
-		epname = pix.readline()[:-1]
16
-	pix.close()
17
-	if epname == '':
18
-		epname = 'XXX'
19
-
20
-	if len(epnum) > 3:
21
-		cureplong = epnum
22
-	else:
23
-		cureplong = '%03d' % curep
24
-
25
-	input = open(cureplong, 'r')
26
-	output = open(cureplong + '.html', 'w')
27
-
28
-	mtime = time.localtime(os.stat(cureplong)[8]);
29
-	mtime_str = '%s %d, %d' % (months[mtime[1]], mtime[2], mtime[0])
30
-
31
-	output.write("""<html>
32
-<head>
33
-<title>Credits: """ + '"' + epname + '"' + """</title>
34
-<link rev=made href="mailto:koreth@midwinter.com">
35
-<link rel=parent href="../guide/""" + cureplong + """.html">
36
-</head>
37
-
38
-<body>
39
-
40
-""" + otros.pageheader(curep, 'credits', 1) + '</p>\n\n')
41
-
42
-	try:
43
-		special = open(cureplong + '-head', 'r')
44
-		output.write(special.read())
45
-		special.close()
46
-	except:
47
-		pass
48
-
49
-	output.write('<pre>\n\n')
50
-	output.write(input.read())
51
-
52
-	output.write("""
53
-
54
-</pre>
55
-""" + otros.pagefooter(curep) + """
56
-
57
-<h5>
58
-Last update:
59
-""" + mtime_str + """
60
-
61
-</h5>
62
-</body>
63
-</html>
64
-""")
65
-
66
-	input.close()
67
-	output.close()
68
-
69
-	print epnum

+ 1
- 0
credits/gen.py View File

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

+ 28
- 29
guide/gen.py View File

@@ -3,17 +3,19 @@
3 3
 import sys,string,time,os
4 4
 sys.path.append('../internal')
5 5
 import otros
6
+sys.path.insert(0, '.')
7
+import perdir
6 8
 
7 9
 months = [ '', 'January', 'February', 'March', 'April', 'May', 'June', 'July',
8 10
 		'August', 'September', 'October', 'November', 'December']
9 11
 
10
-do_jpeg = 1
12
+do_jpeg = perdir.get_do_jpeg()
11 13
 args = sys.argv
12 14
 
13 15
 for epnum in args[1:]:
14 16
 	curep = string.atoi(epnum[:3])
15 17
 
16
-	pix = open('../internal/epnames', 'r')
18
+	pix = open(perdir.get_episode_names_file(), 'r')
17 19
 	for i in range(0, curep + 1):
18 20
 		epname = pix.readline()[:-1]
19 21
 	pix.close()
@@ -23,7 +25,7 @@ for epnum in args[1:]:
23 25
 	cureplong = '%03d' % curep
24 26
 
25 27
 	if len(epnum) == 3:
26
-		which = 'guide'
28
+		which = perdir.get_type()
27 29
 	else:
28 30
 		which = 'extra'
29 31
 
@@ -42,44 +44,37 @@ for epnum in args[1:]:
42 44
 
43 45
 	output = open(epnum + '.html', 'w')
44 46
 
45
-	output.write("""<html>
46
-<head>
47
-<title>Guide page: """ + '"' + epname + '"')
47
+	page_name = perdir.get_page_name_prefix() + ': "' + epname + '"'
48 48
 	if which == 'extra':
49
-		output.write(' (scene in detail)')
50
-	
51
-	output.write("""</title>
52
-<link rev=made href="mailto:koreth@midwinter.com">
53
-<link rel=parent href="../eplist.html">
54
-</head>
49
+		page_name = page_name + ' (scene in detail)'
55 50
 
56
-<body>
51
+	output.write(otros.head(page_name))
57 52
 
58
-""" + otros.pageheader(curep, which, do_jpeg))
53
+	output.write("<body>\n")
59 54
 
60
-	if which == 'guide':
61
-		output.write("""
55
+	try:
56
+		special = open(epnum + '-head', 'r')
57
+		output.write(special.read())
58
+		special.close()
59
+	except:
60
+		pass
62 61
 
63
-<p>
64
-<b>Contents:</b>
65
-<a href="#OV">Overview</a> -
66
-<a href="#BP">Backplot</a> -
67
-<a href="#UQ">Questions</a> -
68
-<a href="#AN">Analysis</a> -
69
-<a href="#NO">Notes</a> -
70
-<a href="#JS">JMS</a>
71
- 
72
-<p>
73
-<hr>
62
+	output.write(otros.pageheader(curep, which, do_jpeg))
74 63
 
75
-""")
76
-	else:
64
+	if which == 'extra':
77 65
 		output.write("""
78 66
 <pre>
79 67
 
80 68
 </pre>
81 69
 
82 70
 """)
71
+	elif perdir.get_type() == 'credits':
72
+		output.write("\n<pre>\n")
73
+	else:
74
+		toc = perdir.get_table_of_contents()
75
+		if len(toc) > 0:
76
+			output.write(toc)
77
+			output.write("\n<p>\n<hr>\n")
83 78
 
84 79
 	wholefile = input.read()
85 80
 	input.close()
@@ -126,6 +121,10 @@ for epnum in args[1:]:
126 121
 	if do_jpeg:
127 122
 		final = otros.mungeimages(final, do_jpeg)
128 123
 	output.write(final)
124
+
125
+	if perdir.get_type() == 'credits':
126
+		output.write("</pre>\n")
127
+
129 128
 	output.write('<pre>\n\n</pre>\n' + otros.pagefooter(curep) + """
130 129
 
131 130
 <h5>

+ 1
- 1
guide/genall.csh View File

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

+ 28
- 0
guide/perdir.py View File

@@ -0,0 +1,28 @@
1
+#!/usr/bin/python
2
+#
3
+# Per-directory values for /lurk/guide
4
+#
5
+def get_type():
6
+	return 'guide'
7
+
8
+def get_episode_names_file():
9
+	return '../internal/epnames'
10
+
11
+def get_page_name_prefix():
12
+	return 'Guide Page'
13
+
14
+def get_table_of_contents():
15
+	return """
16
+
17
+<p>
18
+<b>Contents:</b>
19
+<a href="#OV">Overview</a> -
20
+<a href="#BP">Backplot</a> -
21
+<a href="#UQ">Questions</a> -
22
+<a href="#AN">Analysis</a> -
23
+<a href="#NO">Notes</a> -
24
+<a href="#JS">JMS</a>
25
+"""
26
+
27
+def get_do_jpeg():
28
+	return 1

+ 17
- 2
internal/otros.py View File

@@ -288,8 +288,11 @@ align=bottom
288 288
 # Given an image path, generate the full path to the corresponding file.
289 289
 #
290 290
 def normalize_path(path):
291
-	if path[0:4] == '/lurk/':
292
-		path = '/home/koreth/lurk' + path[5:]
291
+	if path[0:6] == '/lurk/':
292
+		curdir = os.getcwd()
293
+		if (not os.path.exists(curdir + '/lurker.html')):
294
+			curdir = curdir + '/..'
295
+		path = os.path.abspath(curdir) + path[5:]
293 296
 	elif path[0] == '/':
294 297
 		path = '/home/midwinter/docroot' + path
295 298
 	return path
@@ -326,3 +329,15 @@ def mungeimages(text, do_jpeg):
326 329
 	
327 330
 	return result
328 331
 
332
+
333
+#
334
+# Returns the <head> section for a page, including image maps.
335
+#
336
+def head(title):
337
+	result = "<html><head>\n<title>" + title + "</title>\n"
338
+	mapsfile = open('../maps/maps.html', 'r')
339
+	result = result + mapsfile.read()
340
+	mapsfile.close()
341
+	result = result + "</head>\n"
342
+
343
+	return result

+ 0
- 70
novels/gen.py View File

@@ -1,70 +0,0 @@
1
-#!/usr/bin/python
2
-
3
-import sys,string,time,os
4
-sys.path.append('../internal')
5
-import otros
6
-
7
-months = [ '', 'January', 'February', 'March', 'April', 'May', 'June', 'July',
8
-		'August', 'September', 'October', 'November', 'December']
9
-
10
-for epnum in sys.argv[1:]:
11
-	curep = string.atoi(epnum[:3])
12
-
13
-	pix = open('../internal/novelnames', 'r')
14
-	for i in range(0, curep + 1):
15
-		epname = pix.readline()[:-1]
16
-	pix.close()
17
-	if epname == '':
18
-		epname = 'XXX'
19
-
20
-	cureplong = '%03d' % curep
21
-
22
-	which = 'novels'
23
-
24
-	input = open(epnum, 'r')
25
-	mtime = time.localtime(os.stat(epnum)[8]);
26
-	mtime_str = '%s %d, %d' % (months[mtime[1]], mtime[2], mtime[0])
27
-
28
-	output = open(epnum + '.html', 'w')
29
-
30
-	page_name = 'Novel: "' + epname + '"'
31
-	if which == 'extra':
32
-		page_name = page_name + ' (scene in detail)'
33
-	
34
-	output.write(otros.head(page_name))
35
-	output.write("<body>\n")
36
-	output.write(otros.pageheader(curep, which))
37
-
38
-	output.write("""
39
-
40
-<p>
41
-<b>Contents:</b>
42
-<a href="#BC">Back Cover</a> -
43
-<a href="#SY">Synopsis</a> -
44
-<a href="#UQ">Questions</a> -
45
-<a href="#AN">Analysis</a> -
46
-<a href="#NO">Notes</a> -
47
-<a href="#JS">Author</a>
48
- 
49
-<p>
50
-<hr>
51
-
52
-""")
53
-
54
-	output.write(input.read())
55
-
56
-	output.write('<pre>\n\n</pre>\n' + otros.pagefooter(curep) + """
57
-
58
-<h5>
59
-Last update:
60
-""" + mtime_str + """
61
-
62
-</h5>
63
-</body>
64
-</html>
65
-""")
66
-
67
-	input.close()
68
-	output.close()
69
-
70
-	print epnum

+ 1
- 0
novels/gen.py View File

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

+ 29
- 0
novels/perdir.py View File

@@ -0,0 +1,29 @@
1
+#!/usr/bin/python
2
+#
3
+# Per-directory values for /lurk/novels
4
+#
5
+def get_type():
6
+	return 'novels'
7
+
8
+def get_episode_names_file():
9
+	return '../internal/novelnames'
10
+
11
+def get_page_name_prefix():
12
+	return 'Novel'
13
+
14
+def get_table_of_contents():
15
+	return """
16
+
17
+<p>
18
+<b>Contents:</b>
19
+<a href="#BC">Back Cover</a> -
20
+<a href="#SY">Synopsis</a> -
21
+<a href="#UQ">Questions</a> -
22
+<a href="#AN">Analysis</a> -
23
+<a href="#NO">Notes</a> -
24
+<a href="#JS">Author</a>
25
+ 
26
+"""
27
+
28
+def get_do_jpeg():
29
+	return 0

+ 0
- 64
synops/gen.py View File

@@ -1,64 +0,0 @@
1
-#!/usr/bin/python
2
-
3
-import sys,string,time,os
4
-sys.path.append('../internal')
5
-import otros
6
-
7
-months = [ '', 'January', 'February', 'March', 'April', 'May', 'June', 'July',
8
-		'August', 'September', 'October', 'November', 'December']
9
-
10
-for epnum in sys.argv[1:]:
11
-	curep = string.atoi(epnum[:3])
12
-
13
-	pix = open('../internal/epnames', 'r')
14
-	for i in range(0, curep + 1):
15
-		epname = pix.readline()[:-1]
16
-	pix.close()
17
-	if epname == '':
18
-		epname = 'XXX'
19
-
20
-	cureplong = '%03d' % curep
21
-
22
-	which = 'synopsis'
23
-
24
-	input = open(epnum, 'r')
25
-	mtime = time.localtime(os.stat(epnum)[8]);
26
-	mtime_str = '%s %d, %d' % (months[mtime[1]], mtime[2], mtime[0])
27
-
28
-	output = open(epnum + '.html', 'w')
29
-
30
-	output.write("""<html>
31
-<head>
32
-<title>Synopsis: """ + '"' + epname + '"' + """</title>
33
-<link rev=made href="mailto:koreth@midwinter.com">
34
-<link rel=parent href="../eplist.html">
35
-</head>
36
-
37
-<body>
38
-
39
-""" + otros.pageheader(curep, which, 1) + """
40
-
41
-<pre>
42
-
43
-</pre>
44
-
45
-""")
46
-
47
-	output.write(otros.mungeimages(input.read(), 1))
48
-
49
-	output.write('\n<pre>\n\n</pre>' +
50
-			otros.pagefooter(curep, 'synopsis') + """
51
-
52
-<h5>
53
-<a href="/lurk/lastmod.html">Last update:</a>
54
-""" + mtime_str + """
55
-
56
-</h5>
57
-</body>
58
-</html>
59
-""")
60
-
61
-	input.close()
62
-	output.close()
63
-
64
-	print epnum

+ 1
- 0
synops/gen.py View File

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

+ 18
- 0
synops/perdir.py View File

@@ -0,0 +1,18 @@
1
+#!/usr/bin/python
2
+#
3
+# Per-directory values for /lurk/synops
4
+#
5
+def get_type():
6
+	return 'synopsis'
7
+
8
+def get_episode_names_file():
9
+	return '../internal/epnames'
10
+
11
+def get_page_name_prefix():
12
+	return 'Synopsis'
13
+
14
+def get_table_of_contents():
15
+	return ''
16
+
17
+def get_do_jpeg():
18
+	return 1

Loading…
Cancel
Save