templates
This commit is contained in:
parent
7cc0f4be39
commit
a7cf317346
3
.gitignore
vendored
3
.gitignore
vendored
@ -4,4 +4,5 @@ dist
|
|||||||
books-2023
|
books-2023
|
||||||
output
|
output
|
||||||
cookbooks
|
cookbooks
|
||||||
calvin-and-hobbes
|
calvin-and-hobbes
|
||||||
|
build.sh
|
15
main.py
15
main.py
@ -75,7 +75,7 @@ def fetch_list(list_url):
|
|||||||
# to use this next field to direct the pagination instead of an increment
|
# to use this next field to direct the pagination instead of an increment
|
||||||
page += 1
|
page += 1
|
||||||
if not next:
|
if not next:
|
||||||
more_results = False
|
more_results = False
|
||||||
else:
|
else:
|
||||||
more_results = False
|
more_results = False
|
||||||
except:
|
except:
|
||||||
@ -156,7 +156,7 @@ if __name__ == '__main__':
|
|||||||
# create parser
|
# create parser
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
prog='bookshelf-generator',
|
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')
|
epilog='<3')
|
||||||
|
|
||||||
# subparser for building website
|
# subparser for building website
|
||||||
@ -184,25 +184,22 @@ if __name__ == '__main__':
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.subparser == "bookwyrm-download":
|
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):
|
if not os.path.exists(args.output_dir):
|
||||||
os.makedirs(args.output_dir)
|
os.makedirs(args.output_dir)
|
||||||
|
|
||||||
processed_items = process_list(args.list_url)
|
processed_items = process_list(args.list_url)
|
||||||
download_images(processed_items, output_dir=args.output_dir)
|
download_images(processed_items, output_dir=args.output_dir)
|
||||||
write_yaml(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
|
yaml_path = args.yaml_path
|
||||||
images_dir = args.images_dir
|
images_dir = args.images_dir
|
||||||
output_path = args.output_path
|
output_path = args.output_path
|
||||||
template_vars = load_yaml(yaml_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)
|
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")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
14
run.sh
14
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 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 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"
|
||||||
|
|
||||||
|
# cookbooks
|
||||||
|
#python3 main.py bookwyrm-download --list-url="https://bookwyrm.social/list/2609/s/cookbooks" --output-dir="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"
|
||||||
python3 main.py generate-html --yaml-path="cookbooks/books.yaml" --images-dir="cookbooks" --template="cookbooks.html" --output-path="output/cookbooks"
|
|
@ -12,7 +12,7 @@
|
|||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
box-shadow: 12px 14px yellow;
|
box-shadow: 12px 14px yellow;
|
||||||
background-color: lightpink;
|
background-color: lightpink;
|
||||||
padding: 40px;
|
padding: 40px;
|
||||||
}
|
}
|
||||||
.main {
|
.main {
|
||||||
max-width: 600px;
|
max-width: 600px;
|
||||||
@ -23,8 +23,10 @@ padding: 40px;
|
|||||||
background-color: white;
|
background-color: white;
|
||||||
}
|
}
|
||||||
body {
|
body {
|
||||||
font-family: "Roboto Mono,monospace";
|
font-family: "Roboto Mono,monospace";
|
||||||
background-color: mediumpurple;
|
background-color: mediumpurple;
|
||||||
|
padding-bottom: 30px;
|
||||||
|
padding-top: 20px;
|
||||||
}
|
}
|
||||||
.page-title {
|
.page-title {
|
||||||
width: 90%;
|
width: 90%;
|
||||||
@ -34,7 +36,7 @@ padding: 40px;
|
|||||||
background-color: white;
|
background-color: white;
|
||||||
box-shadow: 8px 12px blue;
|
box-shadow: 8px 12px blue;
|
||||||
margin-bottom: 50px;
|
margin-bottom: 50px;
|
||||||
padding-bottom: 10px;
|
padding-bottom: 10px;
|
||||||
padding-left: 25px;
|
padding-left: 25px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,28 +59,49 @@ padding: 40px;
|
|||||||
.page-footer a:hover {
|
.page-footer a:hover {
|
||||||
background-color: yellow;
|
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;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|
||||||
|
<a href="../" class="home-button">
|
||||||
|
<!-- 🞻-->
|
||||||
|
←
|
||||||
|
</a>
|
||||||
|
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<div class="page-title">
|
<div class="page-title">
|
||||||
Calvin & Hobbes
|
Calvin & Hobbes
|
||||||
</div>
|
</div>
|
||||||
{% for book in books %}
|
{% for book in books %}
|
||||||
|
|
||||||
<div class="book-item">
|
<div class="book-item">
|
||||||
<div>
|
<div>
|
||||||
<img src="static/{{book.cover_image_path}}" class="cover-image"/>
|
<img src="static/{{book.cover_image_path}}" class="cover-image"/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{{ 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 %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<div class="page-footer">
|
<div class="page-footer">
|
||||||
source: <a href="https://bookwyrm.social/list/2634/s/calvin-and-hobbes">https://bookwyrm.social/list/2634/s/calvin-and-hobbes</a>
|
source: <a href="https://bookwyrm.social/list/2634/s/calvin-and-hobbes">https://bookwyrm.social/list/2634/s/calvin-and-hobbes</a>
|
||||||
</div>
|
</div>
|
@ -12,7 +12,7 @@
|
|||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
box-shadow: 12px 14px yellow;
|
box-shadow: 12px 14px yellow;
|
||||||
background-color: lightpink;
|
background-color: lightpink;
|
||||||
padding: 40px;
|
padding: 40px;
|
||||||
}
|
}
|
||||||
.main {
|
.main {
|
||||||
max-width: 600px;
|
max-width: 600px;
|
||||||
@ -23,8 +23,10 @@ padding: 40px;
|
|||||||
background-color: white;
|
background-color: white;
|
||||||
}
|
}
|
||||||
body {
|
body {
|
||||||
font-family: "Roboto Mono,monospace";
|
font-family: "Roboto Mono,monospace";
|
||||||
background-color: mediumpurple;
|
background-color: mediumpurple;
|
||||||
|
padding-bottom: 30px;
|
||||||
|
padding-top: 20px;
|
||||||
}
|
}
|
||||||
.page-title {
|
.page-title {
|
||||||
width: 90%;
|
width: 90%;
|
||||||
@ -34,7 +36,7 @@ padding: 40px;
|
|||||||
background-color: white;
|
background-color: white;
|
||||||
box-shadow: 8px 12px blue;
|
box-shadow: 8px 12px blue;
|
||||||
margin-bottom: 50px;
|
margin-bottom: 50px;
|
||||||
padding-bottom: 10px;
|
padding-bottom: 10px;
|
||||||
padding-left: 25px;
|
padding-left: 25px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,29 +58,50 @@ padding: 40px;
|
|||||||
}
|
}
|
||||||
.page-footer a:hover {
|
.page-footer a:hover {
|
||||||
background-color: yellow;
|
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;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
<a href="../" class="home-button">
|
||||||
|
<!-- 🞻-->
|
||||||
|
←
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<div class="page-title">
|
<div class="page-title">
|
||||||
Cookbooks
|
Cookbooks
|
||||||
</div>
|
</div>
|
||||||
{% for book in books %}
|
{% for book in books %}
|
||||||
|
|
||||||
<div class="book-item">
|
<div class="book-item">
|
||||||
<div>
|
<div>
|
||||||
<img src="static/{{book.cover_image_path}}" class="cover-image"/>
|
<img src="static/{{book.cover_image_path}}" class="cover-image"/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{{ 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 %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<div class="page-footer">
|
<div class="page-footer">
|
||||||
source: <a href="https://bookwyrm.social/list/2609/s/cookbooks">https://bookwyrm.social/list/2609/s/cookbooks</a>
|
source: <a href="https://bookwyrm.social/list/2609/s/cookbooks">https://bookwyrm.social/list/2609/s/cookbooks</a>
|
||||||
</div>
|
</div>
|
@ -12,7 +12,7 @@
|
|||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
box-shadow: 12px 14px yellow;
|
box-shadow: 12px 14px yellow;
|
||||||
background-color: lightpink;
|
background-color: lightpink;
|
||||||
padding: 40px;
|
padding: 40px;
|
||||||
}
|
}
|
||||||
.main {
|
.main {
|
||||||
max-width: 600px;
|
max-width: 600px;
|
||||||
@ -23,8 +23,10 @@ padding: 40px;
|
|||||||
background-color: white;
|
background-color: white;
|
||||||
}
|
}
|
||||||
body {
|
body {
|
||||||
/*font-family: "Roboto Mono", monospace;*/
|
/*font-family: "Roboto Mono", monospace;*/
|
||||||
background-color: mediumpurple;
|
background-color: mediumpurple;
|
||||||
|
padding-bottom: 30px;
|
||||||
|
padding-top: 20px;
|
||||||
}
|
}
|
||||||
.page-title {
|
.page-title {
|
||||||
width: 90%;
|
width: 90%;
|
||||||
@ -34,7 +36,7 @@ padding: 40px;
|
|||||||
background-color: white;
|
background-color: white;
|
||||||
box-shadow: 8px 12px blue;
|
box-shadow: 8px 12px blue;
|
||||||
margin-bottom: 50px;
|
margin-bottom: 50px;
|
||||||
padding-bottom: 10px;
|
padding-bottom: 10px;
|
||||||
padding-left: 25px;
|
padding-left: 25px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,29 +58,51 @@ padding: 40px;
|
|||||||
}
|
}
|
||||||
.page-footer a:hover {
|
.page-footer a:hover {
|
||||||
background-color: yellow;
|
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;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
<a href="../" class="home-button">
|
||||||
|
<!-- 🞻-->
|
||||||
|
←
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<div class="page-title">
|
<div class="page-title">
|
||||||
2023
|
2023
|
||||||
</div>
|
</div>
|
||||||
{% for book in books %}
|
{% for book in books %}
|
||||||
|
|
||||||
<div class="book-item">
|
<div class="book-item">
|
||||||
<div>
|
<div>
|
||||||
<img src="static/{{book.cover_image_path}}" class="cover-image"/>
|
<img src="static/{{book.cover_image_path}}" class="cover-image"/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{{ 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 %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
Loading…
x
Reference in New Issue
Block a user