diff --git a/.gitignore b/.gitignore index b6ec3f4..9607449 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ build/index.html build/*/index.html build/ff/*/index.html build/comments/*/index.html +build/single/*/index.html build/feed.xml build/files/*.html build/files/*.pdf diff --git a/build/archive.css b/build/archive.css index 0eebbd6..94810bd 100644 --- a/build/archive.css +++ b/build/archive.css @@ -324,3 +324,9 @@ input#verifyage-checkbox { width: auto; margin: 0; } + +iframe { + height: 100vh; + width: 99%; + border: 2px solid rgb(99, 44, 44); +} diff --git a/build/single/.gitkeep b/build/single/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/generate.py b/generate.py index 29d9b94..1921f59 100644 --- a/generate.py +++ b/generate.py @@ -11,6 +11,7 @@ import indexgen import verifygen import statsgen import fandoms +import single try: if sys.argv[1] == "local": @@ -34,6 +35,7 @@ if __name__ == "__main__": indexgen.indexgen(True) verifygen.verifygen(True) statsgen.yeargen(True) + single.allsingles(True) else: feed.feedgen() masterlist.listgen() @@ -47,3 +49,4 @@ if __name__ == "__main__": indexgen.indexgen() verifygen.verifygen() statsgen.yeargen() + single.allsingles() diff --git a/makeheader.py b/makeheader.py index 5d4519a..8f6568f 100644 --- a/makeheader.py +++ b/makeheader.py @@ -2,16 +2,249 @@ import datetime from importlib import import_module from dateutil.relativedelta import relativedelta -""" -Remove test file -""" - fffandoms = ["FF1","FF2","FF3","FF4","FF5","FF6","FF7","FF8","FF9","FFX","FF11","FF12","FF13","FF14","FF15","FF16"] """ Code to generate the fic header div """ +def linkgen(ficno,output="output.html",local=False): + # convert to three-digit number + if ficno < 10: + ficnostring = "00" + str(ficno) + elif ficno < 100: + ficnostring = "0" + str(ficno) + else: + ficnostring = str(ficno) + # open the file + ficfile = "originalsmeta." + ficnostring + fileread = import_module(ficfile) + # open translation file if there is one + try: + if fileread.translation: + if fileread.translation < 10: + translationstring = "00" + str(fileread.translation) + elif fileread.translation < 100: + translationstring = "0" + str(fileread.translation) + else: + translationstring = str(fileread.translation) + translationfile = "translationsmeta." + translationstring + transread = import_module(translationfile) + except: + pass + filewrite = open(output, "a") + filewrite.write("\n") + # write links for translation if required + try: + if fileread.translation: + if transread.language == "en": + filewrite.write("\n") + except: + pass + def ficgen(ficno,unique=False,output="output.html",local=False): # convert to three-digit number if ficno < 10: @@ -350,216 +583,8 @@ def ficgen(ficno,unique=False,output="output.html",local=False): except: if juvenilia: filewrite.write("

\n") - filewrite.write("\n") - # write links for translation if required - try: - if fileread.translation: - if transread.language == "en": - filewrite.write("\n") - except: - pass + filewrite.close() + linkgen(ficno,output,local) + filewrite = open(output, "a") filewrite.write("\n") filewrite.close() diff --git a/single.py b/single.py new file mode 100644 index 0000000..0930100 --- /dev/null +++ b/single.py @@ -0,0 +1,92 @@ +import datetime, os, shutil +from importlib import import_module + +import headerfooter +import makeheader + +""" +Code to generate standalone fic pages +""" + +def singlepage(ficno,directory,local=False): + # convert to three-digit number + if ficno < 10: + ficnostring = "00" + str(ficno) + elif ficno < 100: + ficnostring = "0" + str(ficno) + else: + ficnostring = str(ficno) + # open the file + ficfile = directory + "." + ficnostring + fileread = import_module(ficfile) + # determine if unlocked + try: + if fileread.locked: + singlestatus = False + else: + singlestatus = True + except: + singlestatus = True + if singlestatus: + singlepath = "build/single/" + ficnostring + if not os.path.isdir(singlepath): + os.mkdir(singlepath) + if os.path.exists(singlepath + "/index.html"): + os.remove(singlepath + "/index.html") + # write to output file + output = singlepath + "/index.html" + headerfooter.headerwrite(output,"Fic no. " + ficnostring,"Fic no. " + ficnostring + "","",False,local) + try: + if fileread.original: + makeheader.ficgen(fileread.original,False,output,local) + else: + makeheader.ficgen(ficno,False,output,local) + except: + makeheader.ficgen(ficno,False,output,local) + filewrite = open(output, "a") + filewrite.write("\n
\n") + filewrite.close() + try: + if fileread.original: + makeheader.linkgen(fileread.original,output,local) + else: + makeheader.linkgen(ficno,output,local) + except: + makeheader.linkgen(ficno,output,local) + filewrite = open(output, "a") + filewrite.write("
\n") + filewrite.close() + headerfooter.footerwrite(output,False,local) + +""" +Generate all single pages +""" + +def allsingles(local=False): + for filename in os.listdir("build/single"): + filepath = os.path.join("build/single", filename) + if os.path.isfile(filepath): + os.unlink(filepath) + elif os.path.isdir(filepath): + shutil.rmtree(filepath) + 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"): + singlepage(ficcount,"originalsmeta",local) + elif os.path.exists("translationsmeta/" + ficcountstring + ".py"): + singlepage(ficcount,"translationsmeta",local) + +if __name__ == "__main__": + allsingles()