Track coupons

master
trémeur 2 weeks ago
parent bcab0d3a2a
commit c5984b53d2

1
.gitignore vendored

@ -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

@ -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 youve 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 arent relevant).
- For each transaction, add a dictionary ={}= to the =log= list like in the example (removing any of ="received"=, ="lost"=, ="crayons"=, ="decks"=, ="coupons">= that arent relevant).
- Run =./build.sh= in this directory to download the relevant card images and then upload everything to the server.
** Currently unaccounted for
- Coupons

@ -562,3 +562,8 @@ span.sorttitle {
span.searchresults {
font-family: monospace;
}
img.coupon.expired {
-webkit-filter: grayscale(100%);
filter: grayscale(100%);
}

@ -268,6 +268,32 @@ def indexgen():
for card in faveslist:
content.write(tcgcore.printcard(card))
content.write("</p>\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("<h2>coupons</h2>\n<p>")
for coupon in coupons:
for key,value in coupon.items():
content.write("<img src=\"/assets/coupons/" + key + ".png\" class=\"coupon")
if value == 0:
content.write(" expired\" title=\"expired\"")
else:
content.write("\" title=\"" + str(value) + " left\"")
content.write(" loading=\"lazy\">")
content.write("</p>\n")
content.close()
skel.footerwrite(thefile)

@ -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"
}
]

@ -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("<p><code>" + event["date"].strftime("%Y-%m-%d") + "</code> <a href=\"" + event["url"] + "\">[" + event["event"] + "]</a>: ")
try:
if event["received"]:

Loading…
Cancel
Save