Show currently reading books
This commit is contained in:
parent
f30e1deb57
commit
009e77c878
1 changed files with 21 additions and 5 deletions
26
generate.py
26
generate.py
|
@ -119,7 +119,7 @@ for file in concernedfiles:
|
|||
status = "existing"
|
||||
readdate = dateobj
|
||||
if status == "new":
|
||||
thedict = {"id":bookid,"readdates":[readdate],"progressdates":[],"obtaineddate":"","work":False}
|
||||
thedict = {"id":bookid,"readdates":[readdate],"progressdates":[],"obtaineddate":"","work":False,"progress":100}
|
||||
if "work" in book.tags:
|
||||
thedict["work"] = True
|
||||
books.append(thedict)
|
||||
|
@ -134,6 +134,7 @@ for file in concernedfiles:
|
|||
origbook["readdates"].extend(twodict["readdates"])
|
||||
if twodict["work"]:
|
||||
origbook["work"] = True
|
||||
origbook["progress"] = 100
|
||||
if action.heading == "progress":
|
||||
for book in action.children:
|
||||
bookid = book.heading
|
||||
|
@ -142,9 +143,13 @@ for file in concernedfiles:
|
|||
bookids.append(bookid)
|
||||
else:
|
||||
status = "existing"
|
||||
if len(re.findall(r"\*.*%.\*",book.body)) > 0:
|
||||
theprogress = int((re.findall(r"\*.*%.\*",book.body))[0][1:-3])
|
||||
else:
|
||||
theprogress = 0
|
||||
progressdate = dateobj
|
||||
if status == "new":
|
||||
thedict = {"id":bookid,"readdates":[],"progressdates":[progressdate],"obtaineddate":"","work":False}
|
||||
thedict = {"id":bookid,"readdates":[],"progressdates":[progressdate],"obtaineddate":"","work":False,"progress":theprogress}
|
||||
if "work" in book.tags:
|
||||
thedict["work"] = True
|
||||
books.append(thedict)
|
||||
|
@ -159,6 +164,8 @@ for file in concernedfiles:
|
|||
origbook["progressdates"].extend(twodict["progressdates"])
|
||||
if twodict["work"]:
|
||||
origbook["work"] = True
|
||||
if theprogress > 0:
|
||||
origbook["progress"] = theprogress
|
||||
if action.heading == "obtained":
|
||||
for book in action.children:
|
||||
bookid = re.sub(" \(.*\)","",book.heading)
|
||||
|
@ -169,7 +176,7 @@ for file in concernedfiles:
|
|||
status = "existing"
|
||||
obtaineddate = dateobj
|
||||
if status == "new":
|
||||
thedict = {"id":bookid,"readdates":[],"progressdates":[],"obtaineddate":obtaineddate,"work":False}
|
||||
thedict = {"id":bookid,"readdates":[],"progressdates":[],"obtaineddate":obtaineddate,"work":False,"progress":0}
|
||||
if "work" in book.tags:
|
||||
thedict["work"] = True
|
||||
books.append(thedict)
|
||||
|
@ -1209,14 +1216,23 @@ def thisyearbooks(theyear=datetime.today().year):
|
|||
booksthisyear.append(bookdict)
|
||||
booksthisyear = sorted(booksthisyear,key=lambda d: d["date"])
|
||||
|
||||
bookindex.write("<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>praze • Books</title>\n <meta property=\"og:title\" content=\"praze • Books\">\n <meta property=\"og:type\" content=\"website\">\n <meta property=\"og:image\" content=\"https://tre.praze.net/ab.png\">\n <meta property=\"og:url\" content=\"https://tre.praze.net/trackers/books\">\n <meta name=\"description\" property=\"og:description\" content=\"Books I have read this year.\">\n <meta property=\"og:locale\" content=\"en_GB\">\n <meta property=\"og:site_name\" content=\"tre.praze.net\">\n <meta name=\"fediverse:creator\" content=\"@tre@praze.net\">\n <link rel=\"webmention\" href=\"https://webmention.io/tre.praze.net/webmention\">\n <link rel=\"me\" href=\"https://kes.praze.net/@tre\">\n <link rel=\"alternate\" type=\"application/rss+xml\" title=\"tre.praze.net\" href=\"/feed.xml\">\n <meta name=\"theme-color\" content=\"#f2f2f2\">\n <link rel=\"stylesheet\" href=\"/new.css\">\n </head>\n <body>\n <nav>\n <input type=\"checkbox\" id=\"toggle\" name=\"toggle\">\n <label class=\"toggle-btn\" for=\"toggle\">Menu</label>\n <ul>\n <li>Fundamentals\n <ul>\n <li><a href=\"/\">Home</a></li>\n <li><a href=\"/about\">About + listings</a></li>\n <li><a href=\"/follow\">Follow</a></li>\n <li><a href=\"/feed.xml\">Changelog</a> <a href=\"/feed.xml\"><span class=\"rss\"></span></a></li>\n <li><a href=\"/sitemap\">Sitemap</a></li>\n <li><a href=\"/siteroll\">Siteroll</a></li>\n </ul>\n </li>\n <li>Projects\n <ul>\n <li><a href=\"/fic\">Fanfiction</a> <a href=\"/fic/feed.xml\"><span class=\"rss\"></span></a></li>\n <li><a href=\"/music\">Music</a></li>\n <li><a href=\"/notes\">Journal</a></li>\n <li>Trackers</li>\n <li><a href=\"https://git.praze.net/tre\" target=\"_blank\">Code</a> <a href=\"https://git.praze.net/tre.rss\"><span class=\"rss\"></span></a></li>\n <li><a href=\"https://img.praze.net\" target=\"_blank\">Photos</a> <a href=\"https://img.praze.net/feed.php\"><span class=\"rss\"></span></a></li>\n </ul>\n </li>\n <li>Fan content\n <ul>\n <li><a href=\"/ffx\">FFX</a></li>\n <li><a href=\"/xvi\">FF16</a></li>\n <li><a href=\"https://morgan.praze.net\" target=\"_blank\">Dermot Morgan</a> <a href=\"https://morgan.praze.net/feed.xml\"><span class=\"rss\"></span></a></li>\n </ul>\n </li>\n <li>Misc.\n <ul>\n <li><a href=\"https://tcg.praze.net\" target=\"_blank\">TCG</a></li>\n <li><a href=\"https://links.praze.net\" target=\"_blank\">Bookmarks</a> <a href=\"https://links.praze.net/feed/rss\"><span class=\"rss\"></span></a></li>\n <li><a href=\"https://kes.praze.net/@tre\" target=\"_blank\">Fediverse</a> <a href=\"https://kes.praze.net/@tre/feed.rss\"><span class=\"rss\"></span></a></li>\n </ul>\n </li>\n </ul>\n </nav>\n <div>\n <main>\n <section>\n <h1>Books read in " + str(theyear) + "</h2>\n")
|
||||
bookindex.write("<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>praze • Books</title>\n <meta property=\"og:title\" content=\"praze • Books\">\n <meta property=\"og:type\" content=\"website\">\n <meta property=\"og:image\" content=\"https://tre.praze.net/ab.png\">\n <meta property=\"og:url\" content=\"https://tre.praze.net/trackers/books\">\n <meta name=\"description\" property=\"og:description\" content=\"Books I have read this year.\">\n <meta property=\"og:locale\" content=\"en_GB\">\n <meta property=\"og:site_name\" content=\"tre.praze.net\">\n <meta name=\"fediverse:creator\" content=\"@tre@praze.net\">\n <link rel=\"webmention\" href=\"https://webmention.io/tre.praze.net/webmention\">\n <link rel=\"me\" href=\"https://kes.praze.net/@tre\">\n <link rel=\"alternate\" type=\"application/rss+xml\" title=\"tre.praze.net\" href=\"/feed.xml\">\n <meta name=\"theme-color\" content=\"#f2f2f2\">\n <link rel=\"stylesheet\" href=\"/new.css\">\n </head>\n <body>\n <nav>\n <input type=\"checkbox\" id=\"toggle\" name=\"toggle\">\n <label class=\"toggle-btn\" for=\"toggle\">Menu</label>\n <ul>\n <li>Fundamentals\n <ul>\n <li><a href=\"/\">Home</a></li>\n <li><a href=\"/about\">About + listings</a></li>\n <li><a href=\"/follow\">Follow</a></li>\n <li><a href=\"/feed.xml\">Changelog</a> <a href=\"/feed.xml\"><span class=\"rss\"></span></a></li>\n <li><a href=\"/sitemap\">Sitemap</a></li>\n <li><a href=\"/siteroll\">Siteroll</a></li>\n </ul>\n </li>\n <li>Projects\n <ul>\n <li><a href=\"/fic\">Fanfiction</a> <a href=\"/fic/feed.xml\"><span class=\"rss\"></span></a></li>\n <li><a href=\"/music\">Music</a></li>\n <li><a href=\"/notes\">Journal</a></li>\n <li>Trackers</li>\n <li><a href=\"https://git.praze.net/tre\" target=\"_blank\">Code</a> <a href=\"https://git.praze.net/tre.rss\"><span class=\"rss\"></span></a></li>\n <li><a href=\"https://img.praze.net\" target=\"_blank\">Photos</a> <a href=\"https://img.praze.net/feed.php\"><span class=\"rss\"></span></a></li>\n </ul>\n </li>\n <li>Fan content\n <ul>\n <li><a href=\"/ffx\">FFX</a></li>\n <li><a href=\"/xvi\">FF16</a></li>\n <li><a href=\"https://morgan.praze.net\" target=\"_blank\">Dermot Morgan</a> <a href=\"https://morgan.praze.net/feed.xml\"><span class=\"rss\"></span></a></li>\n </ul>\n </li>\n <li>Misc.\n <ul>\n <li><a href=\"https://tcg.praze.net\" target=\"_blank\">TCG</a></li>\n <li><a href=\"https://links.praze.net\" target=\"_blank\">Bookmarks</a> <a href=\"https://links.praze.net/feed/rss\"><span class=\"rss\"></span></a></li>\n <li><a href=\"https://kes.praze.net/@tre\" target=\"_blank\">Fediverse</a> <a href=\"https://kes.praze.net/@tre/feed.rss\"><span class=\"rss\"></span></a></li>\n </ul>\n </li>\n </ul>\n </nav>\n <div>\n <main>\n <section>\n <h2>Currently reading</h2>\n<ul>\n")
|
||||
for book in books:
|
||||
if not book["work"]:
|
||||
if len(book["progressdates"]) > 0:
|
||||
if len(book["readdates"]) == 0:
|
||||
if book["author"] == "":
|
||||
bookindex.write("<li><i>" + book["title"] + "</i> <progress value=\"" + str(book["progress"]) + "\" max=\"100\" title=\"" + str(book["progress"]) + "%\">" + str(book["progress"]) + "%</progress></li>\n")
|
||||
else:
|
||||
bookindex.write("<li>" + book["author"] + " – <i>" + book["title"] + "</i> <progress value=\"" + str(book["progress"]) + "\" max=\"100\" title=\"" + str(book["progress"]) + "%\">" + str(book["progress"]) + "%</progress></li>\n")
|
||||
bookindex.write("</ul>\n </section>\n <section>\n <h2>Books read in " + str(theyear) + "</h2>\n")
|
||||
if len(booksthisyear) > 0:
|
||||
bookindex.write("<ol>\n")
|
||||
for book in booksthisyear:
|
||||
if book["author"] == "":
|
||||
bookindex.write("<li><i>" + book["title"] + "</i></li>\n")
|
||||
else:
|
||||
bookindex.write("<li>" + book["author"] + ": <i>" + book["title"] + "</i></li>\n")
|
||||
bookindex.write("<li>" + book["author"] + " – <i>" + book["title"] + "</i></li>\n")
|
||||
bookindex.write("</ol>\n")
|
||||
if workbooks > 1:
|
||||
bookindex.write("<p>+ " + str(workbooks) + " work-related books</p>\n")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue