From 7cc2d7518fcc025dd5959de31837942914a1db93 Mon Sep 17 00:00:00 2001
From: Bauke
Date: Sat, 8 Oct 2022 22:11:52 +0200
Subject: [PATCH] Add the groups table.
---
source/cli/run.rs | 10 +++++++---
source/scss/index.scss | 30 +++++++++++++++++++++++++++++-
source/templates/index.html | 26 ++++++++++++++++++++++++++
source/templates/mod.rs | 8 ++++++--
4 files changed, 68 insertions(+), 6 deletions(-)
diff --git a/source/cli/run.rs b/source/cli/run.rs
index 9280273..3975348 100644
--- a/source/cli/run.rs
+++ b/source/cli/run.rs
@@ -85,15 +85,19 @@ pub async fn run() -> Result<()> {
command: web_command,
} => match web_command {
WebSubcommands::Build { output } => {
- let user_count_group =
+ let (groups, user_count_group) =
if let Some(snapshot) = SnapshotModel::get_most_recent(&db).await? {
- GroupDataModel::get_highest_subscribers(&db, &snapshot).await?
+ (
+ GroupDataModel::get_all_by_snapshot(&db, &snapshot).await?,
+ GroupDataModel::get_highest_subscribers(&db, &snapshot).await?,
+ )
} else {
- None
+ (vec![], None)
};
create_dir_all(&output).await?;
HomeTemplate::new(
+ groups,
user_count_group.as_ref().map(|group| group.subscribers),
)
.render_to_file(&output)
diff --git a/source/scss/index.scss b/source/scss/index.scss
index 67094ff..92c0d3c 100644
--- a/source/scss/index.scss
+++ b/source/scss/index.scss
@@ -24,13 +24,41 @@
.page-main {
h2,
img,
- p {
+ p,
+ table {
margin-bottom: var(--medium-spacing);
&:last-child {
margin-bottom: 0;
}
}
+
+ table {
+ border: 2px solid var(--background-2);
+ border-collapse: collapse;
+ width: 100%;
+ }
+
+ thead {
+ background-color: var(--background-2);
+ border-bottom: 2px solid var(--background-2);
+ text-align: left;
+ }
+
+ tr {
+ border: 2px solid var(--background-2);
+ }
+
+ td,
+ th {
+ padding: var(--medium-spacing);
+ }
+
+ tbody {
+ > tr:nth-of-type(2n) {
+ background-color: var(--background-2);
+ }
+ }
}
.page-footer {
diff --git a/source/templates/index.html b/source/templates/index.html
index a75f6fa..e89c650 100644
--- a/source/templates/index.html
+++ b/source/templates/index.html
@@ -19,6 +19,32 @@
+
+
+
+
+ Group |
+ Subscribers |
+ Description |
+
+
+
+
+ {% for group in groups %}
+
+
+ {{ group.name }}
+ |
+ {{ group.subscribers }} |
+
+ {% if let Some(description) = group.description %}
+ {{ description }}
+ {% endif %}
+ |
+
+ {% endfor %}
+
+