From 222dbaf5c23b41eabb75a83784bd4d110e981547 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 7 Dec 2024 16:11:31 -0500 Subject: Daily upvote email now includes details about webmention likes --- app/helpers/votes_helper.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 app/helpers/votes_helper.rb (limited to 'app/helpers') diff --git a/app/helpers/votes_helper.rb b/app/helpers/votes_helper.rb new file mode 100644 index 0000000..169d7bf --- /dev/null +++ b/app/helpers/votes_helper.rb @@ -0,0 +1,32 @@ +module VotesHelper + + def voters_list(votes, html = false) + voters = votes.select {|v| !v.liker_url.nil?}.map do |v| + if html + tag.strong(link_to v.liker_name, v.liker_url) + else + "#{v.liker_name} (#{v.liker_url})" + end + end + + anons = votes.select {|v| v.liker_url.nil?}.size + if anons > 0 + if voters.empty? && anons == 1 + if html + voters << tag.strong("A guest") + else + voters << "A guest" + end + else + if html + voters << tag.strong(pluralize(anons, "guest")) + else + voters << pluralize(anons, "guest") + end + end + end + + to_sentence(voters) + end + +end -- cgit 1.4.1