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

David Tsiklauri notifications at github.com
Wed Apr 16 12:03:19 UTC 2025


@nertc 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) %>

`truncate_html` method was modified to be public and return object containing `html` and `truncated` information. To avoid calling method twice and caching (e.g. Memoization), truncated object is saved as `truncated_entry` variable in the `.html.erb` file.

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

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


More information about the rails-dev mailing list