From 65b1357963eaa01204e47a14e642ba6361bc57d9 Mon Sep 17 00:00:00 2001 From: Mez Date: Tue, 12 Aug 2025 22:00:43 +0100 Subject: [PATCH] Add books this year page --- generate.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/generate.py b/generate.py index 636eb54..3498e94 100644 --- a/generate.py +++ b/generate.py @@ -1192,6 +1192,8 @@ def bookfeed(): feedwrite.close() def thisyearbooks(theyear=datetime.today().year): + bookindex = open("build/books/index.html","w") + booksthisyear = [] workbooks = 0 for book in books: @@ -1206,17 +1208,28 @@ def thisyearbooks(theyear=datetime.today().year): bookdict["date"] = thedate booksthisyear.append(bookdict) booksthisyear = sorted(booksthisyear,key=lambda d: d["date"]) - index = 1 - for book in booksthisyear: - print(str(index) + ". " + book["author"] + ": " + book["title"]) - index += 1 + + bookindex.write("\n\n \n \n \n praze • Books\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n
\n
\n

Books read in " + str(theyear) + "

\n") + if len(booksthisyear) > 0: + bookindex.write("
    \n") + for book in booksthisyear: + if book["author"] == "": + bookindex.write("
  1. " + book["title"] + "
  2. \n") + else: + bookindex.write("
  3. " + book["author"] + ": " + book["title"] + "
  4. \n") + bookindex.write("
\n") if workbooks > 1: - print("+ " + str(workbooks) + " books read for work") + bookindex.write("

+ " + str(workbooks) + " work-related books

\n") elif workbooks == 1: - print("+ 1 book read for work") + bookindex.write("

+ 1 work-related book

\n") + if len(booksthisyear) == 0 and workbooks == 0: + bookindex.write("

None yet!

\n") + bookindex.write("
\n
\n \n
\n \n\n") + bookindex.close() if __name__ == "__main__": bookfeed() + thisyearbooks() def filmfeed(): if not os.path.isdir("build/films"):