From 8e995e51264d6d6134a6e193e590a542faeaa4b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Fri, 1 Nov 2024 22:22:00 +0000 Subject: [PATCH] CSS updates, elucidate readme --- .gitignore | 3 ++- README.org | 50 +++++++++++++++++++++++++++++++++++++------ build/style.css | 44 ++++++++++++++++++++----------------- collectinggen.py | 9 +++++--- download.py | 4 +--- generate.py | 3 ++- log-template.py | 10 ++++++++- skel.py | 2 +- tradegen.py | 12 +++++++++-- variables-template.py | 3 +++ 10 files changed, 101 insertions(+), 39 deletions(-) diff --git a/.gitignore b/.gitignore index 7c9f02c..a967458 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ build/assets/header.png build/assets/levels/*.gif __pycache__/ variables.py -log.py \ No newline at end of file +log.py +build/user.css \ No newline at end of file diff --git a/README.org b/README.org index d8e0d8b..e1b76f5 100644 --- a/README.org +++ b/README.org @@ -1,9 +1,45 @@ * tcg -a python static site generator for tracking tcg cards (made for [[https://colors-tcg.dreamwidth.org][colors]]). +Python scripts to generate a mobile-friendly static site for tracking tcg cards (designed for [[https://colors-tcg.dreamwidth.org][colors]]). -Current status: very basic functionality and styling, will add more features as I need them. - -** To do -- implement user variables -- CSS -- integrate =download.sh= +** Instructions +*** Requirements +- =python3= +- server space +- subdomain pointing to your site root on the server +- =rclone= with your server set up as a remote +*** Setup +- Download and create the initial files by running: +#+BEGIN_SRC bash + git clone https://git.praze.net/tre/tcg.git + cd tcg + cp log-template.py log.py + cp variables-template.py variables.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) + - =name=: the name you use in the game + - =highpriority=: a list of high priority decks you’re collecting + - =mediumpriority=: a list of other decks you’re collecting + - =tradepost=: URL of your trade post on Dreamwidth + - =faves=: a list of cards to showcase on the index page + - =headerbackground=: an HTML colour to display behind your header image and set as a theme colour + - =british=: True if you want “grey” to display on the site, False if you want “gray” + - =collectthreshold=: minimum number of owned cards for putting a deck in the “collecting” category + - =keepsig=: True if you always want to keep one copy of your signature, False if you want to make them all available for trading +- Run the following: + #+BEGIN_SRC bash + python3 setup.py + chmod +x build.sh +#+END_SRC +- Save a header image to =build/assets/header.png= +- Add level images manually to =build/assets/levels/= +- Add custom CSS to =build/user.css= +*** Updating and building +- For each transaction, add a dictionary ={}= to the =log= list like in the example (removing any of ="received"=, ="lost"=, ="crayons"= that aren’t relevant). +- Run =./build.sh= in this directory to download the relevant card images and then upload everything to the server. +** Currently unaccounted for +- Sketchpads +- Portfolios +- Duplicates +- Masteries diff --git a/build/style.css b/build/style.css index 7d690bb..a70a4ff 100644 --- a/build/style.css +++ b/build/style.css @@ -1,22 +1,7 @@ /* basic colours */ :root { - --textcolour: black; - --linecolour: black; - --bgcolour: white; -} - -@media(prefers-color-scheme: dark) { - :root { - --textcolour: white; - --linecolour: white; - --bgcolour: black; - } -} - -* { - color: var(--textcolour); - background-color: var(--bgcolour); + color-scheme: light dark; } /* basic layout */ @@ -33,7 +18,7 @@ body > aside { grid-column-end: 2; grid-row-start: 1; grid-row-end: 2; - border-bottom: 4px solid var(--linecolour); + border-bottom: 4px solid CanvasText; padding: 5px; } @@ -50,7 +35,7 @@ body > main { grid-row-start: 1; grid-row-end: 3; overflow: auto; - border-left: 4px solid var(--linecolour); + border-left: 4px solid CanvasText; padding: 5px; } @@ -60,7 +45,7 @@ body > main { } body > * { border-left: none !important; - border-bottom: 4px solid var(--linecolour) !important; + border-bottom: 4px solid CanvasText; } body > aside { display: none; @@ -69,39 +54,52 @@ body > main { table.decktable { display: inline-block; - border: 1px solid var(--linecolour); + border: 1px solid CanvasText; } table.decktable.red th { background-color: red; + color: black; } table.decktable.orange th { background-color: orange; + color: black; } table.decktable.yellow th { background-color: yellow; + color: black; } table.decktable.green th { background-color: green; + color: white; } table.decktable.blue th { background-color: blue; + color: white; } table.decktable.purple th { background-color: purple; + color: white; } table.decktable.brown th { background-color: brown; + color: white; } table.decktable.gray th { background-color: gray; + color: white; +} + +table.decktable.special th { + background: linear-gradient(90deg, hsl(0, 100%, 70%), hsl(30, 100%, 70%), hsl(60, 100%, 70%), hsl(90, 100%, 70%), hsl(120, 100%, 70%), hsl(150, 100%, 70%), hsl(180, 100%, 70%), hsl(210, 100%, 70%), hsl(240, 100%, 70%), hsl(270, 100%, 70%), hsl(300, 100%, 70%), hsl(330, 100%, 70%), hsl(360, 100%, 70%)); + color: black; } main img { @@ -130,3 +128,9 @@ img.crayon { table.level { display: inline-block; } + +h2.collectingheader { + position: sticky; + top: 0; + background-color: Canvas; +} diff --git a/collectinggen.py b/collectinggen.py index b855f30..a3530be 100644 --- a/collectinggen.py +++ b/collectinggen.py @@ -27,17 +27,20 @@ def collectinggen(): if tcgcore.collecting(deck): lowpriority.append(deck) if len(highpriority) > 0: - content.write("

High priority

\n") + content.write("
\n

High priority

\n") for deck in highpriority: content.write(tcgcore.printdeck(deck)) + content.write("
\n") if len(medpriority) > 0: - content.write("

Medium priority

\n") + content.write("
\n

Medium priority

\n") for deck in medpriority: content.write(tcgcore.printdeck(deck)) + content.write("
\n") if len(lowpriority) > 0: - content.write("

Low priority

\n") + content.write("
\n

Low priority

\n") for deck in lowpriority: content.write(tcgcore.printdeck(deck)) + content.write("
\n") content.close() skel.footerwrite(thefile) diff --git a/download.py b/download.py index 0001e32..6084868 100644 --- a/download.py +++ b/download.py @@ -4,9 +4,7 @@ import tcgcore def getimg(): for card in tcgcore.ownedcards(): if card[0:4] == "sig_": - if os.path.exists("build/decks/sigs/" + card[4:] + ".gif"): - pass - else: + if not os.path.exists("build/decks/sigs/" + card[4:] + ".gif"): r = requests.get("https://colors-tcg.eu/cards/" + card + ".gif") open("build/decks/sigs/" + card[4:] + ".gif","wb").write(r.content) else: diff --git a/generate.py b/generate.py index b7762c5..141279d 100644 --- a/generate.py +++ b/generate.py @@ -1,4 +1,4 @@ -import download,indexgen,collectinggen,ownedgen,wantedgen,loggen,levelsgen +import download,indexgen,collectinggen,ownedgen,wantedgen,loggen,levelsgen,tradegen download.getimg() indexgen.indexgen() @@ -7,3 +7,4 @@ ownedgen.ownedgen() wantedgen.wantedgen() loggen.loggen() levelsgen.levelsgen() +tradegen.tradegen() diff --git a/log-template.py b/log-template.py index 80f26bc..20bcd52 100644 --- a/log-template.py +++ b/log-template.py @@ -1,3 +1,11 @@ import datetime -log = [{"event":"event name","date":datetime.datetime(Y,M,D),"url":"link to comment","received":["card01","card02"]}] +log = [ + {"event":"event name", + "date":datetime.datetime(Y,M,D), + "url":"link to comment", + "received":["card01","card02"], + "lost":["card03","card04"], + "crayons":{"red":1,"orange":2,"yellow":-3} + } +] diff --git a/skel.py b/skel.py index 7a5a0af..62dbb18 100644 --- a/skel.py +++ b/skel.py @@ -2,7 +2,7 @@ import variables def headerwrite(thefile,pagename): header = open(thefile,"a") - header.write("\n\n \n \n \n \n \n " + variables.name + "’s card collection :: " + pagename + "\n \n \n \n