,
+ pub map_countries: String,
+ pub map_max: u32,
+ pub created_date: String,
+ pub created_time: String,
+}
+
+impl RoasterDetailView {
+ pub fn from_domain(roaster: Roaster) -> Self {
+ let country_flag = country_to_iso(&roaster.country)
+ .map(iso_to_flag_emoji)
+ .unwrap_or_default();
+ let (map_countries, map_max) = build_map_data(&[(&roaster.country, 1)]);
+
+ Self {
+ id: roaster.id.to_string(),
+ name: roaster.name,
+ country_flag,
+ country: roaster.country,
+ city: roaster.city,
+ homepage: roaster.homepage,
+ map_countries,
+ map_max,
+ created_date: roaster.created_at.format("%Y-%m-%d").to_string(),
+ created_time: roaster.created_at.format("%H:%M").to_string(),
+ }
+ }
+}
+
pub struct RoasterOptionView {
pub id: String,
pub name: String,
diff --git a/templates/pages/bag.html b/templates/pages/bag.html
index ef95dfb..4d63275 100644
--- a/templates/pages/bag.html
+++ b/templates/pages/bag.html
@@ -82,7 +82,7 @@
{% endif %}
diff --git a/templates/pages/cafe.html b/templates/pages/cafe.html
new file mode 100644
index 0000000..c802dab
--- /dev/null
+++ b/templates/pages/cafe.html
@@ -0,0 +1,72 @@
+{% extends "base.html" %}
+{% import "partials/detail_cards.html" as detail %}
+{% import "partials/icons.html" as icons %}
+{% block title %}Brewlog · {{ cafe.name }}{% endblock %}
+{% block og_title %}{{ cafe.name }} — Brewlog{% endblock %}
+{% block og_description %}{{ cafe.name }} — {{ cafe.city }}, {{ cafe.country_flag }} {{ cafe.country }}{% endblock %}
+{% block head %}{% endblock %}
+{% block content %}
+
+
+{{ detail::share_script() }}
+
+
+
+
Details
+
+
+
- City
+ - {{ cafe.city }}
+
+
+
- Country
+ -
+ {% if !cafe.country_flag.is_empty() %}{{ cafe.country_flag }} {% endif %}{{ cafe.country }}
+
+
+ {% if let Some(url) = cafe.website %}
+
+ {% endif %}
+
+
+
+ {{ detail::map_with_legend_1(cafe.map_countries, cafe.map_max, "Cafe", "") }}
+
+
+{% if is_authenticated %}
+
+
+
+
+{% endif %}
+{% endblock %}
diff --git a/templates/pages/gear.html b/templates/pages/gear.html
new file mode 100644
index 0000000..c290587
--- /dev/null
+++ b/templates/pages/gear.html
@@ -0,0 +1,62 @@
+{% extends "base.html" %}
+{% import "partials/detail_cards.html" as detail %}
+{% import "partials/icons.html" as icons %}
+{% block title %}Brewlog · {{ gear.make }} {{ gear.model }}{% endblock %}
+{% block og_title %}{{ gear.make }} {{ gear.model }} — Brewlog{% endblock %}
+{% block og_description %}{{ gear.make }} {{ gear.model }} — {{ gear.category_label }}{% endblock %}
+{% block head %}{% endblock %}
+{% block content %}
+
+
+{{ detail::share_script() }}
+
+
+
Details
+
+
+
- Category
+ - {{ gear.category_label }}
+
+
+
- Make
+ - {{ gear.make }}
+
+
+
- Model
+ - {{ gear.model }}
+
+
+
+
+{% if is_authenticated %}
+
+
+
+
+{% endif %}
+{% endblock %}
diff --git a/templates/pages/roaster.html b/templates/pages/roaster.html
new file mode 100644
index 0000000..6cb6de0
--- /dev/null
+++ b/templates/pages/roaster.html
@@ -0,0 +1,74 @@
+{% extends "base.html" %}
+{% import "partials/detail_cards.html" as detail %}
+{% import "partials/icons.html" as icons %}
+{% block title %}Brewlog · {{ roaster.name }}{% endblock %}
+{% block og_title %}{{ roaster.name }} — Brewlog{% endblock %}
+{% block og_description %}{{ roaster.name }} — {{ roaster.country_flag }} {{ roaster.country }}{% if let Some(c) = roaster.city %}, {{ c }}{% endif %}{% endblock %}
+{% block head %}{% endblock %}
+{% block content %}
+
+
+{{ detail::share_script() }}
+
+
+
+
Details
+
+
+
- Country
+ -
+ {% if !roaster.country_flag.is_empty() %}{{ roaster.country_flag }} {% endif %}{{ roaster.country }}
+
+
+ {% if let Some(c) = roaster.city %}
+
+
- City
+ - {{ c }}
+
+ {% endif %}
+ {% if let Some(url) = roaster.homepage %}
+
+ {% endif %}
+
+
+
+ {{ detail::map_with_legend_1(roaster.map_countries, roaster.map_max, "Roaster", "") }}
+
+
+{% if is_authenticated %}
+
+
+
+
+{% endif %}
+{% endblock %}
diff --git a/templates/partials/detail_cards.html b/templates/partials/detail_cards.html
index 319546e..b848136 100644
--- a/templates/partials/detail_cards.html
+++ b/templates/partials/detail_cards.html
@@ -74,6 +74,23 @@ const shareLink = (btn) => {
{% endmacro %}
+{% macro map_with_legend_1(map_countries, map_max, label1, opacity1) %}
+{% if !map_countries.is_empty() %}
+
+
+
+
+ {{ label1 }}
+
+
+
+{% endif %}
+{% endmacro %}
+
{% macro map_with_legend_2(map_countries, map_max, label1, opacity1, label2, opacity2) %}
{% if !map_countries.is_empty() %}
diff --git a/tests/server/datastar.rs b/tests/server/datastar.rs
index 3af3ad9..0269556 100644
--- a/tests/server/datastar.rs
+++ b/tests/server/datastar.rs
@@ -115,6 +115,7 @@ async fn roasters_create_with_datastar_header_returns_fragment() {
.post(app.api_url("/roasters"))
.bearer_auth(app.auth_token.as_ref().unwrap())
.header("datastar-request", "true")
+ .header("referer", format!("{}/data?type=roasters", app.address))
.json(&new_roaster)
.send()
.await
@@ -281,6 +282,7 @@ async fn bags_create_with_datastar_header_returns_fragment() {
.post(app.api_url("/bags"))
.bearer_auth(app.auth_token.as_ref().unwrap())
.header("datastar-request", "true")
+ .header("referer", format!("{}/data?type=bags", app.address))
.json(&new_bag)
.send()
.await
@@ -415,6 +417,7 @@ async fn gear_create_with_datastar_header_returns_fragment() {
.post(app.api_url("/gear"))
.bearer_auth(app.auth_token.as_ref().unwrap())
.header("datastar-request", "true")
+ .header("referer", format!("{}/data?type=gear", app.address))
.json(&new_gear)
.send()
.await
@@ -566,6 +569,7 @@ async fn cafes_create_with_datastar_header_returns_fragment() {
.post(app.api_url("/cafes"))
.bearer_auth(app.auth_token.as_ref().unwrap())
.header("datastar-request", "true")
+ .header("referer", format!("{}/data?type=cafes", app.address))
.json(&new_cafe)
.send()
.await