From e179b011f2e564343171ce969bf27d8f0474c27d Mon Sep 17 00:00:00 2001 From: Mez Date: Thu, 28 Aug 2025 17:15:23 +0100 Subject: [PATCH 1/3] Allow tools functions to be used offline --- colors.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/colors.py b/colors.py index 797f766..ff70508 100644 --- a/colors.py +++ b/colors.py @@ -6,22 +6,24 @@ import log,variables values = ["red","orange","yellow","green","blue","purple","brown","gray","special","limited"] numbers = ["01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20"] -print("Getting list of deck colours") - deckkey = {} -request = requests.get("https://colors-tcg.eu/cards.php?view=alpha") -alldecks = open("key.html","w") -alldecks.write(request.text) -alldecks.close() +try: + request = requests.get("https://colors-tcg.eu/cards.php?view=alpha") + print("Getting list of deck colours") + alldecks = open("key.html","w") + alldecks.write(request.text) + alldecks.close() -# need to correct some html issues + # need to correct some html issues -with open("key.html","r") as file: - filedata = file.read() -filedata = filedata.replace("","") -with open("key.html","w") as file: - file.write(filedata) + with open("key.html","r") as file: + filedata = file.read() + filedata = filedata.replace("","") + with open("key.html","w") as file: + file.write(filedata) +except: + print("Using cached version of decklist") with open("key.html") as decks: decksoup = BeautifulSoup(decks, "html.parser") From ee0879ef794586da4e839b77b6f82813a5072b0d Mon Sep 17 00:00:00 2001 From: Mez Date: Fri, 29 Aug 2025 19:57:44 +0100 Subject: [PATCH 2/3] Fix 04b src when the site is in a subfolder --- .gitignore | 2 ++ build/font.css | 7 +++++++ build/style.css | 8 -------- colors.py | 3 +++ setup.py | 7 +++++++ 5 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 build/font.css diff --git a/.gitignore b/.gitignore index a44f07e..79522fa 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ build/index.html build/decks/*/*.gif build/decks/*/type build/assets/banner.png +build/assets/fonts/* +!build/assets/fonts/04b24.ttf build/assets/header.png build/assets/levels/*.gif build/assets/sketch/*.gif diff --git a/build/font.css b/build/font.css new file mode 100644 index 0000000..49c5495 --- /dev/null +++ b/build/font.css @@ -0,0 +1,7 @@ +@font-face { + src: url("/assets/fonts/04b24.ttf"); + font-display: swap; + font-family: "04b24"; + font-style: normal; + font-weight: 400; +} diff --git a/build/style.css b/build/style.css index 78ba97e..00d0186 100644 --- a/build/style.css +++ b/build/style.css @@ -1,11 +1,3 @@ -@font-face { - src: url("/assets/fonts/04b24.ttf"); - font-display: swap; - font-family: "04b24"; - font-style: normal; - font-weight: 400; -} - /* basic colours */ :root { diff --git a/colors.py b/colors.py index ff70508..7f95b9f 100644 --- a/colors.py +++ b/colors.py @@ -667,6 +667,9 @@ if variables.keepsig == True: def headerwrite(thefile,pagename): header = open(thefile,"a") header.write("\n\n \n \n \n 0: + header.write("/" + variables.subfolder) + header.write("/font.css\">\n 0: header.write("/" + variables.subfolder) header.write("/style.css\">\n 0: + header.write("/" + variables.subfolder) +fontloc.write("/assets/fonts/04b24.ttf\");\n font-display: swap;\n font-family: \"04b24\";\n font-style: normal;\n font-weight: 400;\n}\n") +fontloc.close() + if not os.path.exists("build/user.css"): open("build/user.css","x") From dea672a13ab09b58f578ad0af83fc1eb6fa69066 Mon Sep 17 00:00:00 2001 From: Mez Date: Fri, 29 Aug 2025 20:07:46 +0100 Subject: [PATCH 3/3] Add experimental neocities support --- README.org | 16 ++++++++++------ setup.py | 6 +++++- variables-template.py | 1 + 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/README.org b/README.org index 890cf43..c952b7b 100644 --- a/README.org +++ b/README.org @@ -4,9 +4,12 @@ Python scripts to generate a mobile-friendly static site for tracking tcg cards ** Instructions *** Requirements - =python3= (needs the following libraries: =bs4, collections, datetime, itertools, os, random, re, requests=) -- server space -- subdomain pointing to your site root on the server -- =rclone= with your server set up as a remote +- either: + - server space + - subdomain pointing to your site root on the server + - =rclone= with your server set up as a remote +- or: + - a neocities account with the [[https://neocities.org/cli][neocities CLI]] installed *** Setup - Download and create the initial files by running: #+BEGIN_SRC bash @@ -17,9 +20,10 @@ Python scripts to generate a mobile-friendly static site for tracking tcg cards cp trade-template.py trade.py #+END_SRC - Edit =variables.py= to set the variables as follows: - - =servername=: name set for your remote in =rclone= - - =serverpath=: path to the site root on the server (with leading slash, without trailing slash) - - =subfolder=: subfolder under your (sub)domain in which the TCG pages will be located (leave as an empty string if they are at the top level) + - =neocities=: set to =True= if you will be using the neocities CLI + - =servername=: name set for your remote in =rclone= (if not using the neocities CLI) + - =serverpath=: path to the site root on the server (if not using the neocities CLI; with leading slash, without trailing slash) + - =subfolder=: subfolder under your (sub)domain in which the TCG pages will be located (leave as an empty string if they are at the top level; if using the neocities CLI this will not work and the pages will be uploaded to the site root) - =url=: URL of your site index page including =https://= - =name=: the name you use in the game - =hovertext=: text to display when hovering over the header image diff --git a/setup.py b/setup.py index f130698..38cf0a3 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,11 @@ import os import variables buildscript = open("build.sh","w") -buildscript.write("#!/usr/bin/env bash && python3 colors.py\n\nrclone copy build " + variables.servername + ":" + variables.serverpath + " -P -L") +buildscript.write("#!/usr/bin/env bash && python3 colors.py\n\n") +if variables.neocities: + buildscript.write("neocities push") +else: + buildscript.write("rclone copy build " + variables.servername + ":" + variables.serverpath + " -P -L") buildscript.close() fontloc = open("build/font.css","w") diff --git a/variables-template.py b/variables-template.py index 0ed904e..b32da46 100644 --- a/variables-template.py +++ b/variables-template.py @@ -1,3 +1,4 @@ +neocities = False servername = "" serverpath = "" subfolder = ""