From c5984b53d20f9defd043dac66df056c30efd9125 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?tr=C3=A9meur?=
Date: Sat, 7 Dec 2024 13:40:50 +0000
Subject: [PATCH] Track coupons
---
.gitignore | 1 +
README.org | 5 ++---
build/assets/coupons/.gitkeep | 0
build/style.css | 5 +++++
indexgen.py | 26 ++++++++++++++++++++++++++
log-template.py | 3 ++-
loggen.py | 18 +++++++++++++++++-
7 files changed, 53 insertions(+), 5 deletions(-)
create mode 100644 build/assets/coupons/.gitkeep
diff --git a/.gitignore b/.gitignore
index 0533bc7..bfa4f08 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@ build/decks/*/type
build/assets/header.png
build/assets/levels/*.gif
build/assets/sketch/*.gif
+build/assets/coupons/*.png
__pycache__/
variables.py
log.py
diff --git a/README.org b/README.org
index d1de77e..66ad56b 100644
--- a/README.org
+++ b/README.org
@@ -38,10 +38,9 @@ Python scripts to generate a mobile-friendly static site for tracking tcg cards
#+END_SRC
- Save a header image to =build/assets/header.png=
- Save each stage of a filled sketchpad to =build/assets/sketch/=, as =00.gif=, =01.gif=, etc.
+- Save coupons to =build/assets/coupons/=, with filenames that match the codes you’ve given them in =log.py=.
- 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"=, ="decks"= that aren’t relevant).
+- For each transaction, add a dictionary ={}= to the =log= list like in the example (removing any of ="received"=, ="lost"=, ="crayons"=, ="decks"=, ="coupons">= 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
-- Coupons
diff --git a/build/assets/coupons/.gitkeep b/build/assets/coupons/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/build/style.css b/build/style.css
index 7f0bdec..d5f1a26 100644
--- a/build/style.css
+++ b/build/style.css
@@ -562,3 +562,8 @@ span.sorttitle {
span.searchresults {
font-family: monospace;
}
+
+img.coupon.expired {
+ -webkit-filter: grayscale(100%);
+ filter: grayscale(100%);
+}
diff --git a/indexgen.py b/indexgen.py
index 14d7c8d..bd936ce 100644
--- a/indexgen.py
+++ b/indexgen.py
@@ -268,6 +268,32 @@ def indexgen():
for card in faveslist:
content.write(tcgcore.printcard(card))
content.write("
\n")
+ coupons = []
+ for event in log.log:
+ try:
+ for newcoupon in event["coupons"]:
+ found = False
+ for oldcoupon in coupons:
+ if found == False:
+ if newcoupon == list(oldcoupon.keys())[0]:
+ found = True
+ oldcoupon[newcoupon] += event["coupons"][newcoupon]
+ if found == False:
+ coupons.append({newcoupon:event["coupons"][newcoupon]})
+ except:
+ pass
+ coupons = coupons[::-1]
+ if len(coupons) > 0:
+ content.write("coupons
\n")
+ for coupon in coupons:
+ for key,value in coupon.items():
+ content.write("")
+ content.write("
\n")
content.close()
skel.footerwrite(thefile)
diff --git a/log-template.py b/log-template.py
index b7e7658..cbbb4d1 100644
--- a/log-template.py
+++ b/log-template.py
@@ -6,7 +6,8 @@ log = [
"url":"link to comment",
"received":["card01","card02"],
"lost":["card03","card04"],
- "crayons":{"red":1,"orange":2,"yellow":-3}
+ "crayons":{"red":1,"orange":2,"yellow":-3},
+ "coupons":{"01":5},
"decks":["deck1","deck2","deck3","deck4","deck5","deck6","deck7","deck8"] # only if "event":"portfolio"
}
]
diff --git a/loggen.py b/loggen.py
index 74bfb82..81a7690 100644
--- a/loggen.py
+++ b/loggen.py
@@ -46,7 +46,23 @@ def loggen(month=False):
else:
thelog = log.log[::-1]
for event in thelog:
- if event["event"] != "portfolio":
+ if event == "portfolio":
+ logit = False
+ else:
+ try:
+ if event["received"]:
+ logit = True
+ except:
+ try:
+ if event["lost"]:
+ logit = True
+ except:
+ try:
+ if event["crayons"]:
+ logit = True
+ except:
+ logit = False
+ if logit == True:
content.write("" + event["date"].strftime("%Y-%m-%d") + "
[" + event["event"] + "]: ")
try:
if event["received"]: