diff --git a/tmpl2html/README b/tmpl2html/README new file mode 100644 index 0000000..18db344 --- /dev/null +++ b/tmpl2html/README @@ -0,0 +1,45 @@ +!Warnung: dieses Pythonscript ist ein ein riesen Haufen Stinkescheisse! +Ich hab mir damit nur laestige Schreibarbeit fuer die Erstellung einer +Webseite gespart. Ich wollte schon immer mal ein eigenes +Templatesystem schreiben 8] + + +Die Funktionsweise ist recht einfach und schnell eingaenglich anhand +eines Beispiels: (Das Beispiel laeuft nur, wenn es keine Verzeichnisse ausser den +erwaehnten gibt. Verzeichnisse wie ".svn" wirken z.B. aeusserst stoerend.) + +* in "gerippe.tmpl" kommen Platzhalter z.B. "" + * ins Verz. "placeholder" kommen Dateien mit gleichem Namen "foo", wie der Platzhalter + * der Inhalt der Datei "foo" wird spaeter den gleichnamigen Platzhalter ersetzen + * diese Ersetzungen finden fuer alle html Dateien statt, eignen sich also nur fuer Inhalte, die in jeder .html gleich sind + +* ins Verz. "content" kommt jeweils ein Unterverzeichnis z.B. "bar" + * daraus wird spaeter "bar.html" + * Grundlage fuer "bar.html" bilden gerippe.tmpl + placeholder + * im Verz. "bar" werden Dateien abgelegt, die nach Nummern benannt werden + * diese Dateien bilden spaeter einen Eintrag, im Content der jeweiligen html Datei + * die Nummerierung legt die Reihenfolge innerhalb der html Datei fest (1 ist der erste Eintrag) + + +* +|_ gerippe.tmpl +| +|_ placeholder + +| |_ header +| |_ footer +| |_ immergleicherkrempel +| +|_ content + + |_ index + + | |_ 1 + | |_ 2 + | + |_ kontakt + + | |_ 1 + | + |_ misc + + |_ 1 + |_ 2 + |_ 3 + + diff --git a/tmpl2html/example/content/index/1 b/tmpl2html/example/content/index/1 new file mode 100644 index 0000000..ae605e6 --- /dev/null +++ b/tmpl2html/example/content/index/1 @@ -0,0 +1,6 @@ +
+

Der erste Starteintrag

+

+ Dies ist kein Blog! +

+
diff --git a/tmpl2html/example/content/index/2 b/tmpl2html/example/content/index/2 new file mode 100644 index 0000000..bb85ecc --- /dev/null +++ b/tmpl2html/example/content/index/2 @@ -0,0 +1,6 @@ +
+

Nummer Zwo

+

+ ist aber aehnlich aufgebaut +

+
+

Kontakt

+

+ ruf mich an +

+ diff --git a/tmpl2html/example/content/kontakt/2 b/tmpl2html/example/content/kontakt/2 new file mode 100644 index 0000000..b3a9693 --- /dev/null +++ b/tmpl2html/example/content/kontakt/2 @@ -0,0 +1,6 @@ +
+

blafasel

+

+ Haelt mich denn niemand vom Schreiben ab? +

+
diff --git a/tmpl2html/example/gerippe.tmpl b/tmpl2html/example/gerippe.tmpl new file mode 100644 index 0000000..6423c03 --- /dev/null +++ b/tmpl2html/example/gerippe.tmpl @@ -0,0 +1,7 @@ + + +
+ +
+ + diff --git a/tmpl2html/example/placeholder/footer b/tmpl2html/example/placeholder/footer new file mode 100644 index 0000000..0a66a4d --- /dev/null +++ b/tmpl2html/example/placeholder/footer @@ -0,0 +1,9 @@ + + + + + + + diff --git a/tmpl2html/example/placeholder/header b/tmpl2html/example/placeholder/header new file mode 100644 index 0000000..7664548 --- /dev/null +++ b/tmpl2html/example/placeholder/header @@ -0,0 +1,11 @@ + + + diff --git a/tmpl2html/example/placeholder/preheader b/tmpl2html/example/placeholder/preheader new file mode 100644 index 0000000..a2004ea --- /dev/null +++ b/tmpl2html/example/placeholder/preheader @@ -0,0 +1,12 @@ + + + +Schachtspringer + + + + +
+
+
+ diff --git a/tmpl2html/example/placeholder/rightbar b/tmpl2html/example/placeholder/rightbar new file mode 100644 index 0000000..b609901 --- /dev/null +++ b/tmpl2html/example/placeholder/rightbar @@ -0,0 +1,5 @@ + +
+ +
+ diff --git a/tmpl2html/example/style/aph.jpg b/tmpl2html/example/style/aph.jpg new file mode 100644 index 0000000..220c6cc Binary files /dev/null and b/tmpl2html/example/style/aph.jpg differ diff --git a/tmpl2html/example/style/aph2.jpg b/tmpl2html/example/style/aph2.jpg new file mode 100644 index 0000000..09642b6 Binary files /dev/null and b/tmpl2html/example/style/aph2.jpg differ diff --git a/tmpl2html/example/style/aph3.jpg b/tmpl2html/example/style/aph3.jpg new file mode 100644 index 0000000..930b62a Binary files /dev/null and b/tmpl2html/example/style/aph3.jpg differ diff --git a/tmpl2html/example/style/body_bg.png b/tmpl2html/example/style/body_bg.png new file mode 100644 index 0000000..6bc1147 Binary files /dev/null and b/tmpl2html/example/style/body_bg.png differ diff --git a/tmpl2html/example/style/body_bg2.png b/tmpl2html/example/style/body_bg2.png new file mode 100644 index 0000000..1a3c7f5 Binary files /dev/null and b/tmpl2html/example/style/body_bg2.png differ diff --git a/tmpl2html/example/style/body_bg3.png b/tmpl2html/example/style/body_bg3.png new file mode 100644 index 0000000..55b699f Binary files /dev/null and b/tmpl2html/example/style/body_bg3.png differ diff --git a/tmpl2html/example/style/content_sep.png b/tmpl2html/example/style/content_sep.png new file mode 100644 index 0000000..a4b946c Binary files /dev/null and b/tmpl2html/example/style/content_sep.png differ diff --git a/tmpl2html/example/style/metro01.css b/tmpl2html/example/style/metro01.css new file mode 100644 index 0000000..2b37624 --- /dev/null +++ b/tmpl2html/example/style/metro01.css @@ -0,0 +1,140 @@ + +body{ + /*font: 70%/1.4em Verdana, Arial, Helvetica, sans-serif;*/ + font: 90% Verdana, Arial, Helvetica, sans-serif; + color: #666; + background: #fff url('body_bg3.png') repeat-x; +} + +a:link, a:visited, a:active { + font-weight:bold; + color: #555; + text-decoration:none; +} +a:hover, a:visited:hover { + font-weight:bold; + color:#2a56d6; + text-decoration:underline; +} + +#wrap{ + width:760px; + margin:0 auto; +} +#wrap_top{ + background: url('tab_top_bg.gif') top center no-repeat; + height:5px; +} + +#main{ + background:#fff; + margin:0; + overflow:hidden; +} + +#head{ + margin:0; + padding: 5px 5px 17px 5px; + background: url('title2.jpg') no-repeat; + background-position: 50% 100%; + height:145px; +} +#head .navbar{ + padding:0; + margin:0; +} +#head .navbar li{ + display:inline; +} +#head .navbar li a{ + padding: 0 15px ; + font-weight:bold; + font-size: 13px; + color:#666666; +} +#head .navbar li a:hover,#head .navbar li a:active { + text-decoration:underline; + color:#2a56d6; +} +#head h1.title{ + color:#fff; + font-size: 18px; + text-align:right; + text-transform:uppercase; + margin:0; + padding: 115px 10px 0 0; +} + +#content{ + margin: 5px 0 0 0; + width: 580px; + padding: 0 20px 20px 20px; + float:left; + /* + background: url('content_sep.png') repeat-y; + */ + background-position: 98.5% 0; +} +#content .entry{ +/* + border-bottom: #ddd 1px solid; + */ + text-align:justify; +} +#content .entry p{ + margin: 0.2em 0 1.2em 0; +} +#content .entry h2{ + border-bottom:2px solid #F0F0F0; + margin:25px 0 10px 0; + padding:0; + color:#557ef5; +} +#content .entry .links{ + margin:-8px 0 2px 0; + text-align:right; + letter-spacing:1px; + font-size: 8px; + color:#666; +} + +#rightbar{ + width: 130px; + padding: 10px 10px 5px 0; + float:left; + text-align:right; +} +#rightbar .box{ + margin: 5px 0 20px 0; +} +#rightbar .box h2{ + margin:0 0 2px 0; + padding: 0; + font-size: 11px; + letter-spacing:1px; + font-variant: small-caps; + border-bottom: #666 1px solid; + color:#557ef5; +} +#rightbar .box ul{ + margin:0; + padding:0; + list-style:none; +} +#rightbar .box li{ + font-size: 12px; + padding: 2px 0; +} +#rightbar #desc.box{ + background:#eee; + padding:10px; +} + +#footer{ + clear:both; + text-align:right; + background: #ddd; + padding: 10px; + font-size:8px; + color:#333; +} diff --git a/tmpl2html/example/style/tab_top_bg.gif b/tmpl2html/example/style/tab_top_bg.gif new file mode 100644 index 0000000..e7b32a1 Binary files /dev/null and b/tmpl2html/example/style/tab_top_bg.gif differ diff --git a/tmpl2html/example/style/title.jpg b/tmpl2html/example/style/title.jpg new file mode 100644 index 0000000..0b7c48d Binary files /dev/null and b/tmpl2html/example/style/title.jpg differ diff --git a/tmpl2html/example/style/title2.jpg b/tmpl2html/example/style/title2.jpg new file mode 100644 index 0000000..182ce9e Binary files /dev/null and b/tmpl2html/example/style/title2.jpg differ diff --git a/tmpl2html/templatewriter.py b/tmpl2html/templatewriter.py new file mode 100755 index 0000000..1f19325 --- /dev/null +++ b/tmpl2html/templatewriter.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python + +import string, os + +class TemplateWriter: + templatefile = "gerippe.tmpl" + tmpldir = "./placeholder" + contentdir = "./content" + tmplfileext = ".tmpl" + outfileext = ".html" + + def __init__(self): + pass + + def string_replace(self, infile, outfile): + template = open(infile).read() + open(outfile,"w").write(template) + text = {} + for tmpl in os.listdir(self.tmpldir): + tmplfile = str(self.tmpldir+"/"+tmpl) + if not os.path.isfile(tmplfile): + print " str.repl: cancelling "+tmplfile+" - not a file" + else: + template = open(outfile).read() + print " str.repl: using "+tmplfile + newcontent = open(tmplfile).read() + text[tmpl] = string.replace(template,"",newcontent) + open(outfile,"w").write(text[tmpl]) + return + + def build_sites(self): + '''use all files ending with .tmpl''' + for tmplfile in os.listdir("./"): + if tmplfile.rfind(self.tmplfileext) >= 1: + infile = tmplfile + (tmplfilename, tmplfileext)=os.path.splitext(tmplfile) + outfile = tmplfilename + self.outfileext + print "building: "+tmplfile+" -> "+outfile + self.string_replace(infile, outfile) + return + + def build_sites_from_gerippe(self): + print "Let's build some html files from: "+self.templatefile + for html in os.listdir(self.contentdir): + print " building: "+html+self.outfileext + entries = "" + for entry in os.listdir(self.contentdir+"/"+html): + print " adding entry: "+entry + entries += open(self.contentdir+"/"+html+"/"+entry).read() + + template = open(self.templatefile).read() + text = string.replace(template,"",entries) + infile = html+".tmp" + open(infile,"w").write(text) + outfile = html+self.outfileext + self.string_replace(infile, outfile) + return + + +if __name__ == "__main__": + foo = TemplateWriter() + foo.build_sites_from_gerippe() + #foo.string_replace("gerippe.tmpl", "gerippe.html) # for single tests + #foo.build_sites() # oldfashiond version