Add page to display all fics by fandom
This commit is contained in:
parent
36071d5c1f
commit
a6a5e0a87e
5 changed files with 131 additions and 3 deletions
0
build/byfandom/.gitkeep
Normal file
0
build/byfandom/.gitkeep
Normal file
120
fandoms.py
Normal file
120
fandoms.py
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
import datetime, os
|
||||||
|
from importlib import import_module
|
||||||
|
|
||||||
|
import makeheader
|
||||||
|
import headerfooter
|
||||||
|
|
||||||
|
def fandomlist(local=False):
|
||||||
|
# delete existing file
|
||||||
|
if os.path.exists("build/byfandom/index.html"):
|
||||||
|
os.remove("build/byfandom/index.html")
|
||||||
|
# write header
|
||||||
|
headerfooter.headerwrite("build/byfandom/index.html","Fics by fandom","Fics by fandom","<p>On this page, you’ll find basically everything I’ve ever written that is a. fanfiction and b. extant, grouped by fandom and then sorted newest to oldest; quality may vary. RPF and things I wrote before 2020 require a username and password to access.</p>",False,local)
|
||||||
|
# get list of fandoms
|
||||||
|
fandoms = []
|
||||||
|
ficcount = 500
|
||||||
|
while ficcount > 0:
|
||||||
|
ficcount -= 1
|
||||||
|
if ficcount < 10:
|
||||||
|
ficcountstring = "00" + str(ficcount)
|
||||||
|
elif ficcount < 100:
|
||||||
|
ficcountstring = "0" + str(ficcount)
|
||||||
|
else:
|
||||||
|
ficcountstring = str(ficcount)
|
||||||
|
if os.path.exists("originalsmeta/" + ficcountstring + ".py"):
|
||||||
|
ficfile = "originalsmeta." + ficcountstring
|
||||||
|
fileread = import_module(ficfile)
|
||||||
|
try:
|
||||||
|
if fileread.revealdate > datetime.datetime.now():
|
||||||
|
revealed = False
|
||||||
|
else:
|
||||||
|
revealed = True
|
||||||
|
except:
|
||||||
|
revealed = True
|
||||||
|
if revealed == True:
|
||||||
|
for fandom in fileread.fandom:
|
||||||
|
fandoms.append(fandom)
|
||||||
|
newlist = []
|
||||||
|
for fandom in fandoms:
|
||||||
|
if fandom not in newlist:
|
||||||
|
newlist.append(fandom)
|
||||||
|
fandomlist = []
|
||||||
|
for fandom in newlist:
|
||||||
|
if "FF" in fandom:
|
||||||
|
if fandom == "FFX":
|
||||||
|
newfandom = "FF10"
|
||||||
|
elif len(fandom) == 3:
|
||||||
|
newfandom = "FF0" + fandom[-1]
|
||||||
|
else:
|
||||||
|
newfandom = fandom
|
||||||
|
fandomlist.append({"searchname":fandom,"sortname":newfandom.replace("FF","Final Fantasy "),"displayname":fandom.replace("FF","Final Fantasy ")})
|
||||||
|
else:
|
||||||
|
fandomlist.append({"searchname":fandom,"sortname":fandom,"displayname":fandom})
|
||||||
|
fandomlist = sorted(fandomlist, key=lambda d: d["sortname"])
|
||||||
|
for fandom in fandomlist:
|
||||||
|
fandomfics = []
|
||||||
|
# check which fics are in the fandom
|
||||||
|
ficcount = 500
|
||||||
|
while ficcount > 0:
|
||||||
|
ficcount -= 1
|
||||||
|
if ficcount < 10:
|
||||||
|
ficcountstring = "00" + str(ficcount)
|
||||||
|
elif ficcount < 100:
|
||||||
|
ficcountstring = "0" + str(ficcount)
|
||||||
|
else:
|
||||||
|
ficcountstring = str(ficcount)
|
||||||
|
if os.path.exists("originalsmeta/" + ficcountstring + ".py"):
|
||||||
|
countfile = "originalsmeta." + ficcountstring
|
||||||
|
fileread = import_module(countfile)
|
||||||
|
try:
|
||||||
|
if fileread.revealdate > datetime.datetime.now():
|
||||||
|
revealed = False
|
||||||
|
else:
|
||||||
|
revealed = True
|
||||||
|
except:
|
||||||
|
revealed = True
|
||||||
|
if revealed == True:
|
||||||
|
if fandom["searchname"] in fileread.fandom:
|
||||||
|
fandomfics.append(ficcount)
|
||||||
|
firstfic = fandomfics[-1]
|
||||||
|
if firstfic < 10:
|
||||||
|
firstficstring = "00" + str(firstfic)
|
||||||
|
elif firstfic < 100:
|
||||||
|
firstficstring = "0" + str(firstfic)
|
||||||
|
else:
|
||||||
|
firstficstring = str(firstfic)
|
||||||
|
firstfile = "originalsmeta." + firstficstring
|
||||||
|
firstread = import_module(firstfile)
|
||||||
|
firstyear = (firstread.datewords[0])["date"].year
|
||||||
|
lastfic = fandomfics[0]
|
||||||
|
if lastfic < 10:
|
||||||
|
lastficstring = "00" + str(lastfic)
|
||||||
|
elif lastfic < 100:
|
||||||
|
lastficstring = "0" + str(lastfic)
|
||||||
|
else:
|
||||||
|
lastficstring = str(lastfic)
|
||||||
|
lastfile = "originalsmeta." + lastficstring
|
||||||
|
lastread = import_module(lastfile)
|
||||||
|
lastyear = (lastread.datewords[0])["date"].year
|
||||||
|
if lastyear == firstyear:
|
||||||
|
yearstring = str(firstyear)
|
||||||
|
else:
|
||||||
|
yearstring = str(firstyear) + "–" + str(lastyear)
|
||||||
|
# write details element
|
||||||
|
output = "build/byfandom/index.html"
|
||||||
|
filewrite = open(output, "a")
|
||||||
|
filewrite.write("<details><summary><b>" + fandom["displayname"] + "</b> (" + str(len(fandomfics)) + " fic")
|
||||||
|
if len(fandomfics) > 1:
|
||||||
|
filewrite.write("s")
|
||||||
|
filewrite.write(", " + yearstring + ")</summary>\n")
|
||||||
|
filewrite.close()
|
||||||
|
for fic in fandomfics:
|
||||||
|
makeheader.ficgen(fic,False,output,local)
|
||||||
|
filewrite = open(output, "a")
|
||||||
|
filewrite.write("</details>\n")
|
||||||
|
filewrite.close()
|
||||||
|
# write footer
|
||||||
|
headerfooter.footerwrite("build/byfandom/index.html",False,local)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
fandomlist(True)
|
|
@ -9,6 +9,7 @@ import events
|
||||||
import indexgen
|
import indexgen
|
||||||
import verifygen
|
import verifygen
|
||||||
import statsgen
|
import statsgen
|
||||||
|
import fandoms
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if sys.argv[1] == "local":
|
if sys.argv[1] == "local":
|
||||||
|
@ -22,6 +23,7 @@ if __name__ == "__main__":
|
||||||
if local == True:
|
if local == True:
|
||||||
feed.feedgen(True)
|
feed.feedgen(True)
|
||||||
masterlist.listgen(True)
|
masterlist.listgen(True)
|
||||||
|
fandoms.fandomlist(True)
|
||||||
commentpage.allcomments(True)
|
commentpage.allcomments(True)
|
||||||
commentpage.commentindex(True)
|
commentpage.commentindex(True)
|
||||||
characters.charlist(True)
|
characters.charlist(True)
|
||||||
|
@ -33,6 +35,7 @@ if __name__ == "__main__":
|
||||||
else:
|
else:
|
||||||
feed.feedgen()
|
feed.feedgen()
|
||||||
masterlist.listgen()
|
masterlist.listgen()
|
||||||
|
fandoms.fandomlist()
|
||||||
commentpage.allcomments()
|
commentpage.allcomments()
|
||||||
commentpage.commentindex()
|
commentpage.commentindex()
|
||||||
characters.charlist()
|
characters.charlist()
|
||||||
|
|
|
@ -17,12 +17,17 @@ def indexgen(local=False):
|
||||||
filewrite.write("\">here</a>.</p>\n<p>You can also subscribe to <a href=\"")
|
filewrite.write("\">here</a>.</p>\n<p>You can also subscribe to <a href=\"")
|
||||||
if not local:
|
if not local:
|
||||||
filewrite.write("/fic/")
|
filewrite.write("/fic/")
|
||||||
filewrite.write("feed.xml\">the RSS feed</a> to be notified of new fics and updates to existing ones.</p>\n<div class=\"fic\">\n<h2><a href=\"")
|
filewrite.write("feed.xml\">the RSS feed</a> to be notified of new fics and updates to existing ones.</p>\n<div class=\"fic\">\n<h2>Masterlist</h2>\n<p>Every fic I’ve written since the age of five. You can view these:\n<ul>\n<li><a href=\"")
|
||||||
if local:
|
if local:
|
||||||
filewrite.write("masterlist/index.html")
|
filewrite.write("masterlist/index.html")
|
||||||
else:
|
else:
|
||||||
filewrite.write("/fic/masterlist")
|
filewrite.write("/fic/masterlist")
|
||||||
filewrite.write("\">Masterlist</a></h2>\n<p>Every fic I’ve ever written since the age of five, sorted newest to oldest.</p>\n</div>\n<div class=\"fic\">\n<h2>Final Fantasy</h2>\n<p>Most of the fics I write are in FF fandoms these days. You can browse them:</p>\n<ul>\n<li><a href=\"")
|
filewrite.write("\">chronologically</a></li>\n<li><a href=\"")
|
||||||
|
if local:
|
||||||
|
filewrite.write("byfandom/index.html")
|
||||||
|
else:
|
||||||
|
filewrite.write("/fic/byfandom")
|
||||||
|
filewrite.write("\">by fandom</a></li>\n</ul>\n</div>\n<div class=\"fic\">\n<h2>Final Fantasy</h2>\n<p>Most of the fics I write are in FF fandoms these days. You can browse them:</p>\n<ul>\n<li><a href=\"")
|
||||||
if local:
|
if local:
|
||||||
filewrite.write("ff/characters/index.html")
|
filewrite.write("ff/characters/index.html")
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -13,7 +13,7 @@ def listgen(local=False):
|
||||||
if os.path.exists("build/masterlist/index.html"):
|
if os.path.exists("build/masterlist/index.html"):
|
||||||
os.remove("build/masterlist/index.html")
|
os.remove("build/masterlist/index.html")
|
||||||
# write header
|
# write header
|
||||||
headerfooter.headerwrite("build/masterlist/index.html","Masterlist","Fic masterlist","<p>On this page, from newest to oldest, you’ll find basically everything I’ve ever written that is a. fanfiction and b. extant; quality may vary. RPF and things I wrote before 2020 require a username and password to access; if they’re on AO3, they’re available behind the login wall.</p>",False,local)
|
headerfooter.headerwrite("build/masterlist/index.html","Masterlist","Fic masterlist","<p>On this page, from newest to oldest, you’ll find basically everything I’ve ever written that is a. fanfiction and b. extant; quality may vary. RPF and things I wrote before 2020 require a username and password to access.</p>",False,local)
|
||||||
# write fic divs
|
# write fic divs
|
||||||
ficcount = 500
|
ficcount = 500
|
||||||
while ficcount > 0:
|
while ficcount > 0:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue