1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/factory/create_page Thu May 27 13:10:09 2010 +0200
1.3 @@ -0,0 +1,48 @@
1.4 +#!/usr/bin/python
1.5 +
1.6 +import datetime
1.7 +import sys
1.8 +from optparse import OptionParser
1.9 +
1.10 +content_dir = "v2010"
1.11 +content_files = ("index.html", "resume.html", "howiwork.html", "personalwork.html", "books.html", "links.html", "contact.html")
1.12 +
1.13 +def create_page(frame_filename, content_filename, output_filename):
1.14 + frame_file = open(frame_filename, "r")
1.15 + frame = frame_file.read()
1.16 + content_file = open(content_filename, "r")
1.17 + content = content_file.read()
1.18 + output_file = open(output_filename, "w")
1.19 + output = frame.replace("/insert{content}", content)
1.20 + output_file.write(output)
1.21 + output_file.close()
1.22 + content_file.close()
1.23 + frame_file.close()
1.24 +
1.25 +def main():
1.26 + parser = OptionParser()
1.27 + parser.add_option("-a", "--all", dest="create_all", action="store_true", help="create all pages", default=False)
1.28 + (options, args) = parser.parse_args()
1.29 +
1.30 + #log_file = open("compile.log", "a")
1.31 + frame_filename = args[0]
1.32 +
1.33 + if options.create_all:
1.34 + for f in content_files:
1.35 + content_filename = content_dir + "/" + f
1.36 + output_file = "../" + f
1.37 + create_page(frame_filename, content_filename, output_file)
1.38 + else:
1.39 + create_page(frame_filename, args[1], args[2])
1.40 +
1.41 + #log = "".join(("Update of file ",
1.42 + # args[2],
1.43 + # " at ",
1.44 + # str(datetime.datetime.now()),
1.45 + # ".<br />"))
1.46 + #log_file.write(log)
1.47 + #log_file.close()
1.48 +
1.49 +if __name__ == "__main__":
1.50 + main()
1.51 +