Class: SiteSettings

Inherits:
RailsSettings::Base
  • Object
show all
Defined in:
app/models/site_settings.rb

Overview

RailsSettings Model

Defined Under Namespace

Modules: UserDefaults

Constant Summary collapse

LANDING_PAGES =
[
  "dashboard", # i18n-tasks-use t('settings.landing_pages.dashboard')
  "my_models", # i18n-tasks-use t('settings.landing_pages.my_models')
  "all_models", # i18n-tasks-use t('settings.landing_pages.all_models')
  "all_creators", # i18n-tasks-use t('settings.landing_pages.all_creators')
  "all_collections" # i18n-tasks-use t('settings.landing_pages.all_collections')
]
AVAILABLE_THEMES =
[
  "brite",
  "cerulean",
  "cosmo",
  "cyborg",
  "darkly",
  "default",
  "flatly",
  "journal",
  "litera",
  "lumen",
  "materia",
  "minty",
  "pulse",
  "quartz",
  "sandstone",
  "simplex",
  "sketchy",
  "slate",
  "solar",
  "spacelab",
  "superhero",
  "united",
  "vapor",
  "yeti",
  "zephyr"
]

Class Method Summary collapse

Class Method Details

.demo_mode_enabled? ⇒ Boolean

Returns:

  • (Boolean)


74
75
76
# File 'app/models/site_settings.rb', line 74

def self.demo_mode_enabled?
  Rails.application.config.manyfold_features[:demo_mode]
end

.email_configured? ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
# File 'app/models/site_settings.rb', line 62

def self.email_configured?
  !Rails.env.production? || ENV.fetch("SMTP_SERVER", false)
end

.fasp_data_sharing_enabled? ⇒ Boolean

Returns:

  • (Boolean)


101
102
103
# File 'app/models/site_settings.rb', line 101

def self.fasp_data_sharing_enabled?
  federation_enabled? && FaspClient::Provider.any? { it.has_capability? :account_search }
end

.federation_enabled? ⇒ Boolean

Returns:

  • (Boolean)


82
83
84
# File 'app/models/site_settings.rb', line 82

def self.federation_enabled?
  Rails.application.config.manyfold_features[:federation]
end

.ignored_file?(pathname) ⇒ Boolean

Returns:

  • (Boolean)


94
95
96
97
98
99
# File 'app/models/site_settings.rb', line 94

def self.ignored_file?(pathname)
  patterns ||= model_ignored_files
  ((pathname.split(File::SEPARATOR) + File.split(pathname)) - ["."]).any? do |path_component|
    patterns.any? { |pattern| path_component =~ pattern.to_regexp }
  end
end

.max_file_extract_size ⇒ Object



70
71
72
# File 'app/models/site_settings.rb', line 70

def self.max_file_extract_size
  ENV.fetch("MAX_FILE_EXTRACT_SIZE", 1_073_741_824).to_i
end

.max_file_upload_size ⇒ Object



66
67
68
# File 'app/models/site_settings.rb', line 66

def self.max_file_upload_size
  ENV.fetch("MAX_FILE_UPLOAD_SIZE", 1_073_741_824).to_i
end

.multiuser_enabled? ⇒ Boolean

Returns:

  • (Boolean)


78
79
80
# File 'app/models/site_settings.rb', line 78

def self.multiuser_enabled?
  Rails.application.config.manyfold_features[:multiuser]
end

.oidc_enabled? ⇒ Boolean

Returns:

  • (Boolean)


86
87
88
# File 'app/models/site_settings.rb', line 86

def self.oidc_enabled?
  Rails.application.config.manyfold_features[:oidc]
end

.remove_field(field) ⇒ Object



137
138
139
140
141
142
143
144
# File 'app/models/site_settings.rb', line 137

def self.remove_field(field)
  setting = SiteSettings.find_by(var: field)
  if setting
    previous_value = setting.value
    setting.destroy!
    previous_value
  end
end

.social_enabled? ⇒ Boolean

Returns:

  • (Boolean)


90
91
92
# File 'app/models/site_settings.rb', line 90

def self.social_enabled?
  multiuser_enabled? || federation_enabled?
end

.validated_theme ⇒ Object



133
134
135
# File 'app/models/site_settings.rb', line 133

def self.validated_theme
  AVAILABLE_THEMES.include?(theme) ? theme : "default"
end