Enable narrowing log to current month
This commit is contained in:
parent
b1f90124c6
commit
e05eb19ae9
2 changed files with 32 additions and 10 deletions
|
@ -19,9 +19,9 @@ ownedgen.ownedall()
|
||||||
print(" done\nBuilding wanted page …",end="")
|
print(" done\nBuilding wanted page …",end="")
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
wantedgen.wantedgen()
|
wantedgen.wantedgen()
|
||||||
print(" done\nBuilding log page …",end="")
|
print(" done\nBuilding log pages …",end="")
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
loggen.loggen()
|
loggen.logall()
|
||||||
print(" done\nBuilding levels page …",end="")
|
print(" done\nBuilding levels page …",end="")
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
levelsgen.levelsgen()
|
levelsgen.levelsgen()
|
||||||
|
|
38
loggen.py
38
loggen.py
|
@ -16,16 +16,34 @@ def crayonlog(colour,event):
|
||||||
crayonstring = str(crayonno) + " " + crayonrend
|
crayonstring = str(crayonno) + " " + crayonrend
|
||||||
return crayonstring
|
return crayonstring
|
||||||
|
|
||||||
def loggen():
|
def loggen(month=False):
|
||||||
if not os.path.isdir("build/log"):
|
if month:
|
||||||
os.mkdir("build/log")
|
if not os.path.isdir("build/log/month"):
|
||||||
if os.path.exists("build/log/index.html"):
|
os.mkdir("build/log/month")
|
||||||
os.remove("build/log/index.html")
|
if os.path.exists("build/log/month/index.html"):
|
||||||
thefile = "build/log/index.html"
|
os.remove("build/log/month/index.html")
|
||||||
|
thefile = "build/log/month/index.html"
|
||||||
|
else:
|
||||||
|
if not os.path.isdir("build/log"):
|
||||||
|
os.mkdir("build/log")
|
||||||
|
if os.path.exists("build/log/index.html"):
|
||||||
|
os.remove("build/log/index.html")
|
||||||
|
thefile = "build/log/index.html"
|
||||||
skel.headerwrite(thefile,"log")
|
skel.headerwrite(thefile,"log")
|
||||||
content = open(thefile,"a")
|
content = open(thefile,"a")
|
||||||
content.write("<h1>log</h1>\n")
|
content.write("<h1>log</h1>\n")
|
||||||
thelog = log.log[::-1]
|
if month:
|
||||||
|
content.write("<p><a href=\"/log\">Show all</a></p>\n")
|
||||||
|
else:
|
||||||
|
content.write("<p><a href=\"/log/month\">Show current month only</a></p>\n")
|
||||||
|
if month:
|
||||||
|
thelog = []
|
||||||
|
for event in log.log:
|
||||||
|
if event["date"].month == datetime.datetime.now().month and event["date"].year == datetime.datetime.now().year:
|
||||||
|
thelog.append(event)
|
||||||
|
thelog = thelog[::-1]
|
||||||
|
else:
|
||||||
|
thelog = log.log[::-1]
|
||||||
for event in thelog:
|
for event in thelog:
|
||||||
if event["event"] != "portfolio":
|
if event["event"] != "portfolio":
|
||||||
content.write("<p><code>" + event["date"].strftime("%Y-%m-%d") + "</code> <a href=\"" + event["url"] + "\">[" + event["event"] + "]</a>: ")
|
content.write("<p><code>" + event["date"].strftime("%Y-%m-%d") + "</code> <a href=\"" + event["url"] + "\">[" + event["event"] + "]</a>: ")
|
||||||
|
@ -125,5 +143,9 @@ def loggen():
|
||||||
content.close()
|
content.close()
|
||||||
skel.footerwrite(thefile)
|
skel.footerwrite(thefile)
|
||||||
|
|
||||||
|
def logall():
|
||||||
|
loggen(False)
|
||||||
|
loggen(True)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
loggen()
|
logall()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue