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.

55 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_description,
  9. :site_extended_description,
  10. :site_terms,
  11. to: Setting
  12. )
  13. def contact_account
  14. Account.find_local(Setting.site_contact_username)
  15. end
  16. def user_count
  17. Rails.cache.fetch('user_count') { User.confirmed.count }
  18. end
  19. def status_count
  20. Rails.cache.fetch('local_status_count') { Account.local.sum(:statuses_count) }
  21. end
  22. def domain_count
  23. Rails.cache.fetch('distinct_domain_count') { Account.distinct.count(:domain) }
  24. end
  25. def version_number
  26. Mastodon::Version
  27. end
  28. def commit_hash
  29. current_release_file = Pathname.new('CURRENT_RELEASE').expand_path
  30. if current_release_file.file?
  31. IO.read(current_release_file).strip!
  32. else
  33. ''
  34. end
  35. end
  36. def source_url
  37. Mastodon::Version.source_url
  38. end
  39. def thumbnail
  40. @thumbnail ||= Rails.cache.fetch('site_uploads/thumbnail') { SiteUpload.find_by(var: 'thumbnail') }
  41. end
  42. def hero
  43. @hero ||= Rails.cache.fetch('site_uploads/hero') { SiteUpload.find_by(var: 'hero') }
  44. end
  45. end