about summary refs log tree commit diff stats
path: root/app/helpers
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-12-07 16:11:31 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2024-12-07 16:11:31 -0500
commit222dbaf5c23b41eabb75a83784bd4d110e981547 (patch)
treeb62c594df5c41e5d3e3ee38d6a543adb1daa8539 /app/helpers
parenta996f3bd05fc480247fd112f23fa3e67f7d5d7b5 (diff)
downloadthoughts-222dbaf5c23b41eabb75a83784bd4d110e981547.tar.gz
thoughts-222dbaf5c23b41eabb75a83784bd4d110e981547.tar.bz2
thoughts-222dbaf5c23b41eabb75a83784bd4d110e981547.zip
Daily upvote email now includes details about webmention likes
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/votes_helper.rb32
1 files changed, 32 insertions, 0 deletions
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 @@
1module VotesHelper
2
3 def voters_list(votes, html = false)
4 voters = votes.select {|v| !v.liker_url.nil?}.map do |v|
5 if html
6 tag.strong(link_to v.liker_name, v.liker_url)
7 else
8 "#{v.liker_name} (#{v.liker_url})"
9 end
10 end
11
12 anons = votes.select {|v| v.liker_url.nil?}.size
13 if anons > 0
14 if voters.empty? && anons == 1
15 if html
16 voters << tag.strong("A guest")
17 else
18 voters << "A guest"
19 end
20 else
21 if html
22 voters << tag.strong(pluralize(anons, "guest"))
23 else
24 voters << pluralize(anons, "guest")
25 end
26 end
27 end
28
29 to_sentence(voters)
30 end
31
32end