Create a nice-looking webpage.
This commit is contained in:
parent
4b67edaf53
commit
3be777df7a
|
@ -0,0 +1,74 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import glob, fileinput, os, re, shutil, sys, tempfile, time
|
||||
|
||||
year = 2018
|
||||
webfile_dir = "~/public_html/GunRun{}/".format(year)
|
||||
#print("NOTE: year is {}".format(year))
|
||||
|
||||
webfile_dir = os.path.expanduser(webfile_dir)
|
||||
for root, dirs, files in os.walk(webfile_dir):
|
||||
documents=[]
|
||||
for file in files:
|
||||
if re.search('.(pdf|png|jpg|jpeg)$', file):
|
||||
try:
|
||||
documents.append(os.path.join(file))
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
canonical=[]
|
||||
archive=[]
|
||||
for file in documents:
|
||||
name=os.path.basename(file)
|
||||
if re.search('^\d{8}', name):
|
||||
archive.append(name)
|
||||
else:
|
||||
canonical.append(name)
|
||||
|
||||
indexfile = open(os.path.join(webfile_dir, root, "index.html"), "w")
|
||||
|
||||
output = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Gun Run {} Maps</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Gun Run {} Maps</h1>
|
||||
""".format(year, year)
|
||||
|
||||
if canonical:
|
||||
output += """<p>Maps</p><ul>"""
|
||||
for link in sorted(canonical):
|
||||
overview=re.search("Marshal overview", link)
|
||||
if overview is not None:
|
||||
continue
|
||||
type=re.search("^Gun Run {} - (.*?)\.\S+$".format(year), link, re.IGNORECASE)
|
||||
if type is not None:
|
||||
name=type.group(1)
|
||||
else:
|
||||
name=link
|
||||
output += """<li><a href="{}">{}</a></li>""".format(link, name)
|
||||
output += """</ul>"""
|
||||
|
||||
archive=[i.split(' - ') for i in archive]
|
||||
archive.sort(key=lambda line: (line[2],line[0]))
|
||||
archive = [' - '.join(i) for i in archive]
|
||||
|
||||
if archive:
|
||||
output +="""<p>Source Maps</p><ul>"""
|
||||
for link in archive:
|
||||
output += """<li><a href="{}">{}</a></li>""".format(link, link)
|
||||
output += """</ul>"""
|
||||
|
||||
if dirs:
|
||||
output +="""<p>Clubs</p><ul>"""
|
||||
for link in dirs:
|
||||
output += """<li><a href="{}">{}</a></li>""".format(link, link)
|
||||
output += """</ul>"""
|
||||
|
||||
output += """</body></html>"""
|
||||
|
||||
indexfile.write(output)
|
||||
indexfile.close()
|
||||
|
||||
# vim: set expandtab shiftwidth=4 softtabstop=4 :
|
Loading…
Reference in New Issue