Improve functions for showing genre on stats page + RSS

master
trémeur 2 years ago
parent 84161b7612
commit 1957f92f2c

@ -5,7 +5,7 @@ from importlib import import_module
Code to generate RSS feed Code to generate RSS feed
""" """
def feedgen(): def feedgen(local=False):
# delete existing file # delete existing file
if os.path.exists("build/feed.xml"): if os.path.exists("build/feed.xml"):
os.remove("build/feed.xml") os.remove("build/feed.xml")
@ -103,7 +103,14 @@ def feedgen():
therating = "X" therating = "X"
filewrite.write(", rated " + therating) filewrite.write(", rated " + therating)
if len(origread.genre) > 1: if len(origread.genre) > 1:
filewrite.write(", " + origread.genre[1]) genred = False
for thegenre in origread.genre:
if genred == False:
if thegenre == "gen" or thegenre == "slash" or thegenre == "pre-slash" or thegenre == "poly slash" or thegenre == "het" or thegenre == "pre-het" or thegenre == "femslash" or thegenre == "poly" or thegenre == "masturbation":
pass
else:
filewrite.write(", " + thegenre)
genred = True
except: except:
try: try:
filewrite.write(thefile.fandomtext) filewrite.write(thefile.fandomtext)
@ -130,11 +137,23 @@ def feedgen():
therating = "X" therating = "X"
filewrite.write(", rated " + therating) filewrite.write(", rated " + therating)
if len(thefile.genre) > 1: if len(thefile.genre) > 1:
filewrite.write(", " + thefile.genre[1]) genred = False
for thegenre in thefile.genre:
if genred == False:
if thegenre == "gen" or thegenre == "slash" or thegenre == "pre-slash" or thegenre == "poly slash" or thegenre == "het" or thegenre == "pre-het" or thegenre == "femslash" or thegenre == "poly" or thegenre == "masturbation":
pass
else:
filewrite.write(", " + thegenre)
genred = True
filewrite.write("</title>\n<pubDate>") filewrite.write("</title>\n<pubDate>")
futuredate = date + datetime.timedelta(days=2) futuredate = date + datetime.timedelta(days=2)
filewrite.write(futuredate.strftime("%a, %-d %b %Y")) filewrite.write(futuredate.strftime("%a, %-d %b %Y"))
filewrite.write(" 00:00:00 UT</pubDate>\n<link>https://tre.praze.net/fic/masterlist#fic" + ficcountstring + "</link>\n<guid isPermaLink=\"false\">praze-fic-" + ficcountstring) filewrite.write(" 00:00:00 UT</pubDate>\n<link>")
if local:
filewrite.write("/home/mdd/Documents/drive/proj/fic-archive/build/masterlist")
else:
filewrite.write("https://tre.praze.net/fic/masterlist")
filewrite.write("#fic" + ficcountstring + "</link>\n<guid isPermaLink=\"false\">praze-fic-" + ficcountstring)
datecount = 0 datecount = 0
dateindex = 0 dateindex = 0
for instalment in thefile.datewords: for instalment in thefile.datewords:

@ -19,8 +19,8 @@ except:
local = False local = False
if __name__ == "__main__": if __name__ == "__main__":
feed.feedgen()
if local == True: if local == True:
feed.feedgen(True)
masterlist.listgen(True) masterlist.listgen(True)
commentpage.allcomments(True) commentpage.allcomments(True)
commentpage.commentindex(True) commentpage.commentindex(True)
@ -31,6 +31,7 @@ if __name__ == "__main__":
verifygen.verifygen(True) verifygen.verifygen(True)
statsgen.yeargen(True) statsgen.yeargen(True)
else: else:
feed.feedgen()
masterlist.listgen() masterlist.listgen()
commentpage.allcomments() commentpage.allcomments()
commentpage.commentindex() commentpage.commentindex()

@ -34,11 +34,15 @@ def ficsum(ficcount,year,month=0,showfandom=True,local=False):
fandom = "/".join(origfile.fandom) fandom = "/".join(origfile.fandom)
except: except:
fandom = "/".join(fileread.fandom) fandom = "/".join(fileread.fandom)
thechars = ""
try: try:
if "OW" not in origfile.fandom: if "OW" not in origfile.fandom:
if "gen" not in origfile.genre:
try: try:
thechars = origfile.ship[0] thechars = origfile.ship[0]
except: except:
pass
else:
chars = [] chars = []
try: try:
chars.extend(origfile.charpov) chars.extend(origfile.charpov)
@ -56,9 +60,12 @@ def ficsum(ficcount,year,month=0,showfandom=True,local=False):
thechars = "" thechars = ""
except: except:
if "OW" not in fileread.fandom: if "OW" not in fileread.fandom:
if "gen" not in fileread.genre:
try: try:
thechars = fileread.ship[0] thechars = fileread.ship[0]
except: except:
pass
else:
chars = [] chars = []
try: try:
chars.extend(fileread.charpov) chars.extend(fileread.charpov)
@ -74,6 +81,8 @@ def ficsum(ficcount,year,month=0,showfandom=True,local=False):
thechars = "" thechars = ""
else: else:
thechars = "" thechars = ""
if thechars == "":
thechars = "no characters specified"
if fileread.language == "fr": if fileread.language == "fr":
language = "French" language = "French"
else: else:
@ -82,10 +91,35 @@ def ficsum(ficcount,year,month=0,showfandom=True,local=False):
rating = origfile.rating rating = origfile.rating
except: except:
rating = fileread.rating rating = fileread.rating
genre = []
try: try:
genre = origfile.genre[0] for thegenre in origfile.genre:
if thegenre == "gen":
genre.append(thegenre)
elif thegenre == "het" or thegenre == "pre-het":
genre.append("het")
elif thegenre == "slash" or thegenre == "pre-slash" or thegenre == "poly slash":
genre.append("slash")
elif thegenre == "femslash":
genre.append("femslash")
elif thegenre == "poly":
genre.append("multi")
elif thegenre == "masturbation":
genre.append("other")
except: except:
genre = fileread.genre[0] for thegenre in fileread.genre:
if thegenre == "gen":
genre.append(thegenre)
elif thegenre == "het" or thegenre == "pre-het":
genre.append("het")
elif thegenre == "slash" or thegenre == "pre-slash" or thegenre == "poly slash":
genre.append("slash")
elif thegenre == "femslash":
genre.append("femslash")
elif thegenre == "poly":
genre.append("multi")
elif thegenre == "masturbation":
genre.append("other")
try: try:
if origfile.warnings: if origfile.warnings:
warnings = "?!" warnings = "?!"
@ -130,16 +164,19 @@ def ficsum(ficcount,year,month=0,showfandom=True,local=False):
ficstring += "&nbsp;<span style=\"background-color:#eb7d10;color:white; font-family:serif\">&nbsp;M&nbsp;</span>" ficstring += "&nbsp;<span style=\"background-color:#eb7d10;color:white; font-family:serif\">&nbsp;M&nbsp;</span>"
elif rating == "e": elif rating == "e":
ficstring += "&nbsp;<span style=\"background-color:#9c0000;color:white; font-family:serif\">&nbsp;E&nbsp;</span>" ficstring += "&nbsp;<span style=\"background-color:#9c0000;color:white; font-family:serif\">&nbsp;E&nbsp;</span>"
if genre == "gen": for thegenre in genre:
if thegenre == "gen":
ficstring += "&nbsp;<span style=\"background-color:#8ab60b;color:white; font-family:serif\">&nbsp;☉&nbsp;</span>" ficstring += "&nbsp;<span style=\"background-color:#8ab60b;color:white; font-family:serif\">&nbsp;☉&nbsp;</span>"
elif genre == "slash" or genre == "pre-slash" or genre == "poly slash": elif thegenre == "slash":
ficstring += "&nbsp;<span style=\"background-color:#1256b6;color:white; font-family:serif\">&nbsp;♂&nbsp;</span>" ficstring += "&nbsp;<span style=\"background-color:#1256b6;color:white; font-family:serif\">&nbsp;♂&nbsp;</span>"
elif genre == "het" or genre == "pre-het": elif thegenre == "het":
ficstring += "&nbsp;<span style=\"background-color:#670840;color:white; font-family:serif\">&nbsp;⚤&nbsp;</span>" ficstring += "&nbsp;<span style=\"background-color:#670840;color:white; font-family:serif\">&nbsp;⚤&nbsp;</span>"
elif genre == "femslash": elif thegenre == "femslash":
ficstring += "&nbsp;<span style=\"background-color:#d50636;color:white; font-family:serif\">&nbsp;♀&nbsp;</span>" ficstring += "&nbsp;<span style=\"background-color:#d50636;color:white; font-family:serif\">&nbsp;♀&nbsp;</span>"
elif genre == "poly": elif thegenre == "poly":
ficstring += "&nbsp;<span><span style=\"background:linear-gradient(0deg, rgba(160,0,24,1) 0%, rgba(160,0,24,1) 49%, rgba(171,203,0,1) 50%, rgba(171,203,0,1) 100%);\">&nbsp;&nbsp;</span><span style=\"background: linear-gradient(0deg, rgba(0,51,148,1) 0%, rgba(0,51,148,1) 49%, rgba(129,0,108,1) 50%, rgba(129,0,108,1) 100%);\">&nbsp;&nbsp;</span></span>" ficstring += "&nbsp;<span><span style=\"background:linear-gradient(0deg, rgba(160,0,24,1) 0%, rgba(160,0,24,1) 49%, rgba(171,203,0,1) 50%, rgba(171,203,0,1) 100%);\">&nbsp;&nbsp;</span><span style=\"background: linear-gradient(0deg, rgba(0,51,148,1) 0%, rgba(0,51,148,1) 49%, rgba(129,0,108,1) 50%, rgba(129,0,108,1) 100%);\">&nbsp;&nbsp;</span></span>"
elif thegenre == "other":
ficstring += "&nbsp;<span style=\"background-color:black;color:white; font-family:serif\">&nbsp;☿&nbsp;</span>"
if warnings: if warnings:
ficstring += "&nbsp;<span style=\"background-color:#eb7d10;color:white; font-family:serif\">&nbsp;!<small>?</small>&nbsp;</span>" ficstring += "&nbsp;<span style=\"background-color:#eb7d10;color:white; font-family:serif\">&nbsp;!<small>?</small>&nbsp;</span>"
ficstring += "&nbsp;<code>" + str(words) + "</code>" ficstring += "&nbsp;<code>" + str(words) + "</code>"

Loading…
Cancel
Save