forked from endorphant/ttbp
basic file loading and printing
parent
77cafed642
commit
09edbb12d9
|
@ -9,3 +9,4 @@
|
||||||
<h1><a href="#">~endorphant</a>@<a href="../">tilde.town</a></h1>
|
<h1><a href="#">~endorphant</a>@<a href="../">tilde.town</a></h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="tlogs">
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
WWW = os.path.join("..","www")
|
||||||
|
CONFIG = os.path.join("config")
|
||||||
|
DATA = os.path.join("..", "data")
|
||||||
|
|
||||||
|
HEADER = open(os.path.join(CONFIG, "header.txt")).read()
|
||||||
|
FOOTER = open(os.path.join(CONFIG, "footer.txt")).read()
|
||||||
|
|
||||||
|
FILES = []
|
||||||
|
|
||||||
|
for file in os.listdir(DATA):
|
||||||
|
filename = os.path.join(DATA, file)
|
||||||
|
if os.path.isfile(filename) and os.path.splitext(filename)[1] == ".txt":
|
||||||
|
FILES.append(file)
|
||||||
|
|
||||||
|
print FILES
|
||||||
|
|
||||||
|
def write(outurl="default.html"):
|
||||||
|
outfile = open(os.path.join(WWW, outurl), "w")
|
||||||
|
|
||||||
|
for line in HEADER:
|
||||||
|
outfile.write(line)
|
||||||
|
|
||||||
|
#for line in write_placeholder():
|
||||||
|
# outfile.write(line)
|
||||||
|
|
||||||
|
for file in FILES:
|
||||||
|
for line in write_entry(file):
|
||||||
|
outfile.write(line)
|
||||||
|
|
||||||
|
for line in FOOTER:
|
||||||
|
outfile.write(line)
|
||||||
|
|
||||||
|
outfile.close()
|
||||||
|
|
||||||
|
def write_entry(file):
|
||||||
|
# dump given file into entry format, return as list of strings
|
||||||
|
|
||||||
|
entry = [
|
||||||
|
"\t\t<p><a name=\"$today\"></a><br /><br /></p>\n",
|
||||||
|
"\t\t<div class=\"entry\">\n",
|
||||||
|
"\t\t\t<h5><a href=\"$today\">DD</a> month YYYY</h5>\n",
|
||||||
|
"\t\t\t<P>"
|
||||||
|
]
|
||||||
|
|
||||||
|
raw = []
|
||||||
|
rawfile = open(os.path.join(DATA, file), "r")
|
||||||
|
|
||||||
|
for line in rawfile:
|
||||||
|
raw.append(line)
|
||||||
|
rawfile.close()
|
||||||
|
|
||||||
|
print raw
|
||||||
|
|
||||||
|
for line in raw:
|
||||||
|
entry.append(line+"\t\t\t")
|
||||||
|
if line == "\n":
|
||||||
|
entry.append("</p>\n\t\t\t<p>")
|
||||||
|
|
||||||
|
entry.append("</p>\n\t\t</div>\n")
|
||||||
|
|
||||||
|
return entry
|
||||||
|
|
||||||
|
def parse_date(file):
|
||||||
|
# assuming a filename of YYYYMMDD.txt, returns a list of
|
||||||
|
# ['YYYY', 'MM', 'DD']
|
||||||
|
|
||||||
|
return
|
46
bin/tlog.py
46
bin/tlog.py
|
@ -1,46 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
WWW = os.path.join("..","www")
|
|
||||||
CONFIG = os.path.join("config")
|
|
||||||
|
|
||||||
HEADER = []
|
|
||||||
FOOTER = []
|
|
||||||
|
|
||||||
infile = open(os.path.join(CONFIG, "header.txt"), 'r')
|
|
||||||
for line in infile:
|
|
||||||
HEADER.append(line.rstrip())
|
|
||||||
infile.close()
|
|
||||||
|
|
||||||
infile = open(os.path.join(CONFIG, "header.txt"), 'r')
|
|
||||||
for line in infile:
|
|
||||||
FOOTER.append(line.rstrip())
|
|
||||||
infile.close()
|
|
||||||
|
|
||||||
def write(outurl):
|
|
||||||
outfile = open(os.path.join(WWW, outurl), "w")
|
|
||||||
|
|
||||||
for line in HEADER:
|
|
||||||
outfile.write(line)
|
|
||||||
|
|
||||||
for line in write_placeholder():
|
|
||||||
outfile.write(line)
|
|
||||||
|
|
||||||
for line in FOOTER:
|
|
||||||
outfile.write(line)
|
|
||||||
|
|
||||||
outfile.close()
|
|
||||||
|
|
||||||
def write_placeholder():
|
|
||||||
|
|
||||||
entry = [
|
|
||||||
"<div id=\"tlogs\">",
|
|
||||||
"<p><a name=\"$today\"></a><br /><br /></p>",
|
|
||||||
"<div class=\"entry\">",
|
|
||||||
"<h5><a href=\"$today\">DD</a> month YYYY</h5>",
|
|
||||||
"<p>Feacby waeohaku aywoaeeo fepopo lyhili todepoae, taenga. Ypaogeni, ypnorani geahwaga diioanee aotrilco, aenoail. Oypo, weahipae kucogoyp fyeoim kyreeo? El godineng fengo aheoba himalidi trcoimao imypfe oaeha. In, trratr amlypoga cohitata macoipta? Ta, yeahta ahoyio, feanikre taneypel, bynekuim, enoyha. Adahilre, lylyno, aetaay aoimeo taquam toegeem? Rebyma maquag qunohi, fekyno fyniypdi. Eoaeby ikaeem goenkuao enacli, taliel agerhaza quema nonoimli. Ad amcory, aeypye raanaban lyaekuto coyega, adionige?</p>",
|
|
||||||
"</div>"
|
|
||||||
]
|
|
||||||
|
|
||||||
return entry
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
config file things:
|
||||||
|
-preferred text editor
|
||||||
|
-set www symlink
|
||||||
|
-set page title
|
||||||
|
|
||||||
|
flair:
|
||||||
|
-themes
|
||||||
|
-global post announcements
|
Loading…
Reference in New Issue