about summary refs log tree commit diff
path: root/app/helpers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-03-06 17:52:23 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-03-06 17:52:23 +0100
commit3824c588533f481011d2be19ff9476c001ffbee9 (patch)
tree96203d48ec3d8f54d69591d6b8616c9b4ac7a03b /app/helpers
parent831a187d74791a34270ecdc94df62bcc86dedd03 (diff)
Adding GNU Public license, adding home timeline, reblog/favourite counters
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/stream_entries_helper.rb19
1 files changed, 12 insertions, 7 deletions
diff --git a/app/helpers/stream_entries_helper.rb b/app/helpers/stream_entries_helper.rb
index 529ba98da..d6a14352f 100644
--- a/app/helpers/stream_entries_helper.rb
+++ b/app/helpers/stream_entries_helper.rb
@@ -4,7 +4,7 @@ module StreamEntriesHelper
   end
 
   def avatar_for_status_url(status)
-    status.reblog? ? status.reblog.account.avatar.url(:small) : status.account.avatar.url(:small)
+    status.reblog? ? status.reblog.account.avatar.url(:medium) : status.account.avatar.url(:medium)
   end
 
   def entry_classes(status, is_predecessor, is_successor, include_threads)
@@ -24,12 +24,17 @@ module StreamEntriesHelper
     mention_hash = {}
     status.mentions.each { |m| mention_hash[m.acct] = m }
 
-    status.text.gsub(Account::MENTION_RE) do |m|
-      full_match = Account::MENTION_RE.match(m)
-      acct       = full_match[1]
-      account    = mention_hash[acct]
-
-      "#{m.split('@').first}<a href=\"#{account.url}\" class=\"mention\">@<span>#{acct}</span></a>"
+    auto_link(CGI.escapeHTML(status.text), link: :urls, html: { target: '_blank', rel: 'nofollow' }).gsub(Account::MENTION_RE) do |m|
+      account = mention_hash[Account::MENTION_RE.match(m)[1]]
+      "#{m.split('@').first}<a href=\"#{url_for_target(account)}\" class=\"mention\">@<span>#{account.acct}</span></a>"
     end.html_safe
   end
+
+  def reblogged_by_me_class(status)
+    user_signed_in? && (status.reblog? ? status.reblog : status).reblogs.where(account: current_user.account).count == 1 ? 'reblogged' : ''
+  end
+
+  def favourited_by_me_class(status)
+    user_signed_in? && (status.reblog? ? status.reblog : status).favourites.where(account: current_user.account).count == 1 ? 'favourited' : ''
+  end
 end