stream_entries_helper.rb 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # frozen_string_literal: true
  2. module StreamEntriesHelper
  3. def display_name(account)
  4. account.display_name.blank? ? account.username : account.display_name
  5. end
  6. def acct(account)
  7. "@#{account.acct}#{@external_links && account.local? ? "@#{Rails.configuration.x.local_domain}" : ''}"
  8. end
  9. def avatar_for_status_url(status)
  10. status.reblog? ? status.reblog.account.avatar.url(:original) : status.account.avatar.url(:original)
  11. end
  12. def entry_classes(status, is_predecessor, is_successor, include_threads)
  13. classes = ['entry']
  14. classes << 'entry-reblog' if status.reblog?
  15. classes << 'entry-predecessor' if is_predecessor
  16. classes << 'entry-successor' if is_successor
  17. classes << 'entry-center' if include_threads
  18. classes.join(' ')
  19. end
  20. def relative_time(date)
  21. date < 5.days.ago ? date.strftime('%d.%m.%Y') : "#{time_ago_in_words(date)} ago"
  22. end
  23. def reblogged_by_me_class(status)
  24. user_signed_in? && @reblogged.key?(status.id) ? 'reblogged' : ''
  25. end
  26. def favourited_by_me_class(status)
  27. user_signed_in? && @favourited.key?(status.id) ? 'favourited' : ''
  28. end
  29. def proper_status(status)
  30. status.reblog? ? status.reblog : status
  31. end
  32. end