You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.8 KiB
Python

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import datetime, os
from importlib import import_module
import makeheader
import headerfooter
"""
Code to generate masterlist
"""
def listgen(local=False):
# delete existing file
if os.path.exists("build/masterlist/index.html"):
os.remove("build/masterlist/index.html")
# write header
headerfooter.headerwrite("build/masterlist/index.html","Masterlist","Fic masterlist","<p>On this page, from newest to oldest, youll find basically everything Ive ever written that is a. fanfiction and b. extant; quality may vary. Some fics, such as things I wrote before 2020, require a username and password to access.</p>",False,local)
# write fic divs
ficcount = 500
sortfics = []
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("files/originalsmeta/" + ficcountstring + ".py"):
ficfile = "files.originalsmeta." + ficcountstring
fileread = import_module(ficfile)
try:
if fileread.revealdate <= datetime.datetime.now():
ficdict = {"thefic":ficcount,"thedate":(fileread.datewords[-1])["date"]}
sortfics.append(ficdict)
except:
ficdict = {"thefic":ficcount,"thedate":(fileread.datewords[-1])["date"]}
sortfics.append(ficdict)
thefics = sorted(sortfics, key=lambda d: d["thedate"],reverse=True)
for fic in thefics:
makeheader.ficgen(fic["thefic"],True,"build/masterlist/index.html",local)
# write footer
headerfooter.footerwrite("build/masterlist/index.html",False,local)
if __name__ == "__main__":
listgen()