Compare commits
6 Commits
e1d4e4f683
...
master
Author | SHA1 | Date | |
---|---|---|---|
a5ceb76e43 | |||
e26fced271 | |||
007811bde6 | |||
5177238a53 | |||
2ca297e68c | |||
a6b0eb17e7 |
8
Book.py
8
Book.py
@ -1,19 +1,25 @@
|
||||
class Book:
|
||||
|
||||
def __init__(self, name: str, description: str, image: str, review: str) -> None:
|
||||
def __init__(self, name: str, author: str, description: str, image: str, review: str, release_date: str, reading_date: str) -> None:
|
||||
self.name: str = name
|
||||
self.description: str = description
|
||||
self.image: str = image
|
||||
self.review: str = review
|
||||
self.release_date: str = release_date
|
||||
self.reading_date: str = reading_date
|
||||
self.author: str = author
|
||||
|
||||
def to_html(self) -> str:
|
||||
return f"""
|
||||
<tr>
|
||||
<td class="image-div"><img src="img/{self.image}"></td>
|
||||
<td class="namedesc-div">
|
||||
<p class="author">{self.author}</p>
|
||||
<p class="name">{self.name}</p>
|
||||
<p class="description">{self.description}</p>
|
||||
<p class="release-date">{self.release_date}</p>
|
||||
</td>
|
||||
<td class="review-div">{self.review}</td>
|
||||
<td class="reading-date">{self.reading_date}</td>
|
||||
</tr>
|
||||
"""
|
@ -2,7 +2,7 @@
|
||||
A script to generate a static book review page
|
||||
|
||||
## images
|
||||
|
||||

|
||||
## usage
|
||||
|
||||
- fill the  like the 
|
||||
|
12
cast.html
12
cast.html
@ -11,6 +11,16 @@
|
||||
<body>
|
||||
<h1>My Readings</h1>
|
||||
<table id="table">
|
||||
{{books}}
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Image</th>
|
||||
<th>Name and description</th>
|
||||
<th>My opignon</th>
|
||||
<th>Reading date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{books}}
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
@ -2,9 +2,12 @@
|
||||
"books": [
|
||||
{
|
||||
"name": "1984",
|
||||
"author": "George Orwell",
|
||||
"description": "1984 est un roman dystopique de l'écrivain britannique George Orwell. Publié le 8 juin 1949 par Secker & Warburg, il s'agit du neuvième et dernier livre d'Orwell achevé de son vivant",
|
||||
"image": "1984.jpg",
|
||||
"review": "ct pas mal"
|
||||
"review": "ct pas mal",
|
||||
"reading_date": "08/2024",
|
||||
"release_date": "08/06/1949"
|
||||
}
|
||||
]
|
||||
}
|
23
main.py
23
main.py
@ -4,27 +4,24 @@ from Book import Book
|
||||
|
||||
|
||||
# Opening JSON file
|
||||
f = open('constructor.json', encoding='utf-8')
|
||||
data = json.load(f)
|
||||
f.close()
|
||||
f = open("style.css")
|
||||
style = f.read()
|
||||
f.close()
|
||||
with open('constructor.json', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
|
||||
with open('style.css', encoding='utf-8') as f:
|
||||
style = f.read()
|
||||
|
||||
books = data['books']
|
||||
html = ""
|
||||
|
||||
for book_data in books:
|
||||
book = Book(book_data["name"], book_data["description"], book_data["image"], book_data["review"])
|
||||
book = Book(book_data["name"], book_data["author"], book_data["description"], book_data["image"], book_data["review"], book_data["release_date"], book_data["reading_date"])
|
||||
html += book.to_html()
|
||||
|
||||
f = open("cast.html")
|
||||
text = f.read().replace("{{books}}", html).replace("{{style}}", style)
|
||||
f.close()
|
||||
with open('cast.html', encoding='utf-8') as f:
|
||||
text = f.read().replace("{{books}}", html).replace("{{style}}", style)
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
f = open(sys.argv[1], "w", encoding='utf-8')
|
||||
f.write(text)
|
||||
f.close()
|
||||
with open(sys.argv[1], "w", encoding='utf-8') as f:
|
||||
f.write(text)
|
||||
else:
|
||||
print(text)
|
BIN
screenshots/1.png
Normal file
BIN
screenshots/1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 329 KiB |
48
style.css
48
style.css
@ -1,19 +1,47 @@
|
||||
body{
|
||||
background-color: #586e75;
|
||||
:root{
|
||||
--bg1: #002b36;
|
||||
--bg2: #073642;
|
||||
--content1: #586e75;
|
||||
--content2: #657b83;
|
||||
--content3: #839496;
|
||||
--content4: #93a1a1;
|
||||
--lbg1: #eee8d5;
|
||||
--lbg2: #fdf6e3;
|
||||
}
|
||||
|
||||
h1, #table {
|
||||
table tbody tr:nth-child(odd){
|
||||
background-color: var(--content1);
|
||||
}
|
||||
table tbody tr:nth-child(even) {
|
||||
background-color: var(--content4);
|
||||
}
|
||||
|
||||
body{
|
||||
background-color: var(--bg1);
|
||||
color: white;
|
||||
}
|
||||
|
||||
h1 {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
#table {
|
||||
background-color: green;
|
||||
table {
|
||||
border-collapse:collapse;
|
||||
background-color: var(--bg2);
|
||||
}
|
||||
|
||||
thead {
|
||||
background-color: var(--base1);
|
||||
}
|
||||
|
||||
tbody {
|
||||
background-color: var(--base0);
|
||||
}
|
||||
|
||||
tr {
|
||||
max-height: 250px;
|
||||
background-color: green;
|
||||
background-color: inherit;
|
||||
}
|
||||
|
||||
img {
|
||||
@ -30,9 +58,13 @@ img {
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
.reading-date {
|
||||
width: 5%;
|
||||
}
|
||||
|
||||
td {
|
||||
background-color: red;
|
||||
border: 2px solid;
|
||||
text-align: center;
|
||||
background-color: none;
|
||||
}
|
||||
|
||||
.name {
|
||||
|
Reference in New Issue
Block a user