Forum: thread cards with the start of the opening post, latest threads and pinned threads on the front page
- Every thread card shows the start of the opening post (two lines on a computer, three on a phone), its topic with the icon (a lock for members-only and restricted ones), pinned and the wish; the replies, the last activity and what is new on the right (in the bottom line on a phone). The same card in topics, search and followed threads. - The front page: "Legutóbbi szálak" below the topics, from every topic the viewer may read (not the archived ones), the latest activity first, 20 a page with a pager; pinned threads in "Kitűzve" above the topics. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -52,6 +52,7 @@ pub fn router(state: Arc<AppState>) -> Router {
|
||||
.route("/v1/forum/topics/{slug}/join", post(topics::join).delete(topics::leave))
|
||||
.route("/v1/forum/mod/topic-requests", get(topics::requests).post(topics::decide))
|
||||
.route("/v1/forum/followed", get(home::followed))
|
||||
.route("/v1/forum/latest", get(home::latest))
|
||||
.route("/v1/forum/replies", get(replies::list))
|
||||
.route("/v1/forum/search", get(search::search))
|
||||
.route("/v1/forum/share-card/{slug}", get(attachments::preview))
|
||||
@@ -155,6 +156,9 @@ pub struct CardRow {
|
||||
pub unread: Option<i64>,
|
||||
/// The site's own thread (the daily sky).
|
||||
pub system: bool,
|
||||
pub topic_visibility: String,
|
||||
/// The opening post's text (for the excerpt on the card).
|
||||
pub opening: Option<String>,
|
||||
}
|
||||
|
||||
/// `SELECT` of [`CardRow`]s over the threads the viewer may read; `$1` is
|
||||
@@ -177,7 +181,9 @@ pub fn card_sql(viewer: &Viewer) -> String {
|
||||
AND p.created_at > $2::timestamptz AND {} \
|
||||
AND p.id > COALESCE((SELECT r.last_post_id FROM forum.reads r \
|
||||
WHERE r.user_id = $1 AND r.thread_id = th.id), 0)) END AS unread, \
|
||||
th.system \
|
||||
th.system, tp.visibility AS topic_visibility, \
|
||||
(SELECT p.body FROM forum.posts p WHERE p.thread_id = th.id AND p.is_opening \
|
||||
AND p.deleted_at IS NULL LIMIT 1) AS opening \
|
||||
FROM forum.threads th JOIN forum.topics tp ON tp.id = th.topic_id \
|
||||
WHERE th.deleted_at IS NULL AND ({}) AND {}",
|
||||
not_muted("p.author_id"),
|
||||
@@ -204,8 +210,10 @@ pub async fn cards_json(db: &PgPool, rows: Vec<CardRow>) -> Result<Vec<Value>, s
|
||||
"slug": crate::text::slug(&r.title),
|
||||
"title": r.title,
|
||||
"intent": r.intent,
|
||||
"topic": { "slug": r.topic_slug, "name": r.topic_name },
|
||||
"topic": { "slug": r.topic_slug, "name": r.topic_name, "visibility": r.topic_visibility },
|
||||
"author": r.author_id.and_then(|id| people.get(&id).cloned()),
|
||||
// The start of the opening post, as much as a card shows.
|
||||
"excerpt": r.opening.as_deref().map(|b| crate::text::excerpt(b, 280)),
|
||||
"created_at": rfc3339(r.created_at),
|
||||
"last_post_at": rfc3339(r.last_post_at),
|
||||
"reply_count": r.reply_count,
|
||||
|
||||
Reference in New Issue
Block a user