[openstreetmap/openstreetmap-website] Provide a truncated view of recent diaries (PR #5121)

Tom Hughes notifications at github.com
Thu Apr 10 15:49:05 UTC 2025


@tomhughes commented on this pull request.



> @@ -2,7 +2,10 @@
   <%= render :partial => "diary_entry_heading", :object => diary_entry, :as => "diary_entry" %>
 
   <div class="richtext text-break" xml:lang="<%= diary_entry.language_code %>" lang="<%= diary_entry.language_code %>">
-    <%= diary_entry.body.to_html %>
+    <%= truncated ? diary_entry.body.to_html(2000) : diary_entry.body.to_html %>
+    <% if truncated && diary_entry.body.was_truncated?(2000) %>

This whole business of having the rich text object cache which lengths it has done truncations on is a pretty horrible interface.

Really `to_html` should indicate directly if it's done a truncation though it would probably be quite painful - it seems like one option would be to have it return a pair of values (the HTML and a truncation flag) and the other would be for it to return a single object with `html` and `truncated?` methods.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5121#pullrequestreview-2757349962
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/5121/review/2757349962 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250410/f06649cf/attachment-0001.htm>


More information about the rails-dev mailing list