Add link to stats pages from index
This commit is contained in:
parent
33a5cf09a8
commit
359617a15d
2 changed files with 51 additions and 4 deletions
|
@ -20,8 +20,8 @@ Requisites: =rclone= (just for uploading files to the server), Python 3.
|
||||||
- all my fics are (currently) on AO3, most have HTML versions, newer ones also have EPUB and PDF versions
|
- all my fics are (currently) on AO3, most have HTML versions, newer ones also have EPUB and PDF versions
|
||||||
- I have weird rules about comments and sometimes turn them off after a certain period
|
- I have weird rules about comments and sometimes turn them off after a certain period
|
||||||
|
|
||||||
** Future plans [1/3]
|
** Future plans [2/3]
|
||||||
|
|
||||||
- [X] redirect to a consent page using local storage (h/t [[https://www.fancoders.com/][Fandom Coders]])
|
- [X] redirect to a consent page using local storage (h/t [[https://www.fancoders.com/][Fandom Coders]])
|
||||||
- [ ] pages for times and locations in FF fandoms
|
- [ ] pages for times and locations in FF fandoms
|
||||||
- [ ] possibly a page for non-FF fandoms (as if I even care about these lol)
|
- [X] possibly a page for non-FF fandoms (as if I even care about these lol)
|
||||||
|
|
51
indexgen.py
51
indexgen.py
|
@ -1,7 +1,53 @@
|
||||||
import os
|
import os
|
||||||
|
from importlib import import_module
|
||||||
|
|
||||||
import headerfooter
|
import headerfooter
|
||||||
|
|
||||||
|
def statslist(local=False):
|
||||||
|
yearlist = []
|
||||||
|
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)
|
||||||
|
elif os.path.exists("translationsmeta/" + ficcountstring + ".py"):
|
||||||
|
ficfile = "translationsmeta." + ficcountstring
|
||||||
|
fileread = import_module(ficfile)
|
||||||
|
else:
|
||||||
|
fileread = False
|
||||||
|
if fileread:
|
||||||
|
try:
|
||||||
|
if fileread.revealdate > datetime.datetime.now():
|
||||||
|
revealed = False
|
||||||
|
else:
|
||||||
|
revealed = True
|
||||||
|
except:
|
||||||
|
revealed = True
|
||||||
|
if revealed == True:
|
||||||
|
for date in fileread.datewords:
|
||||||
|
yearlist.append(date["date"].year)
|
||||||
|
yearlist = sorted(list(dict.fromkeys(yearlist)))
|
||||||
|
linkedyears = []
|
||||||
|
for year in yearlist:
|
||||||
|
statstring = ""
|
||||||
|
if local == True:
|
||||||
|
statspath = "/home/mdd/Documents/drive/proj/fic-archive/build/stats/" + str(year) + "/index.html"
|
||||||
|
else:
|
||||||
|
statspath = "/fic/stats/" + str(year)
|
||||||
|
if yearlist.index(year) > 0:
|
||||||
|
statstring += " • "
|
||||||
|
statstring += "<a href=\"" + statspath + "\">" + str(year) + "</a>"
|
||||||
|
linkedyears.append(statstring)
|
||||||
|
listofyears = "".join(linkedyears)
|
||||||
|
return listofyears
|
||||||
|
|
||||||
def indexgen(local=False):
|
def indexgen(local=False):
|
||||||
# delete existing file
|
# delete existing file
|
||||||
if os.path.exists("build/index.html"):
|
if os.path.exists("build/index.html"):
|
||||||
|
@ -47,9 +93,10 @@ def indexgen(local=False):
|
||||||
filewrite.write("events/index.html")
|
filewrite.write("events/index.html")
|
||||||
else:
|
else:
|
||||||
filewrite.write("/fic/events")
|
filewrite.write("/fic/events")
|
||||||
filewrite.write("\">Events</a></h2>\n<p>I’ve been participating in fandom exchanges and other events since late 2020. Most fics I write these days that aren’t in FF fandoms are in this category (although a lot of the FF ones are as well).</p>\n</div>\n")
|
filewrite.write("\">Events</a></h2>\n<p>I’ve been participating in fandom exchanges and other events since late 2020. Most fics I write these days that aren’t in FF fandoms are in this category (although a lot of the FF ones are as well).</p>\n</div>\n<div class=\"fic\">\n<h2>Other</h2>\n<ul>\n<li>Stats by year: " + (str(statslist(local))) + "</li>\n</ul>\n</div>\n")
|
||||||
filewrite.close()
|
filewrite.close()
|
||||||
headerfooter.footerwrite("build/index.html",True,local)
|
headerfooter.footerwrite("build/index.html",True,local)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
indexgen()
|
statslist(True)
|
||||||
|
indexgen(True)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue