Layouts: Classic and Focus, chosen in the profile; Focus on every list page

0c61284 · gmorell · 2026-12-02 19:32

46 files +1378 -349
Message
{commit_body(@commit)}

Files changed

modified README.md
+42 −26
@@ -77,32 +77,48 @@ anyone staff.
77 77 | `OIDC_ENABLED`, `OIDC_LOGIN_MODE`, `OIDC_*` | off | "Sign in with NEIAM"; see below and the neiam-auth README |
78 78 | `OIDC_PASSWORD_LOGIN` | `true` | `false` hides and refuses password login (implied by `OIDC_LOGIN_MODE=sso_strict`) |
79 79
80 −## Visual mode
81 −
82 −Every category and the home page have a **List / Visual** switch. The choice
83 −sticks: on the account when signed in (`users.preferred_view`, like the topic
84 −sort), in a `recourse_view` cookie when not; `?view=list|focus` in any URL
85 −overrides it.
86 −
87 −- **`/c/{slug}?view=focus&sort=…`** — the category fills the page. The
88 − categories beside it are squares on a rail (the current one has the accent
89 − border; on small screens the rail is a horizontal strip), and `..` goes up a
90 − level, or to the visual home from a top-level category. The category's own
91 − topics are tiles: title, poster and top-replier avatars, replies, views,
92 − last activity, tags, reactions, and **new** / **N unread** for signed-in
93 − users. Each subcategory is a column of compact topic squares with a "Focus
94 − on …" link. Categories the viewer may not see never appear, on the rail or
95 − anywhere else.
96 −- **`&topic=<id>`** opens the **reader** over the focus view: the topic's posts
97 − and a filmstrip of the category's topics in the current sort. **← / →**
98 − (or **k / j**) step through them, **Escape** or a click outside closes it,
99 − and every step is a URL, so the back button works. Opening a topic in the
100 − reader counts a view and marks it read, exactly as the topic page does.
101 −- **`/?view=focus`** — the home page as a grid of top-level category tiles,
102 − each with its subcategories and latest topics.
103 −
104 −Modelled on pin_flip's board focus mode and shared pages, and on cartosnap's
105 −shared-trip stepping; see `src/handlers/focus.rs`.
80 +## Layouts: Classic and Focus
81 +
82 +Two layouts for browsing: **Classic** (lists and tables) and **Focus**
83 +(full-screen tiles with a reader you step through). Pick the default under
84 +**Profile → Layout**. The Classic/Focus switch on a page is a temporary
85 +override: signed in, it lasts until the browser closes (a session cookie) and
86 +never changes the profile, and saving the profile clears it; signed out, it is
87 +remembered in a cookie for a year. Links between pages carry no layout, so
88 +nothing flips while you browse. `?view=classic|focus` works in any URL (the
89 +old `list` / `visual` are accepted too).
90 +
91 +In Focus:
92 +
93 +- **Category** `/c/{slug}`: the category fills the page. The categories
94 + beside it are squares on a rail (the current one has the accent border; on
95 + small screens the rail is a horizontal strip), and `..` goes up a level, or
96 + to the home page from a top-level category. The category's own topics are
97 + tiles: title, poster and top-replier avatars, replies, views, last activity,
98 + tags, reactions, and **new** / **N unread** for signed-in users. Each
99 + subcategory is a column of compact topic squares with a "Focus on …" link.
100 +- **Home** `/`: a tile per top-level category with its subcategories and latest
101 + topics. **Tags** `/tags`: a tile per tag with its latest topics.
102 +- **Tag**, **search**, **bookmarks**, **reactions** and **notifications**:
103 + their topics as tiles. Tags get a rail of other tags. Bookmarks, reactions
104 + and notifications add lines to each tile saying what was bookmarked, how many
105 + reactions, or which notifications; notifications are grouped by topic.
106 +- **Reader**: on any of those pages, `&topic=<id>` opens a topic over the page
107 + with a filmstrip of *that page's* list. **← / →** (or **k / j**) step through
108 + it, **Escape** or a click outside closes it, and each step is a URL, so the
109 + back button works.
110 +- **Topic** `/t/{id}`: the same page at full screen. Posts are centred at
111 + reading width, with the category rail on one side and a filmstrip of the
112 + category's topics below; ← / → step and Escape goes back to the category.
113 + The reply form, editing, history, tag editing, watch and moderation work as
114 + on the Classic page.
115 +
116 +Visibility, min-trust, unverified/anonymous permissions, views and read
117 +tracking work the same in both layouts: the reader and the Focus topic page
118 +count a view and mark the topic read exactly as the Classic topic page does.
119 +Admin, auth, profile and the new-topic/edit forms are Classic only. See
120 +`src/handlers/focus.rs` (modelled on pin_flip's focus mode and shared pages,
121 +and cartosnap's shared-trip stepping).
106 122
107 123 ## Email verification
108 124
modified assets/f/js/src.js
+4 −2
@@ -24,7 +24,8 @@ window.toast = (msg, opts = {}) => {
24 24 return alert;
25 25 };
26 26
27 −// Visual mode reader (templates/forum/_reader.html): ←/→ or k/j step through
27 +// Focus layout reader (templates/forum/_reader.html, and the Focus topic
28 +// page forum/topic_focus.html): ←/→ or k/j step through
28 29 // the category's topics, Escape closes, as cartosnap's shared trip pages
29 30 // photos and pin_flip's lightbox. The buttons do the work (they swap #reader
30 31 // and push the URL), so the keys only click them. Ignored while typing.
@@ -37,7 +38,8 @@ const READER_KEYS = {
37 38 };
38 39 document.addEventListener("keydown", (e) => {
39 40 if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
40 − if (!document.querySelector("#reader [data-reader]")) return;
41 + // The reader overlay, or a topic page in the Focus layout.
42 + if (!document.querySelector("[data-reader]")) return;
41 43 const t = e.target;
42 44 if (t instanceof Element && t.closest("input, textarea, select, [contenteditable]")) return;
43 45 const id = READER_KEYS[e.key];
modified migration/src/lib.rs
+2 −0
@@ -16,6 +16,7 @@ mod m20240101_000013_user_trust_level;
16 16 mod m20240101_000014_category_min_trust;
17 17 mod m20240101_000015_email_verification;
18 18 mod m20240101_000016_visual_mode;
19 +mod m20240101_000017_layout_names;
19 20
20 21 pub struct Migrator;
21 22
@@ -43,6 +44,7 @@ impl MigratorTrait for Migrator {
43 44 // Listed after the OIDC migration so databases that already ran it
44 45 // apply this one next.
45 46 Box::new(m20240101_000016_visual_mode::Migration),
47 + Box::new(m20240101_000017_layout_names::Migration),
46 48 ]
47 49 }
48 50 }
added migration/src/m20240101_000017_layout_names.rs
+23 −0
@@ -0,0 +1,23 @@
1 +//! The layouts are called Classic and Focus: store `classic` instead of
2 +//! `list` (the app still reads `list` as an alias).
3 +use sea_orm_migration::prelude::*;
4 +
5 +#[derive(DeriveMigrationName)]
6 +pub struct Migration;
7 +
8 +#[async_trait::async_trait]
9 +impl MigrationTrait for Migration {
10 + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
11 + let db = manager.get_connection();
12 + db.execute_unprepared("UPDATE users SET preferred_view = 'classic' WHERE preferred_view IN ('list', '')").await?;
13 + db.execute_unprepared("ALTER TABLE users ALTER COLUMN preferred_view SET DEFAULT 'classic'").await?;
14 + Ok(())
15 + }
16 +
17 + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
18 + let db = manager.get_connection();
19 + db.execute_unprepared("UPDATE users SET preferred_view = 'list' WHERE preferred_view = 'classic'").await?;
20 + db.execute_unprepared("ALTER TABLE users ALTER COLUMN preferred_view SET DEFAULT 'list'").await?;
21 + Ok(())
22 + }
23 +}
modified src/auth/users.rs
+1 −1
@@ -78,7 +78,7 @@ pub(crate) fn new_user_model(
78 78 is_active: Set(true),
79 79 is_staff: Set(is_staff),
80 80 preferred_sort: Set("latest".to_string()),
81 − preferred_view: Set("list".to_string()),
81 + preferred_view: Set("classic".to_string()),
82 82 reaction_notifications: Set(true),
83 83 trust_level: Set(0),
84 84 created_at: Set(now.into()),
modified src/entities/users.rs
+1 −1

Click to load diff…

modified src/handlers/auth.rs
+16 −2

Click to load diff…

modified src/handlers/bookmarks.rs
+63 −9

Click to load diff…

modified src/handlers/focus.rs
+374 −125

Click to load diff…

modified src/handlers/forum.rs
+76 −14

Click to load diff…

modified src/handlers/notifications.rs
+107 −4

Click to load diff…

modified src/handlers/reactions.rs
+58 −15

Click to load diff…

modified src/handlers/tags.rs
+203 −30

Click to load diff…

modified templates/auth/profile.html
+12 −1

Click to load diff…

modified templates/bookmarks.html
+1 −1

Click to load diff…

added templates/forum/_rail.html
+28 −0

Click to load diff…

added templates/forum/_topic_body.html
+60 −0

Click to load diff…

added templates/forum/_topic_head.html
+22 −0

Click to load diff…

modified templates/forum/_topic_tile.html
+3 −0

Click to load diff…

modified templates/forum/_view_toggle.html
+10 −9

Click to load diff…

modified templates/forum/category.html
+1 −1

Click to load diff…

modified templates/forum/focus.html
+1 −26

Click to load diff…

added templates/forum/focus_list.html
+59 −0

Click to load diff…

modified templates/forum/home.html
+1 −1

Click to load diff…

modified templates/forum/topic.html
+2 −77

Click to load diff…

added templates/forum/topic_focus.html
+60 −0

Click to load diff…

modified templates/notifications.html
+3 −0

Click to load diff…

modified templates/reactions.html
+1 −1

Click to load diff…

modified templates/search.html
+1 −1

Click to load diff…

modified templates/tag.html
+1 −1

Click to load diff…

modified templates/tags.html
+1 −1

Click to load diff…

added templates/tags_focus.html
+35 −0

Click to load diff…

modified tests/templates.rs
+106 −0

Click to load diff…

Parents: 4fe8b36