diff --git a/src/content/assets/css/style.css b/src/content/assets/css/style.css index e6323b0..9dedc02 100644 --- a/src/content/assets/css/style.css +++ b/src/content/assets/css/style.css @@ -110,6 +110,14 @@ blockquote.blockquote { display:none; } +a.preview-link { + display: block; + height: 100; + width: 100; + text-decoration: none; + color: unset; +} + .thread-subject { margin: auto; width: 50%; diff --git a/src/js/js_pretty_post.ml b/src/js/js_pretty_post.ml index 4c09cb1..6a986b9 100644 --- a/src/js/js_pretty_post.ml +++ b/src/js/js_pretty_post.ml @@ -44,14 +44,6 @@ let render_time date_span = in ignore @@ Jv.set date_span "innerHTML" (Jv.of_string date) -(* make threads preview clickable to get to thread *) -let preview_click thread_id _event = - log "preview_click@\n"; - let url = Format.sprintf "/thread/%s" thread_id in - let window = Jv.get Jv.global "window" in - let location = Jv.get window "location" in - ignore @@ Jv.set location "href" (Jv.of_string url) - let make_pretty _event = log "make pretty@\n"; let document = Jv.get Jv.global "document" in @@ -72,23 +64,7 @@ let make_pretty _event = @@ Jv.call el "addEventListener" [| Jv.of_string "click"; Jv.repr (image_click el) |] in - List.iter add_click post_images; - - log "make_pretty_catalog@\n"; - let previews = - Jv.to_jv_list - @@ Jv.call document "getElementsByClassName" - [| Jv.of_string "thread-preview" |] - in - let add_preview_click el = - let thread_id = - Jv.to_string @@ Jv.call el "getAttribute" [| Jv.of_string "data-id" |] - in - ignore - @@ Jv.call el "addEventListener" - [| Jv.of_string "click"; Jv.repr (preview_click thread_id) |] - in - List.iter add_preview_click previews + List.iter add_click post_images (*make pretty after page load*) let () = diff --git a/src/pp_babillard.ml b/src/pp_babillard.ml index 1046abe..37d7e0a 100644 --- a/src/pp_babillard.ml +++ b/src/pp_babillard.ml @@ -103,11 +103,10 @@ let pp_post fmt t = ~some:(fun thread_data -> thread_data.subject) thread_data_opt in - let pp = + (* put inside a link if its a preview *) + let pp_inner_post fmt () = Format.fprintf fmt {| -
-
%s
@@ -115,12 +114,27 @@ let pp_post fmt t = %a
%s
%a -
-
|} - id subject post_info_view () image_view () comment tags_view () + subject post_info_view () image_view () comment tags_view () in - pp + if Option.is_some thread_data_opt then + Format.fprintf fmt + {| +
+ + %a + +
+ |} + id id pp_inner_post () + else + Format.fprintf fmt + {| +
+ %a +
+ |} + id pp_inner_post () let view_post id = let* post = get_post id in @@ -131,11 +145,11 @@ let pp_thread_preview fmt op = let thread_preview = Format.fprintf fmt {| -
- %a -
+
+ %a +
|} - post.id pp_post + pp_post (Op (thread_data, post)) in thread_preview