From a7cf317346762d00c7d631c441331b545ae7c52d Mon Sep 17 00:00:00 2001 From: notplants Date: Wed, 21 Feb 2024 12:32:38 -0600 Subject: [PATCH] templates --- .gitignore | 3 +- main.py | 15 +++--- run.sh | 14 +++--- .../calvin-and-hobbes.html | 47 +++++++++++++----- cookbooks.html => templates/cookbooks.html | 47 +++++++++++++----- .../notplants-2023.html | 48 ++++++++++++++----- 6 files changed, 121 insertions(+), 53 deletions(-) rename calvin-and-hobbes.html => templates/calvin-and-hobbes.html (63%) rename cookbooks.html => templates/cookbooks.html (63%) rename bookshelf.html => templates/notplants-2023.html (60%) diff --git a/.gitignore b/.gitignore index 4465593..44134b1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ dist books-2023 output cookbooks -calvin-and-hobbes \ No newline at end of file +calvin-and-hobbes +build.sh \ No newline at end of file diff --git a/main.py b/main.py index 8c2520d..0c818e8 100644 --- a/main.py +++ b/main.py @@ -75,7 +75,7 @@ def fetch_list(list_url): # to use this next field to direct the pagination instead of an increment page += 1 if not next: - more_results = False + more_results = False else: more_results = False except: @@ -156,7 +156,7 @@ if __name__ == '__main__': # create parser parser = argparse.ArgumentParser( prog='bookshelf-generator', - description='generates HTML for a web-page to display a bookshelf using bookwyrm or a csv as input', + description='generates HTML for a web-page to display a bookshelf using bookwyrm or a yaml as input', epilog='<3') # subparser for building website @@ -184,25 +184,22 @@ if __name__ == '__main__': args = parser.parse_args() if args.subparser == "bookwyrm-download": - - # subargs = bookwyrm_parser.parse_args() - print(args.list_url) - print(args.output_dir) - if not os.path.exists(args.output_dir): os.makedirs(args.output_dir) - processed_items = process_list(args.list_url) download_images(processed_items, output_dir=args.output_dir) write_yaml(processed_items, output_dir=args.output_dir) - else: + elif args.subparser == "generate-html": yaml_path = args.yaml_path images_dir = args.images_dir output_path = args.output_path template_vars = load_yaml(yaml_path) build_site(output_dir=output_path, images_dir=images_dir, relative_template_path=args.template, template_vars=template_vars) + else: + raise Exception("invalid subcommand. must be either bookwyrm-download or generate-html") + diff --git a/run.sh b/run.sh index f95486d..aaa61ab 100755 --- a/run.sh +++ b/run.sh @@ -1,11 +1,11 @@ -# download +# notplants-2023 #python3 main.py bookwyrm-download --list-url="https://bookwyrm.social/list/2458/s/notplants-2023" --output-dir="books-2023" -# python3 main.py generate-html --yaml-path="books-2023/books.yaml" --images-dir="books-2023" --template="bookshelf.html" --output-path="output/notplants-2023" +#python3 main.py generate-html --yaml-path="books-2023/books.yaml" --images-dir="books-2023" --template="templates/bookshelf.html" --output-path="output/notplants-2023" +# calvin-and-hobbes #python3 main.py bookwyrm-download --list-url="https://bookwyrm.social/list/2634/s/calvin-and-hobbes" --output-dir="calvin-and-hobbes" -#python3 main.py generate-html --yaml-path="calvin-and-hobbes/books.yaml" --images-dir="calvin-and-hobbes" --template="calvin-and-hobbes.html" --output-path="output/calvin-and-hobbes" +python3 main.py generate-html --yaml-path="calvin-and-hobbes/books.yaml" --images-dir="calvin-and-hobbes" --template="templates/calvin-and-hobbes.html" --output-path="output/calvin-and-hobbes" - - -python3 main.py bookwyrm-download --list-url="https://bookwyrm.social/list/2609/s/cookbooks" --output-dir="cookbooks" -python3 main.py generate-html --yaml-path="cookbooks/books.yaml" --images-dir="cookbooks" --template="cookbooks.html" --output-path="output/cookbooks" \ No newline at end of file +# cookbooks +#python3 main.py bookwyrm-download --list-url="https://bookwyrm.social/list/2609/s/cookbooks" --output-dir="cookbooks" +#python3 main.py generate-html --yaml-path="cookbooks/books.yaml" --images-dir="cookbooks" --template="templates/cookbooks.html" --output-path="output/cookbooks" \ No newline at end of file diff --git a/calvin-and-hobbes.html b/templates/calvin-and-hobbes.html similarity index 63% rename from calvin-and-hobbes.html rename to templates/calvin-and-hobbes.html index 52f746f..094caa4 100644 --- a/calvin-and-hobbes.html +++ b/templates/calvin-and-hobbes.html @@ -12,7 +12,7 @@ margin-right: 20px; box-shadow: 12px 14px yellow; background-color: lightpink; -padding: 40px; + padding: 40px; } .main { max-width: 600px; @@ -23,8 +23,10 @@ padding: 40px; background-color: white; } body { - font-family: "Roboto Mono,monospace"; + font-family: "Roboto Mono,monospace"; background-color: mediumpurple; + padding-bottom: 30px; + padding-top: 20px; } .page-title { width: 90%; @@ -34,7 +36,7 @@ padding: 40px; background-color: white; box-shadow: 8px 12px blue; margin-bottom: 50px; - padding-bottom: 10px; + padding-bottom: 10px; padding-left: 25px; } @@ -57,28 +59,49 @@ padding: 40px; .page-footer a:hover { background-color: yellow; } + .home-button { + display: none; + width: 28px; + margin: auto; + margin-bottom: auto; + margin-bottom: 25px; + color: black; + text-decoration: none; + /*border: 1px solid black;*/ + padding: 3px; + line-height: 14px; + font-size: 32px; + } + .home-button:hover { + background-color:white; + cursor: pointer; + } + + + ← +
- Calvin & Hobbes -
-{% for book in books %} + Calvin & Hobbes +
+ {% for book in books %}
- -
-
- {{ book.title }} by {{ book.author }} {% if book.published_year %} ({{book.published_year}}) {% endif %} -
+ +
+
+ {{ book.title }} by {{ book.author }} {% if book.published_year %} ({{book.published_year}}) {% endif %} +
-{% endfor %} + {% endfor %} diff --git a/cookbooks.html b/templates/cookbooks.html similarity index 63% rename from cookbooks.html rename to templates/cookbooks.html index 0d7469f..93c01be 100644 --- a/cookbooks.html +++ b/templates/cookbooks.html @@ -12,7 +12,7 @@ margin-right: 20px; box-shadow: 12px 14px yellow; background-color: lightpink; -padding: 40px; + padding: 40px; } .main { max-width: 600px; @@ -23,8 +23,10 @@ padding: 40px; background-color: white; } body { - font-family: "Roboto Mono,monospace"; + font-family: "Roboto Mono,monospace"; background-color: mediumpurple; + padding-bottom: 30px; + padding-top: 20px; } .page-title { width: 90%; @@ -34,7 +36,7 @@ padding: 40px; background-color: white; box-shadow: 8px 12px blue; margin-bottom: 50px; - padding-bottom: 10px; + padding-bottom: 10px; padding-left: 25px; } @@ -56,29 +58,50 @@ padding: 40px; } .page-footer a:hover { background-color: yellow; + } + .home-button { + display:none; + width: 28px; + margin: auto; + margin-bottom: auto; + margin-bottom: 25px; + color: black; + text-decoration: none; + /*border: 1px solid black;*/ + padding: 3px; + line-height: 14px; + font-size: 32px; + } + .home-button:hover { + background-color:white; + cursor: pointer; } + + + ← +
- Cookbooks -
-{% for book in books %} + Cookbooks +
+ {% for book in books %}
- -
-
- {{ book.title }} by {{ book.author }} {% if book.published_year %} ({{book.published_year}}) {% endif %} -
+ +
+
+ {{ book.title }} by {{ book.author }} {% if book.published_year %} ({{book.published_year}}) {% endif %} +
-{% endfor %} + {% endfor %} diff --git a/bookshelf.html b/templates/notplants-2023.html similarity index 60% rename from bookshelf.html rename to templates/notplants-2023.html index 3453049..b37ffaf 100644 --- a/bookshelf.html +++ b/templates/notplants-2023.html @@ -12,7 +12,7 @@ margin-right: 20px; box-shadow: 12px 14px yellow; background-color: lightpink; -padding: 40px; + padding: 40px; } .main { max-width: 600px; @@ -23,8 +23,10 @@ padding: 40px; background-color: white; } body { - /*font-family: "Roboto Mono", monospace;*/ + /*font-family: "Roboto Mono", monospace;*/ background-color: mediumpurple; + padding-bottom: 30px; + padding-top: 20px; } .page-title { width: 90%; @@ -34,7 +36,7 @@ padding: 40px; background-color: white; box-shadow: 8px 12px blue; margin-bottom: 50px; - padding-bottom: 10px; + padding-bottom: 10px; padding-left: 25px; } @@ -56,29 +58,51 @@ padding: 40px; } .page-footer a:hover { background-color: yellow; + } + .home-button { + width: 28px; + margin: auto; + margin-bottom: auto; + margin-bottom: 25px; + display: block; + color: black; + text-decoration: none; + /*border: 1px solid black;*/ + padding: 3px; + line-height: 14px; + font-size: 32px; + display:none; + } + .home-button:hover { + background-color:white; + cursor: pointer; } + + + ← +
- 2023 -
-{% for book in books %} + 2023 +
+ {% for book in books %}
- -
-
- {{ book.title }} by {{ book.author }} {% if book.published_year %} ({{book.published_year}}) {% endif %} -
+ +
+
+ {{ book.title }} by {{ book.author }} {% if book.published_year %} ({{book.published_year}}) {% endif %} +
-{% endfor %} + {% endfor %}