diff --git a/src/client/html.ml b/src/client/html.ml index b8676c6..564cff0 100644 --- a/src/client/html.ml +++ b/src/client/html.ml @@ -208,17 +208,7 @@ module User = struct match user.avatar_info with | None -> [] | Some info -> - let alt_at = - if String.equal "" info.alt then [] - else [ alt info.alt; name info.name; title info.alt ] - in - let at = - [ Fmt.kstr src "/user/%s/avatar" user.user_id - ; class' "img-thumbnail" - ] - @ alt_at - in - [ El.img ~at () ] + [ Html_util.mk_image ~is_small:true (Avatar (user.user_id, info)) ] in h1 user.user_nick :: bio :: img diff --git a/src/client/html_post.ml b/src/client/html_post.ml index b715aa6..ecbe8c4 100644 --- a/src/client/html_post.ml +++ b/src/client/html_post.ml @@ -26,11 +26,8 @@ let date post = [ el_txt (print_date post.date) ] (* TODO rm this since we can click the post_id? *) -let link_to_post ?(is_vignette = false) post = - let url = - if is_vignette then Fmt.str "/thread/%d#%d" post.parent_t_id post.id - else Fmt.str "#%d" post.id - in +let link_to_post post = + let url = Fmt.str "#%d" post.id in El.a ~at:[ href url; title "Link to this post"; class' "post-link-to-self" ] [ el_txt "#" ] @@ -154,21 +151,15 @@ let backlinks t_s post = let l = List.map (post_id_quote t_s) post.backlinks in El.div ~at:[ class' "post-replies" ] l -let image _t_s ?(is_vignette = false) post = +let image _t_s post = match post.image_info with | None -> None - | Some image -> ( + | Some image -> let img_small = Html_util.mk_image ~is_small:true (Img_info.Post (post.id, image)) in let el = El.div ~at:[ class' "post-image-div" ] [ img_small ] in - match is_vignette with - | true -> Some el - | false -> - hold_on el Ev.click (fun _ev -> - let v = Img_info.Post (post.id, image) in - Events.send_action (Image_change (Some v)) ); - Some el ) + Some el let comment = let open Comment in diff --git a/src/client/html_util.ml b/src/client/html_util.ml index 654f2b4..59a539a 100644 --- a/src/client/html_util.ml +++ b/src/client/html_util.ml @@ -133,4 +133,7 @@ let mk_image ~is_small img_info = ; mk_at "loading" "lazy" ] in - El.img ~at () + let el = El.img ~at () in + hold_on el Ev.click (fun _ev -> + Events.send_action (Image_change (Some img_info)) ); + el