diff --git a/create_book.sh b/create_book.sh index b22ee8a..a2e0768 100644 --- a/create_book.sh +++ b/create_book.sh @@ -1,9 +1,7 @@ #!/bin/bash -today=`date '+%B_%dth_%Y'`; -filename="TD;DR_$today" -echo $filename; +echo "execute a bash script that will create a book called " + $1 + +pandoc /home/xpub/www/html/tl-dr/book.html -o /home/xpub/www/html/tl-dr/logged_book.epub -c print.css --metadata title=$1 --epub-cover-image=cover.jpg --epub-embed-font='fonts/Cascadia/ttf/CascadiaCode-Light.ttf' --epub-embed-font='fonts/Ductus/DuctusRegular.otf' +cp /home/xpub/www/html/tl-dr/logged_book.epub /home/xpub/www/html/tl-dr/log-books/$1.epub -pandoc /home/xpub/www/html/tl-dr/book.html -o /home/xpub/www/html/tl-dr/logged_book.epub -c print.css --metadata title=$filename --epub-cover-image=cover.jpg --epub-embed-font='fonts/Cascadia/ttf/CascadiaCode-Light.ttf' --epub-embed-font='fonts/Ductus/DuctusRegular.otf' -cp /home/xpub/www/html/tl-dr/logged_book.epub /home/xpub/www/html/tl-dr/log-books/$filename.epub -echo "did the overwrite" ls log-books > /home/xpub/www/html/tl-dr/log-books/all.txt diff --git a/script.py b/script.py index a4fafff..95d79b9 100644 --- a/script.py +++ b/script.py @@ -8,12 +8,10 @@ import fnmatch path = "/home/xpub/www/html/tl-dr/log-books" if not os.path.exists(path): os.makedirs(path) -# TODO: check sorting of these files (should be chronological) -# Getting the dynamic variables -log_files = fnmatch.filter(os.listdir(path), '*.epub') + + now = datetime.today() -next_report = now + timedelta(hours=3) -log_file_name = "TL;DR_" + now.strftime("%B %dth %Y") +book_name = "TL;DR_" + now.strftime("%B %dth %Y") def create_all_logs_file(): list_logs = subprocess.run(["ls", "/home/xpub/www/html/tl-dr/log-books"], capture_output=True) @@ -71,8 +69,6 @@ template = env.get_template("book.jinja") # rendering the template and storing the resultant text in variable output output = template.render( now = now.strftime("%B %dth %Y"), - next_report = next_report, - log_files = log_files, last_user_added=last_user_added.stdout.decode('UTF-8'), last_user_added_name=last_user_added_name, users_created_today=users_created_today, @@ -103,7 +99,7 @@ print("Output the files"); with open("/home/xpub/www/html/tl-dr/book.html", "w") as f: print(output, file=f) print("execute the bash script now to create the books"); - subprocess.run(['sh', 'create_book.sh']) + subprocess.run(['sh', 'create_book.sh', 'book_name']) print("Finished"); # At the moment, we are not storing logs in the log folder anymore