闭社主体 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.

51 lines
1.2 KiB

  1. # frozen_string_literal: true
  2. class InstancePresenter
  3. delegate(
  4. :closed_registrations_message,
  5. :site_contact_email,
  6. :open_registrations,
  7. :site_title,
  8. :site_short_description,
  9. :site_description,
  10. :site_extended_description,
  11. :site_terms,
  12. to: Setting
  13. )
  14. def contact_account
  15. Account.find_local(Setting.site_contact_username.gsub(/\A@/, ''))
  16. end
  17. def user_count
  18. Rails.cache.fetch('user_count') { User.confirmed.count }
  19. end
  20. def status_count
  21. Rails.cache.fetch('local_status_count') { Account.local.joins(:account_stat).sum('account_stats.statuses_count') }.to_i
  22. end
  23. def domain_count
  24. Rails.cache.fetch('distinct_domain_count') { Account.distinct.count(:domain) }
  25. end
  26. def version_number
  27. Mastodon::Version
  28. end
  29. def source_url
  30. Mastodon::Version.source_url
  31. end
  32. def thumbnail
  33. @thumbnail ||= Rails.cache.fetch('site_uploads/thumbnail') { SiteUpload.find_by(var: 'thumbnail') }
  34. end
  35. def hero
  36. @hero ||= Rails.cache.fetch('site_uploads/hero') { SiteUpload.find_by(var: 'hero') }
  37. end
  38. def mascot
  39. @mascot ||= Rails.cache.fetch('site_uploads/mascot') { SiteUpload.find_by(var: 'mascot') }
  40. end
  41. end