Add age verification gate and some noscript fallbacks

master
trémeur 2 years ago
parent ed37d4172a
commit 2b350a6e1e

@ -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 ** Future plans [1/3]
- redirect to a consent page using local storage - [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) - [ ] possibly a page for non-FF fandoms (as if I even care about these lol)

@ -65,7 +65,7 @@ def commentpage(ficno,directory,local=False):
headerfooter.headerwrite(commentspath + "/index.html","Comments for fic no. " + ficnostring,"Comments for fic no. <span id=\"ficno\">" + ficnostring + "</span>","",False,local) headerfooter.headerwrite(commentspath + "/index.html","Comments for fic no. " + ficnostring,"Comments for fic no. <span id=\"ficno\">" + ficnostring + "</span>","",False,local)
filewrite = open(commentspath + "/index.html", "a") filewrite = open(commentspath + "/index.html", "a")
if fffandom or timeelapsed.days < 730: if fffandom or timeelapsed.days < 730:
filewrite.write("<h2>Leave a comment</h2>\n<p>Comments will be posted manually; please expect a delay between submitting your comment and seeing it below!</p>\n<form id=\"theform\" onsubmit=\"sendContact(event)\">\n<input type=\"text\" id=\"nameInput\" required placeholder=\"Pseudonym (required)\">\n<input type=\"email\" id=\"emailInput\" placeholder=\"Email (if you want email notification of reply)\">\n<input type=\"text\" id=\"siteInput\" placeholder=\"Site (if you want a link back)\">\n<textarea id=\"messageInput\" rows=\"5\" required placeholder=\"Your comment (required, include whatever markup [or down] you like)\"></textarea>\n<button type=\"submit\">Submit</button>\n</form>\n") filewrite.write("<h2>Leave a comment</h2>\n<noscript>\n<p><b>JavaScript is unavailable.</b> Please <a href=\"mailto:eheu48@gmail.com\">email me</a> any comments.</p>\n</noscript>\n<p class=\"jsonly\">Comments will be posted manually; please expect a delay between submitting your comment and seeing it below!</p>\n<form id=\"theform\" onsubmit=\"sendContact(event)\" class=\"jsonly\">\n<input type=\"text\" id=\"nameInput\" required placeholder=\"Pseudonym (required)\">\n<input type=\"email\" id=\"emailInput\" placeholder=\"Email (if you want email notification of reply)\">\n<input type=\"text\" id=\"siteInput\" placeholder=\"Site (if you want a link back)\">\n<textarea id=\"messageInput\" rows=\"5\" required placeholder=\"Your comment (required, include whatever markup [or down] you like)\"></textarea>\n<button type=\"submit\">Submit</button>\n</form>\n")
else: else:
try: try:
if fileread.event == "ao3exchange" and (fileread.datewords[0])["date"].year > 2019: if fileread.event == "ao3exchange" and (fileread.datewords[0])["date"].year > 2019:

@ -7,6 +7,7 @@ import characters
import ships import ships
import events import events
import indexgen import indexgen
import verifygen
try: try:
if sys.argv[1] == "local": if sys.argv[1] == "local":
@ -26,6 +27,7 @@ if __name__ == "__main__":
ships.shiplist(True) ships.shiplist(True)
events.eventlist(True) events.eventlist(True)
indexgen.indexgen(True) indexgen.indexgen(True)
verifygen.verifygen(True)
else: else:
masterlist.listgen() masterlist.listgen()
commentpage.allcomments() commentpage.allcomments()
@ -34,3 +36,4 @@ if __name__ == "__main__":
ships.shiplist() ships.shiplist()
events.eventlist() events.eventlist()
indexgen.indexgen() indexgen.indexgen()
verifygen.verifygen()

@ -5,7 +5,7 @@ def headerwrite(output,title,headerone,desc,main=False,local=False):
header.write("/home/mdd/Documents/drive/proj/fic-archive/build/") header.write("/home/mdd/Documents/drive/proj/fic-archive/build/")
else: else:
header.write("/fic/") header.write("/fic/")
header.write("archive.css\">\n<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\n<link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>\n<link href=\"https://fonts.googleapis.com/css2?family=Hubballi&family=Lato:wght@400;700&family=Merriweather:wght@400;700&display=swap\" rel=\"stylesheet\">\n<title>" + title + "</title>\n</head>\n<body>\n<div id=\"content\">\n<div id=\"inside\">\n<h1>" + headerone + "</h1>\n" + desc + "\n") header.write("archive.css\">\n<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\n<link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>\n<link href=\"https://fonts.googleapis.com/css2?family=Hubballi&family=Lato:wght@400;700&family=Merriweather:wght@400;700&display=swap\" rel=\"stylesheet\">\n<title>" + title + "</title>\n<noscript>\n<style>.jsonly{display:none;}</style>\n</noscript>\n</head>\n<body>\n<div id=\"content\">\n<div id=\"inside\">\n<noscript>\n<div id=\"warning\">\n<p><b>Warning:</b> this part of my site is <b>18+</b>. Fics contain NSFW material and mature themes (death, suicide, mental illness, incest …). Browse at your own risk.</p>\n</div>\n</noscript>\n<h1>" + headerone + "</h1>\n" + desc + "\n")
if not main: if not main:
header.write("<p>\n<a href=\"") header.write("<p>\n<a href=\"")
if local: if local:
@ -31,5 +31,10 @@ def footerwrite(output,main=False,local=False):
footer.write("/home/mdd/Documents/drive/proj/fic-archive/build/emacs.jpg") footer.write("/home/mdd/Documents/drive/proj/fic-archive/build/emacs.jpg")
else: else:
footer.write("/fic/emacs.jpg") footer.write("/fic/emacs.jpg")
footer.write("\">\n</footer>\n</div>\n</body>\n</html>") footer.write("\">\n</footer>\n</div>\n<script>\nif (localStorage.getItem(\"ageVerified\") == null) { window.location = `")
if local:
footer.write("/home/mdd/Documents/drive/proj/fic-archive/build/")
else:
footer.write("/fic/")
footer.write("verify/index.html?returnto=${window.location}`; }\n</script>\n</body>\n</html>")
footer.close() footer.close()

@ -9,7 +9,7 @@ def indexgen(local=False):
# write header # write header
headerfooter.headerwrite("build/index.html","Trés fic archive","Trés fic archive","",True,local) headerfooter.headerwrite("build/index.html","Trés fic archive","Trés fic archive","",True,local)
filewrite = open("build/index.html", "a") filewrite = open("build/index.html", "a")
filewrite.write("<p>Here is all my fanfiction! Its also archived at AO3 under the name <span style=\"white-space: nowrap;\" class=\"ljuser\"><a href=\"https://archiveofourown.org/users/ovely/profile\"><img src=\"https://p.dreamwidth.org/b164c54b26e4/-/archiveofourown.org/favicon.ico\" alt=\"[archiveofourown.org profile]\" width=\"16\" height=\"16\" style=\"vertical-align: text-bottom; border: 0; padding-right: 1px;\" /></a><a href=\"https://archiveofourown.org/users/ovely/pseuds/ovely\"><b>ovely</b></a></span>.</p>\n<p><strong>Warning:</strong> some of my fanfiction is NSFW (ranging from slightly obscene language to explicit sex scenes), some is RPF, and some of it contains mature or potentially objectionable themes (death, suicide, mental illness, incest …). Ratings and warnings are given accordingly, <strong>dont like dont read</strong>. If you happen to be under 18, kindly gtfo and <em>read some real literature instead</em>. Honestly, it will be much more edifying.</p>\n<p>Ive recently implemented comments read about that <a href=\"") filewrite.write("<p>Here is all my fanfiction! Its also archived at AO3 under the name <span style=\"white-space: nowrap;\" class=\"ljuser\"><a href=\"https://archiveofourown.org/users/ovely/profile\"><img src=\"https://p.dreamwidth.org/b164c54b26e4/-/archiveofourown.org/favicon.ico\" alt=\"[archiveofourown.org profile]\" width=\"16\" height=\"16\" style=\"vertical-align: text-bottom; border: 0; padding-right: 1px;\" /></a><a href=\"https://archiveofourown.org/users/ovely/pseuds/ovely\"><b>ovely</b></a></span>.</p>\n<p>Ive recently implemented comments read about that <a href=\"")
if local: if local:
filewrite.write("comments/index.html") filewrite.write("comments/index.html")
else: else:

@ -0,0 +1,21 @@
import os
import headerfooter
def verifygen(local=False):
# delete existing file
if os.path.exists("build/verify/index.html"):
os.remove("build/verify/index.html")
# write header
headerfooter.headerwrite("build/verify/index.html","Trés fic archive","Warning","",True,local)
filewrite = open("build/verify/index.html", "a")
filewrite.write("<p><strong>Please note before proceeding:</strong></p>\n<p>Some of my fanfiction is NSFW (ranging from slightly obscene language to explicit sex scenes), some is RPF, and some of it contains mature or potentially objectionable themes (death, suicide, mental illness, incest …). Ratings and warnings are given accordingly, <strong>dont like dont read</strong>. If you happen to be under 18, kindly gtfo and <em>read some real literature instead</em>. Honestly, it will be much more edifying.</p>\n<label for=\"verifyage-checkbox\">Please tick to confirm you have read this warning and are an adult:</label>\n<input type=\"checkbox\" id=\"verifyage-checkbox\">\n<button id=\"verifyage-button\">Let me in!</button>\n</div>\n</div>\n<script>\nvar verifyageButton = document.getElementById(\"verifyage-button\"); var verifyageCheckbox = document.getElementById(\"verifyage-checkbox\"); verifyageButton.addEventListener(\"click\", () => {if (verifyageCheckbox.checked) {localStorage.setItem(\"ageVerified\", \"\"); if (window.location = window.location.search.startsWith(\"?returnto=\")) {window.location = window.location.search.substring(\"?returnto=\".length);} else {window.location = \"")
if local:
filewrite.write("/home/mdd/Documents/drive/proj/fic-archive/build/index.html")
else:
filewrite.write("/fic")
filewrite.write("\";}} else {alert(\"You must agree before proceeding.\");}});\n</script>\n</body>\n</html>")
filewrite.close()
if __name__ == "__main__":
verifygen()
Loading…
Cancel
Save