Add IDs to service links for CSS, make opening in new tabs optional
This commit is contained in:
parent
3b9f830d95
commit
a24391d01d
3 changed files with 99 additions and 16 deletions
|
@ -54,6 +54,7 @@ Python scripts to generate a mobile-friendly static site for tracking tcg cards
|
|||
- =maxmastered=: maximum number of most recently mastered decks to show on the index page
|
||||
- =firstmasteries=: a list of decks you mastered first
|
||||
- =misclink=: under ="link"=, a link to any page you choose, and under ~"text"~, text to display as the link
|
||||
- =newtab=: whether links to external sites should open in new tabs
|
||||
- =donations= : lists of donated decks and individual scrapbook cards
|
||||
- =masscollect=: list (python dict) of series/themes being mass collected, each containing at least one of ="series"= specifying a list of series from the online decklist, ="decks"= specifying a list of decks, or ="singles"= specifying a list of individual cards
|
||||
- =anniversary= : list of current anniversary decks
|
||||
|
|
113
colors.py
113
colors.py
|
@ -772,7 +772,43 @@ def headerwrite(thefile,pagename):
|
|||
if len(variables.subfolder) > 0:
|
||||
header.write("/" + variables.subfolder)
|
||||
header.write("/log\">log</a>")
|
||||
header.write("</li>\n <li><a href=\"" + variables.tradepost + "\" target=\"_blank\">trade post @ dw</a></li>\n <li> <details>\n <summary>service links</summary>\n <ul>\n <li><a href=\"https://colors-tcg.dreamwidth.org/tag/%21activity+rewards\" target=\"_blank\">activity rewards</a></li>\n <li><a href=\"https://colors-tcg.dreamwidth.org/tag/%2Aart+shop\" target=\"_blank\">art shop</a></li>\n <li><a href=\"https://colors-tcg.dreamwidth.org/tag/%2Aart+studio\" target=\"_blank\">art studio</a></li>\n <li><a href=\"https://colors-tcg.dreamwidth.org/tag/%2Adonate+a+deck\" target=\"_blank\">deck donations</a></li>\n <li><a href=\"https://colors-tcg.dreamwidth.org/tag/%2Adonate+a+special+deck\" target=\"_blank\">special deck donations</a></li>\n <li><a href=\"https://colors-tcg.dreamwidth.org/tag/%2Adonate+graphics\" target=\"_blank\">graphics donations</a></li>\n <li><a href=\"https://colors-tcg.dreamwidth.org/tag/%21levels\" target=\"_blank\">levels</a></li>\n <li><a href=\"https://colors-tcg.dreamwidth.org/tag/%21masteries\" target=\"_blank\">masteries</a></li>\n <li><a href=\"https://colors-tcg.dreamwidth.org/tag/%2Aportfolios\" target=\"_blank\">portfolios</a></li>\n <li><a href=\"https://colors-tcg.eu/recycledart.php\" target=\"_blank\">recycled art</a></li>\n <li><a href=\"https://colors-tcg.dreamwidth.org/tag/%2Asignatures\" target=\"_blank\">signatures</a></li>\n </ul>\n </details>\n </li>\n </ul>\n </nav>\n <main>\n")
|
||||
header.write("</li>\n <li><a href=\"" + variables.tradepost + "\"")
|
||||
if variables.newtab:
|
||||
header.write(" target=\"_blank\"")
|
||||
header.write(">trade post @ dw</a></li>\n <li> <details>\n <summary>service links</summary>\n <ul>\n <li id=\"activityrewards\"><a href=\"https://colors-tcg.dreamwidth.org/tag/%21activity+rewards\"")
|
||||
if variables.newtab:
|
||||
header.write(" target=\"_blank\"")
|
||||
header.write(">activity rewards</a></li>\n <li id=\"artshop\"><a href=\"https://colors-tcg.dreamwidth.org/tag/%2Aart+shop\"")
|
||||
if variables.newtab:
|
||||
header.write(" target=\"_blank\"")
|
||||
header.write(">art shop</a></li>\n <li id=\"artstudio\"><a href=\"https://colors-tcg.dreamwidth.org/tag/%2Aart+studio\"")
|
||||
if variables.newtab:
|
||||
header.write(" target=\"_blank\"")
|
||||
header.write(">art studio</a></li>\n <li id=\"donation\"><a href=\"https://colors-tcg.dreamwidth.org/tag/%2Adonate+a+deck\"")
|
||||
if variables.newtab:
|
||||
header.write(" target=\"_blank\"")
|
||||
header.write(">deck donations</a></li>\n <li id=\"specialdonation\"><a href=\"https://colors-tcg.dreamwidth.org/tag/%2Adonate+a+special+deck\"")
|
||||
if variables.newtab:
|
||||
header.write(" target=\"_blank\"")
|
||||
header.write(">special deck donations</a></li>\n <li id=\"graphicdonation\"><a href=\"https://colors-tcg.dreamwidth.org/tag/%2Adonate+graphics\"")
|
||||
if variables.newtab:
|
||||
header.write(" target=\"_blank\"")
|
||||
header.write(">graphics donations</a></li>\n <li id=\"redeemlevel\"><a href=\"https://colors-tcg.dreamwidth.org/tag/%21levels\"")
|
||||
if variables.newtab:
|
||||
header.write(" target=\"_blank\"")
|
||||
header.write(">levels</a></li>\n <li id=\"redeemmastery\"><a href=\"https://colors-tcg.dreamwidth.org/tag/%21masteries\"")
|
||||
if variables.newtab:
|
||||
header.write(" target=\"_blank\"")
|
||||
header.write(">masteries</a></li>\n <li id=\"redeemportfolio\"><a href=\"https://colors-tcg.dreamwidth.org/tag/%2Aportfolios\"")
|
||||
if variables.newtab:
|
||||
header.write(" target=\"_blank\"")
|
||||
header.write(">portfolios</a></li>\n <li id=\"recycledart\"><a href=\"https://colors-tcg.eu/recycledart.php\"")
|
||||
if variables.newtab:
|
||||
header.write(" target=\"_blank\"")
|
||||
header.write(">recycled art</a></li>\n <li id=\"getsigs\"><a href=\"https://colors-tcg.dreamwidth.org/tag/%2Asignatures\"")
|
||||
if variables.newtab:
|
||||
header.write(" target=\"_blank\"")
|
||||
header.write(">signatures</a></li>\n </ul>\n </details>\n </li>\n </ul>\n </nav>\n <main>\n")
|
||||
if variables.hiatus:
|
||||
header.write("<div id=\"hiatus\">\n<h1>hiatus</h1>\n<p>")
|
||||
if type(variables.hiatus) == str:
|
||||
|
@ -1021,7 +1057,10 @@ def portfoliogen(theportfolio,thetype,portnumber):
|
|||
portstring += "□"
|
||||
break
|
||||
portstring += " " + specialdeck
|
||||
portstring += "</td>\n</tr>\n<tr>\n<td colspan=\"2\"><a href=\"" + theportfolio["url"] + "\" target=\"_blank\">palette portfolio "
|
||||
portstring += "</td>\n</tr>\n<tr>\n<td colspan=\"2\"><a href=\"" + theportfolio["url"] + "\""
|
||||
if variables.newtab:
|
||||
portstring += " target=\"_blank\""
|
||||
portstring += ">palette portfolio "
|
||||
if portnumber < 10:
|
||||
portstring += "0" + str(portnumber)
|
||||
else:
|
||||
|
@ -1094,7 +1133,10 @@ def portfoliogen(theportfolio,thetype,portnumber):
|
|||
else:
|
||||
portstring += "□"
|
||||
break
|
||||
portstring += " " + thedecks[7] + "</td>\n</tr>\n<tr>\n<td colspan=\"2\"><a href=\"" + theportfolio["url"] + "\" target=\"_blank\">monochrome portfolio "
|
||||
portstring += " " + thedecks[7] + "</td>\n</tr>\n<tr>\n<td colspan=\"2\"><a href=\"" + theportfolio["url"] + "\""
|
||||
if variables.newtab:
|
||||
portstring += " target=\"_blank\""
|
||||
portstring += ">monochrome portfolio "
|
||||
if portnumber < 10:
|
||||
portstring += "0" + str(portnumber)
|
||||
else:
|
||||
|
@ -1230,7 +1272,10 @@ def printdeck(deck,fold=True):
|
|||
deckstring += " </tr>\n"
|
||||
test += 1
|
||||
if deck["mastered"]:
|
||||
deckstring += " <tr>\n <td colspan=\"5\" align=\"center\"><a href=\"https://colors-tcg.eu/viewcards.php?deck=" + deck["name"] + "\" target=\"_blank\"><img src=\""
|
||||
deckstring += " <tr>\n <td colspan=\"5\" align=\"center\"><a href=\"https://colors-tcg.eu/viewcards.php?deck=" + deck["name"] + "\""
|
||||
if variables.newtab:
|
||||
deckstring += " target=\"_blank\""
|
||||
deckstring += "><img src=\""
|
||||
if len(variables.subfolder) > 0:
|
||||
deckstring += "/" + variables.subfolder
|
||||
deckstring += "/decks/" + deck["name"] + "/master.gif\" title=\"mastered " + deck["name"]
|
||||
|
@ -1283,7 +1328,10 @@ def indexgen():
|
|||
content.write("/" + variables.subfolder)
|
||||
content.write("/decks/sigs/" + variables.name.lower() + ".gif\" loading=\"lazy\">")
|
||||
if variables.banner:
|
||||
content.write("<a target=\"_blank\" href=\"" + variables.tradepost + "\"><img src=\"")
|
||||
content.write("<a href=\"" + variables.tradepost + "\"")
|
||||
if variables.newtab:
|
||||
content.write(" target=\"_blank\"")
|
||||
content.write("><img src=\"")
|
||||
if len(variables.subfolder) > 0:
|
||||
content.write("/" + variables.subfolder)
|
||||
content.write("/assets/banner.png\" loading=\"lazy\"></a>")
|
||||
|
@ -1411,11 +1459,17 @@ def indexgen():
|
|||
if tradepend > 1:
|
||||
content.write("s")
|
||||
content.write(" held for trades</li>\n")
|
||||
content.write("<li>started <code>" + firstdate.strftime("%Y-%m-%d") + "</code></li>\n<li>last updated <code>" + datetime.datetime.now().strftime("%Y-%m-%d") + "</code></li>\n<li><a href=\"https://git.praze.net/tre/tcg\" target=\"_blank\">code</a> ")
|
||||
content.write("<li>started <code>" + firstdate.strftime("%Y-%m-%d") + "</code></li>\n<li>last updated <code>" + datetime.datetime.now().strftime("%Y-%m-%d") + "</code></li>\n<li><a href=\"https://git.praze.net/tre/tcg\"")
|
||||
if variables.newtab:
|
||||
content.write(" target=\"_blank\"")
|
||||
content.write(">code</a> ")
|
||||
if variables.name == "Mez":
|
||||
content.write("under construction")
|
||||
else:
|
||||
content.write("by <a href=\https://tcg.praze.net\" target=\"_blank\">mez</a>")
|
||||
content.write("by <a href=\https://tcg.praze.net\"")
|
||||
if variables.newtab:
|
||||
content.write(" target=\"_blank\"")
|
||||
content.write(">mez</a>")
|
||||
content.write("</li>\n")
|
||||
try:
|
||||
if len(variables.misclink["text"]) > 0:
|
||||
|
@ -1519,7 +1573,10 @@ def indexgen():
|
|||
masteredcount = 0
|
||||
for deck in mastereddecks:
|
||||
if masteredcount < variables.maxmastered:
|
||||
content.write("<a href=\"https://colors-tcg.eu/viewcards.php?deck=" + deck["name"] + "\" target=\"_blank\"><img src=\"")
|
||||
content.write("<a href=\"https://colors-tcg.eu/viewcards.php?deck=" + deck["name"] + "\"")
|
||||
if variables.newtab:
|
||||
content.write(" target=\"_blank\"")
|
||||
content.write("><img src=\"")
|
||||
if len(variables.subfolder) > 0:
|
||||
content.write("/" + variables.subfolder)
|
||||
content.write("/decks/" + deck["name"] + "/master.gif\" title=\"mastered " + deck["name"])
|
||||
|
@ -1553,7 +1610,10 @@ def indexgen():
|
|||
else:
|
||||
memberlink = False
|
||||
if memberlink:
|
||||
content.write("<a href=\"" + memberlink + "\" target=\"_blank\">")
|
||||
content.write("<a href=\"" + memberlink + "\"")
|
||||
if variables.newtab:
|
||||
content.write(" target=\"_blank\"")
|
||||
content.write(">")
|
||||
content.write(printcard(card))
|
||||
if memberlink:
|
||||
content.write("</a>")
|
||||
|
@ -1568,7 +1628,10 @@ def indexgen():
|
|||
content.write("<h2>coupons</h2>\n<p>")
|
||||
for coupon in coupons:
|
||||
if coupons[coupon]["count"] > 0:
|
||||
content.write("<a href=\"" + coupons[coupon]["inurl"] + "\" target=\"_blank\">")
|
||||
content.write("<a href=\"" + coupons[coupon]["inurl"] + "\"")
|
||||
if variables.newtab:
|
||||
content.write(" target=\"_blank\"")
|
||||
content.write(">")
|
||||
content.write("<img src=\"")
|
||||
if len(variables.subfolder) > 0:
|
||||
content.write("/" + variables.subfolder)
|
||||
|
@ -1610,9 +1673,15 @@ def indexgen():
|
|||
for donation in donations:
|
||||
content.write("<a href=\"https://colors-tcg.eu/viewcards.php?deck=")
|
||||
if donation["type"] == "single":
|
||||
content.write(donation["name"][:-2] + "\" target=\"_blank\">" + printcard(donation["name"]))
|
||||
content.write(donation["name"][:-2] + "\"")
|
||||
if variables.newtab:
|
||||
content.write(" target=\"_blank\"")
|
||||
content.write(">" + printcard(donation["name"]))
|
||||
else:
|
||||
content.write(donation["name"] + "\" target=\"_blank\">")
|
||||
content.write(donation["name"] + "\"")
|
||||
if variables.newtab:
|
||||
content.write(" target=\"_blank\"")
|
||||
content.write(">")
|
||||
if donation["type"] == "deck":
|
||||
content.write("<img src=\"")
|
||||
if len(variables.subfolder) > 0:
|
||||
|
@ -2342,7 +2411,10 @@ def massseriesgen(series,massindex):
|
|||
for deck in decklist:
|
||||
if deck["mastered"]:
|
||||
if series in deck["mass"] or series in deck["massmaster"]:
|
||||
content.write("<a href=\"https://colors-tcg.eu/viewcards.php?deck=" + deck["name"] + "\" target=\"_blank\"><img src=\"")
|
||||
content.write("<a href=\"https://colors-tcg.eu/viewcards.php?deck=" + deck["name"] + "\"")
|
||||
if variables.newtab:
|
||||
content.write(" target=\"_blank\"")
|
||||
content.write("><img src=\"")
|
||||
if len(variables.subfolder) > 0:
|
||||
content.write("/" + variables.subfolder)
|
||||
content.write("/decks/" + deck["name"] + "/master.gif\" title=\"mastered " + deck["name"])
|
||||
|
@ -2354,7 +2426,10 @@ def massseriesgen(series,massindex):
|
|||
content.write("\"></a>")
|
||||
elif series == "colors universe":
|
||||
if deck["colour"] == "limited":
|
||||
content.write("<a href=\"https://colors-tcg.eu/viewcards.php?deck=" + deck["name"] + "\" target=\"_blank\"><img src=\"")
|
||||
content.write("<a href=\"https://colors-tcg.eu/viewcards.php?deck=" + deck["name"] + "\"")
|
||||
if variables.newtab:
|
||||
content.write(" target=\"_blank\"")
|
||||
content.write("><img src=\"")
|
||||
if len(variables.subfolder) > 0:
|
||||
content.write("/" + variables.subfolder)
|
||||
content.write("/decks/" + deck["name"] + "/master.gif\" title=\"mastered " + deck["name"])
|
||||
|
@ -2447,7 +2522,10 @@ def tradegen(colour=False):
|
|||
content.write("<h1>available for trade</h1>\n" + filterwrite("trade",colour,True,True) + "<p class=\"tradeterms\">")
|
||||
if len(variables.tradestatement) > 0:
|
||||
content.write(variables.tradestatement + " ")
|
||||
content.write("Trade cards <a href=\"" + variables.tradepost + "\" target=\"_blank\">here</a></p>\n<p><textarea readonly>")
|
||||
content.write("Trade cards <a href=\"" + variables.tradepost + "\"")
|
||||
if variables.newtab:
|
||||
content.write(" target=\"_blank\"")
|
||||
content.write(">here</a></p>\n<p><textarea readonly>")
|
||||
precomma = False
|
||||
for card in alltradelist:
|
||||
if colour:
|
||||
|
@ -2689,7 +2767,10 @@ def loggen(month=False):
|
|||
else:
|
||||
admit = True
|
||||
if admit == True:
|
||||
content.write("<p><code>" + event["date"].strftime("%Y-%m-%d") + "</code> <a href=\"" + event["url"] + "\" target=\"_blank\">[" + event["name"] + "]</a>: ")
|
||||
content.write("<p><code>" + event["date"].strftime("%Y-%m-%d") + "</code> <a href=\"" + event["url"] + "\"")
|
||||
if variables.newtab:
|
||||
content.write(" target=\"_blank\"")
|
||||
content.write(">[" + event["name"] + "]</a>: ")
|
||||
try:
|
||||
if event["received"]:
|
||||
content.write("Received ")
|
||||
|
|
|
@ -25,6 +25,7 @@ tradestatement = ""
|
|||
maxmastered = 20
|
||||
firstmasteries = ["deckname","nameofdeck"]
|
||||
misclink = {"link":"","text":""}
|
||||
newtab = True
|
||||
donations = {"decks":[],"scrapbook":[]}
|
||||
masscollect = {"series":{"series":["a series","another series"],"decks":["firstdeck","seconddeck"],"singles":["card01","card02"]}}
|
||||
anniversary = ["deckname"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue