]> gitweb.mndrdr.org Git - arelpe.git/commitdiff
Fixed weekly digest issues (formatting, links)
authorAidan Cornelius-Bell <[email protected]>
Fri, 22 Nov 2024 22:50:34 +0000 (09:20 +1030)
committerAidan Cornelius-Bell <[email protected]>
Fri, 22 Nov 2024 22:50:34 +0000 (09:20 +1030)
app/views/digest_mailer/weekly_bookmarks_digest.html.erb

index ace210cd9067bfc8462ee0f22622a4ce9b7fefe8..24a72219a12319b96239a2914a26bded00bad55b 100644 (file)
@@ -1,20 +1,19 @@
 <p>Dear <%= @user.first_name %>,</p>
-
 <p>Here's what's new from mind reader this week:</p>
-
 <% @bookmarks.group_by { |bookmark| bookmark.created_at.to_date }.each do |date, bookmarks| %>
-  <p>On <%= date.strftime('%B %e, %Y') %>:</p>
-
+  <p span="dateline">On <%= date.strftime('%B %e, %Y') %>:</p>
   <ul>
     <% bookmarks.each do |bookmark| %>
       <li>
-        <% if bookmark.url.present? %>
-          <strong><a href="<%= bookmark.url %>" target="_blank"><%= bookmark.title %></a></strong>
-        <% else %>
-          <strong><%= bookmark.title %></strong>
-        <% end %>
+        <% url = if bookmark&.url&.present?
+                  bookmark.url
+                else
+                  year = bookmark&.created_at&.year || "2000"
+                  "https://mndrdr.org/#{year}/#{bookmark.slug}"
+                end %>
+        <strong><a href="<%= url %>" target="_blank"><%= bookmark.title %></a></strong>
         <% if bookmark.content.present? %>
-          <br><em><%= bookmark.content %></em>
+          <br><em><%= truncate(bookmark.content, length: 255, separator: ' ', omission: '...') %></em>
         <% end %>
         <% if bookmark.created_at.present? %>
           <br><small>Added at <%= bookmark.created_at.strftime('%l:%M%P') %></small>
     <% end %>
   </ul>
 <% end %>
-
 <p>Have a great weekend,<br>
 Aidan.</p>
+<style type="text/css">
+<!--
+    li { margin-bottom: 3px; }
+    .dateline:first-of-type { margin-top: 0 }
+    .dateline { margin-top: 5px; }
+-->
+</style>