added tabular view and tags
parent
3d77b2a187
commit
10be370469
@ -1,2 +1,3 @@
|
|||||||
web/index.html
|
web/index.html
|
||||||
reviews.json
|
reviews.json
|
||||||
|
__pycache__
|
||||||
|
@ -0,0 +1,66 @@
|
|||||||
|
from make_website import populate_template_str, datetime, get_json, review_id
|
||||||
|
|
||||||
|
|
||||||
|
with open('web/templates/table.html', 'r') as f:
|
||||||
|
TABLE_TEMPLATE = f.read()
|
||||||
|
|
||||||
|
|
||||||
|
def generate_table_row(review: dict) -> str:
|
||||||
|
return ("<tr>" + ("<td>{}</td>" * 12) + "</tr>").format(
|
||||||
|
review['company'],
|
||||||
|
make_link(
|
||||||
|
review['name'] + (' ({})'.format(review['variant']) if review['variant'] else ''),
|
||||||
|
'index.html#' + review_id(review)
|
||||||
|
),
|
||||||
|
get_type_from_categories(review),
|
||||||
|
review['final_verdict']['string'],
|
||||||
|
review['rating_value']['taste'],
|
||||||
|
review['rating_value']['consistency'],
|
||||||
|
review['rating_value']['ingredients'],
|
||||||
|
review['rating_value']['size'],
|
||||||
|
review['rating_value']['price'],
|
||||||
|
price_per_100g(review),
|
||||||
|
taste_grams_per_price(review),
|
||||||
|
", ".join(cat for cat in review['category'] if cat in ('Creamy', 'Rustic'))
|
||||||
|
)
|
||||||
|
|
||||||
|
def make_link(name, url):
|
||||||
|
return '<a href="{}">{}</a>'.format(
|
||||||
|
url, name
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_type_from_categories(review: dict) -> str:
|
||||||
|
cats = review['category']
|
||||||
|
for name in ('Genovese', 'Calabrese', 'Ricotta', 'Tomato'):
|
||||||
|
if name in cats:
|
||||||
|
return name
|
||||||
|
|
||||||
|
def price_per_100g(review: dict, raw=False):
|
||||||
|
weight, price = review['rating_value'].get('size_value', None), review['rating_value'].get('price_value', None)
|
||||||
|
if None in (weight, price):
|
||||||
|
return "???"
|
||||||
|
if raw:
|
||||||
|
return price / weight * 100
|
||||||
|
return "{:.2f}€".format(price / weight * 100)
|
||||||
|
|
||||||
|
def taste_grams_per_price(review):
|
||||||
|
price_per_100g_val = price_per_100g(review, True)
|
||||||
|
if price_per_100g_val == '???':
|
||||||
|
return '???'
|
||||||
|
return "{:.1f}".format(
|
||||||
|
review['rating_value']['taste_percent'] / price_per_100g_val * 10
|
||||||
|
)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
reviews = get_json()['reviews']
|
||||||
|
|
||||||
|
html = populate_template_str(
|
||||||
|
TABLE_TEMPLATE,
|
||||||
|
{
|
||||||
|
'table_rows': "\n".join(generate_table_row(review) for review in reviews),
|
||||||
|
'current_year': str(datetime.datetime.now().year)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
with open("web/table.html", 'w') as f:
|
||||||
|
f.write(html)
|
@ -0,0 +1,64 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="stylesheet" href="style.css?v=Unknown field CSS_HASH"/>
|
||||||
|
<title>Blog of Pesto - Table</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<header>
|
||||||
|
<h1>
|
||||||
|
Blog of Pesto
|
||||||
|
<span class="thin"> - reviewing all sorts of pesto</span>
|
||||||
|
</h1>
|
||||||
|
</header>
|
||||||
|
<main>
|
||||||
|
<h1>Tabular Overview</h1>
|
||||||
|
<p>Tabular overview over all reviews on this blog:</p>
|
||||||
|
|
||||||
|
<div class="large-table-wrapper">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Brand</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Type</th>
|
||||||
|
<th>Rating</th>
|
||||||
|
<th>Taste</th>
|
||||||
|
<th>Consistency</th>
|
||||||
|
<th>Ingredient</th>
|
||||||
|
<th>Weight</th>
|
||||||
|
<th>Price</th>
|
||||||
|
<th>100g Price</th>
|
||||||
|
<th>Value *</th>
|
||||||
|
<th>Creamy / Rustic</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr><td>Barilla</td><td><a href="index.html#barilla_pesto-alla-genovese_">Pesto alla Genovese</a></td><td>Genovese</td><td>★★★★★</td><td>5/5</td><td>5/5</td><td>4/5</td><td>190g</td><td>3.29€</td><td>1.73€</td><td>5.8</td><td>Creamy</td></tr>
|
||||||
|
<tr><td>Barilla</td><td><a href="index.html#barilla_pesto-con-pomodori-secchi_">Pesto con Pomodori Secchi</a></td><td>Tomato</td><td>★★☆☆☆</td><td>4/5</td><td>5/5</td><td>3/5</td><td>200g</td><td>3.29€</td><td>1.65€</td><td>4.9</td><td>Creamy</td></tr>
|
||||||
|
<tr><td>Barilla</td><td><a href="index.html#barilla_pesto-ricotta-e-noci_">Pesto Ricotta e Noci</a></td><td>Ricotta</td><td>★★★★☆</td><td>4/5</td><td>5/5</td><td>3/5</td><td>190g</td><td>3.29€</td><td>1.73€</td><td>4.6</td><td>Creamy</td></tr>
|
||||||
|
<tr><td>Barilla</td><td><a href="index.html#barilla_pesto-rosso_">Pesto Rosso</a></td><td>Tomato</td><td>★★★★☆</td><td>5/5</td><td>5/5</td><td>5/5</td><td>200g</td><td>3.29€</td><td>1.65€</td><td>6.1</td><td>Creamy</td></tr>
|
||||||
|
<tr><td>Barilla</td><td><a href="index.html#barilla_pesto-vegan_green">Pesto Vegan (Green)</a></td><td>None</td><td>★★★★★</td><td>5/5</td><td>5/5</td><td>3/5</td><td>195g</td><td>3.59€</td><td>1.84€</td><td>5.4</td><td>Creamy</td></tr>
|
||||||
|
<tr><td>Bernbacher</td><td><a href="index.html#bernbacher_pesto-calabrese_">Pesto Calabrese</a></td><td>Calabrese</td><td>★☆☆☆☆</td><td>1/5</td><td>2/5</td><td>1/5</td><td>140g</td><td>2.29€</td><td>1.64€</td><td>1.2</td><td>Creamy</td></tr>
|
||||||
|
<tr><td>Bertolli</td><td><a href="index.html#bertolli_pesto-calabrese_">Pesto Calabrese</a></td><td>Calabrese</td><td>★★★★★</td><td>5/5</td><td>5/5</td><td>5/5</td><td>185g</td><td>2.99€</td><td>1.62€</td><td>6.2</td><td>Creamy</td></tr>
|
||||||
|
<tr><td>Cucina</td><td><a href="index.html#cucina_premium-pesto-alla-genovese_">Premium Pesto alla Genovese</a></td><td>Genovese</td><td>★★★★☆</td><td>4/5</td><td>4/5</td><td>4/5</td><td>190g</td><td>???</td><td>???</td><td>???</td><td>Rustic</td></tr>
|
||||||
|
<tr><td>Gut & Günstig</td><td><a href="index.html#gut-&-günstig_pesto-rosso_">Pesto Rosso</a></td><td>Tomato</td><td>★★★★★</td><td>5/5</td><td>5/5</td><td>5/5</td><td>190g</td><td>1.19€</td><td>0.63€</td><td>16.0</td><td>Creamy</td></tr>
|
||||||
|
<tr><td>Ja!</td><td><a href="index.html#ja!_pesto-rosso_">Pesto Rosso</a></td><td>Tomato</td><td>★★★★☆</td><td>4/5</td><td>4/5</td><td>4/5</td><td>190g</td><td>1.19€</td><td>0.63€</td><td>12.8</td><td>Creamy</td></tr>
|
||||||
|
<tr><td>Ja!</td><td><a href="index.html#ja!_pesto-verde_">Pesto Verde</a></td><td>None</td><td>★★★★☆</td><td>3/5</td><td>4/5</td><td>4/5</td><td>190g</td><td>1.19€</td><td>0.63€</td><td>9.6</td><td>Rustic</td></tr>
|
||||||
|
<tr><td>Terre di Liguiria</td><td><a href="index.html#terre-di-liguiria_pesto-alla-genovese_">Pesto alla Genovese</a></td><td>Genovese</td><td>★★☆☆☆</td><td>4/5</td><td>3/5</td><td>4/5</td><td>180g</td><td>4.79€</td><td>2.66€</td><td>3.0</td><td>Rustic</td></tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<p>* Value is defined as the taste rating divided by the price of 10 grams of pesto. This is an arbitrary metric, but you can interpret it as "taste per normalized price". Higher is better.</p>
|
||||||
|
|
||||||
|
</main>
|
||||||
|
<footer>
|
||||||
|
<p>© copyright 2022 by Anton Lydike</p> <p>Download raw review data: <a href="reviews.json">reviews.json</a></p>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,53 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="stylesheet" href="style.css?v={CSS_HASH}"/>
|
||||||
|
<title>Blog of Pesto - Table</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<header>
|
||||||
|
<h1>
|
||||||
|
Blog of Pesto
|
||||||
|
<span class="thin"> - reviewing all sorts of pesto</span>
|
||||||
|
</h1>
|
||||||
|
</header>
|
||||||
|
<main>
|
||||||
|
<h1>Tabular Overview</h1>
|
||||||
|
<p>Tabular overview over all reviews on this blog:</p>
|
||||||
|
|
||||||
|
<div class="large-table-wrapper">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Brand</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Type</th>
|
||||||
|
<th>Rating</th>
|
||||||
|
<th>Taste</th>
|
||||||
|
<th>Consistency</th>
|
||||||
|
<th>Ingredient</th>
|
||||||
|
<th>Weight</th>
|
||||||
|
<th>Price</th>
|
||||||
|
<th>100g Price</th>
|
||||||
|
<th>Value *</th>
|
||||||
|
<th>Creamy / Rustic</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{TABLE_ROWS}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<p>* Value is defined as the taste rating divided by the price of 10 grams of pesto. This is an arbitrary metric, but you can interpret it as "taste per normalized price". Higher is better.</p>
|
||||||
|
|
||||||
|
</main>
|
||||||
|
<footer>
|
||||||
|
<p>© copyright {CURRENT_YEAR} by Anton Lydike</p> <p>Download raw review data: <a href="reviews.json">reviews.json</a></p>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue