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.

56 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.sum(:statuses_count) }
  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 commit_hash
  30. current_release_file = Pathname.new('CURRENT_RELEASE').expand_path
  31. if current_release_file.file?
  32. IO.read(current_release_file).strip!
  33. else
  34. ''
  35. end
  36. end
  37. def source_url
  38. Mastodon::Version.source_url
  39. end
  40. def thumbnail
  41. @thumbnail ||= Rails.cache.fetch('site_uploads/thumbnail') { SiteUpload.find_by(var: 'thumbnail') }
  42. end
  43. def hero
  44. @hero ||= Rails.cache.fetch('site_uploads/hero') { SiteUpload.find_by(var: 'hero') }
  45. end
  46. end