Rebuild in modular fashion

master
trémeur 10 months ago
parent cfd5b0ca34
commit 3b5cb360d5

6
.gitignore vendored

@ -1 +1,5 @@
*.html
__pycache__/
build/*
!build/*.css
!build/*.png
variables.py

@ -1,12 +1,10 @@
#+TITLE: Trackers
* Roadmap
** Books
- something goodreads or storygraph-esque; goodreads relies heavily on cover art, storygraph on genre and other user-submitted data so neither is brilliant for this tbh
- not started
** Films
- letterboxd, but … a text-only version?
- not started
** Games
- backloggery beta version: see [[https://backloggery.club/demo][here]]
- basic script is created
* Tracking games with a backloggery clone
Rename =variables-template.py= to =variables.py= and edit:
- =endlessgames=: a list of “endless” games in the format =title (console)=
- =orgpath=: absolute path to the root directory in which =.org= files are stored, including trailing slash
- =localpath=: absolute path to this directory, including trailing slash
- =serverpath=: path to directory on the server where files will be uploaded, including trailing slash
- =description=: content for the “about” section (can include HTML tags)
- =consoles=: add or remove consoles following the format provided (=.png= images must be added to the build directory with a filename corresponding with the value of ="img"= for each console)

@ -0,0 +1,408 @@
import os
import cardstring,gamesort,skeleton,variables
from pathlib import Path
from datetime import datetime,timedelta
"""
Generates backlog page
"""
home = str(Path.home())
def backlog(local=False):
# delete existing file
if not os.path.isdir("build/backlog"):
os.mkdir("build/backlog")
if os.path.exists("build/backlog/index.html"):
os.remove("build/backlog/index.html")
# write header
skeleton.headerwrite("build/backlog/index.html","backlog",local)
output = "build/backlog/index.html"
filewrite = open(output, "a")
filewrite.write(" <section>\n <div>\n <h1>Now Playing</h1>\n <div class=\"now-playing\">\n")
playingnow = []
def nowplaying():
for console in gamesort.consolelists:
if len(console["games"]) > 0:
thegame = (console["games"])[-1]
try:
if thegame["gameplay"] > (datetime.now() - timedelta(days=180)):
try:
if thegame["completed"]:
if thegame["completed"] >= thegame["gameplay"]:
playing = False
else:
playing = True
except:
try:
if thegame["beaten"]:
if thegame["beaten"] >= thegame["gameplay"]:
playing = False
else:
playing = True
except:
playing = True
else:
playing = False
except:
playing = False
if playing == True:
playingnow.append(thegame)
nowplaying()
playingnow = sorted(playingnow,key=lambda d: d["lastupdate"],reverse=True)
for game in playingnow:
if playingnow.index(game) == 0:
filewrite.write(cardstring.playcard(game,local))
else:
filewrite.write(cardstring.playcard(game,local,True))
filewrite.write(" </div>\n")
# BACKLOG BREAKDOWN
filewrite.write(" <h1>Backlog Breakdown</h1>\n <div class=\"backlog-breakdown\">\n <div class=\"backlog-charts\">\n <div class=\"mem-sum\">\n <div class=\"donut\">\n <svg viewBox=\"0 0 42 42\">\n <a href=\"")
if local:
filewrite.write(variables.localpath + "build/library/index.html")
else:
filewrite.write(variables.serverpath + "library")
filewrite.write("\"><text x=\"21\" y=\"17.5\" style=\"font-size: 3.5px; opacity: 0.75; text-anchor: middle;\">Total Games</text>\n <text x=\"21\" y=\"27\" style=\"font-size: 10px; text-anchor: middle;\">" + str(len(gamesort.games)) + "</text>\n <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"4\" stroke=\"#000000c0\" fill=\"transparent\">\n </circle>\n")
backlog = gamesort.unfinished(gamesort.games) + gamesort.unplayed(gamesort.games)
takeup = 100
if gamesort.unplayed(gamesort.games) > 0:
filewrite.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(200, 30%, 30%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(takeup) + " 100\">\n </circle>\n")
takeup = takeup - round(((gamesort.unplayed(gamesort.games)/gamesort.total(gamesort.games))*100),1)
if gamesort.unfinished(gamesort.games) > 0:
filewrite.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(0, 38%, 35%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(takeup) + " 100\">\n </circle>\n")
takeup = takeup - round(((gamesort.unfinished(gamesort.games)/gamesort.total(gamesort.games))*100),1)
if gamesort.beaten(gamesort.games) > 0:
filewrite.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(0, 0%, 82%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(takeup) + " 100\">\n </circle>\n")
takeup = takeup - round(((gamesort.beaten(gamesort.games)/gamesort.total(gamesort.games))*100),1)
if gamesort.completed(gamesort.games) > 0:
filewrite.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(48, 75%, 70%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(takeup) + " 100\">\n </circle>\n")
takeup = takeup - round(((gamesort.completed(gamesort.games)/gamesort.total(gamesort.games))*100),1)
if gamesort.endless(gamesort.games) > 0:
filewrite.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(275, 39%, 32%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(takeup) + " 100\">\n </circle>\n")
yeargames = 0
yearplaying = 0
for game in gamesort.games:
if game["initialdate"].year == int(gamesort.thisyear):
try:
if game["gameplay"]:
if game["id"] not in variables.endlessgames:
yeargames += 1
except:
yeargames += 1
for game in gamesort.games:
try:
if game["beaten"].year == int(gamesort.thisyear):
yeargames -= 1
except:
try:
if game["completed"].year == int(gamesort.thisyear):
yeargames -= 1
except:
pass
filewrite.write(" </a></svg>\n </div>\n <div class=\"donut\">\n <svg viewBox=\"0 0 42 42\">\n <text x=\"21\" y=\"17.5\" style=\"font-size: 3.5px; opacity: 0.75; text-anchor: middle;\">" + gamesort.thisyear + " Backlog</text>\n <text x=\"21\" y=\"27\" style=\"font-size: 10px; text-anchor: middle;\">")
if yeargames > 0:
filewrite.write("")
elif yeargames < 0:
filewrite.write("")
filewrite.write(str(abs(yeargames)) + "</text>\n <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"4\" stroke=\"#000000c0\" fill=\"transparent\">\n </circle>\n")
yearbacklog = []
for game in gamesort.games:
try:
if game["completed"].year == int(gamesort.thisyear):
yearbacklog.append(game)
except:
try:
if game["beaten"].year == int(gamesort.thisyear):
yearbacklog.append(game)
except:
if game["initialdate"].year == int(gamesort.thisyear):
yearbacklog.append(game)
yearcompleted = 0
yearbeaten = 0
yearendless = 0
yearunfinished = 0
yeartotal = len(yearbacklog)
if yeartotal > 0:
for game in yearbacklog:
try:
if game["completed"]:
yearcompleted += 1
except:
try:
if game["beaten"]:
yearbeaten += 1
except:
try:
if game["gameplay"]:
if game["id"] in variables.endlessgames:
yearendless += 1
else:
yearunfinished += 1
except:
pass
yearunplayed = yeartotal - (yearcompleted + yearbeaten + yearunfinished + yearendless)
yeartakeup = 100
if yearunplayed > 0:
filewrite.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(200, 30%, 30%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(yeartakeup) + " 100\">\n </circle>\n")
yeartakeup = yeartakeup - round(((yearunplayed/yeartotal)*100),1)
if yearunfinished > 0:
filewrite.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(0, 38%, 35%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(yeartakeup) + " 100\">\n </circle>\n")
yeartakeup = yeartakeup - round(((yearunfinished/yeartotal)*100),1)
if yearbeaten > 0:
filewrite.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(0, 0%, 82%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(yeartakeup) + " 100\">\n </circle>\n")
yeartakeup = yeartakeup - round(((yearbeaten/yeartotal)*100),1)
if yearcompleted > 0:
filewrite.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(48, 75%, 70%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(yeartakeup) + " 100\">\n </circle>\n")
yeartakeup = yeartakeup - round(((yearcompleted/yeartotal)*100),1)
if yearendless > 0:
filewrite.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(275, 39%, 32%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(yeartakeup) + " 100\">\n </circle>\n")
filewrite.write(" </svg>\n </div>\n </div>\n <div class=\"status-tally\">\n <div class=\"backlog-tally\">\n <div style=\"width: " + str(round(((backlog/gamesort.total(gamesort.games))*100),1)) + "%;\">")
if ((backlog/gamesort.total(gamesort.games))*100) > 50:
filewrite.write("\n <span>Active Backlog · " + str(backlog) + " · " + str(round(((backlog/gamesort.total(gamesort.games))*100),1)) + "%</span>")
filewrite.write("\n </div>\n <div style=\"width: " + str(100 - round(((backlog/gamesort.total(gamesort.games))*100),1)) + "%;\">")
if ((backlog/gamesort.total(gamesort.games))*100) <= 50:
filewrite.write("\n <span>Active Backlog · " + str(backlog) + " · " + str(round(((backlog/gamesort.total(gamesort.games))*100),1)) + "%</span>")
filewrite.write("\n </div>\n </div>\n")
compare = []
compare.append(gamesort.unplayed(gamesort.games))
compare.append(gamesort.unfinished(gamesort.games))
compare.append(gamesort.beaten(gamesort.games))
compare.append(gamesort.completed(gamesort.games))
compare.append(gamesort.endless(gamesort.games))
maxvalue = max(compare)
if gamesort.unplayed(gamesort.games) / maxvalue > 0.5:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "build/library/all-unplayed/index.html")
else:
filewrite.write(variables.serverpath + "library/all-unplayed")
filewrite.write("\">\n <div>" + str(gamesort.unplayed(gamesort.games)) + "</div>\n <div>\n <img src=\"")
if local:
filewrite.write(variables.localpath + "build/")
else:
filewrite.write(variables.serverpath)
filewrite.write("UP.png\">\n </div>\n <div>\n <div class=\"Unplayed\" style=\"width: calc(100% * (" + str(gamesort.unplayed(gamesort.games)) + " / " + str(maxvalue) + "));\">" + str(round(((gamesort.unplayed(gamesort.games)/gamesort.total(gamesort.games))*100),1)) + "% Unplayed</div>\n </div>\n </a>\n")
else:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "build/library/all-unplayed/index.html")
else:
filewrite.write(variables.serverpath + "library/all-unplayed")
filewrite.write("\">\n <div>" + str(gamesort.unplayed(gamesort.games)) + "</div>\n <div>\n <img src=\"")
if local:
filewrite.write(variables.localpath + "build/")
else:
filewrite.write(variables.serverpath)
filewrite.write("UP.png\">\n </div>\n <div>\n <div class=\"Unplayed\" style=\"width: calc(100% * (" + str(gamesort.unplayed(gamesort.games)) + " / " + str(maxvalue) + "));\">\n </div>\n <div class=\"borderless\">" + str(round(((gamesort.unplayed(gamesort.games)/gamesort.total(gamesort.games))*100),1)) + "% Unplayed</div>\n </div>\n </a>\n")
if gamesort.unfinished(gamesort.games) / maxvalue > 0.5:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "build/library/all-unfinished/index.html")
else:
filewrite.write(variables.serverpath + "library/all-unfinished")
filewrite.write("\">\n <div>" + str(gamesort.unfinished(gamesort.games)) + "</div>\n <div>\n <img src=\"")
if local:
filewrite.write(variables.localpath + "build/")
else:
filewrite.write(variables.serverpath)
filewrite.write("UF.png\">\n </div>\n <div>\n <div class=\"Unfinished\" style=\"width: calc(100% * (" + str(gamesort.unfinished(gamesort.games)) + " / " + str(maxvalue) + "));\">" + str(round(((gamesort.unfinished(gamesort.games)/gamesort.total(gamesort.games))*100),1)) + "% Unfinished</div>\n </div>\n </a>\n")
else:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "build/library/all-unfinished/index.html")
else:
filewrite.write(variables.serverpath + "library/all-unfinished")
filewrite.write("\">\n <div>" + str(gamesort.unfinished(gamesort.games)) + "</div>\n <div>\n <img src=\"")
if local:
filewrite.write(variables.localpath + "build/")
else:
filewrite.write(variables.serverpath)
filewrite.write("UF.png\">\n </div>\n <div>\n <div class=\"Unfinished\" style=\"width: calc(100% * (" + str(gamesort.unfinished(gamesort.games)) + " / " + str(maxvalue) + "));\">\n </div>\n <div class=\"borderless\">" + str(round(((gamesort.unfinished(gamesort.games)/gamesort.total(gamesort.games))*100),1)) + "% Unfinished</div>\n </div>\n </a>\n")
if gamesort.beaten(gamesort.games) / maxvalue > 0.5:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "build/library/all-beaten/index.html")
else:
filewrite.write(variables.serverpath + "library/all-beaten")
filewrite.write("\">\n <div>" + str(gamesort.beaten(gamesort.games)) + "</div>\n <div>\n <img src=\"")
if local:
filewrite.write(variables.localpath + "build/")
else:
filewrite.write(variables.serverpath)
filewrite.write("B.png\">\n </div>\n <div>\n <div class=\"Beaten\" style=\"width: calc(100% * (" + str(gamesort.beaten(gamesort.games)) + " / " + str(maxvalue) + "));\">" + str(round(((gamesort.beaten(gamesort.games)/gamesort.total(gamesort.games))*100),1)) + "% Beaten</div>\n </div>\n </a>\n")
else:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "build/library/all-beaten/index.html")
else:
filewrite.write(variables.serverpath + "library/all-beaten")
filewrite.write("\">\n <div>" + str(gamesort.beaten(gamesort.games)) + "</div>\n <div>\n <img src=\"")
if local:
filewrite.write(variables.localpath + "build/")
else:
filewrite.write(variables.serverpath)
filewrite.write("B.png\">\n </div>\n <div>\n <div class=\"Beaten\" style=\"width: calc(100% * (" + str(gamesort.beaten(gamesort.games)) + " / " + str(maxvalue) + "));\">\n </div>\n <div class=\"borderless\">" + str(round(((gamesort.beaten(gamesort.games)/gamesort.total(gamesort.games))*100),1)) + "% Beaten</div>\n </div>\n </a>\n")
if gamesort.completed(gamesort.games) / maxvalue > 0.5:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "build/library/all-completed/index.html")
else:
filewrite.write(variables.serverpath + "library/all-completed")
filewrite.write("\">\n <div>" + str(gamesort.completed(gamesort.games)) + "</div>\n <div>\n <img src=\"")
if local:
filewrite.write(variables.localpath + "build/")
else:
filewrite.write(variables.serverpath)
filewrite.write("C.png\">\n </div>\n <div>\n <div class=\"Completed\" style=\"width: calc(100% * (" + str(gamesort.completed(gamesort.games)) + " / " + str(maxvalue) + "));\">" + str(round(((gamesort.completed(gamesort.games)/gamesort.total(gamesort.games))*100),1)) + "% Completed</div>\n </div>\n </a>\n")
else:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "build/library/all-completed/index.html")
else:
filewrite.write(variables.serverpath + "library/all-completed")
filewrite.write("\">\n <div>" + str(gamesort.completed(gamesort.games)) + "</div>\n <div>\n <img src=\"")
if local:
filewrite.write(variables.localpath + "build/")
else:
filewrite.write(variables.serverpath)
filewrite.write("C.png\">\n </div>\n <div>\n <div class=\"Completed\" style=\"width: calc(100% * (" + str(gamesort.completed(gamesort.games)) + " / " + str(maxvalue) + "));\">\n </div>\n <div class=\"borderless\">" + str(round(((gamesort.completed(gamesort.games)/gamesort.total(gamesort.games))*100),1)) + "% Completed</div>\n </div>\n </a>\n")
if gamesort.endless(gamesort.games) / maxvalue > 0.5:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "build/library/all-endless/index.html")
else:
filewrite.write(variables.serverpath + "library/all-endless")
filewrite.write("\">\n <div>" + str(gamesort.endless(gamesort.games)) + "</div>\n <div>\n <img src=\"")
if local:
filewrite.write(variables.localpath + "build/")
else:
filewrite.write(variables.serverpath)
filewrite.write("E.png\">\n </div>\n <div>\n <div class=\"Endless\" style=\"width: calc(100% * (" + str(gamesort.endless(gamesort.games)) + " / " + str(maxvalue) + "));\">" + str(round(((gamesort.endless(gamesort.games)/gamesort.total(gamesort.games))*100),1)) + "% Endless</div>\n </div>\n </a>\n")
else:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "build/library/all-endless/index.html")
else:
filewrite.write(variables.serverpath + "library/all-endless")
filewrite.write("\">\n <div>" + str(gamesort.endless(gamesort.games)) + "</div>\n <div>\n <img src=\"")
if local:
filewrite.write(variables.localpath + "build/")
else:
filewrite.write(variables.serverpath)
filewrite.write("E.png\">\n </div>\n <div>\n <div class=\"Endless\" style=\"width: calc(100% * (" + str(gamesort.endless(gamesort.games)) + " / " + str(maxvalue) + "));\">\n </div>\n <div class=\"borderless\">" + str(round(((gamesort.endless(gamesort.games)/gamesort.total(gamesort.games))*100),1)) + "% Endless</div>\n </div>\n </a>\n")
filewrite.write(" </div>\n </div>\n </div>\n")
# PLATFORM SUMMARY
filewrite.write(" <h1>Platform Summary</h1>\n <div class=\"platform-summary\">\n")
listofconsoles = sorted(variables.consoles,key=lambda d: d["name"])
for console in listofconsoles:
consolegames = []
for game in gamesort.games:
if game["console"] == console["code"]:
consolegames.append(game)
ccompleted = 0
cbeaten = 0
cendless = 0
cunfinished = 0
ctotal = len(consolegames)
if ctotal > 0:
filewrite.write(" <div class=\"platform-card\">\n <a href=\"")
if local:
filewrite.write(variables.localpath + "build/library/" + console["shortname"].lower() + "-all/index.html")
else:
filewrite.write(variables.serverpath + "library/" + console["shortname"].lower() + "-all")
filewrite.write("\" class=\"title\">" + console["name"] + "</a>\n <a href=\"")
if local:
filewrite.write(variables.localpath + "build/library/" + console["shortname"].lower() + "-all/index.html")
else:
filewrite.write(variables.serverpath + "library/" + console["shortname"].lower() + "-all")
filewrite.write("\"class=\"abbr\">" + console["shortname"] + "</a>\n <div class=\"bars\">\n")
for game in consolegames:
try:
if game["completed"]:
ccompleted += 1
except:
try:
if game["beaten"]:
cbeaten += 1
except:
try:
if game["gameplay"]:
if game["id"] in variables.endlessgames:
cendless += 1
else:
cunfinished += 1
except:
pass
cunplayed = ctotal - (ccompleted + cbeaten + cunfinished + cendless)
if cunplayed > 0:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "build/library/" + console["shortname"].lower() + "-unplayed/index.html")
else:
filewrite.write(variables.serverpath + "library/" + console["shortname"].lower() + "-unplayed")
filewrite.write("\" class=\"unplayed\" title=\"Unplayed\" style=\"flex: " + str(cunplayed) + " 1 0%;\">" + str(cunplayed) + "</a>\n")
if cunfinished > 0:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "build/library/" + console["shortname"].lower() + "-unfinished/index.html")
else:
filewrite.write(variables.serverpath + "library/" + console["shortname"].lower() + "-unfinished")
filewrite.write("\" class=\"unfinished\" title=\"Unfinished\" style=\"flex: " + str(cunfinished) + " 1 0%;\">" + str(cunfinished) + "</a>\n")
if cbeaten > 0:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "build/library/" + console["shortname"].lower() + "-beaten/index.html")
else:
filewrite.write(variables.serverpath + "library/" + console["shortname"].lower() + "-beaten")
filewrite.write("\"class=\"beaten\" title=\"Beaten\" style=\"flex: " + str(cbeaten) + " 1 0%;\">" + str(cbeaten) + "</a>\n")
if ccompleted > 0:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "build/library/" + console["shortname"].lower() + "-completed/index.html")
else:
filewrite.write(variables.serverpath + "library/" + console["shortname"].lower() + "-completed")
filewrite.write("\" class=\"completed\" title=\"Completed\" style=\"flex: " + str(ccompleted) + " 1 0%;\">" + str(ccompleted) + "</a>\n")
if cendless > 0:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "build/library/" + console["shortname"].lower() + "-endless/index.html")
else:
filewrite.write(variables.serverpath + "library/" + console["shortname"].lower() + "-endless")
filewrite.write("\" class=\"endless\" title=\"Endless\" style=\"flex: " + str(cendless) + " 1 0%;\">" + str(cendless) + "</a>\n")
filewrite.write(" </div>\n <a href=\"")
if local:
filewrite.write(variables.localpath + "build/library/" + console["shortname"].lower() + "-all/index.html")
else:
filewrite.write(variables.serverpath + "library/" + console["shortname"].lower() + "-all")
filewrite.write("\" class=\"total\">" + str(ctotal) + "\n <span>Total</span>\n </a>\n </div>\n")
filewrite.write(" </div>\n </div>\n </div>\n")
filewrite.close()
skeleton.footerwrite("build/backlog/index.html")
if __name__ == "__main__":
backlog(True)

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Before

Width:  |  Height:  |  Size: 885 B

After

Width:  |  Height:  |  Size: 885 B

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

@ -400,10 +400,6 @@ div.profile main {
width:100%
}
.platform-card a {
cursor: default;
}
.platform-card .bars {
border-radius:0 4px 4px 0;
display:-webkit-inline-box;
@ -584,7 +580,6 @@ div.profile main {
-ms-flex-align:center;
align-items:center;
margin:-5px 20px -5px 0;
cursor: default;
}
.status-tally a div {
@ -757,8 +752,6 @@ div.profile main {
margin-right:.5rem}
}
/* NEW */
.game-item .game-info {
-webkit-box-align:start;
-ms-flex-align:start;
@ -859,3 +852,45 @@ div.profile main {
.history .box_1 {
width: 95%;
}
div.profile aside {
grid-area:side;
margin-top:1.5rem;
position: sticky;
}
/* NEW */
.library .filters {
margin:.25rem 0 1.5rem;
width:100%}
.library .filters>div {
padding:1rem;
width:95%}
/* .library .filters .empty-filters {
border:2px solid rgba(0,0,0,.5);
background-color:var(--active-secondary);
color:var(--active-secondary-text);
border-radius:.5rem;
margin:.5rem auto;
opacity:.8;
padding:.4rem;
text-align:center}
.library .filters .empty-filters:hover {
opacity:1} */
.library .filters .item {
border:2px solid rgba(0,0,0,.5);
background-color:var(--active-secondary);
color:var(--active-secondary-text);
border-radius:.5rem;
margin:.25rem;
max-width:8rem;
opacity:.8;
padding:.4rem 1rem .5rem}
.library .filters .item:hover {
opacity:1}

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

@ -0,0 +1,200 @@
import gamesort,variables
from pathlib import Path
from datetime import datetime,timedelta
home = str(Path.home())
def playcard(game,local=False,decay=False):
cardstring = ""
if decay == True:
cardstring += " <details class=\"game-item decay\">\n"
else:
cardstring += " <details class=\"game-item\">\n"
cardstring += " <summary>\n <div class=\"platform\">\n <div>\n"
for console in variables.consoles:
if game["console"] == console["code"]:
cardstring += " <img src=\""
if local:
cardstring += variables.localpath + "build/"
else:
cardstring += variables.serverpath
cardstring += console["img"] + ".png\" title=\"" + console["name"] + "\" alt=\"" + console["shortname"] + "\" class=\"bw\">\n"
cardstring += " </div>\n </div>\n <div class=\"status\">\n"
try:
if game["completed"]:
cardstring += " <img src=\""
if local:
cardstring += variables.localpath + "build/"
else:
cardstring += variables.serverpath
cardstring += "C.png\" alt=\"C\" title=\"Completed\">\n"
except:
try:
if game["beaten"]:
cardstring += " <img src=\""
if local:
cardstring += variables.localpath + "build/"
else:
cardstring += variables.serverpath
cardstring += "B.png\" alt=\"B\" title=\"Beaten\">\n"
except:
try:
if game["gameplay"]:
if game["id"] in variables.endlessgames:
cardstring += " <img src=\""
if local:
cardstring += variables.localpath + "build/"
else:
cardstring += variables.serverpath
cardstring += "E.png\" alt=\"E\" title=\"Endless\">\n"
else:
cardstring += " <img src=\""
if local:
cardstring += variables.localpath + "build/"
else:
cardstring += variables.serverpath
cardstring += "UF.png\" alt=\"UF\" title=\"Unfinished\">\n"
except:
cardstring += " <img src=\""
if local:
cardstring += variables.localpath + "build/"
else:
cardstring += variables.serverpath
cardstring += "UP.png\" alt=\"UP\" title=\"Unplayed\">\n"
cardstring += " </div>\n <div class=\"text\">\n <div class=\"title\">" + game["name"] + "</div>\n"
try:
if len(game["recent"]) > 1:
cardstring += " <div class=\"markdown\">" + game["recent"] + "</div>\n"
except:
pass
try:
if game["gameplay"]:
try:
if game["completed"]:
if game["gameplay"] > game["completed"]:
if game["gameplay"] < (datetime.now() - timedelta(days=180)):
cardstring += " </div>\n <div class=\"priority\">\n <span title=\"Normal\"/>\n </div>\n"
else:
cardstring += " </div>\n <div class=\"priority\">\n <img src=\""
if local:
cardstring += variables.localpath + "build/"
else:
cardstring += variables.serverpath
cardstring += "nowplaying.png\" alt=\"\" title=\"Now Playing\">\n </div>\n"
else:
cardstring += " </div>\n <div class=\"priority\">\n <span title=\"Normal\"/>\n </div>\n"
except:
try:
if game["beaten"]:
if game["gameplay"] > game["beaten"]:
if game["gameplay"] < (datetime.now() - timedelta(days=180)):
cardstring += " </div>\n <div class=\"priority\">\n <span title=\"Normal\"/>\n </div>\n"
else:
cardstring += " </div>\n <div class=\"priority\">\n <img src=\""
if local:
cardstring += variables.localpath + "build/"
else:
cardstring += variables.serverpath
cardstring += "nowplaying.png\" alt=\"\" title=\"Now Playing\">\n </div>\n"
else:
cardstring += " </div>\n <div class=\"priority\">\n <span title=\"Normal\"/>\n </div>\n"
except:
if game["gameplay"] < (datetime.now() - timedelta(days=180)):
if game["id"] in variables.endlessgames:
cardstring += " </div>\n <div class=\"priority\">\n <span title=\"Normal\"/>\n </div>\n"
else:
cardstring += " </div>\n <div class=\"priority\">\n <img src=\""
if local:
cardstring += variables.localpath + "build/"
else:
cardstring += variables.serverpath
cardstring += "paused.png\" alt=\"\" title=\"Paused\">\n </div>\n"
else:
cardstring += " </div>\n <div class=\"priority\">\n <img src=\""
if local:
cardstring += variables.localpath + "build/"
else:
cardstring += variables.serverpath
cardstring += "nowplaying.png\" alt=\"\" title=\"Now Playing\">\n </div>\n"
except:
cardstring += " </div>\n <div class=\"priority\">\n <span title=\"Normal\"/>\n </div>\n"
cardstring += " </summary>\n <div class=\"game-info game-guest\">\n <div class=\"data\">\n <div class=\"box_2\">\n"
try:
if len(game["recent"]) > 1:
cardstring += " <div>\n <label>Notes</label>\n <div class=\"markdown\">" + game["recent"] + "</div>\n </div>\n"
except:
pass
cardstring += " <div class=\"flex\">\n <div>\n <label>Status</label>\n <p>"
try:
if game["completed"]:
cardstring += "Completed"
except:
try:
if game["beaten"]:
cardstring += "Beaten"
except:
try:
if game["gameplay"]:
if game["id"] in variables.endlessgames:
cardstring += "Endless"
else:
cardstring += "Unfinished"
except:
cardstring += "Unplayed"
cardstring += "</p>\n </div>\n <div>\n <label>Currently</label>\n <p>"
try:
if game["gameplay"]:
try:
if game["completed"]:
if game["gameplay"] > game["completed"]:
if game["gameplay"] < (datetime.now() - timedelta(days=180)):
cardstring += "Not playing"
else:
cardstring += "Playing"
else:
cardstring += "Not playing"
except:
try:
if game["beaten"]:
if game["gameplay"] > game["beaten"]:
if game["gameplay"] < (datetime.now() - timedelta(days=180)):
cardstring += "Not playing"
else:
cardstring += "Playing"
else:
cardstring += "Not playing"
except:
if game["gameplay"] < (datetime.now() - timedelta(days=180)):
if game["id"] in variables.endlessgames:
cardstring += "Not playing"
else:
cardstring += "Paused"
else:
cardstring += "Playing"
except:
cardstring += "Not playing"
cardstring += "</p>\n </div>\n </div>\n </div>\n <div class=\"box_1 m-r0\">\n <div>\n <label>Platform</label>\n <p>"
for console in variables.consoles:
if game["console"] == console["code"]:
cardstring += console["name"]
cardstring += "</p>\n </div>\n <div>\n <label>Last Updated</label>\n <p>" + game["lastupdate"].strftime("%Y-%m-%d") + "</p>\n </div>\n </div>\n </div>\n <div class=\"history\">\n <div class=\"box_1\">\n <h2>Milestones</h2>\n <div class=\"list\">\n <div>\n <div>" + game["initialdate"].strftime("%Y-%m-%d") + "</div>\n <div>\n Added</div>\n </div>\n"
try:
if game["firstplayed"]:
cardstring += " <div>\n <div>" + game["firstplayed"].strftime("%Y-%m-%d") + "</div>\n <div>\n Started</div>\n </div>\n"
except:
pass
try:
if game["beaten"]:
cardstring += " <div>\n <div>" + game["beaten"].strftime("%Y-%m-%d") + "</div>\n <div>\n Beaten</div>\n </div>\n"
except:
pass
try:
if game["completed"]:
cardstring += " <div>\n <div>" + game["completed"].strftime("%Y-%m-%d") + "</div>\n <div>\n Completed</div>\n </div>\n"
except:
pass
cardstring += " </div>\n </div>\n </div>\n </div>\n </details>\n"
return cardstring
if __name__ == "__main__":
playcard(gamesort.games[0],True)

@ -1,676 +0,0 @@
import orgparse,os,re
from pathlib import Path
from datetime import datetime,timedelta
home = str(Path.home())
thisyear = datetime.now().strftime("%Y")
basedir = home + "/Documents/drive/org/journal/"
if os.path.exists("backlog.html"):
os.remove("backlog.html")
writeindex = open("backlog.html", "a")
if os.path.exists("library.html"):
os.remove("library.html")
writelibrary = open("library.html", "a")
year = 2016
concernedfiles = []
endlessgames = ["the sims 4 (pc)","american truck simulator (pc)","civilization iv (pc)","final fantasy xiv (pc)","medieval ii: total war (pc)","tabletop simulator (pc)","train simulator 2020 (pc)","theatrhythm curtain call (nintendo 3ds)"]
while year < int(thisyear) + 1:
month = 0
while month < 13:
if month < 10:
strmonth = "0" + str(month)
else:
strmonth = str(month)
recdir = str(year) + "/" + strmonth + "/"
fullpath = basedir + recdir
if os.path.exists(fullpath):
for file in sorted(os.listdir(fullpath)):
filename = fullpath + str(file)
if filename.endswith(".org"):
concernedfiles.append(filename)
month = month + 1
year = year + 1
games = []
gamenames = []
holding = []
for file in concernedfiles:
filedate = file[-14:-4]
dateobj = datetime.strptime(filedate,"%Y-%m-%d")
parsefile = orgparse.load(file)
try:
for node in parsefile.children:
if node.heading == "games":
for action in node.children:
for game in action.children:
name = re.sub(" \(.*\)","",game.heading)
if game.heading not in gamenames:
status = "new"
gamenames.append(game.heading)
else:
status = "existing"
console = (re.findall("\(.*\)",game.heading)[0])[1:-1]
if status == "new":
thedict = {"id":game.heading,"name":name,"initialdate":dateobj,"console":console,game.parent.heading:dateobj,"recent":game.body,"lastupdate":dateobj}
if game.parent.heading != "acquired":
thedict.update({"firstplayed":dateobj})
games.append(thedict)
else:
twodict = {"id":game.heading,game.parent.heading:dateobj,"lastupdate":dateobj}
if len(game.body) > 1:
twodict.update({"recent":game.body})
for origgame in games:
if twodict["id"] == origgame["id"]:
try:
if origgame["firstplayed"]:
playedbefore = True
except:
playedbefore = False
if playedbefore == False:
twodict.update({"firstplayed":dateobj})
holding.append(twodict)
for gameupdate in holding:
for origgame in games:
if gameupdate["id"] == origgame["id"]:
gamemerge = {**origgame, **gameupdate}
games.remove(origgame)
games.insert(0,gamemerge)
holding.remove(gameupdate)
except:
pass
games = sorted(games,key=lambda d: d["lastupdate"])
ps5list = []
for game in games:
if game["console"] == "ps5":
ps5list.append(game)
ps2list = []
for game in games:
if game["console"] == "ps2":
ps2list.append(game)
ps3list = []
for game in games:
if game["console"] == "ps3":
ps3list.append(game)
xbox360list = []
for game in games:
if game["console"] == "xbox 360":
xbox360list.append(game)
pclist = []
for game in games:
if game["console"] == "pc":
pclist.append(game)
dslist = []
for game in games:
if game["console"] == "nintendo ds":
dslist.append(game)
switchlist = []
for game in games:
if game["console"] == "nintendo switch":
switchlist.append(game)
threedslist = []
for game in games:
if game["console"] == "nintendo 3ds":
threedslist.append(game)
writeindex.write("<!DOCTYPE html>\n<html lang=\"en\" style=\"--active-base: #364563; --active-text: #FFFFFF; --active-text-50: #FFFFFF60; --active-text-25: #FFFFFF30; --active-secondary: #222a3a; --active-secondary-50: #222a3a80; --active-secondary-text: #FFFFFF; --active-secondary-text-50: #FFFFFF70; --active-secondary-text-25: #FFFFFF30; --active-accent: #00fffb; --active-accent-75: #00fffbc0; --active-accent-text: #000000DD; --beaten-color: hsla(0, 0%, 82%, 0.9); --completed-color: hsla(48, 80%, 82%, 0.9); --unplayed-color: hsla(200, 30%, 30%, 0.9); --unfinished-color: hsla(0, 38%, 35%, 0.9); --endless-color: hsla(275, 39%, 32%, 0.9); --platform-bw: none; --active-accent-shadow: #FFFFFF66; --retro-border: url('/img/border.png');\">\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n <meta name=\"theme-color\" content=\"#364563\">\n <link href=\"https://fonts.googleapis.com/icon?family=Material+Icons\" rel=\"stylesheet\">\n <link href=\"https://fonts.googleapis.com/css?family=Lato|Teko|Titillium+Web\" rel=\"stylesheet\">\n <title>Selfhostery etc.</title>\n <link href=\"backloggery.css\" rel=\"stylesheet\">\n </head>\n <body>\n <div id=\"app\">\n <div class=\"profile\">\n <main>\n <section>\n <div class=\"tabs\">\n <a href=\"\" class=\"router-link-exact-active router-link-active\" aria-current=\"page\">Backlog</a>\n <a href=\"library.html\" class=\"\">Library</a>\n <a href=\"\" class=\"\">History</a>\n </div>\n")
# NOW PLAYING
writeindex.write(" <section>\n <div>\n <h1>Now Playing</h1>\n <div class=\"now-playing\">\n")
playingnow = []
def nowplaying(consolelist):
if len(consolelist) > 0:
thegame = consolelist[-1]
try:
if thegame["gameplay"] > (datetime.now() - timedelta(days=180)):
try:
if thegame["completed"]:
if thegame["completed"] > thegame["gameplay"]:
playing = False
else:
playing = True
except:
try:
if thegame["beaten"]:
if thegame["beaten"] > thegame["gameplay"]:
playing = False
else:
playing = True
except:
playing = True
if playing:
playingnow.append(thegame)
except:
pass
nowplaying(dslist)
nowplaying(threedslist)
nowplaying(switchlist)
nowplaying(pclist)
nowplaying(ps2list)
nowplaying(ps3list)
nowplaying(ps5list)
nowplaying(xbox360list)
playingnow = sorted(playingnow,key=lambda d: d["lastupdate"],reverse=True)
decay = False
def playcard(game,page):
cardstring = ""
if decay == True:
cardstring += " <details class=\"game-item decay\">\n"
else:
cardstring += " <details class=\"game-item\">\n"
cardstring += " <summary>\n <div class=\"platform\">\n <div>\n"
if game["console"] == "ps5":
cardstring += " <img src=\"PS5.png\" title=\"PlayStation 5\" alt=\"PS5\" class=\"bw\">\n"
elif game["console"] == "ps2":
cardstring += " <img src=\"PS2.png\" title=\"PlayStation 2\" alt=\"PS2\" class=\"bw\">\n"
elif game["console"] == "ps3":
cardstring += " <img src=\"PS3.png\" title=\"PlayStation 3\" alt=\"PS3\" class=\"bw\">\n"
elif game["console"] == "nintendo switch":
cardstring += " <img src=\"Switch.png\" title=\"Nintendo Switch\" alt=\"Switch\" class=\"bw\">\n"
elif game["console"] == "nintendo ds":
cardstring += " <img src=\"NDS.png\" title=\"Nintendo DS\" alt=\"DS\" class=\"bw\">\n"
elif game["console"] == "nintendo 3ds":
cardstring += " <img src=\"3DS.png\" title=\"Nintendo 3DS\" alt=\"3DS\" class=\"bw\">\n"
elif game["console"] == "xbox 360":
cardstring += " <img src=\"360.png\" title=\"Xbox 360\" alt=\"Xbox360\" class=\"bw\">\n"
elif game["console"] == "pc":
cardstring += " <img src=\"PC.png\" title=\"PC\" alt=\"PC\" class=\"bw\">\n"
cardstring += " </div>\n </div>\n <div class=\"status\">\n"
try:
if game["completed"]:
cardstring += " <img src=\"C.png\" alt=\"C\" title=\"Completed\">\n"
except:
try:
if game["beaten"]:
cardstring += " <img src=\"B.png\" alt=\"B\" title=\"Beaten\">\n"
except:
try:
if game["gameplay"]:
if game["id"] in endlessgames:
cardstring += " <img src=\"E.png\" alt=\"E\" title=\"Endless\">\n"
else:
cardstring += " <img src=\"UF.png\" alt=\"UF\" title=\"Unfinished\">\n"
except:
cardstring += " <img src=\"UP.png\" alt=\"UP\" title=\"Unplayed\">\n"
cardstring += " </div>\n <div class=\"text\">\n <div class=\"title\">" + game["name"] + "</div>\n"
try:
if len(game["recent"]) > 1:
cardstring += " <div class=\"markdown\">" + game["recent"] + "</div>\n"
except:
pass
try:
if game["gameplay"]:
try:
if game["completed"]:
if game["gameplay"] > game["completed"]:
if game["gameplay"] < (datetime.now() - timedelta(days=180)):
cardstring += " </div>\n <div class=\"priority\">\n <span title=\"Normal\"/>\n </div>\n"
else:
cardstring += " </div>\n <div class=\"priority\">\n <img src=\"nowplaying.png\" alt=\"\" title=\"Now Playing\">\n </div>\n"
else:
cardstring += " </div>\n <div class=\"priority\">\n <span title=\"Normal\"/>\n </div>\n"
except:
try:
if game["beaten"]:
if game["gameplay"] > game["beaten"]:
if game["gameplay"] < (datetime.now() - timedelta(days=180)):
cardstring += " </div>\n <div class=\"priority\">\n <span title=\"Normal\"/>\n </div>\n"
else:
cardstring += " </div>\n <div class=\"priority\">\n <img src=\"nowplaying.png\" alt=\"\" title=\"Now Playing\">\n </div>\n"
else:
cardstring += " </div>\n <div class=\"priority\">\n <span title=\"Normal\"/>\n </div>\n"
except:
if game["gameplay"] < (datetime.now() - timedelta(days=180)):
if game["id"] in endlessgames:
cardstring += " </div>\n <div class=\"priority\">\n <span title=\"Normal\"/>\n </div>\n"
else:
cardstring += " </div>\n <div class=\"priority\">\n <img src=\"paused.png\" alt=\"\" title=\"Paused\">\n </div>\n"
else:
cardstring += " </div>\n <div class=\"priority\">\n <img src=\"nowplaying.png\" alt=\"\" title=\"Now Playing\">\n </div>\n"
except:
cardstring += " </div>\n <div class=\"priority\">\n <span title=\"Normal\"/>\n </div>\n"
cardstring += " </summary>\n <div class=\"game-info game-guest\">\n <div class=\"data\">\n <div class=\"box_2\">\n"
try:
if len(game["recent"]) > 1:
cardstring += " <div>\n <label>Notes</label>\n <div class=\"markdown\">" + game["recent"] + "</div>\n </div>\n"
except:
pass
cardstring += " <div class=\"flex\">\n <div>\n <label>Status</label>\n <p>"
try:
if game["completed"]:
cardstring += "Completed"
except:
try:
if game["beaten"]:
cardstring += "Beaten"
except:
try:
if game["gameplay"]:
if game["id"] in endlessgames:
cardstring += "Endless"
else:
cardstring += "Unfinished"
except:
cardstring += "Unplayed"
cardstring += "</p>\n </div>\n <div>\n <label>Currently</label>\n <p>"
try:
if game["gameplay"]:
try:
if game["completed"]:
if game["gameplay"] > game["completed"]:
if game["gameplay"] < (datetime.now() - timedelta(days=180)):
cardstring += "Not playing"
else:
cardstring += "Playing"
else:
cardstring += "Not playing"
except:
try:
if game["beaten"]:
if game["gameplay"] > game["beaten"]:
if game["gameplay"] < (datetime.now() - timedelta(days=180)):
cardstring += "Not playing"
else:
cardstring += "Playing"
else:
cardstring += "Not playing"
except:
if game["gameplay"] < (datetime.now() - timedelta(days=180)):
if game["id"] in endlessgames:
cardstring += "Not playing"
else:
cardstring += "Paused"
else:
cardstring += "Playing"
except:
cardstring += "Not playing"
cardstring += "</p>\n </div>\n </div>\n </div>\n <div class=\"box_1 m-r0\">\n <div>\n <label>Platform</label>\n <p>"
if game["console"] == "ps5":
cardstring += "PlayStation 5"
elif game["console"] == "ps2":
cardstring += "PlayStation 2"
elif game["console"] == "ps3":
cardstring += "PlayStation 3"
elif game["console"] == "nintendo switch":
cardstring += "Nintendo Switch"
elif game["console"] == "nintendo ds":
cardstring += "Nintendo DS"
elif game["console"] == "nintendo 3ds":
cardstring += "Nintendo 3DS"
elif game["console"] == "xbox 360":
cardstring += "XBox 360"
elif game["console"] == "pc":
cardstring += "PC"
cardstring += "</p>\n </div>\n <div>\n <label>Last Updated</label>\n <p>" + game["lastupdate"].strftime("%Y-%m-%d") + "</p>\n </div>\n </div>\n </div>\n <div class=\"history\">\n <div class=\"box_1\">\n <h2>Milestones</h2>\n <div class=\"list\">\n <div>\n <div>" + game["initialdate"].strftime("%Y-%m-%d") + "</div>\n <div>\n Added</div>\n </div>\n"
try:
if game["firstplayed"]:
cardstring += " <div>\n <div>" + game["firstplayed"].strftime("%Y-%m-%d") + "</div>\n <div>\n Started</div>\n </div>\n"
except:
pass
try:
if game["beaten"]:
cardstring += " <div>\n <div>" + game["beaten"].strftime("%Y-%m-%d") + "</div>\n <div>\n Beaten</div>\n </div>\n"
except:
pass
try:
if game["completed"]:
cardstring += " <div>\n <div>" + game["completed"].strftime("%Y-%m-%d") + "</div>\n <div>\n Completed</div>\n </div>\n"
except:
pass
cardstring += " </div>\n </div>\n </div>\n </div>\n </details>\n"
if page == "main":
writeindex.write(cardstring)
elif page == "library":
writelibrary.write(cardstring)
for game in playingnow:
playcard(game,"main")
decay = True
writeindex.write(" </div>\n")
# BACKLOG BREAKDOWN
writeindex.write(" <h1>Backlog Breakdown</h1>\n <div class=\"backlog-breakdown\">\n <div class=\"backlog-charts\">\n <div class=\"mem-sum\">\n <div class=\"donut\">\n <svg viewBox=\"0 0 42 42\">\n <text x=\"21\" y=\"17.5\" style=\"font-size: 3.5px; opacity: 0.75; text-anchor: middle;\">Total Games</text>\n <text x=\"21\" y=\"27\" style=\"font-size: 10px; text-anchor: middle;\">" + str(len(games)) + "</text>\n <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"4\" stroke=\"#000000c0\" fill=\"transparent\">\n </circle>\n")
completed = 0
beaten = 0
endless = 0
unfinished = 0
total = len(games)
if total > 0:
for game in games:
try:
if game["completed"]:
completed += 1
except:
try:
if game["beaten"]:
beaten += 1
except:
try:
if game["gameplay"]:
if game["id"] in endlessgames:
endless += 1
else:
unfinished += 1
except:
pass
unplayed = total - (completed + beaten + unfinished + endless)
backlog = unfinished + unplayed
takeup = 100
if unplayed > 0:
writeindex.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(200, 30%, 30%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(takeup) + " 100\">\n </circle>\n")
takeup = takeup - round(((unplayed/total)*100),1)
if unfinished > 0:
writeindex.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(0, 38%, 35%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(takeup) + " 100\">\n </circle>\n")
takeup = takeup - round(((unfinished/total)*100),1)
if beaten > 0:
writeindex.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(0, 0%, 82%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(takeup) + " 100\">\n </circle>\n")
takeup = takeup - round(((beaten/total)*100),1)
if completed > 0:
writeindex.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(48, 75%, 70%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(takeup) + " 100\">\n </circle>\n")
takeup = takeup - round(((completed/total)*100),1)
if endless > 0:
writeindex.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(275, 39%, 32%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(takeup) + " 100\">\n </circle>\n")
yeargames = 0
yearplaying = 0
for game in games:
if game["initialdate"].year == int(thisyear):
try:
if game["gameplay"]:
if game["id"] not in endlessgames:
yeargames += 1
except:
yeargames += 1
for game in games:
try:
if game["beaten"].year == int(thisyear):
yeargames -= 1
except:
try:
if game["completed"].year == int(thisyear):
yeargames -= 1
except:
pass
writeindex.write(" </svg>\n </div>\n <div class=\"donut\">\n <svg viewBox=\"0 0 42 42\">\n <text x=\"21\" y=\"17.5\" style=\"font-size: 3.5px; opacity: 0.75; text-anchor: middle;\">" + thisyear + " Backlog</text>\n <text x=\"21\" y=\"27\" style=\"font-size: 10px; text-anchor: middle;\">")
if yeargames > 0:
writeindex.write("")
elif yeargames < 0:
writeindex.write("")
writeindex.write(str(abs(yeargames)) + "</text>\n <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"4\" stroke=\"#000000c0\" fill=\"transparent\">\n </circle>\n")
yearbacklog = []
for game in games:
try:
if game["completed"].year == int(thisyear):
yearbacklog.append(game)
except:
try:
if game["beaten"].year == int(thisyear):
yearbacklog.append(game)
except:
if game["initialdate"].year == int(thisyear):
yearbacklog.append(game)
yearcompleted = 0
yearbeaten = 0
yearendless = 0
yearunfinished = 0
yeartotal = len(yearbacklog)
if yeartotal > 0:
for game in yearbacklog:
try:
if game["completed"]:
yearcompleted += 1
except:
try:
if game["beaten"]:
yearbeaten += 1
except:
try:
if game["gameplay"]:
if game["id"] in endlessgames:
yearendless += 1
else:
yearunfinished += 1
except:
pass
yearunplayed = yeartotal - (yearcompleted + yearbeaten + yearunfinished + yearendless)
yeartakeup = 100
if yearunplayed > 0:
writeindex.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(200, 30%, 30%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(yeartakeup) + " 100\">\n </circle>\n")
yeartakeup = yeartakeup - round(((yearunplayed/yeartotal)*100),1)
if yearunfinished > 0:
writeindex.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(0, 38%, 35%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(yeartakeup) + " 100\">\n </circle>\n")
yeartakeup = yeartakeup - round(((yearunfinished/yeartotal)*100),1)
if yearbeaten > 0:
writeindex.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(0, 0%, 82%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(yeartakeup) + " 100\">\n </circle>\n")
yeartakeup = yeartakeup - round(((yearbeaten/yeartotal)*100),1)
if yearcompleted > 0:
writeindex.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(48, 75%, 70%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(yeartakeup) + " 100\">\n </circle>\n")
yeartakeup = yeartakeup - round(((yearcompleted/yeartotal)*100),1)
if yearendless > 0:
writeindex.write(" <circle id=\"circle\" r=\"15.91549430918954\" cy=\"21\" cx=\"21\" stroke-width=\"3\" stroke=\"hsla(275, 39%, 32%, 0.9)\" fill=\"transparent\" stroke-dasharray=\"" + str(yeartakeup) + " 100\">\n </circle>\n")
writeindex.write(" </svg>\n </div>\n </div>\n <div class=\"status-tally\">\n <div class=\"backlog-tally\">\n <div style=\"width: " + str(round(((backlog/total)*100),1)) + "%;\">")
if ((backlog/total)*100) > 50:
writeindex.write("\n <span>Active Backlog · " + str(backlog) + " · " + str(round(((backlog/total)*100),1)) + "%</span>")
writeindex.write("\n </div>\n <div style=\"width: " + str(100 - round(((backlog/total)*100),1)) + "%;\">")
if ((backlog/total)*100) <= 50:
writeindex.write("\n <span>Active Backlog · " + str(backlog) + " · " + str(round(((backlog/total)*100),1)) + "%</span>")
writeindex.write("\n </div>\n </div>\n")
compare = []
compare.append(unplayed)
compare.append(unfinished)
compare.append(beaten)
compare.append(completed)
compare.append(endless)
maxvalue = max(compare)
if unplayed / maxvalue > 0.5:
writeindex.write(" <a>\n <div>" + str(unplayed) + "</div>\n <div>\n <img src=\"UP.png\">\n </div>\n <div>\n <div class=\"Unplayed\" style=\"width: calc(100% * (" + str(unplayed) + " / " + str(maxvalue) + "));\">" + str(round(((unplayed/total)*100),1)) + "% Unplayed</div>\n </div>\n </a>\n")
else:
writeindex.write(" <a>\n <div>" + str(unplayed) + "</div>\n <div>\n <img src=\"UP.png\">\n </div>\n <div>\n <div class=\"Unplayed\" style=\"width: calc(100% * (" + str(unplayed) + " / " + str(maxvalue) + "));\">\n </div>\n <div class=\"borderless\">" + str(round(((unplayed/total)*100),1)) + "% Unplayed</div>\n </div>\n </a>\n")
if unfinished / maxvalue > 0.5:
writeindex.write(" <a>\n <div>" + str(unfinished) + "</div>\n <div>\n <img src=\"UF.png\">\n </div>\n <div>\n <div class=\"Unfinished\" style=\"width: calc(100% * (" + str(unfinished) + " / " + str(maxvalue) + "));\">" + str(round(((unfinished/total)*100),1)) + "% Unfinished</div>\n </div>\n </a>\n")
else:
writeindex.write(" <a>\n <div>" + str(unfinished) + "</div>\n <div>\n <img src=\"UF.png\">\n </div>\n <div>\n <div class=\"Unfinished\" style=\"width: calc(100% * (" + str(unfinished) + " / " + str(maxvalue) + "));\">\n </div>\n <div class=\"borderless\">" + str(round(((unfinished/total)*100),1)) + "% Unfinished</div>\n </div>\n </a>\n")
if beaten / maxvalue > 0.5:
writeindex.write(" <a>\n <div>" + str(beaten) + "</div>\n <div>\n <img src=\"B.png\">\n </div>\n <div>\n <div class=\"Beaten\" style=\"width: calc(100% * (" + str(beaten) + " / " + str(maxvalue) + "));\">" + str(round(((beaten/total)*100),1)) + "% Beaten</div>\n </div>\n </a>\n")
else:
writeindex.write(" <a>\n <div>" + str(beaten) + "</div>\n <div>\n <img src=\"B.png\">\n </div>\n <div>\n <div class=\"Beaten\" style=\"width: calc(100% * (" + str(beaten) + " / " + str(maxvalue) + "));\">\n </div>\n <div class=\"borderless\">" + str(round(((beaten/total)*100),1)) + "% Beaten</div>\n </div>\n </a>\n")
if completed / maxvalue > 0.5:
writeindex.write(" <a>\n <div>" + str(completed) + "</div>\n <div>\n <img src=\"C.png\">\n </div>\n <div>\n <div class=\"Completed\" style=\"width: calc(100% * (" + str(completed) + " / " + str(maxvalue) + "));\">" + str(round(((completed/total)*100),1)) + "% Completed</div>\n </div>\n </a>\n")
else:
writeindex.write(" <a>\n <div>" + str(completed) + "</div>\n <div>\n <img src=\"C.png\">\n </div>\n <div>\n <div class=\"Completed\" style=\"width: calc(100% * (" + str(completed) + " / " + str(maxvalue) + "));\">\n </div>\n <div class=\"borderless\">" + str(round(((completed/total)*100),1)) + "% Completed</div>\n </div>\n </a>\n")
if endless / maxvalue > 0.5:
writeindex.write(" <a>\n <div>" + str(endless) + "</div>\n <div>\n <img src=\"E.png\">\n </div>\n <div>\n <div class=\"Endless\" style=\"width: calc(100% * (" + str(endless) + " / " + str(maxvalue) + "));\">" + str(round(((endless/total)*100),1)) + "% Endless</div>\n </div>\n </a>\n")
else:
writeindex.write(" <a>\n <div>" + str(endless) + "</div>\n <div>\n <img src=\"E.png\">\n </div>\n <div>\n <div class=\"Endless\" style=\"width: calc(100% * (" + str(endless) + " / " + str(maxvalue) + "));\">\n </div>\n <div class=\"borderless\">" + str(round(((endless/total)*100),1)) + "% Endless</div>\n </div>\n </a>\n")
writeindex.write(" </div>\n </div>\n </div>")
# PLATFORM SUMMARY
writeindex.write(" <h1>Platform Summary</h1>\n <div class=\"platform-summary\">\n")
def liststats(title,abbr,consolelist):
completed = 0
beaten = 0
endless = 0
unfinished = 0
total = len(consolelist)
if total > 0:
writeindex.write(" <div class=\"platform-card\">\n <a class=\"title\">" + title + "</a>\n <a class=\"abbr\">" + abbr + "</a>\n <div class=\"bars\">\n")
for game in consolelist:
try:
if game["completed"]:
completed += 1
except:
try:
if game["beaten"]:
beaten += 1
except:
try:
if game["gameplay"]:
if game["id"] in endlessgames:
endless += 1
else:
unfinished += 1
except:
pass
unplayed = total - (completed + beaten + unfinished + endless)
if unplayed > 0:
writeindex.write(" <a class=\"unplayed\" title=\"Unplayed\" style=\"flex: " + str(unplayed) + " 1 0%;\">" + str(unplayed) + "</a>\n")
if unfinished > 0:
writeindex.write(" <a class=\"unfinished\" title=\"Unfinished\" style=\"flex: " + str(unfinished) + " 1 0%;\">" + str(unfinished) + "</a>\n")
if beaten > 0:
writeindex.write(" <a class=\"beaten\" title=\"Beaten\" style=\"flex: " + str(beaten) + " 1 0%;\">" + str(beaten) + "</a>\n")
if completed > 0:
writeindex.write(" <a class=\"completed\" title=\"Completed\" style=\"flex: " + str(completed) + " 1 0%;\">" + str(completed) + "</a>\n")
if endless > 0:
writeindex.write(" <a class=\"endless\" title=\"Endless\" style=\"flex: " + str(endless) + " 1 0%;\">" + str(endless) + "</a>\n")
writeindex.write(" </div>\n <a class=\"total\">" + str(total) + "\n <span>Total</span>\n </a>\n </div>\n")
liststats("Nintendo DS","DS",dslist)
liststats("Nintendo 3DS","3DS",threedslist)
liststats("Nintendo Switch","Switch",switchlist)
liststats("PC","PC",pclist)
liststats("PlayStation 2","PS2",ps2list)
liststats("PlayStation 3","PS3",ps3list)
liststats("PlayStation 5","PS5",ps5list)
liststats("Xbox 360","Xbox360",xbox360list)
writeindex.write(" </div>\n </div>\n </section>\n </section>\n </main>\n </div>\n </div>\n </body>\n</html>\n")
# LIBRARY
writelibrary.write("<!DOCTYPE html>\n<html lang=\"en\" style=\"--active-base: #364563; --active-text: #FFFFFF; --active-text-50: #FFFFFF60; --active-text-25: #FFFFFF30; --active-secondary: #222a3a; --active-secondary-50: #222a3a80; --active-secondary-text: #FFFFFF; --active-secondary-text-50: #FFFFFF70; --active-secondary-text-25: #FFFFFF30; --active-accent: #00fffb; --active-accent-75: #00fffbc0; --active-accent-text: #000000DD; --beaten-color: hsla(0, 0%, 82%, 0.9); --completed-color: hsla(48, 80%, 82%, 0.9); --unplayed-color: hsla(200, 30%, 30%, 0.9); --unfinished-color: hsla(0, 38%, 35%, 0.9); --endless-color: hsla(275, 39%, 32%, 0.9); --platform-bw: none; --active-accent-shadow: #FFFFFF66; --retro-border: url('/img/border.png');\">\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n <meta name=\"theme-color\" content=\"#364563\">\n <link href=\"https://fonts.googleapis.com/icon?family=Material+Icons\" rel=\"stylesheet\">\n <link href=\"https://fonts.googleapis.com/css?family=Lato|Teko|Titillium+Web\" rel=\"stylesheet\">\n <title>Selfhostery etc.</title>\n <link href=\"backloggery.css\" rel=\"stylesheet\">\n </head>\n <body>\n <div id=\"app\">\n <div class=\"profile\">\n <main>\n <section>\n <div class=\"tabs\">\n <a href=\"backlog.html\" class=\"\">Backlog</a>\n <a href=\"\" class=\"router-link-exact-active router-link-active\" style=\"\" aria-current=\"page\">Library</a>\n <a href=\"\" class=\"\">History</a>\n </div>\n <section id=\"library-top\" class=\"library\">\n <div>\n <div class=\"unibar\">\n <div>\n <span>Total Found</span> " + str(total) + "\n </div>\n")
if unplayed > 0:
writelibrary.write(" <div class=\"unplayed\" style=\"flex: " + str(unplayed) + " 1 0%;\">" + str(unplayed) + "</div>\n")
if unfinished > 0:
writelibrary.write(" <div class=\"unfinished\" style=\"flex: " + str(unfinished) + " 1 0%;\">" + str(unfinished) + "</div>\n")
if beaten > 0:
writelibrary.write(" <div class=\"beaten\" style=\"flex: " + str(beaten) + " 1 0%;\">" + str(beaten) + "</div>\n")
if completed > 0:
writelibrary.write(" <div class=\"completed\" style=\"flex: " + str(completed) + " 1 0%;\">" + str(completed) + "</div>\n")
if endless > 0:
writelibrary.write(" <div class=\"endless\" style=\"flex: " + str(endless) + " 1 0%;\">" + str(endless) + "</div>\n")
writelibrary.write(" </div>\n <div class=\"library-list sorted\">\n")
newgames = sorted(games,key=lambda d: d["id"])
decay = False
for game in newgames:
playcard(game,"library")
# HISTORY
theyear = int(thisyear)
while theyear > 2016:
added = 0
started = 0
beat = 0
completed = 0
beatorcompleted = 0
for game in games:
if game["initialdate"].year == theyear:
added += 1
try:
if game["firstplayed"].year == theyear:
started += 1
except:
pass
try:
if game["beaten"].year == theyear:
beat += 1
beatorcompleted += 1
try:
if game["completed"].year == theyear:
completed += 1
except:
pass
except:
try:
if game["completed"].year == theyear:
completed += 1
beatorcompleted += 1
except:
pass
backlog = added - beatorcompleted
print(str(theyear) + " Summary")
if backlog > 0:
print("Backlog ▲ " + str(backlog))
elif backlog == 0:
print("Backlog 0")
elif backlog < 0:
print("Backlog ▼ " + str(backlog * -1))
print("Added " + str(added))
print("Started " + str(started))
print("Beat " + str(beat))
print("Completed " + str(completed))
yearlist = []
enddate = datetime.strptime((str(theyear) + "-12-31"),"%Y-%m-%d")
startdate = datetime.strptime((str(theyear) + "-01-01"),"%Y-%m-%d")
eachdate = enddate
while eachdate >= startdate:
for game in games:
if game["initialdate"] == eachdate:
yearlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Added"})
try:
if game["firstplayed"] == eachdate:
yearlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Started"})
except:
pass
try:
if game["beaten"] == eachdate:
yearlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Beat"})
except:
pass
try:
if game["completed"] == eachdate:
yearlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Completed"})
except:
pass
eachdate -= timedelta(days=1)
checkdate = enddate
for event in yearlist:
if checkdate != event["date"]:
print(event["date"].strftime("%Y-%-m-%-d"))
print(event["action"] + ": " + event["name"] + " (" + event["console"] + ")")
checkdate = event["date"]
theyear -= 1

@ -0,0 +1,187 @@
import orgparse,os,re,variables
from pathlib import Path
from datetime import datetime
"""
Load in the list of games from a set of .org files.
"""
home = str(Path.home())
thisyear = datetime.now().strftime("%Y")
year = 2016
concernedfiles = []
while year < int(thisyear) + 1:
month = 0
while month < 13:
if month < 10:
strmonth = "0" + str(month)
else:
strmonth = str(month)
recdir = str(year) + "/" + strmonth + "/"
fullpath = variables.orgpath + recdir
if os.path.exists(fullpath):
for file in sorted(os.listdir(fullpath)):
filename = fullpath + str(file)
if filename.endswith(".org"):
concernedfiles.append(filename)
month = month + 1
year = year + 1
games = []
gamenames = []
holding = []
for file in concernedfiles:
filedate = file[-14:-4]
dateobj = datetime.strptime(filedate,"%Y-%m-%d")
parsefile = orgparse.load(file)
try:
for node in parsefile.children:
if node.heading == "games":
for action in node.children:
for game in action.children:
name = re.sub(" \(.*\)","",game.heading)
if game.heading not in gamenames:
status = "new"
gamenames.append(game.heading)
else:
status = "existing"
console = (re.findall("\(.*\)",game.heading)[0])[1:-1]
if status == "new":
thedict = {"id":game.heading,"name":name,"initialdate":dateobj,"console":console,game.parent.heading:dateobj,"recent":game.body,"lastupdate":dateobj}
if game.parent.heading != "acquired":
thedict.update({"firstplayed":dateobj})
games.append(thedict)
else:
twodict = {"id":game.heading,game.parent.heading:dateobj,"lastupdate":dateobj}
if len(game.body) > 1:
twodict.update({"recent":game.body})
for origgame in games:
if twodict["id"] == origgame["id"]:
try:
if origgame["firstplayed"]:
playedbefore = True
except:
playedbefore = False
if playedbefore == False:
twodict.update({"firstplayed":dateobj})
holding.append(twodict)
for gameupdate in holding:
for origgame in games:
if gameupdate["id"] == origgame["id"]:
gamemerge = {**origgame, **gameupdate}
games.remove(origgame)
games.insert(0,gamemerge)
holding.remove(gameupdate)
except:
pass
games = sorted(games,key=lambda d: d["lastupdate"])
consolelists = []
for console in variables.consoles:
consolegames = []
for game in games:
if game["console"] == console["code"]:
consolegames.append(game)
consolelists.append({"code":console["code"],"name":console["name"],"games":consolegames})
def completed(selection):
completed = 0
for game in selection:
try:
if game["completed"]:
completed += 1
except:
pass
return completed
def beaten(selection):
beaten = 0
for game in selection:
try:
if game["completed"]:
pass
except:
try:
if game["beaten"]:
beaten += 1
except:
pass
return beaten
def endless(selection):
endless = 0
for game in selection:
try:
if game["completed"]:
pass
except:
try:
if game["beaten"]:
pass
except:
try:
if game["gameplay"]:
if game["id"] in variables.endlessgames:
endless += 1
except:
pass
return(endless)
def unfinished(selection):
unfinished = 0
for game in selection:
try:
if game["completed"]:
pass
except:
try:
if game["beaten"]:
pass
except:
try:
if game["gameplay"]:
if game["id"] not in variables.endlessgames:
unfinished += 1
except:
pass
return(unfinished)
def total(selection):
return len(selection)
def unplayed(selection):
unplayed = total(selection) - (completed(selection) + beaten(selection) + unfinished(selection) + endless(selection))
return(unplayed)
# completed = 0
# beaten = 0
# endless = 0
# unfinished = 0
# total = len(games)
# if total > 0:
# for game in games:
# try:
# if game["completed"]:
# completed += 1
# except:
# try:
# if game["beaten"]:
# beaten += 1
# except:
# try:
# if game["gameplay"]:
# if game["id"] in variables.endlessgames:
# endless += 1
# else:
# unfinished += 1
# except:
# pass
# unplayed = total - (completed + beaten + unfinished + endless)
if __name__ == "__main__":
print(endless(games))

@ -0,0 +1,23 @@
import sys
import backlog
import library
import sublibrary
try:
if sys.argv[1] == "local":
local = True
else:
local = False
except:
local = False
if __name__ == "__main__":
if local == True:
backlog.backlog(True)
library.library(True)
sublibrary.sublibrary(True)
else:
backlog.backlog()
library.library()
sublibrary.sublibrary()

@ -0,0 +1,97 @@
import os
import gamesort,skeleton
from datetime import datetime,timedelta
"""
Generates history page
"""
def history(local=False):
# delete existing file
if os.path.exists("build/history/index.html"):
os.remove("build/history/index.html")
# write header
skeleton.headerwrite("build/history/index.html","history",local)
output = "build/history/index.html"
filewrite = open(output, "a")
theyear = int(gamesort.thisyear)
while theyear > 2016:
added = 0
started = 0
beat = 0
completed = 0
beatorcompleted = 0
for game in gamesort.games:
if game["initialdate"].year == theyear:
added += 1
try:
if game["firstplayed"].year == theyear:
started += 1
except:
pass
try:
if game["beaten"].year == theyear:
beat += 1
beatorcompleted += 1
try:
if game["completed"].year == theyear:
completed += 1
except:
pass
except:
try:
if game["completed"].year == theyear:
completed += 1
beatorcompleted += 1
except:
pass
backlog = added - beatorcompleted
print(str(theyear) + " Summary")
if backlog > 0:
print("Backlog ▲ " + str(backlog))
elif backlog == 0:
print("Backlog 0")
elif backlog < 0:
print("Backlog ▼ " + str(backlog * -1))
print("Added " + str(added))
print("Started " + str(started))
print("Beat " + str(beat))
print("Completed " + str(completed))
yearlist = []
enddate = datetime.strptime((str(theyear) + "-12-31"),"%Y-%m-%d")
startdate = datetime.strptime((str(theyear) + "-01-01"),"%Y-%m-%d")
eachdate = enddate
while eachdate >= startdate:
for game in gamesort.games:
if game["initialdate"] == eachdate:
yearlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Added"})
try:
if game["firstplayed"] == eachdate:
yearlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Started"})
except:
pass
try:
if game["beaten"] == eachdate:
yearlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Beat"})
except:
pass
try:
if game["completed"] == eachdate:
yearlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Completed"})
except:
pass
eachdate -= timedelta(days=1)
checkdate = enddate
for event in yearlist:
if checkdate != event["date"]:
print(event["date"].strftime("%Y-%m-%d"))
print(event["action"] + ": " + event["name"] + " (" + event["console"] + ")")
checkdate = event["date"]
theyear -= 1
filewrite.close()
skeleton.footerwrite("build/history/index.html")
if __name__ == "__main__":
history(True)

@ -0,0 +1,40 @@
import os
import cardstring,gamesort,skeleton
"""
Generates library page
"""
def library(local=False):
# delete existing file
if not os.path.isdir("build/library"):
os.mkdir("build/library")
if os.path.exists("build/library/index.html"):
os.remove("build/library/index.html")
# write header
skeleton.headerwrite("build/library/index.html","library",local)
output = "build/library/index.html"
filewrite = open(output, "a")
filewrite.write(" <section id=\"library-top\" class=\"library\">\n <div>\n <div class=\"unibar\">\n <div>\n <span>Total Found</span> " + str(gamesort.total(gamesort.games)) + "\n </div>\n")
if gamesort.unplayed(gamesort.games) > 0:
filewrite.write(" <div class=\"unplayed\" style=\"flex: " + str(gamesort.unplayed(gamesort.games)) + " 1 0%;\">" + str(gamesort.unplayed(gamesort.games)) + "</div>\n")
if gamesort.unfinished(gamesort.games) > 0:
filewrite.write(" <div class=\"unfinished\" style=\"flex: " + str(gamesort.unfinished(gamesort.games)) + " 1 0%;\">" + str(gamesort.unfinished(gamesort.games)) + "</div>\n")
if gamesort.beaten(gamesort.games) > 0:
filewrite.write(" <div class=\"beaten\" style=\"flex: " + str(gamesort.beaten(gamesort.games)) + " 1 0%;\">" + str(gamesort.beaten(gamesort.games)) + "</div>\n")
if gamesort.completed(gamesort.games) > 0:
filewrite.write(" <div class=\"completed\" style=\"flex: " + str(gamesort.completed(gamesort.games)) + " 1 0%;\">" + str(gamesort.completed(gamesort.games)) + "</div>\n")
if gamesort.endless(gamesort.games) > 0:
filewrite.write(" <div class=\"endless\" style=\"flex: " + str(gamesort.endless(gamesort.games)) + " 1 0%;\">" + str(gamesort.endless(gamesort.games)) + "</div>\n")
filewrite.write(" </div>\n <div class=\"library-list sorted\">\n")
newgames = sorted(gamesort.games,key=lambda d: d["id"])
for game in newgames:
filewrite.write(cardstring.playcard(game,local))
filewrite.close()
skeleton.footerwrite("build/library/index.html")
if __name__ == "__main__":
library(True)

@ -0,0 +1,55 @@
import variables
from pathlib import Path
"""
Generate the skeleton for an HTML page.
"""
home = str(Path.home())
def headerwrite(output,section,local=False):
header = open(output, "a")
header.write("<!DOCTYPE html>\n<html lang=\"en\" style=\"--active-base: #364563; --active-text: #FFFFFF; --active-text-50: #FFFFFF60; --active-text-25: #FFFFFF30; --active-secondary: #222a3a; --active-secondary-50: #222a3a80; --active-secondary-text: #FFFFFF; --active-secondary-text-50: #FFFFFF70; --active-secondary-text-25: #FFFFFF30; --active-accent: #00fffb; --active-accent-75: #00fffbc0; --active-accent-text: #000000DD; --beaten-color: hsla(0, 0%, 82%, 0.9); --completed-color: hsla(48, 80%, 82%, 0.9); --unplayed-color: hsla(200, 30%, 30%, 0.9); --unfinished-color: hsla(0, 38%, 35%, 0.9); --endless-color: hsla(275, 39%, 32%, 0.9); --platform-bw: none; --active-accent-shadow: #FFFFFF66; --retro-border: url('/img/border.png');\">\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n <meta name=\"theme-color\" content=\"#364563\">\n <link href=\"https://fonts.googleapis.com/icon?family=Material+Icons\" rel=\"stylesheet\">\n <link href=\"https://fonts.googleapis.com/css?family=Lato|Teko|Titillium+Web\" rel=\"stylesheet\">\n <title>Selfhostery</title>\n <link href=\"")
if local:
header.write(variables.localpath + "build/")
else:
header.write(variables.serverpath)
header.write("backloggery.css\" rel=\"stylesheet\">\n </head>\n <body>\n <div id=\"app\">\n <div class=\"profile\">\n <aside>\n <div>\n <div id=\"about_note\">\n <h2>About</h2>\n <div class=\"markdown\">" + variables.description + "</div>\n </div>\n </div>\n </aside>\n <main>\n <section>\n <div class=\"tabs\">\n")
header.write(" <a href=\"")
if section == "backlog":
header.write("\" class=\"router-link-exact-active router-link-active\" aria-current=\"page")
else:
if local:
header.write(variables.localpath + "build/backlog/index.html")
else:
header.write(variables.serverpath + "backlog")
header.write("\">Backlog</a>\n <a ")
if section == "library":
header.write("class=\"router-link-exact-active router-link-active\" aria-current=\"page\" href=\"")
else:
if section == "sublibrary":
header.write("class=\"router-link-active\" aria-current=\"page\" ")
header.write("href=\"")
if local:
header.write(variables.localpath + "build/library/index.html")
else:
header.write(variables.serverpath + "library")
header.write("\">Library</a>\n <a href=\"")
if section == "history":
header.write("\" class=\"router-link-exact-active router-link-active\" aria-current=\"page")
else:
if local:
header.write(variables.localpath + "build/history/index.html")
else:
header.write(variables.serverpath + "history")
header.write("\">History</a>\n </div>\n")
header.close()
def footerwrite(output):
footer = open(output, "a")
footer.write(" </section>\n </main>\n </div>\n </div>\n </body>\n</html>\n")
footer.close()
if __name__ == "__main__":
headerwrite("build/backlog/index.html","backlog",True)
footerwrite("test.html")

@ -0,0 +1,151 @@
import os
import cardstring,gamesort,skeleton,variables
from pathlib import Path
"""
Generates sublibrary pages
"""
home = str(Path.home())
def sublibrary(local=False):
statuses = ["all","completed","beaten","unfinished","endless","unplayed"]
consoleextra = [{"shortname":"all"}]
consolesplus = variables.consoles + consoleextra
for console in consolesplus:
gameslist = []
for game in gamesort.games:
if console["shortname"] == "all":
gameslist.append(game)
elif game["console"] == console["code"]:
gameslist.append(game)
for status in statuses:
filterlist = []
if status == "all":
for game in gameslist:
filterlist.append(game)
elif status == "completed":
for game in gameslist:
try:
if game["completed"]:
filterlist.append(game)
except:
pass
elif status == "beaten":
for game in gameslist:
try:
if game["completed"]:
pass
except:
try:
if game["beaten"]:
filterlist.append(game)
except:
pass
elif status == "unfinished":
for game in gameslist:
try:
if game["completed"]:
pass
except:
try:
if game["beaten"]:
pass
except:
try:
if game["gameplay"]:
if game["id"] not in variables.endlessgames:
filterlist.append(game)
except:
pass
elif status == "endless":
for game in gameslist:
try:
if game["completed"]:
pass
except:
try:
if game["beaten"]:
pass
except:
try:
if game["gameplay"]:
if game["id"] in variables.endlessgames:
filterlist.append(game)
except:
pass
elif status == "unplayed":
for game in gameslist:
try:
if game["completed"]:
pass
except:
try:
if game["beaten"]:
pass
except:
try:
if game["gameplay"]:
pass
except:
filterlist.append(game)
if not os.path.isdir("build/library/" + console["shortname"].lower() + "-" + status):
if len(filterlist) > 0:
os.mkdir("build/library/" + console["shortname"].lower() + "-" + status)
if os.path.exists("build/library/" + console["shortname"].lower() + "-" + status + "/index.html"):
os.remove("build/library/" + console["shortname"].lower() + "-" + status + "/index.html")
# write header
if len(filterlist) > 0:
skeleton.headerwrite(("build/library/" + console["shortname"].lower() + "-" + status + "/index.html"),"sublibrary",local)
output = "build/library/" + console["shortname"].lower() + "-" + status + "/index.html"
filewrite = open(output, "a")
filewrite.write(" <section id=\"library-top\" class=\"library\">\n <div>\n <div class=\"filters\">\n <div>Filtered by\n")
if console["shortname"] != "all":
filewrite.write(" <span class=\"item\"><a href=\"")
if status == "all":
if local:
filewrite.write(variables.localpath + "build/library/index.html")
else:
filewrite.write(variables.serverpath + "library")
else:
if local:
filewrite.write(variables.localpath + "build/library/all-" + status + "/index.html")
else:
filewrite.write(variables.serverpath + "library/all-" + status)
filewrite.write("\">1 Platform</a></span>\n")
if status != "all":
filewrite.write(" <span class=\"item\"><a href=\"")
if console["shortname"] == "all":
if local:
filewrite.write(variables.localpath + "build/library/index.html")
else:
filewrite.write(variables.serverpath + "library")
else:
if local:
filewrite.write(variables.localpath + "build/library/" + console["shortname"].lower() + "-all/index.html")
else:
filewrite.write(variables.serverpath + "library/" + console["shortname"].lower() + "-all")
filewrite.write("\">1 Status</a></span>\n")
filewrite.write(" </div>\n</div> <div class=\"unibar\">\n <div>\n <span>Total Found</span> " + str(gamesort.total(filterlist)) + "\n </div>\n")
if gamesort.unplayed(filterlist) > 0:
filewrite.write(" <div class=\"unplayed\" style=\"flex: " + str(gamesort.unplayed(filterlist)) + " 1 0%;\">" + str(gamesort.unplayed(filterlist)) + "</div>\n")
if gamesort.unfinished(filterlist) > 0:
filewrite.write(" <div class=\"unfinished\" style=\"flex: " + str(gamesort.unfinished(filterlist)) + " 1 0%;\">" + str(gamesort.unfinished(filterlist)) + "</div>\n")
if gamesort.beaten(filterlist) > 0:
filewrite.write(" <div class=\"beaten\" style=\"flex: " + str(gamesort.beaten(filterlist)) + " 1 0%;\">" + str(gamesort.beaten(filterlist)) + "</div>\n")
if gamesort.completed(filterlist) > 0:
filewrite.write(" <div class=\"completed\" style=\"flex: " + str(gamesort.completed(filterlist)) + " 1 0%;\">" + str(gamesort.completed(filterlist)) + "</div>\n")
if gamesort.endless(filterlist) > 0:
filewrite.write(" <div class=\"endless\" style=\"flex: " + str(gamesort.endless(filterlist)) + " 1 0%;\">" + str(gamesort.endless(filterlist)) + "</div>\n")
filewrite.write(" </div>\n <div class=\"library-list sorted\">\n")
newgames = sorted(filterlist,key=lambda d: d["id"])
for game in newgames:
filewrite.write(cardstring.playcard(game,local))
filewrite.close()
skeleton.footerwrite("build/library/" + console["shortname"].lower() + "-" + status + "/index.html")
if __name__ == "__main__":
sublibrary(True)

@ -0,0 +1,22 @@
"""
User-defined variables live here.
"""
endlessgames = []
orgpath = ""
localpath = ""
serverpath = ""
description = ""
consoles = [{"code":"ps5","name":"PlayStation 5","shortname":"PS5","img":"PS5"},
{"code":"ps2","name":"PlayStation 2","shortname":"PS2","img":"PS2"},
{"code":"ps3","name":"PlayStation 3","shortname":"PS3","img":"PS3"},
{"code":"xbox 360","name":"Xbox 360","shortname":"Xbox360","img":"360"},
{"code":"nintendo ds","name":"Nintendo DS","shortname":"DS","img":"NDS"},
{"code":"nintendo 3ds","name":"Nintendo 3DS","shortname":"3DS","img":"3DS"},
{"code":"nintendo switch","name":"Nintendo Switch","shortname":"Switch","img":"Switch"},
{"code":"pc","name":"PC","shortname":"PC","img":"PC"}]
Loading…
Cancel
Save