Compare commits

...

10 commits

35 changed files with 575 additions and 210 deletions

9
.gitignore vendored
View file

@ -1,6 +1,9 @@
__pycache__/
build.sh
build/*
!build/*.css
!build/*.png
gamebuild/*
!gamebuild/*.css
!gamebuild/*.png
placebuild/*
!placebuild/.gitkeep
recordbuild/index.html
variables.py

View file

@ -1,28 +1,67 @@
#+TITLE: Trackers
* About
The scripts in this repository build static webpages based on information from two sources:
- a structured set of =.org= files;
- APIs of selected third-party websites (so far: Discogs).
These pages can be used as a replacement for third-party services e.g. Backloggery.
* Dependencies
- =python3=
- =orgparse= (install via pip)
- =python3=
- =rclone= (for syncing to the server)
- =geopy= if you are tracking places visited (install via pip)
- =python3-discogs-client= if you are displaying a record collection (install via pip)
* General setup
** Structure of the .org files
See =demo.org= for an example.
** Setting the variables
Copy =variables-template.py= to =variables.py= and edit:
- =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
- =domain=: =https://yourdomain.tld= without trailing slash
- =rclonesiteroot=: path =rclone= uses to access your webserver
* Tracking games with a backloggery clone
** Setup
*** Fonts
Upload the fonts Lato, Titillium Web, and Material Icons to the directory =/fonts= on your server (I recommend [[https://gwfh.mranftl.com/fonts][google-webfonts-helper]]). Check the filenames are consistent with those in =build/backloggery.css=. Alternatively, you can load the fonts remotely and adjust the page head HTML generated by =skeleton.py=.
Upload the fonts Lato, Titillium Web, and Material Icons to the directory =/fonts= on your server (I recommend [[https://gwfh.mranftl.com/fonts][google-webfonts-helper]]). Check the filenames are consistent with those in =gamebuild/backloggery.css=. Alternatively, you can load the fonts remotely and adjust the page head HTML generated by =gameskel.py=.
*** Setting the variables
Rename =variables-template.py= to =variables.py= and edit:
In =variables.py=, edit:
- =trackgames=: set to =True=
- =gameserverpath=: path to directory on the server where files will be uploaded, including trailing slash
- =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
- =domain=: =https://yourdomain.tld= without trailing slash
- =rclonesiteroot=: path =rclone= uses to access your webserver
- =description=: content for the “about” section (can include HTML tags)
- =startyear=: year from which to begin tracking (an integer)
- =hue=: theme colour expressed as a hue from 0 to 360
- =gamestartyear=: year from which to begin tracking (an integer)
- =gamehue=: theme colour expressed as a hue from 0 to 360
- =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)
*** The rest
** Testing
- Run =python3 generategames.py local= to build in =gamebuild=.
* Tracking places visited using Leaflet
** Setup
Upload a CSS file to the server if necessary. Most CSS is set by Leaflet.
*** Setting the variables
In =variables.py=, edit:
- =trackplaces=: set to =True=
- =placeserverpath=: path to directory on the server where files will be uploaded, including trailing slash
- =placestartyear=: year from which to begin tracking (an integer)
- =placecss=: location of the CSS file you wish to apply, relative to the site root
** Testing
- Run =python3 generateplaces.py local= to build in =placebuild=. (This may take some time.)
- Check whether places are displayed accurately in the output file. If not, add regions/countries to disambiguate any incorrectly displayed places to the =disambig= dictionary in =variables.py= (see examples).
* Displaying a record collection (taking data from Discogs)
** Setup
- Upload a CSS file to the server for styling fonts etc; most CSS is set inline.
- Get a Discogs API token [[https://www.discogs.com/settings/developers][here]].
*** Setting the variables
In =variables.py=, edit:
- =trackrecords=: set to =True=
- =recordserverpath=: path to directory on the server where files will be uploaded, including trailing slash
- =recordcss=: location of the CSS file you wish to apply, relative to the site root
- =discogstoken=: the API token you generated
- =discogsuser=: your Discogs username
** Testing
- Run =python3 generaterecords.py local= to build in =recordbuild=.
* First run (or if adding any new trackers)
- Run =python3 init.py= and then =chmod +x build.sh=.
- Create the directory on the server.
** Generating the files
- Run =python3 generate.py local= to build in the local =build= directory.
- Create directories on the server corresponding to any =*serverpath= variables you have set.
* Building
- Run =./build.sh= to build and upload to the server.

View file

@ -1,5 +1,5 @@
import os
import cardstring,gamesort,skeleton,variables
import cardstring,gamesort,gameskel,variables
from pathlib import Path
from datetime import datetime,timedelta
@ -11,13 +11,13 @@ 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")
if not os.path.isdir("gamebuild/backlog"):
os.mkdir("gamebuild/backlog")
if os.path.exists("gamebuild/backlog/index.html"):
os.remove("gamebuild/backlog/index.html")
# write header
skeleton.headerwrite("build/backlog/index.html","backlog",local)
output = "build/backlog/index.html"
gameskel.headerwrite("gamebuild/backlog/index.html","backlog",local)
output = "gamebuild/backlog/index.html"
filewrite = open(output, "a")
filewrite.write(" <section>\n <div>\n <h1>Now Playing</h1>\n <div class=\"now-playing\">\n")
playingnow = []
@ -65,9 +65,9 @@ def backlog(local=False):
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")
filewrite.write(variables.localpath + "gamebuild/library/index.html")
else:
filewrite.write(variables.serverpath + "library")
filewrite.write(variables.gameserverpath + "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)
@ -110,9 +110,9 @@ def backlog(local=False):
filewrite.write(" </a></svg>\n </div>\n <div class=\"donut\">\n <svg viewBox=\"0 0 42 42\">\n <a href=\"")
if local:
filewrite.write(variables.localpath + "build/history/index.html")
filewrite.write(variables.localpath + "gamebuild/history/index.html")
else:
filewrite.write(variables.serverpath + "history")
filewrite.write(variables.gameserverpath + "history")
filewrite.write("\"><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:
@ -194,126 +194,126 @@ def backlog(local=False):
if gamesort.unplayed(gamesort.games) / maxvalue > 0.5:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "build/library/all-unplayed/index.html")
filewrite.write(variables.localpath + "gamebuild/library/all-unplayed/index.html")
else:
filewrite.write(variables.serverpath + "library/all-unplayed")
filewrite.write(variables.gameserverpath + "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/")
filewrite.write(variables.localpath + "gamebuild/")
else:
filewrite.write(variables.serverpath)
filewrite.write(variables.gameserverpath)
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")
filewrite.write(variables.localpath + "gamebuild/library/all-unplayed/index.html")
else:
filewrite.write(variables.serverpath + "library/all-unplayed")
filewrite.write(variables.gameserverpath + "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/")
filewrite.write(variables.localpath + "gamebuild/")
else:
filewrite.write(variables.serverpath)
filewrite.write(variables.gameserverpath)
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")
filewrite.write(variables.localpath + "gamebuild/library/all-unfinished/index.html")
else:
filewrite.write(variables.serverpath + "library/all-unfinished")
filewrite.write(variables.gameserverpath + "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/")
filewrite.write(variables.localpath + "gamebuild/")
else:
filewrite.write(variables.serverpath)
filewrite.write(variables.gameserverpath)
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")
filewrite.write(variables.localpath + "gamebuild/library/all-unfinished/index.html")
else:
filewrite.write(variables.serverpath + "library/all-unfinished")
filewrite.write(variables.gameserverpath + "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/")
filewrite.write(variables.localpath + "gamebuild/")
else:
filewrite.write(variables.serverpath)
filewrite.write(variables.gameserverpath)
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")
filewrite.write(variables.localpath + "gamebuild/library/all-beaten/index.html")
else:
filewrite.write(variables.serverpath + "library/all-beaten")
filewrite.write(variables.gameserverpath + "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/")
filewrite.write(variables.localpath + "gamebuild/")
else:
filewrite.write(variables.serverpath)
filewrite.write(variables.gameserverpath)
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")
filewrite.write(variables.localpath + "gamebuild/library/all-beaten/index.html")
else:
filewrite.write(variables.serverpath + "library/all-beaten")
filewrite.write(variables.gameserverpath + "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/")
filewrite.write(variables.localpath + "gamebuild/")
else:
filewrite.write(variables.serverpath)
filewrite.write(variables.gameserverpath)
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")
filewrite.write(variables.localpath + "gamebuild/library/all-completed/index.html")
else:
filewrite.write(variables.serverpath + "library/all-completed")
filewrite.write(variables.gameserverpath + "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/")
filewrite.write(variables.localpath + "gamebuild/")
else:
filewrite.write(variables.serverpath)
filewrite.write(variables.gameserverpath)
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")
filewrite.write(variables.localpath + "gamebuild/library/all-completed/index.html")
else:
filewrite.write(variables.serverpath + "library/all-completed")
filewrite.write(variables.gameserverpath + "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/")
filewrite.write(variables.localpath + "gamebuild/")
else:
filewrite.write(variables.serverpath)
filewrite.write(variables.gameserverpath)
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")
filewrite.write(variables.localpath + "gamebuild/library/all-endless/index.html")
else:
filewrite.write(variables.serverpath + "library/all-endless")
filewrite.write(variables.gameserverpath + "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/")
filewrite.write(variables.localpath + "gamebuild/")
else:
filewrite.write(variables.serverpath)
filewrite.write(variables.gameserverpath)
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")
filewrite.write(variables.localpath + "gamebuild/library/all-endless/index.html")
else:
filewrite.write(variables.serverpath + "library/all-endless")
filewrite.write(variables.gameserverpath + "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/")
filewrite.write(variables.localpath + "gamebuild/")
else:
filewrite.write(variables.serverpath)
filewrite.write(variables.gameserverpath)
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")
@ -337,14 +337,14 @@ def backlog(local=False):
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")
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-all/index.html")
else:
filewrite.write(variables.serverpath + "library/" + console["shortname"].lower() + "-all")
filewrite.write(variables.gameserverpath + "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")
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-all/index.html")
else:
filewrite.write(variables.serverpath + "library/" + console["shortname"].lower() + "-all")
filewrite.write(variables.gameserverpath + "library/" + console["shortname"].lower() + "-all")
filewrite.write("\"class=\"abbr\">" + console["shortname"] + "</a>\n <div class=\"bars\">\n")
for game in consolegames:
try:
@ -367,47 +367,47 @@ def backlog(local=False):
if cunplayed > 0:
filewrite.write(" <a href=\"")
if local:
filewrite.write(variables.localpath + "build/library/" + console["shortname"].lower() + "-unplayed/index.html")
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-unplayed/index.html")
else:
filewrite.write(variables.serverpath + "library/" + console["shortname"].lower() + "-unplayed")
filewrite.write(variables.gameserverpath + "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")
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-unfinished/index.html")
else:
filewrite.write(variables.serverpath + "library/" + console["shortname"].lower() + "-unfinished")
filewrite.write(variables.gameserverpath + "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")
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-beaten/index.html")
else:
filewrite.write(variables.serverpath + "library/" + console["shortname"].lower() + "-beaten")
filewrite.write(variables.gameserverpath + "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")
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-completed/index.html")
else:
filewrite.write(variables.serverpath + "library/" + console["shortname"].lower() + "-completed")
filewrite.write(variables.gameserverpath + "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")
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-endless/index.html")
else:
filewrite.write(variables.serverpath + "library/" + console["shortname"].lower() + "-endless")
filewrite.write(variables.gameserverpath + "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")
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-all/index.html")
else:
filewrite.write(variables.serverpath + "library/" + console["shortname"].lower() + "-all")
filewrite.write(variables.gameserverpath + "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")
gameskel.footerwrite("gamebuild/backlog/index.html")
if __name__ == "__main__":
backlog(True)

View file

@ -15,27 +15,27 @@ def playcard(game,local=False,decay=False):
if game["console"] == console["code"]:
cardstring += " <img src=\""
if local:
cardstring += variables.localpath + "build/"
cardstring += variables.localpath + "gamebuild/"
else:
cardstring += variables.serverpath
cardstring += variables.gameserverpath
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/"
cardstring += variables.localpath + "gamebuild/"
else:
cardstring += variables.serverpath
cardstring += variables.gameserverpath
cardstring += "C.png\" alt=\"C\" title=\"Completed\">\n"
except:
try:
if game["beaten"]:
cardstring += " <img src=\""
if local:
cardstring += variables.localpath + "build/"
cardstring += variables.localpath + "gamebuild/"
else:
cardstring += variables.serverpath
cardstring += variables.gameserverpath
cardstring += "B.png\" alt=\"B\" title=\"Beaten\">\n"
except:
try:
@ -43,23 +43,23 @@ def playcard(game,local=False,decay=False):
if game["id"] in variables.endlessgames:
cardstring += " <img src=\""
if local:
cardstring += variables.localpath + "build/"
cardstring += variables.localpath + "gamebuild/"
else:
cardstring += variables.serverpath
cardstring += variables.gameserverpath
cardstring += "E.png\" alt=\"E\" title=\"Endless\">\n"
else:
cardstring += " <img src=\""
if local:
cardstring += variables.localpath + "build/"
cardstring += variables.localpath + "gamebuild/"
else:
cardstring += variables.serverpath
cardstring += variables.gameserverpath
cardstring += "UF.png\" alt=\"UF\" title=\"Unfinished\">\n"
except:
cardstring += " <img src=\""
if local:
cardstring += variables.localpath + "build/"
cardstring += variables.localpath + "gamebuild/"
else:
cardstring += variables.serverpath
cardstring += variables.gameserverpath
cardstring += "UP.png\" alt=\"UP\" title=\"Unplayed\">\n"
cardstring += " </div>\n <div class=\"text\">\n <div class=\"title\">" + game["name"] + "</div>\n"
try:
@ -77,9 +77,9 @@ def playcard(game,local=False,decay=False):
else:
cardstring += " </div>\n <div class=\"priority\">\n <img src=\""
if local:
cardstring += variables.localpath + "build/"
cardstring += variables.localpath + "gamebuild/"
else:
cardstring += variables.serverpath
cardstring += variables.gameserverpath
cardstring += "nowplaying.png\" alt=\"\" title=\"Now Playing\">\n </div>\n"
else:
cardstring += " </div>\n <div class=\"priority\">\n <span title=\"Normal\"/>\n </div>\n"
@ -92,9 +92,9 @@ def playcard(game,local=False,decay=False):
else:
cardstring += " </div>\n <div class=\"priority\">\n <img src=\""
if local:
cardstring += variables.localpath + "build/"
cardstring += variables.localpath + "gamebuild/"
else:
cardstring += variables.serverpath
cardstring += variables.gameserverpath
cardstring += "nowplaying.png\" alt=\"\" title=\"Now Playing\">\n </div>\n"
else:
cardstring += " </div>\n <div class=\"priority\">\n <span title=\"Normal\"/>\n </div>\n"
@ -105,16 +105,16 @@ def playcard(game,local=False,decay=False):
else:
cardstring += " </div>\n <div class=\"priority\">\n <img src=\""
if local:
cardstring += variables.localpath + "build/"
cardstring += variables.localpath + "gamebuild/"
else:
cardstring += variables.serverpath
cardstring += variables.gameserverpath
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/"
cardstring += variables.localpath + "gamebuild/"
else:
cardstring += variables.serverpath
cardstring += variables.gameserverpath
cardstring += "nowplaying.png\" alt=\"\" title=\"Now Playing\">\n </div>\n"
except:
cardstring += " </div>\n <div class=\"priority\">\n <span title=\"Normal\"/>\n </div>\n"

View file

@ -12,3 +12,7 @@ Notes about the games can be stored under each heading.
*** demo game 3 (pc)
** completed
*** demo game 4 (nintendo ds)
* places
** visited
*** demo place 1
*** demo place 2 <2024-02-17 Sat>--<2024-02-18 Sun>

View file

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 885 B

After

Width:  |  Height:  |  Size: 885 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Before After
Before After

View file

@ -239,7 +239,9 @@ svg text {
width:100%
}
.unibar a {
color: inherit;
}
.Added,.unplayed,.Unplayed {
background-color:var(--unplayed-color)!important;
@ -828,14 +830,27 @@ width:95%}
opacity:1} */
.library .filters .item {
border:2px solid rgba(0,0,0,.5);
background-color:var(--active-secondary);
color:var(--active-secondary-text);
border:2px solid rgba(0,0,0,.5);
background-color:var(--active-secondary);
color:var(--active-secondary-text);
display: inline-block;
font-size: 0.8rem;
border-radius:.5rem;
margin:.25rem;
max-width:8rem;
opacity:.8;
padding:.4rem 1rem .5rem}
opacity:.8;
position: relative;
padding:.45rem 2rem .5rem 1rem;
white-space: nowrap;
}
.library .filters .item .filter_clear {
border-radius: .5rem;
padding: .425rem .5rem .475rem;
position: absolute;
right: 0;
top: 0;
}
.library .filters .item:hover {
opacity:1}

View file

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Before After
Before After

View file

@ -3,31 +3,31 @@ import variables
from pathlib import Path
"""
Generate the skeleton for an HTML page.
Generate the skeleton for a games backlog HTML page.
"""
home = str(Path.home())
def headerwrite(output,section,local=False):
header = open(output, "a")
rgb = colorsys.hls_to_rgb((variables.hue)/360,0.3,0.45)
rgb = colorsys.hls_to_rgb((variables.gamehue)/360,0.3,0.45)
hexstring = ""
for element in rgb:
hexstring += str(hex(int(element * 255)))[2:]
header.write("<!DOCTYPE html>\n<html lang=\"en\" style=\"--active-base: hsl(" + str(variables.hue) + ", 45%, 30%); --active-secondary: hsl(" + str(variables.hue) + ", 15%, 30%); --active-accent: hsl(" + str(variables.hue) + ", 90%, 70%);\">\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n <meta name=\"theme-color\" content=\"#" + hexstring + "\">\n <title>Static backlog</title>\n <link rel=\"alternate\" type=\"application/rss+xml\" title=\"Static backlog\" href=\"" + variables.serverpath + "feed.xml\">\n <link href=\"")
header.write("<!DOCTYPE html>\n<html lang=\"en\" style=\"--active-base: hsl(" + str(variables.gamehue) + ", 45%, 30%); --active-secondary: hsl(" + str(variables.gamehue) + ", 15%, 30%); --active-accent: hsl(" + str(variables.gamehue) + ", 90%, 70%);\">\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n <meta name=\"theme-color\" content=\"#" + hexstring + "\">\n <title>Static backlog</title>\n <link rel=\"alternate\" type=\"application/rss+xml\" title=\"Static backlog\" href=\"" + variables.gameserverpath + "feed.xml\">\n <link href=\"")
if local:
header.write(variables.localpath + "build/")
header.write(variables.localpath + "gamebuild/")
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\"><p>" + variables.description + "</p></div>\n </div>\n </div>\n </aside>\n <main>\n <section>\n <div class=\"tabs\">\n")
header.write(variables.gameserverpath)
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\"><p>" + variables.gamedescription + "</p></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")
header.write(variables.localpath + "gamebuild/backlog/index.html")
else:
header.write(variables.serverpath + "backlog")
header.write(variables.gameserverpath + "backlog")
header.write("\">Backlog</a>\n <a ")
if section == "library":
header.write("class=\"router-link-exact-active router-link-active\" aria-current=\"page\" href=\"")
@ -36,17 +36,17 @@ def headerwrite(output,section,local=False):
header.write("class=\"router-link-active\" aria-current=\"page\" ")
header.write("href=\"")
if local:
header.write(variables.localpath + "build/library/index.html")
header.write(variables.localpath + "gamebuild/library/index.html")
else:
header.write(variables.serverpath + "library")
header.write(variables.gameserverpath + "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")
header.write(variables.localpath + "gamebuild/history/index.html")
else:
header.write(variables.serverpath + "history")
header.write(variables.gameserverpath + "history")
header.write("\">History</a>\n </div>\n")
header.close()
@ -56,5 +56,5 @@ def footerwrite(output):
footer.close()
if __name__ == "__main__":
headerwrite("build/backlog/index.html","backlog",True)
headerwrite("gamebuild/backlog/index.html","backlog",True)
footerwrite("test.html")

View file

@ -8,7 +8,7 @@ Load in the list of games from a set of .org files.
thisyear = datetime.now().strftime("%Y")
year = variables.startyear - 1
year = variables.gamestartyear - 1
concernedfiles = []

View file

@ -1,26 +0,0 @@
import sys
import backlog
import library
import sublibrary
import history
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)
history.history(True)
else:
backlog.backlog()
library.library()
sublibrary.sublibrary()
history.history()

26
generategames.py Normal file
View file

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

121
generateplaces.py Normal file
View file

@ -0,0 +1,121 @@
import orgparse,os,re,sys,variables
import time
from datetime import datetime
from geopy.geocoders import Nominatim
try:
if sys.argv[1] == "local":
local = True
else:
local = False
except:
local = False
if variables.trackplaces == True:
thisyear = datetime.now().strftime("%Y")
year = variables.placestartyear
concernedfiles = []
geo = Nominatim(user_agent="python3")
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
places = []
placenames = []
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 == "places":
for action in node.children:
if action.heading == "visited":
for place in action.children:
placename = re.sub(" <.*>","",re.sub("<.*> ","",place.heading))
if placename not in placenames:
status = "new"
placenames.append(placename)
else:
status = "existing"
if "<" in place.heading:
dates = re.sub(" [A-Z][a-z][a-z]","",re.sub("--"," to ",re.sub(">","",re.sub("<","",(re.findall("\<.*\>",place.heading)[0])))))
else:
dates = filedate
if status == "new":
try:
lookup = placename + ", " + variables.disambig[placename]
except:
lookup = placename
thedict = {"name":placename,"dates":[dates],"lookup":lookup}
places.append(thedict)
else:
twodict = {"name":placename,"dates":[dates]}
for origplace in places:
if twodict["name"] == origplace["name"]:
origplace["dates"].extend(twodict["dates"])
except:
pass
for place in places:
place["dates"] = list(dict.fromkeys(place["dates"]))
theplaces = sorted(places,key=lambda d: d["name"])
for place in theplaces:
print("Fetching " + place["name"])
place["lat"] = None
while place["lat"] == None:
try:
place["lat"] = geo.geocode(place["lookup"]).latitude
except:
time.sleep(3)
continue
place["long"] = None
while place["long"] == None:
try:
place["long"] = geo.geocode(place["lookup"]).longitude
except:
time.sleep(3)
continue
alllats = []
alllongs = []
for place in theplaces:
if place["lat"] != 0:
alllats.append(place["lat"])
if place["long"] != 0:
alllongs.append(place["long"])
avglat = (max(alllats) + min(alllats))/2
avglong = (max(alllongs) + min(alllongs))/2
writefile = open("placebuild/index.html","w")
writefile.write("<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <base target=\"_top\">\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"> \n <title>Map</title>\n <link rel=\"stylesheet\" href=\"")
if local:
writefile.write(variables.domain)
writefile.write(variables.placecss + "\">\n <link rel=\"stylesheet\" href=\"https://unpkg.com/leaflet@1.9.4/dist/leaflet.css\" integrity=\"sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=\" crossorigin=\"\"/>\n <script src=\"https://unpkg.com/leaflet@1.9.4/dist/leaflet.js\" integrity=\"sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=\" crossorigin=\"\"></script>\n <style>\n #map {\n width: 90vw;\n height: 90vh;\n margin: auto;\n }\n </style>\n </head>\n <body>\n <div id=\"map\" style=\"width: 90vw; height: 90vh;\"></div>\n <script>\n const map = L.map('map').fitBounds([[" + str(min(alllats)) + ", " + str(min(alllongs)) + "],[" + str(max(alllats)) + ", " + str(max(alllongs)) + "]]);\n const tiles = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {\n attribution: '&copy; <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>'\n }).addTo(map);\n")
for place in theplaces:
saniname = re.sub(" ","",(re.sub("","",(re.sub("-","",place["name"])))))
writefile.write(" const " + saniname + " = L.marker([" + str(place["lat"]) + ", " + str(place["long"]) + "]).addTo(map).bindTooltip('<h2>" + place["name"] + "</h2><ul>")
for date in place["dates"]:
writefile.write("<li><code>" + date + "</code></li>")
writefile.write("</ul>');\n")
writefile.write(" </script>\n </body>\n</html>")

88
generaterecords.py Normal file
View file

@ -0,0 +1,88 @@
import discogs_client,re,time,variables
d = discogs_client.Client("Python/1.0",user_token=variables.discogstoken)
user = d.user(variables.discogsuser)
try:
if sys.argv[1] == "local":
local = True
else:
local = False
except:
local = False
if variables.trackrecords == True:
records = []
thenumber = 1
maxno = len(user.collection_folders[0].releases)
def typography(thestring):
return re.sub(" / ","/",re.sub(" \(.*\)","",re.sub(" - "," ",re.sub(" "," ",re.sub("\.\.\.","",re.sub("'","",re.sub(" = .*","",thestring)))))))
print("Fetching records from Discogs")
for item in user.collection_folders[0].releases:
print("Fetching " + str(thenumber) + " of " + str(maxno))
theitem = {}
theitem["artist"] = typography(item.release.artists[0].name)
theitem["title"] = typography(item.release.title)
try:
if "LP" in item.release.formats[0]["descriptions"] or "12\"" in item.release.formats[0]["descriptions"]:
theitem["format"] = "large"
else:
theitem["format"] = "small"
except:
theitem["format"] = "small"
try:
theitem["img"] = item.release.images[0]["uri"]
except:
pass
records.append(theitem)
thenumber += 1
time.sleep(1) # only allowed 1 request per second
records = sorted(records, key=lambda d: d["title"])
records = sorted(records, key=lambda d: d["artist"])
smalls = []
larges = []
for record in records:
if record["format"] == "large":
larges.append(record)
else:
smalls.append(record)
def recordwrite(record):
recordstring = " <div class=\"container " + record["format"] + "\">\n <img src=\""
try:
recordstring += record["img"]
except:
if record["format"] == "large":
if local:
recordstring += variables.domain
recordstring += variables.recordserverpath + "large.png"
elif record["format"] == "small":
if local:
recordstring += variables.domain
recordstring += variables.recordserverpath + "small.png"
recordstring += "\">\n <div>\n <p>" + record["artist"] + "<br>•<br>" + record["title"] + "</p>\n </div>\n </div>\n"
return recordstring
writefile = open("recordbuild/index.html","w")
writefile.write("<!DOCTYPE html>\n<html>\n <head>\n <link rel=\"stylesheet\" href=\"")
if local:
writefile.write(variables.domain)
writefile.write(variables.recordcss + "\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <title>Record collection</title>\n <style>\n main {\n display: flex;\n gap: 10px;\n flex-wrap: wrap;\n justify-content: space-evenly;\n }\n .container {\n position: relative;\n display: flex;\n justify-content: center;\n }\n .container.small {\n width: 180px;\n min-width: 180px;\n }\n .container.large {\n width: 300px;\n min-width: 300px;\n }\n .container img {\n display: block;\n width: 100%;\n height: auto;\n margin: auto;\n }\n .container div {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n height: 100%;\n width: 100%;\n opacity: 0;\n transition: .5s ease;\n background-color: rgba(0,0,0,0.5);\n overflow: auto;\n }\n .container:hover div {\n opacity: 1;\n }\n .container div p {\n color: white;\n width: 100%;\n margin: 0;\n position: absolute;\n top: 50%;\n left: 50%;\n -webkit-transform: translate(-50%, -50%);\n -ms-transform: translate(-50%, -50%);\n transform: translate(-50%, -50%);\n text-align: center;\n text-transform: lowercase;\n }\n </style>\n </head>\n <body>\n <h1>Record collection</h1>\n <main>\n")
for record in smalls:
writefile.write(recordwrite(record))
for record in larges:
writefile.write(recordwrite(record))
writefile.write(" </main>\n <p>Generic disc icons by <a href=\"https://www.flaticon.com/free-icon/cd_5344201\">popo2021</a> and <a href=\"https://www.flaticon.com/free-icon/disc_5613845\">Dinosoft Labs</a> on Flaticon.<p>\n </body>\n</html>\n")
writefile.close()

View file

@ -1,5 +1,5 @@
import os
import gamesort,skeleton,variables
import gamesort,gameskel,variables
from datetime import datetime,timedelta
"""
@ -8,24 +8,24 @@ Generates history page and RSS feed
def history(local=False):
# delete existing files
if not os.path.isdir("build/history"):
os.mkdir("build/history")
if os.path.exists("build/history/index.html"):
os.remove("build/history/index.html")
if os.path.exists("build/feed.xml"):
os.remove("build/feed.xml")
if not os.path.isdir("gamebuild/history"):
os.mkdir("gamebuild/history")
if os.path.exists("gamebuild/history/index.html"):
os.remove("gamebuild/history/index.html")
if os.path.exists("gamebuild/feed.xml"):
os.remove("gamebuild/feed.xml")
# write header
skeleton.headerwrite("build/history/index.html","history",local)
output = "build/history/index.html"
gameskel.headerwrite("gamebuild/history/index.html","history",local)
output = "gamebuild/history/index.html"
filewrite = open(output, "a")
filewrite.write(" <section class=\"history\">\n <div class=\"list\">\n")
feedwrite = open("build/feed.xml", "a")
feedwrite.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n <channel>\n <atom:link href=\"" + variables.domain + variables.serverpath + "feed.xml\" rel=\"self\" type=\"application/rss+xml\" />\n <title>Static backlog</title>\n <link>" + variables.domain + variables.serverpath + "backlog</link>\n <description>Feed for gaming updates</description>\n <language>en-gb</language>")
feedwrite = open("gamebuild/feed.xml", "a")
feedwrite.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n <channel>\n <atom:link href=\"" + variables.domain + variables.gameserverpath + "feed.xml\" rel=\"self\" type=\"application/rss+xml\" />\n <title>Static backlog</title>\n <link>" + variables.domain + variables.gameserverpath + "backlog</link>\n <description>Feed for gaming updates</description>\n <language>en-gb</language>")
theyear = int(gamesort.thisyear)
while theyear >= variables.startyear:
while theyear >= variables.gamestartyear:
yearlist = []
enddate = datetime.strptime((str(theyear) + "-12-31"),"%Y-%m-%d")
startdate = datetime.strptime((str(theyear) + "-01-01"),"%Y-%m-%d")
@ -65,7 +65,7 @@ def history(local=False):
else:
filewrite.write(event["action"])
filewrite.write("\"></div>\n </div>\n <div> " + event["name"] + "\n <span>(" + event["console"] + ")</span>\n </div>\n </div>\n </div>\n")
feedwrite.write(" <item>\n <title>" + event["action"] + " " + event["name"] + " (" + event["console"] + ")</title>\n <pubDate>" + event["date"].strftime("%a, %-d %b %Y") + " 00:00:00 GMT</pubDate>\n <link>" + variables.domain + variables.serverpath + "history</link>\n <guid isPermaLink=\"false\">" + event["action"] + "-" + event["name"].replace(" ","-") + "-" + event["console"] + "</guid>\n <description>" + event["action"] + " " + event["name"] + " (" + event["console"] + ")</description>\n </item>\n")
feedwrite.write(" <item>\n <title>" + event["action"] + " " + event["name"] + " (" + event["console"] + ")</title>\n <pubDate>" + event["date"].strftime("%a, %-d %b %Y") + " 00:00:00 GMT</pubDate>\n <link>" + variables.domain + variables.gameserverpath + "history</link>\n <guid isPermaLink=\"false\">" + event["action"] + "-" + event["name"].replace(" ","-") + "-" + event["console"] + "</guid>\n <description>" + event["action"] + " " + event["name"] + " (" + event["console"] + ")</description>\n </item>\n")
checkdate = event["date"]
theyear -= 1
@ -162,7 +162,7 @@ def history(local=False):
filewrite.write(" </div>\n </section>\n")
filewrite.close()
skeleton.footerwrite("build/history/index.html")
gameskel.footerwrite("gamebuild/history/index.html")
if __name__ == "__main__":
history(True)

15
init.py
View file

@ -1,5 +1,16 @@
import variables
script = open("build.sh", "a")
script = open("build.sh", "w")
script.write("#!/usr/bin/env bash\npython3 generate.py\nrclone copy build " + variables.rclonesiteroot + variables.serverpath + " -P")
script.write("#!/usr/bin/env bash\n")
if variables.trackgames == True:
script.write("python3 generategames.py\nrclone copy gamebuild " + variables.rclonesiteroot + variables.gameserverpath + " -P\n")
if variables.trackplaces == True:
script.write("python3 generateplaces.py\nrclone copy placebuild " + variables.rclonesiteroot + variables.placeserverpath + " -P\n")
if variables.trackrecords == True:
script.write("python3 generaterecords.py\nrclone copy recordbuild " + variables.rclonesiteroot + variables.recordserverpath + " -P\n")
script.close()

View file

@ -1,5 +1,5 @@
import os
import cardstring,gamesort,skeleton
import cardstring,gamesort,gameskel,variables
"""
Generates library page
@ -7,25 +7,50 @@ 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")
if not os.path.isdir("gamebuild/library"):
os.mkdir("gamebuild/library")
if os.path.exists("gamebuild/library/index.html"):
os.remove("gamebuild/library/index.html")
# write header
skeleton.headerwrite("build/library/index.html","library",local)
output = "build/library/index.html"
gameskel.headerwrite("gamebuild/library/index.html","library",local)
output = "gamebuild/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")
filewrite.write(" <div class=\"unplayed\" style=\"flex: " + str(gamesort.unplayed(gamesort.games)) + " 1 0%;\"><a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/all-unplayed/index.html")
else:
filewrite.write(variables.gameserverpath + "library/all-unplayed")
filewrite.write("\">" + str(gamesort.unplayed(gamesort.games)) + "</a></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")
filewrite.write(" <div class=\"unfinished\" style=\"flex: " + str(gamesort.unfinished(gamesort.games)) + " 1 0%;\"><a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/all-unfinished/index.html")
else:
filewrite.write(variables.gameserverpath + "library/all-unfinished")
filewrite.write("\">" + str(gamesort.unfinished(gamesort.games)) + "</a></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")
filewrite.write(" <div class=\"beaten\" style=\"flex: " + str(gamesort.beaten(gamesort.games)) + " 1 0%;\"><a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/all-beaten/index.html")
else:
filewrite.write(variables.gameserverpath + "library/all-beaten")
filewrite.write("\">" + str(gamesort.beaten(gamesort.games)) + "</a></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")
filewrite.write(" <div class=\"completed\" style=\"flex: " + str(gamesort.completed(gamesort.games)) + " 1 0%;\"><a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/all-completed/index.html")
else:
filewrite.write(variables.gameserverpath + "library/all-completed")
filewrite.write("\">" + str(gamesort.completed(gamesort.games)) + "</a></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 class=\"endless\" style=\"flex: " + str(gamesort.endless(gamesort.games)) + " 1 0%;\"><a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/all-endless/index.html")
else:
filewrite.write(variables.gameserverpath + "library/all-endless")
filewrite.write("\">" + str(gamesort.endless(gamesort.games)) + "</a></div>\n")
filewrite.write(" </div>\n <div class=\"library-list sorted\">\n")
newgames = sorted(gamesort.games,key=lambda d: d["id"])
@ -34,7 +59,7 @@ def library(local=False):
filewrite.write(cardstring.playcard(game,local))
filewrite.close()
skeleton.footerwrite("build/library/index.html")
gameskel.footerwrite("gamebuild/library/index.html")
if __name__ == "__main__":
library(True)

0
placebuild/.gitkeep Normal file
View file

BIN
recordbuild/large.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
recordbuild/small.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View file

@ -1,5 +1,5 @@
import os
import cardstring,gamesort,skeleton,variables
import cardstring,gamesort,gameskel,variables
from pathlib import Path
"""
@ -89,54 +89,79 @@ def sublibrary(local=False):
pass
except:
filterlist.append(game)
if not os.path.isdir("build/library/" + console["shortname"].lower() + "-" + status):
if not os.path.isdir("gamebuild/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")
os.mkdir("gamebuild/library/" + console["shortname"].lower() + "-" + status)
if os.path.exists("gamebuild/library/" + console["shortname"].lower() + "-" + status + "/index.html"):
os.remove("gamebuild/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"
gameskel.headerwrite(("gamebuild/library/" + console["shortname"].lower() + "-" + status + "/index.html"),"sublibrary",local)
output = "gamebuild/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")
filewrite.write(variables.localpath + "gamebuild/library/index.html")
else:
filewrite.write(variables.serverpath + "library")
filewrite.write(variables.gameserverpath + "library")
else:
if local:
filewrite.write(variables.localpath + "build/library/all-" + status + "/index.html")
filewrite.write(variables.localpath + "gamebuild/library/all-" + status + "/index.html")
else:
filewrite.write(variables.serverpath + "library/all-" + status)
filewrite.write("\">1 Platform</a></span>\n")
filewrite.write(variables.gameserverpath + "library/all-" + status)
filewrite.write("\">1 Platform<span class=\"filter_clear\">x</span></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")
filewrite.write(variables.localpath + "gamebuild/library/index.html")
else:
filewrite.write(variables.serverpath + "library")
filewrite.write(variables.gameserverpath + "library")
else:
if local:
filewrite.write(variables.localpath + "build/library/" + console["shortname"].lower() + "-all/index.html")
filewrite.write(variables.localpath + "gamebuild/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(variables.gameserverpath + "library/" + console["shortname"].lower() + "-all")
filewrite.write("\">1 Status<span class=\"filter_clear\">x</span></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")
filewrite.write(" <div class=\"unplayed\" style=\"flex: " + str(gamesort.unplayed(filterlist)) + " 1 0%;\"><a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-unplayed/index.html")
else:
filewrite.write(variables.gameserverpath + "library/" + console["shortname"].lower() + "-unplayed")
filewrite.write("\">" + str(gamesort.unplayed(filterlist)) + "</a></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")
filewrite.write(" <div class=\"unfinished\" style=\"flex: " + str(gamesort.unfinished(filterlist)) + " 1 0%;\"><a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-unfinished/index.html")
else:
filewrite.write(variables.gameserverpath + "library/" + console["shortname"].lower() + "-unfinished")
filewrite.write("\">" + str(gamesort.unfinished(filterlist)) + "</a></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")
filewrite.write(" <div class=\"beaten\" style=\"flex: " + str(gamesort.beaten(filterlist)) + " 1 0%;\"><a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-beaten/index.html")
else:
filewrite.write(variables.gameserverpath + "library/" + console["shortname"].lower() + "-beaten")
filewrite.write("\">" + str(gamesort.beaten(filterlist)) + "</a></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")
filewrite.write(" <div class=\"completed\" style=\"flex: " + str(gamesort.completed(filterlist)) + " 1 0%;\"><a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-completed/index.html")
else:
filewrite.write(variables.gameserverpath + "library/" + console["shortname"].lower() + "-completed")
filewrite.write("\">" + str(gamesort.completed(filterlist)) + "</a></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 class=\"endless\" style=\"flex: " + str(gamesort.endless(filterlist)) + " 1 0%;\"><a href=\"")
if local:
filewrite.write(variables.localpath + "gamebuild/library/" + console["shortname"].lower() + "-endless/index.html")
else:
filewrite.write(variables.gameserverpath + "library/" + console["shortname"].lower() + "-endless")
filewrite.write("\">" + str(gamesort.endless(filterlist)) + "</a></div>\n")
filewrite.write(" </div>\n <div class=\"library-list sorted\">\n")
newgames = sorted(filterlist,key=lambda d: d["id"])
@ -145,7 +170,7 @@ def sublibrary(local=False):
filewrite.write(cardstring.playcard(game,local))
filewrite.close()
skeleton.footerwrite("build/library/" + console["shortname"].lower() + "-" + status + "/index.html")
gameskel.footerwrite("gamebuild/library/" + console["shortname"].lower() + "-" + status + "/index.html")
if __name__ == "__main__":
sublibrary(True)

View file

@ -2,23 +2,29 @@
User-defined variables live here.
"""
endlessgames = []
orgpath = ""
localpath = ""
serverpath = ""
domain = ""
rclonesiteroot = ""
description = ""
"""
Games
"""
startyear =
trackgames = False
hue =
gameserverpath = ""
endlessgames = []
gamedescription = ""
gamestartyear = 0
gamehue = 0
consoles = [{"code":"ps5","name":"PlayStation 5","shortname":"PS5","img":"PS5"},
{"code":"ps2","name":"PlayStation 2","shortname":"PS2","img":"PS2"},
@ -28,3 +34,31 @@ consoles = [{"code":"ps5","name":"PlayStation 5","shortname":"PS5","img":"PS5"},
{"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"}]
"""
Places
"""
trackplaces = False
placeserverpath = ""
placestartyear = 0
placecss = ""
# disambig = {"london":"england","belfast":"northern ireland"}
"""
Records
"""
trackrecords = False
recordserverpath = ""
recordcss = ""
discogstoken = ""
discogsuser = ""