From 3138379e7d16c553edcfccc3d135d6ac76d9ddf3 Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Sun, 27 Oct 2024 12:27:16 -0700 Subject: [PATCH] web: add tag when viewing news posts --- web/src/view/mod.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/web/src/view/mod.rs b/web/src/view/mod.rs index 22702c0..dda7969 100644 --- a/web/src/view/mod.rs +++ b/web/src/view/mod.rs @@ -981,9 +981,43 @@ fn news_post( set_title(subject); let read_thread_id = post.thread_id.clone(); let unread_thread_id = post.thread_id.clone(); + fn tag(tag: String, is_mobile: bool) -> Node { + let hex = compute_color(&tag); + let style = style! {St::BackgroundColor=>hex}; + let classes = C!["tag", IF!(is_mobile => "is-small")]; + let attrs = attrs! { + At::Href => urls::search(&format!("tag:{tag}"), 0) + }; + let tag = tag.clone(); + div![ + C!["control"], + div![ + C!["tags", "has-addons"], + a![ + classes, + attrs, + style, + match tag.as_str() { + "attachment" => span!["📎"], + "replied" => span![i![C!["fa-solid", "fa-reply"]]], + _ => span![&tag], + }, + ev(Ev::Click, move |_| Msg::FrontPageRequest { + query: format!("tag:{tag}"), + after: None, + before: None, + first: None, + last: None, + }) + ] + ] + ] + } + div![ C!["thread"], h3![C!["is-size-5"], subject], + tag(format!("News/{}", post.slug), false), div![ C!["level", "is-mobile"], div![