neiam
/recourse
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
Landing: Popular row under Latest; /p/latest and /p/popular feeds
ad7d0f4 · gmorell · 2026-12-03 03:40
Message
{commit_body(@commit)}
Files changed
modified
src/handlers/landing.rs
+244
−18
@@ -1,11 +1,13 @@
| 1 | 1 | //! The landing page (`/`): two columns in both layouts. Categories on the |
| 2 | −//! left (the visible top level, each with its visible children), the latest | |
| 3 | −//! topics across everything the viewer can see on the right. Classic shows | |
| 4 | −//! the latest as the usual topic table; Focus as tiles, with the reader | |
| 5 | −//! (`&topic=<id>`) stepping through that same list. | |
| 2 | +//! left (the visible top level, each with its visible children); on the | |
| 3 | +//! right a Latest row and, under it, a Popular row, across everything the | |
| 4 | +//! viewer can see. Classic shows each as the usual topic table; Focus as | |
| 5 | +//! tiles, with the reader (`&topic=<id>`, plus `&list=popular` for the second | |
| 6 | +//! row) stepping through that row. | |
| 6 | 7 | //! |
| 7 | −//! The full categories page that used to be the landing lives at `/c/` | |
| 8 | −//! ([`super::forum::categories_index`]). | |
| 8 | +//! Each row's heading opens its full feed, `/p/latest` and `/p/popular` | |
| 9 | +//! ([`feed`]), in either layout. The full categories page that used to be | |
| 10 | +//! the landing lives at `/c/` ([`super::forum::categories_index`]). | |
| 9 | 11 | |
| 10 | 12 | use std::collections::HashSet; |
| 11 | 13 |
@@ -17,15 +19,23 @@ use sea_orm::*;
| 17 | 19 | use serde::{Deserialize, Serialize}; |
| 18 | 20 | use uuid::Uuid; |
| 19 | 21 | |
| 20 | −use super::focus::{self, subtree_count, topic_counts, ViewMode}; | |
| 22 | +use std::collections::HashMap; | |
| 23 | + | |
| 24 | +use chrono::Utc; | |
| 25 | + | |
| 26 | +use super::focus::{self, subtree_count, topic_counts, ListPage, ViewMode}; | |
| 21 | 27 | use super::forum::{build_topic_rows, ise, viewer_of, TopicSort}; |
| 22 | 28 | use crate::category_tree::{color_widget_css, CategoryTree}; |
| 23 | −use crate::entities::{topics, users}; | |
| 29 | +use crate::entities::{post_reactions, posts, topics, users}; | |
| 24 | 30 | use crate::middleware::UserContext; |
| 25 | 31 | use crate::AppState; |
| 26 | 32 | |
| 27 | −/// How many topics the latest column shows. | |
| 28 | −pub(crate) const LATEST_LIMIT: u64 = 30; | |
| 33 | +/// How many topics each landing row shows; the full feeds show [`FEED_LIMIT`]. | |
| 34 | +pub(crate) const LANDING_LATEST: u64 = 12; | |
| 35 | +pub(crate) const LANDING_POPULAR: usize = 8; | |
| 36 | +pub(crate) const FEED_LIMIT: u64 = 50; | |
| 37 | +/// Popular considers topics active within this many days. | |
| 38 | +const POPULAR_WINDOW_DAYS: i64 = 30; | |
| 29 | 39 | |
| 30 | 40 | #[derive(Debug, Deserialize)] |
| 31 | 41 | pub struct LandingQuery { |
@@ -34,6 +44,37 @@ pub struct LandingQuery {
| 34 | 44 | pub view: Option<String>, |
| 35 | 45 | /// Focus: open the reader at this topic. |
| 36 | 46 | pub topic: Option<Uuid>, |
| 47 | + /// Focus on the landing: which row the reader steps through | |
| 48 | + /// (`popular`; anything else = latest). | |
| 49 | + pub list: Option<String>, | |
| 50 | +} | |
| 51 | + | |
| 52 | +/// The two feeds. | |
| 53 | +#[derive(Clone, Copy, PartialEq, Eq)] | |
| 54 | +pub(crate) enum Feed { | |
| 55 | + Latest, | |
| 56 | + Popular, | |
| 57 | +} | |
| 58 | + | |
| 59 | +impl Feed { | |
| 60 | + fn parse(s: Option<&str>) -> Self { | |
| 61 | + if s == Some("popular") { Feed::Popular } else { Feed::Latest } | |
| 62 | + } | |
| 63 | + fn slug(self) -> &'static str { | |
| 64 | + match self { Feed::Latest => "latest", Feed::Popular => "popular" } | |
| 65 | + } | |
| 66 | + fn heading(self) -> &'static str { | |
| 67 | + match self { Feed::Latest => "Latest", Feed::Popular => "Popular" } | |
| 68 | + } | |
| 69 | + fn icon(self) -> &'static str { | |
| 70 | + match self { Feed::Latest => "fa-clock", Feed::Popular => "fa-fire" } | |
| 71 | + } | |
| 72 | + fn blurb(self) -> &'static str { | |
| 73 | + match self { | |
| 74 | + Feed::Latest => "Topics with the most recent activity.", | |
| 75 | + Feed::Popular => "The most engaged-with topics of the last 30 days: replies, reactions and views, with newer activity counting for more.", | |
| 76 | + } | |
| 77 | + } | |
| 37 | 78 | } |
| 38 | 79 | |
| 39 | 80 | #[derive(Serialize)] |
@@ -66,6 +107,150 @@ pub(crate) async fn latest_topics(
| 66 | 107 | .map_err(ise("load latest topics")) |
| 67 | 108 | } |
| 68 | 109 | |
| 110 | +/// Engagement score for Popular: replies weigh most, then reactions, then | |
| 111 | +/// views, all decayed by how long ago the topic was last active. | |
| 112 | +pub(crate) fn popular_score(replies: i64, reactions: i64, views: i64, hours_since_bump: f64) -> f64 { | |
| 113 | + let engagement = 3.0 * replies.max(0) as f64 + 2.0 * reactions.max(0) as f64 + views.max(0) as f64 / 10.0; | |
| 114 | + engagement / (hours_since_bump.max(0.0) + 2.0).powf(1.2) | |
| 115 | +} | |
| 116 | + | |
| 117 | +/// Live topics the viewer can see, active in the last | |
| 118 | +/// [`POPULAR_WINDOW_DAYS`], ranked by [`popular_score`]. Pinned topics get | |
| 119 | +/// no special place here. | |
| 120 | +pub(crate) async fn popular_topics( | |
| 121 | + state: &AppState, | |
| 122 | + vis: &HashSet<Uuid>, | |
| 123 | + limit: usize, | |
| 124 | +) -> Result<Vec<(topics::Model, Option<users::Model>)>, StatusCode> { | |
| 125 | + if vis.is_empty() { | |
| 126 | + return Ok(Vec::new()); | |
| 127 | + } | |
| 128 | + let since = Utc::now() - chrono::Duration::days(POPULAR_WINDOW_DAYS); | |
| 129 | + let loaded = topics::Entity::find() | |
| 130 | + .filter(topics::Column::CategoryId.is_in(vis.iter().copied())) | |
| 131 | + .filter(topics::Column::DeletedAt.is_null()) | |
| 132 | + .filter(topics::Column::BumpedAt.gte(since)) | |
| 133 | + .find_also_related(users::Entity) | |
| 134 | + .all(state.db.as_ref()) | |
| 135 | + .await | |
| 136 | + .map_err(ise("load popular candidates"))?; | |
| 137 | + let ids: Vec<Uuid> = loaded.iter().map(|(t, _)| t.id).collect(); | |
| 138 | + let reactions: HashMap<Uuid, i64> = if ids.is_empty() { | |
| 139 | + HashMap::new() | |
| 140 | + } else { | |
| 141 | + post_reactions::Entity::find() | |
| 142 | + .select_only() | |
| 143 | + .column(posts::Column::TopicId) | |
| 144 | + .column_as(post_reactions::Column::Id.count(), "n") | |
| 145 | + .join(JoinType::InnerJoin, post_reactions::Relation::Posts.def()) | |
| 146 | + .filter(posts::Column::TopicId.is_in(ids)) | |
| 147 | + .filter(posts::Column::DeletedAt.is_null()) | |
| 148 | + .group_by(posts::Column::TopicId) | |
| 149 | + .into_tuple::<(Uuid, i64)>() | |
| 150 | + .all(state.db.as_ref()) | |
| 151 | + .await | |
| 152 | + .map_err(ise("count reactions per topic"))? | |
| 153 | + .into_iter() | |
| 154 | + .collect() | |
| 155 | + }; | |
| 156 | + let now = Utc::now(); | |
| 157 | + let mut scored: Vec<(f64, (topics::Model, Option<users::Model>))> = loaded | |
| 158 | + .into_iter() | |
| 159 | + .map(|(t, u)| { | |
| 160 | + let hours = (now - t.bumped_at.with_timezone(&Utc)).num_seconds() as f64 / 3600.0; | |
| 161 | + let score = popular_score( | |
| 162 | + (t.posts_count - 1) as i64, | |
| 163 | + reactions.get(&t.id).copied().unwrap_or(0), | |
| 164 | + t.views as i64, | |
| 165 | + hours, | |
| 166 | + ); | |
| 167 | + (score, (t, u)) | |
| 168 | + }) | |
| 169 | + .collect(); | |
| 170 | + scored.sort_by(|a, b| b.0.partial_cmp(&a.0).unwrap_or(std::cmp::Ordering::Equal) | |
| 171 | + .then_with(|| b.1 .0.bumped_at.cmp(&a.1 .0.bumped_at))); | |
| 172 | + Ok(scored.into_iter().take(limit).filter(|(s, _)| *s > 0.0).map(|(_, r)| r).collect()) | |
| 173 | +} | |
| 174 | + | |
| 175 | +async fn feed_topics( | |
| 176 | + state: &AppState, | |
| 177 | + vis: &HashSet<Uuid>, | |
| 178 | + feed: Feed, | |
| 179 | + limit: usize, | |
| 180 | +) -> Result<Vec<(topics::Model, Option<users::Model>)>, StatusCode> { | |
| 181 | + match feed { | |
| 182 | + Feed::Latest => latest_topics(state, vis, limit as u64).await, | |
| 183 | + Feed::Popular => popular_topics(state, vis, limit).await, | |
| 184 | + } | |
| 185 | +} | |
| 186 | + | |
| 187 | +#[derive(Debug, Deserialize)] | |
| 188 | +pub struct FeedQuery { | |
| 189 | + pub view: Option<String>, | |
| 190 | + pub topic: Option<Uuid>, | |
| 191 | +} | |
| 192 | + | |
| 193 | +/// `/p/latest` and `/p/popular`: the full feed in the viewer's layout | |
| 194 | +/// (Classic table or Focus tiles with the reader). | |
| 195 | +async fn feed( | |
| 196 | + state: AppState, | |
| 197 | + feed: Feed, | |
| 198 | + q: FeedQuery, | |
| 199 | + headers: HeaderMap, | |
| 200 | + user_context: Option<UserContext>, | |
| 201 | +) -> Result<Response, StatusCode> { | |
| 202 | + let uc = user_context.as_ref(); | |
| 203 | + let view = focus::view_for(&state, q.view.as_deref(), uc, &headers); | |
| 204 | + let tree = CategoryTree::load(state.db.as_ref()).await.map_err(ise("load category tree"))?; | |
| 205 | + let vis = tree.visible_category_ids(viewer_of(&user_context)); | |
| 206 | + let loaded = feed_topics(&state, &vis, feed, FEED_LIMIT as usize).await?; | |
| 207 | + let path = format!("/p/{}", feed.slug()); | |
| 208 | + | |
| 209 | + if view.is_focus() { | |
| 210 | + let (tiles, reader) = focus::tiles_and_reader(&state, &tree, loaded, uc, &headers, q.topic).await?; | |
| 211 | + let mut page = ListPage::new(feed.slug(), feed.heading(), path); | |
| 212 | + page.heading_icon = feed.icon(); | |
| 213 | + page.subheading = Some(feed.blurb().into()); | |
| 214 | + page.empty = "Nothing here yet.".into(); | |
| 215 | + let html = page.render(&state, tiles, reader, uc, &headers)?; | |
| 216 | + return Ok(view.respond(html)); | |
| 217 | + } | |
| 218 | + let rows = build_topic_rows(&state, &tree, loaded).await?; | |
| 219 | + let page = super::render( | |
| 220 | + &state, | |
| 221 | + "forum/feed.html", | |
| 222 | + context! { | |
| 223 | + title => feed.heading(), | |
| 224 | + app_name => state.config.app_name, | |
| 225 | + user => uc.map(|c| c.user.clone()), | |
| 226 | + heading => feed.heading(), | |
| 227 | + heading_icon => feed.icon(), | |
| 228 | + blurb => feed.blurb(), | |
| 229 | + toggle_base => path, | |
| 230 | + topics => rows, | |
| 231 | + }, | |
| 232 | + )?; | |
| 233 | + Ok(view.respond(page)) | |
| 234 | +} | |
| 235 | + | |
| 236 | +pub async fn feed_latest( | |
| 237 | + State(state): State<AppState>, | |
| 238 | + Query(q): Query<FeedQuery>, | |
| 239 | + headers: HeaderMap, | |
| 240 | + user_context: Option<UserContext>, | |
| 241 | +) -> Result<Response, StatusCode> { | |
| 242 | + feed(state, Feed::Latest, q, headers, user_context).await | |
| 243 | +} | |
| 244 | + | |
| 245 | +pub async fn feed_popular( | |
| 246 | + State(state): State<AppState>, | |
| 247 | + Query(q): Query<FeedQuery>, | |
| 248 | + headers: HeaderMap, | |
| 249 | + user_context: Option<UserContext>, | |
| 250 | +) -> Result<Response, StatusCode> { | |
| 251 | + feed(state, Feed::Popular, q, headers, user_context).await | |
| 252 | +} | |
| 253 | + | |
| 69 | 254 | pub async fn home( |
| 70 | 255 | State(state): State<AppState>, |
| 71 | 256 | Query(q): Query<LandingQuery>, |
@@ -78,13 +263,20 @@ pub async fn home(
| 78 | 263 | |
| 79 | 264 | let tree = CategoryTree::load(state.db.as_ref()).await.map_err(ise("load category tree"))?; |
| 80 | 265 | let vis = tree.visible_category_ids(viewer_of(&user_context)); |
| 81 | − let loaded = latest_topics(&state, &vis, LATEST_LIMIT).await?; | |
| 266 | + let latest = latest_topics(&state, &vis, LANDING_LATEST).await?; | |
| 267 | + let popular = popular_topics(&state, &vis, LANDING_POPULAR).await?; | |
| 82 | 268 | |
| 83 | − // Focus: the reader's own htmx requests need only #reader. | |
| 84 | − let base = "/?view=focus".to_string(); | |
| 269 | + // Focus: the reader steps through the row its tile came from. | |
| 270 | + let reader_feed = Feed::parse(q.list.as_deref()); | |
| 271 | + let latest_base = "/?view=focus".to_string(); | |
| 272 | + let popular_base = "/?view=focus&list=popular".to_string(); | |
| 85 | 273 | if is_focus && focus::wants_reader(&headers) { |
| 274 | + let (loaded, base) = match reader_feed { | |
| 275 | + Feed::Latest => (latest, &latest_base), | |
| 276 | + Feed::Popular => (popular, &popular_base), | |
| 277 | + }; | |
| 86 | 278 | let (_, reader) = focus::tiles_and_reader(&state, &tree, loaded, uc, &headers, q.topic).await?; |
| 87 | − return Ok(view.respond(focus::reader_fragment(&state, reader, &base, uc)?)); | |
| 279 | + return Ok(view.respond(focus::reader_fragment(&state, reader, base, uc)?)); | |
| 88 | 280 | } |
| 89 | 281 | |
| 90 | 282 | let counts = topic_counts(&state).await?; |
@@ -124,7 +316,19 @@ pub async fn home(
| 124 | 316 | let user = uc.map(|c| c.user.clone()); |
| 125 | 317 | let can_write = uc.is_some_and(|c| super::may_write(&state, &c.user)); |
| 126 | 318 | let page = if is_focus { |
| 127 | − let (tiles, reader) = focus::tiles_and_reader(&state, &tree, loaded, uc, &headers, q.topic).await?; | |
| 319 | + // Only the row named by `list` can open the reader. | |
| 320 | + let (latest_open, popular_open) = match reader_feed { | |
| 321 | + Feed::Latest => (q.topic, None), | |
| 322 | + Feed::Popular => (None, q.topic), | |
| 323 | + }; | |
| 324 | + let (latest_tiles, latest_reader) = | |
| 325 | + focus::tiles_and_reader(&state, &tree, latest, uc, &headers, latest_open).await?; | |
| 326 | + let (popular_tiles, popular_reader) = | |
| 327 | + focus::tiles_and_reader(&state, &tree, popular, uc, &headers, popular_open).await?; | |
| 328 | + let (reader, base) = match reader_feed { | |
| 329 | + Feed::Latest => (latest_reader, latest_base.clone()), | |
| 330 | + Feed::Popular => (popular_reader, popular_base.clone()), | |
| 331 | + }; | |
| 128 | 332 | super::render( |
| 129 | 333 | &state, |
| 130 | 334 | "forum/landing_focus.html", |
@@ -134,13 +338,17 @@ pub async fn home(
| 134 | 338 | user => user, |
| 135 | 339 | can_write => can_write, |
| 136 | 340 | categories => categories, |
| 137 | − topics => tiles, | |
| 341 | + latest => latest_tiles, | |
| 342 | + popular => popular_tiles, | |
| 343 | + latest_base => latest_base, | |
| 344 | + popular_base => popular_base, | |
| 138 | 345 | reader => reader, |
| 139 | 346 | base => base, |
| 140 | 347 | }, |
| 141 | 348 | )? |
| 142 | 349 | } else { |
| 143 | − let rows = build_topic_rows(&state, &tree, loaded).await?; | |
| 350 | + let latest_rows = build_topic_rows(&state, &tree, latest).await?; | |
| 351 | + let popular_rows = build_topic_rows(&state, &tree, popular).await?; | |
| 144 | 352 | super::render( |
| 145 | 353 | &state, |
| 146 | 354 | "forum/landing.html", |
@@ -150,9 +358,27 @@ pub async fn home(
| 150 | 358 | user => user, |
| 151 | 359 | can_write => can_write, |
| 152 | 360 | categories => categories, |
| 153 | − topics => rows, | |
| 361 | + latest => latest_rows, | |
| 362 | + popular => popular_rows, | |
| 154 | 363 | }, |
| 155 | 364 | )? |
| 156 | 365 | }; |
| 157 | 366 | Ok(view.respond(page)) |
| 158 | 367 | } |
| 368 | + | |
| 369 | +#[cfg(test)] | |
| 370 | +mod tests { | |
| 371 | + use super::*; | |
| 372 | + | |
| 373 | + #[test] | |
| 374 | + fn popular_prefers_engagement_and_freshness() { | |
| 375 | + // More engagement wins at the same age. | |
| 376 | + assert!(popular_score(10, 5, 200, 24.0) > popular_score(2, 0, 40, 24.0)); | |
| 377 | + // The same engagement counts for less as it ages. | |
| 378 | + assert!(popular_score(5, 5, 100, 2.0) > popular_score(5, 5, 100, 240.0)); | |
| 379 | + // Nothing at all scores zero (and is left out). | |
| 380 | + assert_eq!(popular_score(0, 0, 0, 1.0), 0.0); | |
| 381 | + assert_eq!(Feed::parse(Some("popular")).slug(), "popular"); | |
| 382 | + assert_eq!(Feed::parse(Some("bogus")).slug(), "latest"); | |
| 383 | + } | |
| 384 | +} |
modified
src/handlers/mod.rs
+1
−1
@@ -37,7 +37,7 @@ pub use forum::{
| 37 | 37 | topic_show, update_topic_tags, |
| 38 | 38 | }; |
| 39 | 39 | pub use invites::{create_invite_inline, invite_add_slot}; |
| 40 | −pub use landing::home; | |
| 40 | +pub use landing::{feed_latest, feed_popular, home}; | |
| 41 | 41 | pub use posts::{ |
| 42 | 42 | delete_post, edit_post_form, post_history, post_permalink, restore_post, update_post, |
| 43 | 43 | }; |
modified
src/web.rs
+3
−0
@@ -41,6 +41,9 @@ pub fn router(db: Arc<DatabaseConnection>) -> Router<AppState> {
| 41 | 41 | // visitors and signed-in users. |
| 42 | 42 | let public_routes = Router::new() |
| 43 | 43 | .route("/", get(handlers::home)) |
| 44 | + // The landing rows' full feeds; static, so they win over /p/{id}. | |
| 45 | + .route("/p/latest", get(handlers::feed_latest)) | |
| 46 | + .route("/p/popular", get(handlers::feed_popular)) | |
| 44 | 47 | .route("/c", get(handlers::categories_index)) |
| 45 | 48 | .route("/c/", get(handlers::categories_index)) |
| 46 | 49 | .route("/c/{slug}", get(handlers::category_show)) |
added
templates/forum/feed.html
+21
−0
@@ -0,0 +1,21 @@
| 1 | +{% extends "root.html" %} | |
| 2 | +{# A landing row's full feed in Classic (/p/latest, /p/popular; | |
| 3 | + src/handlers/landing.rs feed). Focus uses forum/focus_list.html. #} | |
| 4 | +{% block width %}max-w-5xl{% endblock %} | |
| 5 | +{% block content %} | |
| 6 | +<div class="space-y-4 text-left"> | |
| 7 | + <nav class="text-sm opacity-70" aria-label="Breadcrumb"><a href="/" class="link link-hover">Home</a> / {{ heading }}</nav> | |
| 8 | + <div class="flex flex-wrap items-center justify-between gap-3"> | |
| 9 | + <div> | |
| 10 | + <h1 class="text-3xl font-bold"><i class="fas {{ heading_icon }} mr-2 text-2xl opacity-60" aria-hidden="true"></i>{{ heading }}</h1> | |
| 11 | + <p class="text-sm opacity-60">{{ blurb }}</p> | |
| 12 | + </div> | |
| 13 | + {% set view_mode = "classic" %}{% include "forum/_view_toggle.html" %} | |
| 14 | + </div> | |
| 15 | + {% if topics %} | |
| 16 | + {% include "forum/_topic_list.html" %} | |
| 17 | + {% else %} | |
| 18 | + <p class="rounded-box border border-dashed border-base-300 p-6 text-center text-sm opacity-60">Nothing here yet.</p> | |
| 19 | + {% endif %} | |
| 20 | +</div> | |
| 21 | +{% endblock %} |
modified
templates/forum/landing.html
+36
−14
@@ -1,6 +1,7 @@
| 1 | 1 | {% extends "root.html" %} |
| 2 | −{# Landing, Classic (src/handlers/landing.rs): categories on the left, the | |
| 3 | − latest topics everywhere the viewer can see on the right. The full | |
| 2 | +{# Landing, Classic (src/handlers/landing.rs): categories on the left; on the | |
| 3 | + right Latest and, under it, Popular, across everything the viewer can see. | |
| 4 | + Each heading opens its full feed (/p/latest, /p/popular). The full | |
| 4 | 5 | categories page is /c/. #} |
| 5 | 6 | {% block width %}max-w-7xl{% endblock %} |
| 6 | 7 | {% block content %} |
@@ -8,17 +9,38 @@
| 8 | 9 | {% set all_href = "/c/" %} |
| 9 | 10 | {% include "forum/_landing_categories.html" %} |
| 10 | 11 | |
| 11 | − <section id="landing-latest" aria-label="Latest topics" class="min-w-0 space-y-3"> | |
| 12 | − <div class="flex flex-wrap items-center justify-between gap-2"> | |
| 13 | − <h1 class="text-2xl font-bold">Latest</h1> | |
| 14 | − {% set toggle_base = "/" %}{% set view_mode = "classic" %} | |
| 15 | − {% include "forum/_view_toggle.html" %} | |
| 16 | − </div> | |
| 17 | − {% if topics %} | |
| 18 | − {% include "forum/_topic_list.html" %} | |
| 19 | − {% else %} | |
| 20 | − <p class="rounded-box border border-dashed border-base-300 p-6 text-center text-sm opacity-60">No topics yet.</p> | |
| 21 | − {% endif %} | |
| 22 | − </section> | |
| 12 | + <div class="min-w-0 space-y-8"> | |
| 13 | + <section id="landing-latest" aria-label="Latest topics" class="space-y-3"> | |
| 14 | + <div class="flex flex-wrap items-center justify-between gap-2"> | |
| 15 | + <h1 class="text-2xl font-bold"> | |
| 16 | + <a href="/p/latest" class="hover:text-primary" title="All latest topics"><i class="fas fa-clock mr-1 text-lg opacity-60" aria-hidden="true"></i>Latest</a> | |
| 17 | + </h1> | |
| 18 | + <div class="flex items-center gap-2"> | |
| 19 | + <a href="/p/latest" class="link link-hover text-sm opacity-70">All latest <i class="fas fa-arrow-right text-xs"></i></a> | |
| 20 | + {% set toggle_base = "/" %}{% set view_mode = "classic" %} | |
| 21 | + {% include "forum/_view_toggle.html" %} | |
| 22 | + </div> | |
| 23 | + </div> | |
| 24 | + {% if latest %} | |
| 25 | + {% set topics = latest %}{% include "forum/_topic_list.html" %} | |
| 26 | + {% else %} | |
| 27 | + <p class="rounded-box border border-dashed border-base-300 p-6 text-center text-sm opacity-60">No topics yet.</p> | |
| 28 | + {% endif %} | |
| 29 | + </section> | |
| 30 | + | |
| 31 | + <section id="landing-popular" aria-label="Popular topics" class="space-y-3"> | |
| 32 | + <div class="flex flex-wrap items-center justify-between gap-2"> | |
| 33 | + <h2 class="text-2xl font-bold"> | |
| 34 | + <a href="/p/popular" class="hover:text-primary" title="All popular topics"><i class="fas fa-fire mr-1 text-lg opacity-60" aria-hidden="true"></i>Popular</a> | |
| 35 | + </h2> | |
| 36 | + <a href="/p/popular" class="link link-hover text-sm opacity-70">All popular <i class="fas fa-arrow-right text-xs"></i></a> | |
| 37 | + </div> | |
| 38 | + {% if popular %} | |
| 39 | + {% set topics = popular %}{% include "forum/_topic_list.html" %} | |
| 40 | + {% else %} | |
| 41 | + <p class="rounded-box border border-dashed border-base-300 p-6 text-center text-sm opacity-60">Nothing popular in the last 30 days yet.</p> | |
| 42 | + {% endif %} | |
| 43 | + </section> | |
| 44 | + </div> | |
| 23 | 45 | </div> |
| 24 | 46 | {% endblock %} |
modified
templates/forum/landing_focus.html
+45
−18
@@ -1,7 +1,8 @@
| 1 | 1 | {% extends "root.html" %} |
| 2 | −{# Landing, Focus (src/handlers/landing.rs): categories on the left, the | |
| 3 | − latest topics as tiles on the right, full width. A tile opens the reader | |
| 4 | − (`&topic=<id>`), which steps through this same latest list. #} | |
| 2 | +{# Landing, Focus (src/handlers/landing.rs): categories on the left; on the | |
| 3 | + right a Latest row of tiles and, under it, a Popular row, full width. A | |
| 4 | + tile opens the reader, which steps through its own row (`list=popular` | |
| 5 | + for the second). Each heading opens its full feed in Focus. #} | |
| 5 | 6 | {% block width %}w-full max-w-none{% endblock %} |
| 6 | 7 | {% block main_class %}px-3 py-3 sm:px-4 lg:px-5{% endblock %} |
| 7 | 8 | {% block content %} |
@@ -9,21 +10,47 @@
| 9 | 10 | {% set all_href = "/c/?view=focus" %} |
| 10 | 11 | {% include "forum/_landing_categories.html" %} |
| 11 | 12 | |
| 12 | − <section id="landing-latest" aria-label="Latest topics" | |
| 13 | − class="min-w-0 space-y-4 rounded-box border border-primary/40 bg-base-200/40 p-4"> | |
| 14 | − <div class="flex flex-wrap items-center justify-between gap-2"> | |
| 15 | − <h1 class="text-2xl font-bold">Latest</h1> | |
| 16 | − {% set toggle_base = "/" %}{% set view_mode = "focus" %} | |
| 17 | − {% include "forum/_view_toggle.html" %} | |
| 18 | − </div> | |
| 19 | − {% if topics %} | |
| 20 | − <div class="grid grid-cols-[repeat(auto-fill,minmax(17rem,1fr))] gap-3"> | |
| 21 | − {% for t in topics %}{% include "forum/_topic_tile.html" %}{% endfor %} | |
| 22 | − </div> | |
| 23 | − {% else %} | |
| 24 | − <p class="rounded-box border border-dashed border-base-300 p-6 text-center text-sm opacity-60">No topics yet.</p> | |
| 25 | − {% endif %} | |
| 26 | − </section> | |
| 13 | + <div class="min-w-0 space-y-4"> | |
| 14 | + <section id="landing-latest" aria-label="Latest topics" | |
| 15 | + class="space-y-4 rounded-box border border-primary/40 bg-base-200/40 p-4"> | |
| 16 | + <div class="flex flex-wrap items-center justify-between gap-2"> | |
| 17 | + <h1 class="text-2xl font-bold"> | |
| 18 | + <a href="/p/latest?view=focus" class="hover:text-primary" title="All latest topics"><i class="fas fa-clock mr-1 text-lg opacity-60" aria-hidden="true"></i>Latest</a> | |
| 19 | + </h1> | |
| 20 | + <div class="flex items-center gap-2"> | |
| 21 | + <a href="/p/latest?view=focus" class="link link-hover text-sm opacity-70">All latest <i class="fas fa-arrow-right text-xs"></i></a> | |
| 22 | + {% set toggle_base = "/" %}{% set view_mode = "focus" %} | |
| 23 | + {% include "forum/_view_toggle.html" %} | |
| 24 | + </div> | |
| 25 | + </div> | |
| 26 | + {% if latest %} | |
| 27 | + <div class="grid grid-cols-[repeat(auto-fill,minmax(17rem,1fr))] gap-3"> | |
| 28 | + {% set base = latest_base %} | |
| 29 | + {% for t in latest %}{% include "forum/_topic_tile.html" %}{% endfor %} | |
| 30 | + </div> | |
| 31 | + {% else %} | |
| 32 | + <p class="rounded-box border border-dashed border-base-300 p-6 text-center text-sm opacity-60">No topics yet.</p> | |
| 33 | + {% endif %} | |
| 34 | + </section> | |
| 35 | + | |
| 36 | + <section id="landing-popular" aria-label="Popular topics" | |
| 37 | + class="space-y-4 rounded-box border border-base-300 bg-base-200/40 p-4"> | |
| 38 | + <div class="flex flex-wrap items-center justify-between gap-2"> | |
| 39 | + <h2 class="text-2xl font-bold"> | |
| 40 | + <a href="/p/popular?view=focus" class="hover:text-primary" title="All popular topics"><i class="fas fa-fire mr-1 text-lg opacity-60" aria-hidden="true"></i>Popular</a> | |
| 41 | + </h2> | |
| 42 | + <a href="/p/popular?view=focus" class="link link-hover text-sm opacity-70">All popular <i class="fas fa-arrow-right text-xs"></i></a> | |
| 43 | + </div> | |
| 44 | + {% if popular %} | |
| 45 | + <div class="grid grid-cols-[repeat(auto-fill,minmax(17rem,1fr))] gap-3"> | |
| 46 | + {% set base = popular_base %} | |
| 47 | + {% for t in popular %}{% include "forum/_topic_tile.html" %}{% endfor %} | |
| 48 | + </div> | |
| 49 | + {% else %} | |
| 50 | + <p class="rounded-box border border-dashed border-base-300 p-6 text-center text-sm opacity-60">Nothing popular in the last 30 days yet.</p> | |
| 51 | + {% endif %} | |
| 52 | + </section> | |
| 53 | + </div> | |
| 27 | 54 | |
| 28 | 55 | {% include "forum/_reader.html" %} |
| 29 | 56 | </div> |
Parents: 01d6190