闭社主体 forked from https://github.com/tootsuite/mastodon
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.

34 lines
1.0 KiB

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