summaryrefslogtreecommitdiff
path: root/scripts/template.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/template.py')
-rwxr-xr-xscripts/template.py71
1 files changed, 71 insertions, 0 deletions
diff --git a/scripts/template.py b/scripts/template.py
new file mode 100755
index 0000000..eaa1682
--- /dev/null
+++ b/scripts/template.py
@@ -0,0 +1,71 @@
+#!/usr/bin/python
+
+import string
+import time
+import datetime
+from string import Template
+
+def readfiles(prefix):
+
+ #set globals
+ global content
+ global keywords
+ global desc_de
+ global desc_en
+
+ #set content
+ f = open(prefix + ".content.html", "r")
+ content = f.read()
+ f.close
+
+ #set keywords
+ f = open(prefix + ".keywords", "r")
+ keywords = f.read()
+ f.close
+
+ #set german description
+ f = open(prefix + ".desc_de", "r")
+ desc_de = f.read()
+ f.close
+
+ #set english description
+ f = open(prefix + ".desc_en", "r")
+ desc_en = f.read()
+ f.close
+
+def substitute(target, prefix, htmltemplate, datenow, chattopic, keywords, content, desc_de, desc_en):
+
+ #create template-string
+ htmltext = Template(htmltemplate)
+ htmltext = htmltext.substitute(template_date = datenow, template_chattopic = chattopic, template_keywords = keywords, template_content = content, template_desc_de = desc_de, template_desc_en = desc_en)
+
+ #write it to the outpufile
+ outputfile = open(target + prefix + ".html", "w")
+ outputfile.write(htmltext)
+ outputfile.close()
+
+contentpath = "../template/"
+target = "../public/"
+
+#set template
+f = open(contentpath + "template.html", "r")
+htmltemplate = f.read()
+f.close
+print ("template read")
+
+#set chattopic
+f = open(contentpath + "chattopic", "r")
+chattopic = f.read()
+f.close
+print ("chattopic read")
+
+#set date
+datenow = time.strftime("%Y-%m-%dT%H:%M:%S +0100")
+print ("Set date: " + datenow)
+
+prefixes = ['index', 'neues', 'termine', 'raeume', 'lage', 'kontakt', 'verein', 'impressum', 'webcam']
+
+for prefix in prefixes:
+ readfiles(contentpath + prefix)
+ substitute(target, prefix, htmltemplate, datenow, chattopic, keywords, content, desc_de, desc_en)
+ print(prefix + ".html written")