Add microformats to singles pages

master
trémeur 5 months ago
parent d3d579840a
commit e684db95fe

@ -92,14 +92,14 @@ def linkgen(ficno,output="output.html",local=False):
# write ao3 link if there is one
try:
if fileread.ao3slug:
filewrite.write("<li class=\"ao3link\"><a ")
filewrite.write("<li class=\"ao3link\"><a class=\"u-syndication")
try:
if fileread.ao3locked:
filewrite.write("class=\"locked\" ")
filewrite.write(" locked")
except:
if fileread.locked:
filewrite.write("class=\"locked\" ")
filewrite.write("href=\"https://archiveofourown.org/works/" + str(fileread.ao3slug) + "\">AO3</a></li>\n")
filewrite.write(" locked")
filewrite.write("\" href=\"https://archiveofourown.org/works/" + str(fileread.ao3slug) + "\">AO3</a></li>\n")
except:
pass
# write fedi share link if there is one
@ -250,7 +250,7 @@ def linkgen(ficno,output="output.html",local=False):
except:
pass
def ficgen(ficno,unique=False,output="output.html",local=False):
def ficgen(ficno,unique=False,output="output.html",local=False,single=False):
# convert to three-digit number
if ficno < 10:
ficnostring = "00" + str(ficno)
@ -284,11 +284,14 @@ def ficgen(ficno,unique=False,output="output.html",local=False):
if revealed == True:
# write to output file
filewrite = open(output, "a")
filewrite.write("<div class=\"fic\"")
filewrite.write("<div class=\"fic")
if single:
filewrite.write(" h-entry")
filewrite.write("\"")
# give the div an id if requested
if unique:
filewrite.write(" id=\"fic" + ficnostring + "\"")
filewrite.write(">\n<h1><span class=\"ficnoprelim\">no. </span><span class=\"ficno\"><a href=\"")
filewrite.write(">\n<h1><span class=\"ficnoprelim\">no. </span><span class=\"ficno\"><a class=\"u-url\" href=\"")
if local:
filewrite.write("/home/mdd/Documents/proj/fic-archive/build/single/" + ficnostring + "/index.html")
else:
@ -307,7 +310,7 @@ def ficgen(ficno,unique=False,output="output.html",local=False):
filewrite.write("</span>")
# write title if requested
if fileread.showtitle:
filewrite.write(" <span class=\"fictitle\">" + fileread.title)
filewrite.write(" <span class=\"fictitle p-name\">" + fileread.title)
try:
if transread.showtitle:
filewrite.write("/" + transread.title)
@ -322,26 +325,26 @@ def ficgen(ficno,unique=False,output="output.html",local=False):
pass
if fileread.status == "abandoned":
filewrite.write(" <span class=\"abandoned\"> (abandoned)</span>")
filewrite.write("</h1>\n<ul class=\"ficmeta\">\n<li class=\"ficdate\"><i>Date:</i> ")
filewrite.write("</h1>\n<div class=\"e-content\">\n<ul class=\"ficmeta\">\n<li class=\"ficdate\"><i>Date:</i> ")
# write date, date range if ranged or translation
if fileread.status == "incomplete":
filewrite.write((fileread.datewords[0])["date"].strftime("%-d %B %Y") + "")
filewrite.write("<time datetime=\"" + (fileread.datewords[0])["date"].strftime("%Y-%m-%d") + "\" class=\"dt-published\">" + (fileread.datewords[0])["date"].strftime("%-d %B %Y") + "</time>")
else:
try:
if transread.status == "incomplete":
filewrite.write((fileread.datewords[0])["date"].strftime("%-d %B %Y") + "")
filewrite.write("<time datetime=\"" + (fileread.datewords[0])["date"].strftime("%Y-%m-%d") + "\" class=\"dt-published\">" + (fileread.datewords[0])["date"].strftime("%-d %B %Y") + "</time>")
else:
if fileread.translation:
if (transread.datewords[-1])["date"].year == (fileread.datewords[0])["date"].year:
if (transread.datewords[-1])["date"].month == (fileread.datewords[0])["date"].month:
if (transread.datewords[-1])["date"].date == (fileread.datewords[0])["date"].date:
filewrite.write((fileread.datewords[0])["date"].strftime("%-d %B %Y"))
filewrite.write("<time datetime=\"" + (fileread.datewords[0])["date"].strftime("%Y-%m-%d") + "\" class=\"dt-published\">" + (fileread.datewords[0])["date"].strftime("%-d %B %Y") + "</time>")
else:
filewrite.write((fileread.datewords[0])["date"].strftime("%-d") + "" + (transread.datewords[-1])["date"].strftime("%-d %B %Y"))
filewrite.write("<time datetime=\"" + (fileread.datewords[0])["date"].strftime("%Y-%m-%d") + "\" class=\"dt-published\">" + (fileread.datewords[0])["date"].strftime("%-d") + "</time><time datetime=\"" + (transread.datewords[-1])["date"].strftime("%Y-%m-%d") + "\" class=\"dt-updated\">" + (transread.datewords[-1])["date"].strftime("%-d %B %Y") + "</time>")
else:
filewrite.write((fileread.datewords[0])["date"].strftime("%-d %B") + "" + (transread.datewords[-1])["date"].strftime("%-d %B %Y"))
filewrite.write("<time datetime=\"" + (fileread.datewords[0])["date"].strftime("%Y-%m-%d") + "\" class=\"dt-published\">" + (fileread.datewords[0])["date"].strftime("%-d %B") + "</time><time datetime=\"" + (transread.datewords[-1])["date"].strftime("%Y-%m-%d") + "\" class=\"dt-updated\">" + (transread.datewords[-1])["date"].strftime("%-d %B %Y") + "<time>")
else:
filewrite.write((fileread.datewords[0])["date"].strftime("%-d %B %Y") + "" + (transread.datewords[-1])["date"].strftime("%-d %B %Y"))
filewrite.write("<time datetime=\"" + (fileread.datewords[0])["date"].strftime("%Y-%m-%d") + "\" class=\"dt-published\">" + (fileread.datewords[0])["date"].strftime("%-d %B %Y") + "</time><time datetime=\"" + (transread.datewords[-1])["date"].strftime("%Y-%m-%d") + "\" class=\"dt-updated\">" + (transread.datewords[-1])["date"].strftime("%-d %B %Y") + "</time>")
except:
try:
filewrite.write(fileread.approxdate)
@ -349,13 +352,13 @@ def ficgen(ficno,unique=False,output="output.html",local=False):
if (fileread.datewords[0])["date"].year == (fileread.datewords[-1])["date"].year:
if (fileread.datewords[0])["date"].month == (fileread.datewords[-1])["date"].month:
if (fileread.datewords[0])["date"] == (fileread.datewords[-1])["date"]:
filewrite.write((fileread.datewords[-1])["date"].strftime("%-d %B %Y"))
filewrite.write("<time datetime=\"" + (fileread.datewords[-1])["date"].strftime("%Y-%m-%d") + "\" class=\"dt-published\">" + (fileread.datewords[-1])["date"].strftime("%-d %B %Y") + "</time>")
else:
filewrite.write((fileread.datewords[0])["date"].strftime("%-d") + "" + (fileread.datewords[-1])["date"].strftime("%-d %B %Y"))
filewrite.write("<time datetime=\"" + (fileread.datewords[0])["date"].strftime("%Y-%m-%d") + "\" class=\"dt-published\">" + (fileread.datewords[0])["date"].strftime("%-d") + "</time><time datetime=\"" + (fileread.datewords[-1])["date"].strftime("%Y-%m-%d") + "\" class=\"dt-updated\">" + (fileread.datewords[-1])["date"].strftime("%-d %B %Y") + "</time>")
else:
filewrite.write((fileread.datewords[0])["date"].strftime("%-d %B") + "" + (fileread.datewords[-1])["date"].strftime("%-d %B %Y"))
filewrite.write("<time datetime=\"" + (fileread.datewords[0])["date"].strftime("%Y-%m-%d") + "\" class=\"dt-published\">" + (fileread.datewords[0])["date"].strftime("%-d %B") + "</time><time datetime=\"" + (fileread.datewords[-1])["date"].strftime("%Y-%m-%d") + "\" class=\"dt-updated\">" + (fileread.datewords[-1])["date"].strftime("%-d %B %Y") + "</time>")
else:
filewrite.write((fileread.datewords[0])["date"].strftime("%-d %B %Y") + "" + (fileread.datewords[-1])["date"].strftime("%-d %B %Y"))
filewrite.write("<time datetime=\"" + (fileread.datewords[0])["date"].strftime("%Y-%m-%d") + "\" class=\"dt-published\">" + (fileread.datewords[0])["date"].strftime("%-d %B %Y") + "</time><time datetime=\"" + (fileread.datewords[-1])["date"].strftime("%Y-%m-%d") + "\" class=\"dt-updated\">" + (fileread.datewords[-1])["date"].strftime("%-d %B %Y") + "</time>")
# write wordcount
sumwords = 0
for instalment in fileread.datewords:
@ -384,13 +387,13 @@ def ficgen(ficno,unique=False,output="output.html",local=False):
filewrite.write(" (" + fileread.ratingreason + ")")
except:
pass
filewrite.write("</span></li>\n<li class=\"fandom\"><i>Fandom: </i>")
filewrite.write("</li>\n<li class=\"fandom\"><i>Fandom: </i><span class=\"p-category\">")
# write fandom
try:
filewrite.write(fileread.fandomtext)
except:
filewrite.write("/".join(fileread.fandom))
filewrite.write("</li>\n")
filewrite.write("</span></li>\n")
# write characters in pov, main, secondary categories, if they exist
try:
filewrite.write("<li class=\"characters\"><i>Characters: </i>" + fileread.charactertext + "</li>\n")
@ -602,4 +605,7 @@ def ficgen(ficno,unique=False,output="output.html",local=False):
linkgen(ficno,output,local)
filewrite = open(output, "a")
filewrite.write("</div>\n")
if single:
filewrite.write("<div id=\"federation\" hidden=\"from-humans\">\n<a class=\"u-bridgy-fed\" href=\"https://fed.brid.gy/\"></a>\n<a rel=\"author\" class=\"p-author h-card\" href=\"/\">“tré”<img class=\"u-photo\" src=\"/ab.png\"></a>\n</div>\n")
filewrite.write("</div>\n")
filewrite.close()

@ -37,11 +37,11 @@ def singlepage(ficno,directory,local=False):
headerfooter.headerwrite(output,"Fic no. " + ficnostring,"Fic no. <span id=\"ficno\">" + ficnostring + "</span>","",False,local)
try:
if fileread.original:
makeheader.ficgen(fileread.original,False,output,local)
makeheader.ficgen(fileread.original,False,output,local,True)
else:
makeheader.ficgen(ficno,False,output,local)
makeheader.ficgen(ficno,False,output,local,True)
except:
makeheader.ficgen(ficno,False,output,local)
makeheader.ficgen(ficno,False,output,local,True)
if singlestatus:
filewrite = open(output, "a")
filewrite.write("<iframe src=\"")

Loading…
Cancel
Save