diff --git a/.gitignore b/.gitignore
index 5145293..3ea2f47 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,4 +23,5 @@ texts/*
!texts/.gitkeep
translationsmeta/*
!translationsmeta/__init__.py
-!translationsmeta/template.py
\ No newline at end of file
+!translationsmeta/template.py
+build/stats/*/index.html
\ No newline at end of file
diff --git a/build/fic4.css b/build/fic4.css
new file mode 100644
index 0000000..f3cdb99
--- /dev/null
+++ b/build/fic4.css
@@ -0,0 +1,157 @@
+/* ----- COLOURS ----- */
+
+body, details > summary::marker {
+ color: #222;
+}
+
+body {
+ background-color: white;
+}
+
+a, a:link, a:hover, a:visited, a:active, h1, h2, h3, details > summary {
+ color: var(--colourone);
+}
+
+li:before {
+ color: #9e9e9e;
+}
+
+details, blockquote {
+ border: 2px solid var(--colourone);
+ box-shadow: 8px 8px 0px var(--colourone);
+}
+
+body {
+ font-family: 'Lato', sans-serif;
+ font-size: 13px; word-wrap: break-word;
+}
+
+img {
+ max-width: 100%;
+}
+
+a, a:link, a:hover, a:visited, a:active {
+ text-decoration: none;
+}
+
+a:hover {
+ border-bottom: 1px solid;
+}
+
+/* ---- BOXES ---- */
+
+details > summary {
+ cursor: pointer;
+ font-weight: bold;
+}
+
+details, blockquote {
+ padding: 20px;
+ margin-bottom: 15px !important;
+}
+
+blockquote {
+ max-width: 100%;
+ min-width: 10%;
+ display: inline-block;
+}
+
+blockquote p, details p {
+ margin: 0;
+ padding: 0;
+}
+
+blockquote ul {
+ margin-top: 0;
+ margin-bottom: 0;
+}
+
+blockquote > * + *, details > * + * {
+ margin-top: 20px !important;
+}
+
+/* ---- CONTENT ---- */
+
+@media only screen and (min-width: 900px) {
+
+ div#site-wrapper {
+ width: 90%;
+ margin: 1em auto;
+ }
+}
+
+@media only screen and (max-width: 900px) {
+
+ div#site-wrapper {
+ width: 99%; margin: 1em auto;
+ }
+}
+
+input, select {
+ background-color: white;
+ font-family: 'Lato', sans-serif;
+}
+
+textarea {
+ font-family: 'Inconsolata', monospace;
+}
+
+code, pre, .timestamp {
+ background: #f0f0f0;
+ font-family: 'Inconsolata', monospace !important;
+}
+
+pre {
+ display: inline-block;
+ padding: 2px;
+ max-width: 100%;
+ overflow: auto;
+}
+
+
+ul {
+ list-style: none;
+}
+
+ul li:before {
+ content: "+ ";
+ font-weight: bold;
+}
+
+ol {
+ list-style: none;
+ counter-reset: li
+}
+
+ol li:before {
+ content: counter(li)". ";
+ font-weight: bold;
+}
+
+ol li {
+ counter-increment: li;
+}
+
+/* ----- GIFSETS ----- */
+
+div.figure {
+ text-align: center;
+ padding: 0;
+}
+
+div.figure img {
+ display: inline;
+ margin: 5px;
+}
+
+div.figure.oneup img {
+ width: 90%;
+}
+
+div.figure.twoup img {
+ width: 40%;
+}
+
+div.figure.threeup img {
+ width: 30%;
+}
diff --git a/build/stats/.gitkeep b/build/stats/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/generate.py b/generate.py
index 672d644..a13b581 100644
--- a/generate.py
+++ b/generate.py
@@ -8,6 +8,7 @@ import ships
import events
import indexgen
import verifygen
+import statsgen
try:
if sys.argv[1] == "local":
@@ -28,6 +29,7 @@ if __name__ == "__main__":
events.eventlist(True)
indexgen.indexgen(True)
verifygen.verifygen(True)
+ statsgen.yeargen(True)
else:
masterlist.listgen()
commentpage.allcomments()
@@ -37,3 +39,4 @@ if __name__ == "__main__":
events.eventlist()
indexgen.indexgen()
verifygen.verifygen()
+ statsgen.yeargen()
diff --git a/statsgen.py b/statsgen.py
new file mode 100644
index 0000000..8f57a41
--- /dev/null
+++ b/statsgen.py
@@ -0,0 +1,658 @@
+import datetime, os, shutil
+from importlib import import_module
+
+"""
+Warning: code in this file is /particularly/ bizarre and non-optimised.
+"""
+
+"""
+Write the wee blurb for each fic
+"""
+
+def ficsum(ficcount,year,month=0,showfandom=True,local=False):
+ 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:
+ theorig = "originalsmeta." + str(fileread.original)
+ origfile = import_module(theorig)
+ except:
+ pass
+ try:
+ fandom = "/".join(origfile.fandom)
+ except:
+ fandom = "/".join(fileread.fandom)
+ try:
+ if "OW" not in origfile.fandom:
+ try:
+ thechars = origfile.ship[0]
+ except:
+ chars = []
+ try:
+ chars.extend(origfile.charpov)
+ except:
+ pass
+ try:
+ chars.extend(origfile.charmain)
+ except:
+ pass
+ if chars != []:
+ thechars = ", ".join(chars)
+ else:
+ thechars = ""
+ else:
+ thechars = ""
+ except:
+ if "OW" not in fileread.fandom:
+ try:
+ thechars = fileread.ship[0]
+ except:
+ chars = []
+ try:
+ chars.extend(fileread.charpov)
+ except:
+ pass
+ try:
+ chars.extend(fileread.charmain)
+ except:
+ pass
+ if chars != []:
+ thechars = ", ".join(chars)
+ else:
+ thechars = ""
+ else:
+ thechars = ""
+ if fileread.language == "fr":
+ language = "French"
+ else:
+ language = ""
+ try:
+ rating = origfile.rating
+ except:
+ rating = fileread.rating
+ try:
+ genre = origfile.genre[0]
+ except:
+ genre = fileread.genre[0]
+ try:
+ if origfile.warnings:
+ warnings = "?!"
+ except:
+ try:
+ if fileread.warnings:
+ warnings = "?!"
+ except:
+ warnings = ""
+ words = 0
+ for datewords in fileread.datewords:
+ if month:
+ if int((datewords["date"]).year) == year:
+ if int((datewords["date"]).month) == month:
+ words += datewords["words"]
+ else:
+ if int((datewords["date"]).year) == year:
+ words += datewords["words"]
+ ficstring = ""
+ ficstring += ""
+ if showfandom:
+ ficstring += fandom
+ if thechars or language:
+ ficstring += ", "
+ if thechars:
+ ficstring += thechars
+ if language:
+ ficstring += ", "
+ if language:
+ ficstring += language
+ ficstring += ""
+ if rating == "g":
+ ficstring += " G "
+ elif rating == "t":
+ ficstring += " T "
+ elif rating == "m":
+ ficstring += " M "
+ elif rating == "e":
+ ficstring += " E "
+ if genre == "gen":
+ ficstring += " ☉ "
+ elif genre == "slash" or genre == "pre-slash" or genre == "poly slash":
+ ficstring += " ♂ "
+ elif genre == "het" or genre == "pre-het":
+ ficstring += " ⚤ "
+ elif genre == "femslash":
+ ficstring += " ♀ "
+ elif genre == "poly":
+ ficstring += " "
+ if warnings:
+ ficstring += " !? "
+ ficstring += " " + str(words) + "
"
+ return ficstring
+
+"""
+Generate stats page for each year
+"""
+
+def yeargen(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:
+ for date in fileread.datewords:
+ yearlist.append(date["date"].year)
+ yearlist = sorted(list(dict.fromkeys(yearlist)))
+ for year in yearlist:
+ yearpath = "build/stats/" + str(year)
+ if not os.path.isdir(yearpath):
+ os.mkdir(yearpath)
+ if os.path.exists(yearpath + "/index.html"):
+ os.remove(yearpath + "/index.html")
+ filewrite = open(yearpath + "/index.html", "a")
+ filewrite.write("\n\n
Total: " + str(len (allfics)) + " fic, " + str(totalwords) + " words
\n") + else: + filewrite.write("Total: " + str(len (allfics)) + " fics, " + str(totalwords) + " words
") + prompts = [] + for fic in ficdeets: + if fic["event"] == "prompt": + prompts.append(fic) + if prompts: + promptwords = 0 + for fic in prompts: + promptwords += fic["words"] + promptdict = {"type":"Prompt fills","fics":len(prompts),"words":promptwords,"list":prompts} + else: + promptdict = False + unprompted = [] + for fic in ficdeets: + if fic["event"] == False: + unprompted.append(fic) + if unprompted: + unpromptedwords = 0 + for fic in unprompted: + unpromptedwords += fic["words"] + unprompteddict = {"type":"Unprompted","fics":len(unprompted),"words":unpromptedwords,"list":unprompted} + else: + unprompteddict = False + challenges = [] + for fic in ficdeets: + if fic["event"] == "challenge": + challenges.append(fic) + if challenges: + challengewords = 0 + for fic in challenges: + challengewords += fic["words"] + challengedict = {"type":"Challenges","fics":len(challenges),"words":challengewords,"list":challenges} + else: + challengedict = False + exchanges = [] + for fic in ficdeets: + if fic["event"] == "exchange" or fic["event"] == "ao3exchange": + exchanges.append(fic) + if exchanges: + exchangewords = 0 + for fic in exchanges: + exchangewords += fic["words"] + exchangedict = {"type":"Exchanges","fics":len(exchanges),"words":exchangewords,"list":exchanges} + else: + exchangedict = False + byevent = [] + if promptdict: + byevent.append(promptdict) + if unprompteddict: + byevent.append(unprompteddict) + if challengedict: + byevent.append(challengedict) + if exchangedict: + byevent.append(exchangedict) + byevent = sorted(byevent,key=lambda d: d["words"],reverse=True) + filewrite.write("Type | \nWords | \n
---|---|
" + event["type"] + " | \n" + str(event["words"]) + "" + str(event["fics"]) + " fic") + if event["fics"] > 1: + filewrite.write("s") + filewrite.write(", " + str(event["words"]) + " words | \n
Event | \nWords | \n
---|---|
") + if event["eventlocation"] == "dwcomm": + filewrite.write("" + (event["eventname"]).replace("-","_") + "") + elif event["eventlocation"] == "dwjournal": + filewrite.write("" + (event["eventname"]).replace("-","_")+ "") + elif event["eventlocation"] == "ljjournal": + filewrite.write("" + (event["eventname"]).replace("-","_")+ "") + else: + filewrite.write(event["eventname"]) + filewrite.write(" | \n" + str(event["words"]) + "" + str(len(event["ficno"])) + " fic") + if len(event["ficno"]) > 1: + filewrite.write("s") + filewrite.write(", " + str(event["words"]) + " words | \n
Fandom | \nWords | \n
---|---|
" + fandom["name"] + " | \n" + str(fandom["words"]) + "" + str(len(fandom["ficno"])) + " fic") + if len(fandom["ficno"]) > 1: + filewrite.write("s") + filewrite.write(", " + str(fandom["words"]) + " words | \n
Month | \nWords | \n
---|---|
Jan | \n" + str(jan["words"]) + "" + str(len(jan["fics"])) + " fic") + if len(jan["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(jan["words"]) + " words | \n
Feb | \n" + str(feb["words"]) + "" + str(len(feb["fics"])) + " fic") + if len(feb["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(feb["words"]) + " words | \n
Mar | \n" + str(mar["words"]) + "" + str(len(mar["fics"])) + " fic") + if len(mar["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(mar["words"]) + " words | \n
Apr | \n" + str(apr["words"]) + "" + str(len(apr["fics"])) + " fic") + if len(apr["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(apr["words"]) + " words | \n
May | \n" + str(may["words"]) + "" + str(len(may["fics"])) + " fic") + if len(may["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(may["words"]) + " words | \n
Jun | \n" + str(jun["words"]) + "" + str(len(jun["fics"])) + " fic") + if len(jun["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(jun["words"]) + " words | \n
Jul | \n" + str(jul["words"]) + "" + str(len(jul["fics"])) + " fic") + if len(jul["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(jul["words"]) + " words | \n
Aug | \n" + str(aug["words"]) + "" + str(len(aug["fics"])) + " fic") + if len(aug["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(aug["words"]) + " words | \n
Sep | \n" + str(sep["words"]) + "" + str(len(sep["fics"])) + " fic") + if len(sep["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(sep["words"]) + " words | \n
Oct | \n" + str(octo["words"]) + "" + str(len(octo["fics"])) + " fic") + if len(octo["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(octo["words"]) + " words | \n
Nov | \n" + str(nov["words"]) + "" + str(len(nov["fics"])) + " fic") + if len(nov["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(nov["words"]) + " words | \n
Dec | \n" + str(dec["words"]) + "" + str(len(dec["fics"])) + " fic") + if len(dec["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(dec["words"]) + " words | \n
") + listposition = yearlist.index(year) + if year != 1998: + prevyear = yearlist[listposition - 1] + filewrite.write("« " + str(prevyear) + "") + thisyear = int(datetime.datetime.now().strftime("%Y")) + if year < thisyear: + nextyear = yearlist[listposition + 1] + filewrite.write("" + str(nextyear) + " »") + filewrite.write("
\n