You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.0 KiB

  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 avatar_for_status_url(status)
  7. status.reblog? ? status.reblog.account.avatar.url( :original) : status.account.avatar.url( :original)
  8. end
  9. def entry_classes(status, is_predecessor, is_successor, include_threads)
  10. classes = ['entry']
  11. classes << 'entry-reblog' if status.reblog?
  12. classes << 'entry-predecessor' if is_predecessor
  13. classes << 'entry-successor' if is_successor
  14. classes << 'entry-center' if include_threads
  15. classes.join(' ')
  16. end
  17. def relative_time(date)
  18. date < 5.days.ago ? date.strftime('%d.%m.%Y') : "#{time_ago_in_words(date)} ago"
  19. end
  20. def reblogged_by_me_class(status)
  21. user_signed_in? && @reblogged.key?(status.id) ? 'reblogged' : ''
  22. end
  23. def favourited_by_me_class(status)
  24. user_signed_in? && @favourited.key?(status.id) ? 'favourited' : ''
  25. end
  26. def proper_status(status)
  27. status.reblog? ? status.reblog : status
  28. end
  29. end