Add age verification gate and some noscript fallbacks
This commit is contained in:
parent
ed37d4172a
commit
2b350a6e1e
7 changed files with 37 additions and 8 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
|
||||
- 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
|
||||
- pages for times and locations in FF fandoms
|
||||
- possibly a page for non-FF fandoms (as if I even care about these lol)
|
||||
- [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
|
||||
- [ ] possibly a page for non-FF fandoms (as if I even care about these lol)
|
||||
|
|
0
build/verify/.gitkeep
Normal file
0
build/verify/.gitkeep
Normal file
|
@ -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)
|
||||
filewrite = open(commentspath + "/index.html", "a")
|
||||
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:
|
||||
try:
|
||||
if fileread.event == "ao3exchange" and (fileread.datewords[0])["date"].year > 2019:
|
||||
|
|
|
@ -7,6 +7,7 @@ import characters
|
|||
import ships
|
||||
import events
|
||||
import indexgen
|
||||
import verifygen
|
||||
|
||||
try:
|
||||
if sys.argv[1] == "local":
|
||||
|
@ -26,6 +27,7 @@ if __name__ == "__main__":
|
|||
ships.shiplist(True)
|
||||
events.eventlist(True)
|
||||
indexgen.indexgen(True)
|
||||
verifygen.verifygen(True)
|
||||
else:
|
||||
masterlist.listgen()
|
||||
commentpage.allcomments()
|
||||
|
@ -34,3 +36,4 @@ if __name__ == "__main__":
|
|||
ships.shiplist()
|
||||
events.eventlist()
|
||||
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/")
|
||||
else:
|
||||
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:
|
||||
header.write("<p>\n<a href=\"")
|
||||
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")
|
||||
else:
|
||||
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()
|
||||
|
|
|
@ -9,7 +9,7 @@ def indexgen(local=False):
|
|||
# write header
|
||||
headerfooter.headerwrite("build/index.html","Tré’s fic archive","Tré’s fic archive","",True,local)
|
||||
filewrite = open("build/index.html", "a")
|
||||
filewrite.write("<p>Here is all my fanfiction! It’s 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>don’t like don’t 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>I’ve recently implemented comments – read about that <a href=\"")
|
||||
filewrite.write("<p>Here is all my fanfiction! It’s 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>I’ve recently implemented comments – read about that <a href=\"")
|
||||
if local:
|
||||
filewrite.write("comments/index.html")
|
||||
else:
|
||||
|
|
21
verifygen.py
Normal file
21
verifygen.py
Normal file
|
@ -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>don’t like don’t 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…
Add table
Add a link
Reference in a new issue