three
This commit is contained in:
parent
162e91e662
commit
7cc0f4be39
|
@ -2,3 +2,6 @@
|
|||
static
|
||||
dist
|
||||
books-2023
|
||||
output
|
||||
cookbooks
|
||||
calvin-and-hobbes
|
|
@ -2,23 +2,71 @@
|
|||
<head>
|
||||
<style>
|
||||
.cover-image {
|
||||
width: 200px;
|
||||
max-width: 200px;
|
||||
max-height: 200px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.book-item {
|
||||
margin-bottom: 100px;
|
||||
width: 80%;
|
||||
margin-right: 20px;
|
||||
box-shadow: 12px 14px yellow;
|
||||
background-color: lightpink;
|
||||
padding: 40px;
|
||||
}
|
||||
.main {
|
||||
max-width: 600px;
|
||||
margin: auto;
|
||||
border: 1px solid purple;
|
||||
padding: 15px;
|
||||
box-shadow: 8px 12px blue;
|
||||
background-color: white;
|
||||
}
|
||||
body {
|
||||
/*font-family: "Roboto Mono", monospace;*/
|
||||
background-color: mediumpurple;
|
||||
}
|
||||
.page-title {
|
||||
width: 90%;
|
||||
margin-bottom: 20px;
|
||||
color: purple;
|
||||
font-size: 32px;
|
||||
background-color: white;
|
||||
box-shadow: 8px 12px blue;
|
||||
margin-bottom: 50px;
|
||||
padding-bottom: 10px;
|
||||
padding-left: 25px;
|
||||
}
|
||||
|
||||
@media (min-width:900px) {
|
||||
.book-item {
|
||||
width: 80%;
|
||||
}
|
||||
}
|
||||
.page-footer {
|
||||
text-align: center;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.page-footer a {
|
||||
color: black;
|
||||
line-height: 32px;
|
||||
border-bottom: 1px solid purple;
|
||||
text-decoration: none;
|
||||
padding-bottom: 7px;
|
||||
}
|
||||
.page-footer a:hover {
|
||||
background-color: yellow;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
bookshelf
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="main">
|
||||
<div class="page-title">
|
||||
2023
|
||||
</div>
|
||||
{% for book in books %}
|
||||
|
||||
<div class="book-item">
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
<html>
|
||||
<head>
|
||||
<style>
|
||||
.cover-image {
|
||||
max-width: 200px;
|
||||
max-height: 200px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.book-item {
|
||||
margin-bottom: 100px;
|
||||
width: 80%;
|
||||
margin-right: 20px;
|
||||
box-shadow: 12px 14px yellow;
|
||||
background-color: lightpink;
|
||||
padding: 40px;
|
||||
}
|
||||
.main {
|
||||
max-width: 600px;
|
||||
margin: auto;
|
||||
border: 1px solid purple;
|
||||
padding: 15px;
|
||||
box-shadow: 8px 12px blue;
|
||||
background-color: white;
|
||||
}
|
||||
body {
|
||||
font-family: "Roboto Mono,monospace";
|
||||
background-color: mediumpurple;
|
||||
}
|
||||
.page-title {
|
||||
width: 90%;
|
||||
margin-bottom: 20px;
|
||||
color: purple;
|
||||
font-size: 32px;
|
||||
background-color: white;
|
||||
box-shadow: 8px 12px blue;
|
||||
margin-bottom: 50px;
|
||||
padding-bottom: 10px;
|
||||
padding-left: 25px;
|
||||
}
|
||||
|
||||
@media (min-width:900px) {
|
||||
.book-item {
|
||||
width: 80%;
|
||||
}
|
||||
}
|
||||
.page-footer {
|
||||
text-align: center;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.page-footer a {
|
||||
color: black;
|
||||
line-height: 32px;
|
||||
border-bottom: 1px solid purple;
|
||||
text-decoration: none;
|
||||
padding-bottom: 7px;
|
||||
}
|
||||
.page-footer a:hover {
|
||||
background-color: yellow;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<div class="main">
|
||||
<div class="page-title">
|
||||
Calvin & Hobbes
|
||||
</div>
|
||||
{% for book in books %}
|
||||
|
||||
<div class="book-item">
|
||||
<div>
|
||||
<img src="static/{{book.cover_image_path}}" class="cover-image"/>
|
||||
</div>
|
||||
<div>
|
||||
{{ book.title }} by {{ book.author }} {% if book.published_year %} ({{book.published_year}}) {% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,88 @@
|
|||
<html>
|
||||
<head>
|
||||
<style>
|
||||
.cover-image {
|
||||
max-width: 200px;
|
||||
max-height: 200px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.book-item {
|
||||
margin-bottom: 100px;
|
||||
width: 80%;
|
||||
margin-right: 20px;
|
||||
box-shadow: 12px 14px yellow;
|
||||
background-color: lightpink;
|
||||
padding: 40px;
|
||||
}
|
||||
.main {
|
||||
max-width: 600px;
|
||||
margin: auto;
|
||||
border: 1px solid purple;
|
||||
padding: 15px;
|
||||
box-shadow: 8px 12px blue;
|
||||
background-color: white;
|
||||
}
|
||||
body {
|
||||
font-family: "Roboto Mono,monospace";
|
||||
background-color: mediumpurple;
|
||||
}
|
||||
.page-title {
|
||||
width: 90%;
|
||||
margin-bottom: 20px;
|
||||
color: purple;
|
||||
font-size: 32px;
|
||||
background-color: white;
|
||||
box-shadow: 8px 12px blue;
|
||||
margin-bottom: 50px;
|
||||
padding-bottom: 10px;
|
||||
padding-left: 25px;
|
||||
}
|
||||
|
||||
@media (min-width:900px) {
|
||||
.book-item {
|
||||
width: 80%;
|
||||
}
|
||||
}
|
||||
.page-footer {
|
||||
text-align: center;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.page-footer a {
|
||||
color: black;
|
||||
line-height: 32px;
|
||||
border-bottom: 1px solid purple;
|
||||
text-decoration: none;
|
||||
padding-bottom: 7px;
|
||||
}
|
||||
.page-footer a:hover {
|
||||
background-color: yellow;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<div class="main">
|
||||
<div class="page-title">
|
||||
Cookbooks
|
||||
</div>
|
||||
{% for book in books %}
|
||||
|
||||
<div class="book-item">
|
||||
<div>
|
||||
<img src="static/{{book.cover_image_path}}" class="cover-image"/>
|
||||
</div>
|
||||
<div>
|
||||
{{ book.title }} by {{ book.author }} {% if book.published_year %} ({{book.published_year}}) {% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
<div class="page-footer">
|
||||
source: <a href="https://bookwyrm.social/list/2609/s/cookbooks">https://bookwyrm.social/list/2609/s/cookbooks</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
26
main.py
26
main.py
|
@ -25,6 +25,8 @@ def build_site(output_dir, images_dir, relative_template_path, template_vars):
|
|||
|
||||
# copy over static files
|
||||
input_static_dir = images_dir
|
||||
if not os.path.exists(output_dir):
|
||||
os.makedirs(output_dir)
|
||||
output_static_dir = os.path.join(output_dir, 'static')
|
||||
if os.path.exists(output_static_dir):
|
||||
os.system('rm -r {}'.format(output_static_dir))
|
||||
|
@ -107,7 +109,9 @@ def process_list(list_url):
|
|||
to_print += " ({})".format(published_year)
|
||||
print(to_print)
|
||||
print("cover: {}".format(cover_url))
|
||||
image_title = book.get("title").replace(" ", "-")
|
||||
image_title = book.get("title")
|
||||
image_title = ''.join(c for c in image_title if (c.isalnum() or c == " "))
|
||||
image_title = image_title.replace(" ", "-")
|
||||
image_title = image_title.replace(":", "")
|
||||
image_path = "{}.jpg".format(image_title)
|
||||
# return item
|
||||
|
@ -161,13 +165,20 @@ if __name__ == '__main__':
|
|||
bookwyrm_parser = subparsers.add_parser('bookwyrm-download')
|
||||
|
||||
# bookwyrm-download subparser
|
||||
bookwyrm_parser.add_argument('list_url') # bookwyrm list url to use as a source input
|
||||
bookwyrm_parser.add_argument('output_dir') # path where images should be downloaded and csv should be written
|
||||
required_bookwyrm_args = bookwyrm_parser.add_argument_group('required named arguments')
|
||||
required_bookwyrm_args.add_argument('-l', '--list-url', help="bookwyrm list url to use as a source input",
|
||||
required=True)
|
||||
required_bookwyrm_args.add_argument('-o', '--output-dir',
|
||||
help="path where images should be downloaded and yaml should be written",
|
||||
required=True)
|
||||
|
||||
# generate-html subparser
|
||||
build_parser.add_argument('images_dir') # path to folder containing cover images
|
||||
build_parser.add_argument('yaml_path') # yaml path to use as input
|
||||
build_parser.add_argument('-t', '--template') # path to jinja file to use as a template for the html
|
||||
required_build_args = build_parser.add_argument_group('required named arguments')
|
||||
required_build_args.add_argument('-i', '--images-dir', help="path to folder containing cover images", required=True)
|
||||
required_build_args.add_argument('-y', '--yaml-path', help="yaml path to use as input", required=True)
|
||||
required_build_args.add_argument('-t', '--template', help="path to jinja file to use as a template for the html",
|
||||
required=True)
|
||||
required_build_args.add_argument('-o', '--output-path', help="path to generate html inside of", required=True)
|
||||
|
||||
# parse args
|
||||
args = parser.parse_args()
|
||||
|
@ -188,8 +199,9 @@ if __name__ == '__main__':
|
|||
else:
|
||||
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_DIR, 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)
|
||||
|
||||
|
||||
|
||||
|
|
12
run.sh
12
run.sh
|
@ -1,5 +1,11 @@
|
|||
# download
|
||||
#python3 main.py bookwyrm-download "https://bookwyrm.social/list/2458/s/notplants-2023" "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"
|
||||
|
||||
# build
|
||||
python3 main.py generate-html "example.yaml" --template="bookshelf.html"
|
||||
#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 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"
|
|
@ -0,0 +1,34 @@
|
|||
<html>
|
||||
<head>
|
||||
<style>
|
||||
.cover-image {
|
||||
width: 200px;
|
||||
}
|
||||
.book-item {
|
||||
margin-bottom: 100px;
|
||||
}
|
||||
.main {
|
||||
max-width: 600px;
|
||||
margin: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="main">
|
||||
{% for book in books %}
|
||||
|
||||
<div class="book-item">
|
||||
<div>
|
||||
<img src="static/{{book.cover_image_path}}" class="cover-image"/>
|
||||
</div>
|
||||
<div>
|
||||
{{ book.title }} by {{ book.author }} {% if book.published_year %} ({{book.published_year}}) {% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,71 @@
|
|||
<html>
|
||||
<head>
|
||||
<style>
|
||||
.cover-image {
|
||||
max-width: 200px;
|
||||
max-height: 200px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.book-item {
|
||||
margin-bottom: 100px;
|
||||
width: 80%;
|
||||
margin-right: 20px;
|
||||
box-shadow: 12px 14px yellow;
|
||||
background-color: lightpink;
|
||||
padding: 40px;
|
||||
}
|
||||
.main {
|
||||
max-width: 600px;
|
||||
margin: auto;
|
||||
border: 1px solid purple;
|
||||
padding: 15px;
|
||||
box-shadow: 8px 12px blue;
|
||||
background-color: white;
|
||||
}
|
||||
body {
|
||||
font-family: "Roboto Mono,monospace";
|
||||
background-color: mediumpurple;
|
||||
}
|
||||
.page-title {
|
||||
width: 90%;
|
||||
margin-bottom: 20px;
|
||||
color: purple;
|
||||
font-size: 32px;
|
||||
background-color: white;
|
||||
box-shadow: 8px 12px blue;
|
||||
margin-bottom: 50px;
|
||||
padding-bottom: 10px;
|
||||
padding-left: 25px;
|
||||
}
|
||||
|
||||
@media (min-width:900px) {
|
||||
.book-item {
|
||||
width: 80%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<div class="main">
|
||||
<div class="page-title">
|
||||
2023
|
||||
</div>
|
||||
{% for book in books %}
|
||||
|
||||
<div class="book-item">
|
||||
<div>
|
||||
<img src="static/{{book.cover_image_path}}" class="cover-image"/>
|
||||
</div>
|
||||
<div>
|
||||
{{ book.title }} by {{ book.author }} {% if book.published_year %} ({{book.published_year}}) {% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue