Class: Platform::Config
Class Method Summary collapse
- .admin_helpers ⇒ Object
- .admin_layout ⇒ Object
- .admin_user?(user = current_user) ⇒ Boolean
- .after_filters ⇒ Object
- .api ⇒ Object
- .api_allow_public? ⇒ Boolean
- .api_base_url ⇒ Object
- .api_config_path ⇒ Object
- .api_cookies_enabled? ⇒ Boolean
- .api_default_version ⇒ Object
- .api_explorer_app ⇒ Object
- .api_explorer_app? ⇒ Boolean
- .api_explorer_app_id ⇒ Object
- .api_explorer_groups(api_version = api_default_version) ⇒ Object
- .api_logging_enabled? ⇒ Boolean
- .api_max_models ⇒ Object
- .api_proxies_path ⇒ Object
-
.api_reference(api_version = api_default_version) ⇒ Object
API References.
- .api_reference_by_path(api_version, path) ⇒ Object
- .api_request_limit ⇒ Object
- .api_request_window ⇒ Object
- .api_scheme ⇒ Object
- .api_supported_version_options ⇒ Object
- .api_supported_versions ⇒ Object
- .api_token_lifetime ⇒ Object
- .before_filters ⇒ Object
- .cache_adapter ⇒ Object
- .cache_store ⇒ Object
- .cache_version ⇒ Object
-
.caching ⇒ Object
Config Sections.
- .config ⇒ Object
- .create_media(file) ⇒ Object
- .current_application ⇒ Object
- .current_application=(app) ⇒ Object
- .current_developer ⇒ Object
- .current_user ⇒ Object
- .current_user_is_admin? ⇒ Boolean
- .current_user_is_developer? ⇒ Boolean
- .current_user_is_guest? ⇒ Boolean
- .current_user_method ⇒ Object
- .default_app_icon ⇒ Object
- .default_app_logo ⇒ Object
- .default_applications ⇒ Object
- .default_categories ⇒ Object
- .default_url ⇒ Object
- .developer_agreement_path ⇒ Object
- .disabled? ⇒ Boolean
-
.enable_api? ⇒ Boolean
API.
- .enable_api_verification? ⇒ Boolean
- .enable_app_directory? ⇒ Boolean
- .enable_app_statistics? ⇒ Boolean
-
.enable_caching? ⇒ Boolean
Caching.
- .enable_developer_agreement? ⇒ Boolean
- .enable_embedded_applications? ⇒ Boolean
-
.enable_logger? ⇒ Boolean
Logger.
- .enable_mobile_applications? ⇒ Boolean
- .enabled? ⇒ Boolean
- .env ⇒ Object
-
.featured_apps_enabled? ⇒ Boolean
Application Directory.
- .featured_apps_per_page ⇒ Object
- .featured_apps_per_row ⇒ Object
- .featured_apps_title ⇒ Object
- .features ⇒ Object
- .guest_user?(user = current_user) ⇒ Boolean
- .helpers ⇒ Object
- .icon_url(media) ⇒ Object
- .init(site_current_user, current_application = nil) ⇒ Object
- .init_categories(parent, categories) ⇒ Object
- .init_default_applications ⇒ Object
- .init_default_categories ⇒ Object
- .load_proxies ⇒ Object
- .load_yml(file_path, for_env = env) ⇒ Object
- .log_path ⇒ Object
- .logger ⇒ Object
- .login_url(params = {}) ⇒ Object
- .logo_url(media) ⇒ Object
- .logout_method ⇒ Object
- .logout_url(params = {}) ⇒ Object
- .media_directory ⇒ Object
- .media_path ⇒ Object
- .models ⇒ Object
- .oauth_desktop_layout ⇒ Object
- .oauth_fluid_layout ⇒ Object
- .oauth_mobile_layout ⇒ Object
- .oauth_popup_layout ⇒ Object
- .oauth_web_layout ⇒ Object
- .proxies ⇒ Object
- .reset! ⇒ Object
- .reset_all! ⇒ Object
- .root ⇒ Object
- .searched_apps_per_page ⇒ Object
- .searched_apps_title ⇒ Object
- .silhouette_image(user = current_user) ⇒ Object
- .site_base_url ⇒ Object
- .site_info ⇒ Object
- .site_layout ⇒ Object
- .site_logo_url ⇒ Object
- .site_media_class ⇒ Object
- .site_media_enabled? ⇒ Boolean
-
.site_media_info ⇒ Object
site media info The following methods could be overloaded in the initializer.
- .site_media_write_method ⇒ Object
-
.site_title ⇒ Object
Site Info.
-
.site_user_info ⇒ Object
site user info The following methods could be overloaded in the initializer.
- .site_user_info_disabled? ⇒ Boolean
- .site_user_info_enabled? ⇒ Boolean
- .skip_before_filters ⇒ Object
- .suggested_apps_per_page ⇒ Object
- .suggested_apps_per_row ⇒ Object
- .suggested_apps_title ⇒ Object
- .system_developer ⇒ Object
- .system_user ⇒ Object
- .user_class ⇒ Object
- .user_class_name ⇒ Object
- .user_email(user = current_user) ⇒ Object
- .user_gender(user = current_user) ⇒ Object
- .user_id(user = current_user) ⇒ Object
- .user_link(user = current_user) ⇒ Object
- .user_locale(user = current_user) ⇒ Object
- .user_mugshot(user = current_user) ⇒ Object
- .user_name(user = current_user) ⇒ Object
Class Method Details
.admin_helpers ⇒ Object
312 313 314 315 |
# File 'lib/platform/config.rb', line 312 def self.admin_helpers return [] unless site_info[:admin_helpers] @admin_helpers ||= site_info[:admin_helpers].collect{|helper| helper.to_sym} end |
.admin_layout ⇒ Object
275 276 277 |
# File 'lib/platform/config.rb', line 275 def self.admin_layout site_info[:admin_layout] end |
.admin_user?(user = current_user) ⇒ Boolean
424 425 426 427 428 429 |
# File 'lib/platform/config.rb', line 424 def self.admin_user?(user = current_user) user.send(site_user_info[:methods][:admin]) rescue Exception => ex Platform::Logger.error("Failed to fetch #{user_class_name} admin flag: #{ex.to_s}") false end |
.after_filters ⇒ Object
327 328 329 330 |
# File 'lib/platform/config.rb', line 327 def self.after_filters return [] unless site_info[:after_filters] @after_filters ||= site_info[:after_filters].collect{|filter| filter.to_sym} end |
.api ⇒ Object
216 217 218 |
# File 'lib/platform/config.rb', line 216 def self.api config[:API] end |
.api_allow_public? ⇒ Boolean
556 557 558 |
# File 'lib/platform/config.rb', line 556 def self.api_allow_public? api[:allow_public] end |
.api_base_url ⇒ Object
576 577 578 |
# File 'lib/platform/config.rb', line 576 def self.api_base_url api[:base_url] end |
.api_config_path ⇒ Object
540 541 542 |
# File 'lib/platform/config.rb', line 540 def self.api_config_path api[:config_path] end |
.api_cookies_enabled? ⇒ Boolean
552 553 554 |
# File 'lib/platform/config.rb', line 552 def self. api[:cookies_enabled] end |
.api_default_version ⇒ Object
592 593 594 |
# File 'lib/platform/config.rb', line 592 def self.api_default_version api[:default_version] end |
.api_explorer_app ⇒ Object
600 601 602 603 |
# File 'lib/platform/config.rb', line 600 def self.api_explorer_app return if api_explorer_app_id.blank? @api_explorer_app ||= Platform::Application.find_by_id(api_explorer_app_id) end |
.api_explorer_app? ⇒ Boolean
605 606 607 |
# File 'lib/platform/config.rb', line 605 def self.api_explorer_app? !api_explorer_app_id.blank? end |
.api_explorer_app_id ⇒ Object
596 597 598 |
# File 'lib/platform/config.rb', line 596 def self.api_explorer_app_id config[:api_explorer_app_id] end |
.api_explorer_groups(api_version = api_default_version) ⇒ Object
660 661 662 |
# File 'lib/platform/config.rb', line 660 def self.api_explorer_groups(api_version = api_default_version) api[:explorer_groups][api_version] end |
.api_logging_enabled? ⇒ Boolean
544 545 546 |
# File 'lib/platform/config.rb', line 544 def self.api_logging_enabled? api[:logging_enabled] end |
.api_max_models ⇒ Object
560 561 562 |
# File 'lib/platform/config.rb', line 560 def self.api_max_models api[:max_models] end |
.api_proxies_path ⇒ Object
609 610 611 |
# File 'lib/platform/config.rb', line 609 def self.api_proxies_path api[:proxies_path] end |
.api_reference(api_version = api_default_version) ⇒ Object
API References
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 |
# File 'lib/platform/config.rb', line 627 def self.api_reference(api_version = api_default_version) @api_reference ||= begin ref = HashWithIndifferentAccess.new api_supported_versions.each do |version| ref[version] = {} path = "#{root}/#{api[:config_path]}/#{version}" files = Dir.glob("#{path}/*.yml") files.each do |file| ref[version].merge!(YAML.load_file(file)) end end ref.freeze end @api_reference[api_version] end |
.api_reference_by_path(api_version, path) ⇒ Object
643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 |
# File 'lib/platform/config.rb', line 643 def self.api_reference_by_path(api_version, path) @api_reference_by_path ||= {} @api_reference_by_path[api_version] ||= begin api = api_reference(api_version) by_path = {} api.each do |key, defs| by_path[defs["path"]] = api[key] (defs[:actions] || []).each do |act_key, acts| path = acts["path"] || "#{defs["path"]}/#{act_key}" by_path[path] = defs[:actions][act_key] end end by_path end @api_reference_by_path[api_version][path] end |
.api_request_limit ⇒ Object
548 549 550 |
# File 'lib/platform/config.rb', line 548 def self.api_request_limit api[:request_limit] end |
.api_request_window ⇒ Object
564 565 566 |
# File 'lib/platform/config.rb', line 564 def self.api_request_window api[:request_window] end |
.api_scheme ⇒ Object
580 581 582 |
# File 'lib/platform/config.rb', line 580 def self.api_scheme api[:scheme] end |
.api_supported_version_options ⇒ Object
588 589 590 |
# File 'lib/platform/config.rb', line 588 def self. @api_supported_version_options ||= api[:supported_versions].collect{|v| ["v #{v}", v]} end |
.api_supported_versions ⇒ Object
584 585 586 |
# File 'lib/platform/config.rb', line 584 def self.api_supported_versions api[:supported_versions] end |
.api_token_lifetime ⇒ Object
568 569 570 |
# File 'lib/platform/config.rb', line 568 def self.api_token_lifetime api[:token_lifetime] end |
.before_filters ⇒ Object
322 323 324 325 |
# File 'lib/platform/config.rb', line 322 def self.before_filters return [] unless site_info[:before_filters] @before_filters ||= site_info[:before_filters].collect{|filter| filter.to_sym} end |
.cache_adapter ⇒ Object
228 229 230 |
# File 'lib/platform/config.rb', line 228 def self.cache_adapter caching[:adapter] end |
.cache_store ⇒ Object
232 233 234 |
# File 'lib/platform/config.rb', line 232 def self.cache_store caching[:store] end |
.cache_version ⇒ Object
236 237 238 |
# File 'lib/platform/config.rb', line 236 def self.cache_version caching[:version] end |
.caching ⇒ Object
Config Sections
204 205 206 |
# File 'lib/platform/config.rb', line 204 def self.caching config[:caching] end |
.config ⇒ Object
153 154 155 |
# File 'lib/platform/config.rb', line 153 def self.config @config ||= load_yml("/config/platform/config.yml") end |
.create_media(file) ⇒ Object
469 470 471 472 473 474 475 476 477 |
# File 'lib/platform/config.rb', line 469 def self.create_media(file) media = site_media_class.constantize.create media.send(site_media_write_method, file) media rescue Exception => ex pp ex Platform::Logger.error("Failed to create media: #{ex.to_s}") nil end |
.current_application ⇒ Object
41 42 43 |
# File 'lib/platform/config.rb', line 41 def self.current_application Thread.current[:platform_current_application] end |
.current_application=(app) ⇒ Object
45 46 47 |
# File 'lib/platform/config.rb', line 45 def self.current_application=(app) Thread.current[:platform_current_application] = app end |
.current_developer ⇒ Object
37 38 39 |
# File 'lib/platform/config.rb', line 37 def self.current_developer Thread.current[:platform_current_developer] end |
.current_user ⇒ Object
33 34 35 |
# File 'lib/platform/config.rb', line 33 def self.current_user Thread.current[:platform_current_user] end |
.current_user_is_admin? ⇒ Boolean
431 432 433 |
# File 'lib/platform/config.rb', line 431 def self.current_user_is_admin? admin_user? end |
.current_user_is_developer? ⇒ Boolean
49 50 51 |
# File 'lib/platform/config.rb', line 49 def self.current_user_is_developer? Thread.current[:platform_current_developer] != nil end |
.current_user_is_guest? ⇒ Boolean
443 444 445 |
# File 'lib/platform/config.rb', line 443 def self.current_user_is_guest? guest_user? end |
.current_user_method ⇒ Object
340 341 342 |
# File 'lib/platform/config.rb', line 340 def self.current_user_method site_user_info[:current_user_method] end |
.default_app_icon ⇒ Object
193 194 195 |
# File 'lib/platform/config.rb', line 193 def self.default_app_icon "/assets/platform/default_app_icon.gif" end |
.default_app_logo ⇒ Object
197 198 199 |
# File 'lib/platform/config.rb', line 197 def self.default_app_logo "/assets/platform/default_app_logo.gif" end |
.default_applications ⇒ Object
130 131 132 |
# File 'lib/platform/config.rb', line 130 def self.default_applications @default_applications ||= load_yml("/config/platform/data/default_applications.yml") end |
.default_categories ⇒ Object
134 135 136 |
# File 'lib/platform/config.rb', line 134 def self.default_categories @default_categories ||= load_yml("/config/platform/data/default_categories.yml") end |
.default_url ⇒ Object
267 268 269 |
# File 'lib/platform/config.rb', line 267 def self.default_url site_info[:default_url] end |
.developer_agreement_path ⇒ Object
181 182 183 |
# File 'lib/platform/config.rb', line 181 def self.developer_agreement_path config[:developer_agreement_path] end |
.disabled? ⇒ Boolean
161 162 163 |
# File 'lib/platform/config.rb', line 161 def self.disabled? not enabled? end |
.enable_api? ⇒ Boolean
API
536 537 538 |
# File 'lib/platform/config.rb', line 536 def self.enable_api? api[:enabled] end |
.enable_api_verification? ⇒ Boolean
189 190 191 |
# File 'lib/platform/config.rb', line 189 def self.enable_api_verification? config[:enable_api_verification] end |
.enable_app_directory? ⇒ Boolean
165 166 167 |
# File 'lib/platform/config.rb', line 165 def self.enable_app_directory? config[:enable_app_directory] end |
.enable_app_statistics? ⇒ Boolean
185 186 187 |
# File 'lib/platform/config.rb', line 185 def self.enable_app_statistics? config[:enable_app_statistics] end |
.enable_caching? ⇒ Boolean
Caching
224 225 226 |
# File 'lib/platform/config.rb', line 224 def self.enable_caching? caching[:enabled] end |
.enable_developer_agreement? ⇒ Boolean
177 178 179 |
# File 'lib/platform/config.rb', line 177 def self.enable_developer_agreement? config[:enable_developer_agreement] end |
.enable_embedded_applications? ⇒ Boolean
169 170 171 |
# File 'lib/platform/config.rb', line 169 def self. config[:enable_embedded_applications] end |
.enable_logger? ⇒ Boolean
Logger
244 245 246 |
# File 'lib/platform/config.rb', line 244 def self.enable_logger? logger[:enabled] end |
.enable_mobile_applications? ⇒ Boolean
173 174 175 |
# File 'lib/platform/config.rb', line 173 def self.enable_mobile_applications? config[:enable_mobile_applications] end |
.enabled? ⇒ Boolean
157 158 159 |
# File 'lib/platform/config.rb', line 157 def self.enabled? config[:enable_platform] end |
.env ⇒ Object
142 143 144 |
# File 'lib/platform/config.rb', line 142 def self.env Rails.env end |
.featured_apps_enabled? ⇒ Boolean
Application Directory
497 498 499 |
# File 'lib/platform/config.rb', line 497 def self.featured_apps_enabled? true end |
.featured_apps_per_page ⇒ Object
509 510 511 |
# File 'lib/platform/config.rb', line 509 def self.featured_apps_per_page 2 end |
.featured_apps_per_row ⇒ Object
505 506 507 |
# File 'lib/platform/config.rb', line 505 def self.featured_apps_per_row 2 end |
.featured_apps_title ⇒ Object
501 502 503 |
# File 'lib/platform/config.rb', line 501 def self.featured_apps_title "Featured Applications" end |
.features ⇒ Object
670 671 672 673 674 675 676 677 678 679 680 |
# File 'lib/platform/config.rb', line 670 def self.features @features ||= begin defs = load_yml("/config/platform/site/features.yml") feats = [] defs[:enabled_features].each do |key| defs[key][:key] = key feats << defs[key] end feats end end |
.guest_user?(user = current_user) ⇒ Boolean
435 436 437 438 439 440 441 |
# File 'lib/platform/config.rb', line 435 def self.guest_user?(user = current_user) return true unless user user.send(site_user_info[:methods][:guest]) rescue Exception => ex Platform::Logger.error("Failed to fetch #{user_class_name} guest flag: #{ex.to_s}") true end |
.helpers ⇒ Object
307 308 309 310 |
# File 'lib/platform/config.rb', line 307 def self.helpers return [] unless site_info[:helpers] @tr8n_helpers ||= site_info[:helpers].collect{|helper| helper.to_sym} end |
.icon_url(media) ⇒ Object
486 487 488 489 490 491 |
# File 'lib/platform/config.rb', line 486 def self.icon_url(media) eval("media.#{site_media_info[:icon_url_method]}") rescue Exception => ex Platform::Logger.error("Failed to fetch icon url: #{ex.to_s}") default_app_icon end |
.init(site_current_user, current_application = nil) ⇒ Object
27 28 29 30 31 |
# File 'lib/platform/config.rb', line 27 def self.init(site_current_user, current_application = nil) Thread.current[:platform_current_user] = site_current_user Thread.current[:platform_current_developer] = Platform::Developer.for(site_current_user) Thread.current[:platform_current_application] = current_application end |
.init_categories(parent, categories) ⇒ Object
123 124 125 126 127 128 |
# File 'lib/platform/config.rb', line 123 def self.init_categories(parent, categories) categories.each do |keyword, info| cat = Platform::Category.create(:parent => parent, :keyword => keyword, :name => info[:name], :position => info[:position]) init_categories(cat, info[:categories]) if info[:categories] end end |
.init_default_applications ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/platform/config.rb', line 105 def self.init_default_applications puts "Initializing default applications..." unless system_developer puts "Cannot initialize default application because system user id is not specified in the config." return end default_applications.each do |keyword, description| app = Platform::Application.create(description.merge(:developer => system_developer)) puts "Initialized #{app.name}." end end |
.init_default_categories ⇒ Object
118 119 120 121 |
# File 'lib/platform/config.rb', line 118 def self.init_default_categories puts "Initializing default categories..." init_categories(Platform::Category.root, default_categories) end |
.load_proxies ⇒ Object
613 614 615 616 617 |
# File 'lib/platform/config.rb', line 613 def self.load_proxies Dir["#{root}/#{api_proxies_path}/*_proxy_*.rb"].each do |file| require_or_load file end end |
.load_yml(file_path, for_env = env) ⇒ Object
146 147 148 149 150 151 |
# File 'lib/platform/config.rb', line 146 def self.load_yml(file_path, for_env = env) yml_path = "#{root}#{file_path}" yml = YAML.load_file(yml_path) yml = yml['defaults'].rmerge(yml[for_env] || {}) unless for_env.nil? HashWithIndifferentAccess.new(yml) end |
.log_path ⇒ Object
248 249 250 |
# File 'lib/platform/config.rb', line 248 def self.log_path logger[:log_path] end |
.logger ⇒ Object
208 209 210 |
# File 'lib/platform/config.rb', line 208 def self.logger config[:logger] end |
.login_url(params = {}) ⇒ Object
348 349 350 |
# File 'lib/platform/config.rb', line 348 def self.login_url(params = {}) site_info[:login_url] + (site_info[:logout_url].index('?') ? ':' : '?') + params.collect{|n,v| "#{n}=#{CGI.escape(v.to_s)}"}.join('&') end |
.logo_url(media) ⇒ Object
479 480 481 482 483 484 |
# File 'lib/platform/config.rb', line 479 def self.logo_url(media) eval("media.#{site_media_info[:logo_url_method]}") rescue Exception => ex Platform::Logger.error("Failed to fetch logo url: #{ex.to_s}") default_app_logo end |
.logout_method ⇒ Object
344 345 346 |
# File 'lib/platform/config.rb', line 344 def self.logout_method site_user_info[:logout_method] end |
.logout_url(params = {}) ⇒ Object
352 353 354 |
# File 'lib/platform/config.rb', line 352 def self.logout_url(params = {}) site_info[:logout_url] + (site_info[:logout_url].index('?') ? ':' : '?') + params.collect{|n,v| "#{n}=#{CGI.escape(v.to_s)}"}.join('&') end |
.media_directory ⇒ Object
299 300 301 |
# File 'lib/platform/config.rb', line 299 def self.media_directory site_info[:media_directory] end |
.media_path ⇒ Object
303 304 305 |
# File 'lib/platform/config.rb', line 303 def self.media_path "#{root}/public#{media_directory}" end |
.models ⇒ Object
.oauth_desktop_layout ⇒ Object
295 296 297 |
# File 'lib/platform/config.rb', line 295 def self.oauth_desktop_layout site_info[:oauth_desktop_layout] end |
.oauth_fluid_layout ⇒ Object
283 284 285 |
# File 'lib/platform/config.rb', line 283 def self.oauth_fluid_layout site_info[:oauth_fluid_layout] end |
.oauth_mobile_layout ⇒ Object
291 292 293 |
# File 'lib/platform/config.rb', line 291 def self.oauth_mobile_layout site_info[:oauth_mobile_layout] end |
.oauth_popup_layout ⇒ Object
287 288 289 |
# File 'lib/platform/config.rb', line 287 def self.oauth_popup_layout site_info[:oauth_popup_layout] end |
.oauth_web_layout ⇒ Object
279 280 281 |
# File 'lib/platform/config.rb', line 279 def self.oauth_web_layout site_info[:oauth_web_layout] end |
.proxies ⇒ Object
619 620 621 |
# File 'lib/platform/config.rb', line 619 def self.proxies @proxies ||= {} end |
.reset! ⇒ Object
53 54 55 56 57 |
# File 'lib/platform/config.rb', line 53 def self.reset! Thread.current[:platform_current_user] = nil Thread.current[:platform_current_developer] = nil Thread.current[:platform_current_application] = nil end |
.reset_all! ⇒ Object
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/platform/config.rb', line 85 def self.reset_all! models.each do |cls| puts ">> Resetting #{cls.name}..." cls.delete_all end init_default_categories puts "Done." end |
.searched_apps_per_page ⇒ Object
529 530 531 |
# File 'lib/platform/config.rb', line 529 def self.searched_apps_per_page 15 end |
.searched_apps_title ⇒ Object
525 526 527 |
# File 'lib/platform/config.rb', line 525 def self.searched_apps_title "Search Results" end |
.silhouette_image(user = current_user) ⇒ Object
666 667 668 |
# File 'lib/platform/config.rb', line 666 def self.silhouette_image(user = current_user) "/assets/platform/photo_silhouette.gif" end |
.site_base_url ⇒ Object
263 264 265 |
# File 'lib/platform/config.rb', line 263 def self.site_base_url site_info[:base_url] end |
.site_info ⇒ Object
212 213 214 |
# File 'lib/platform/config.rb', line 212 def self.site_info config[:site_info] end |
.site_layout ⇒ Object
271 272 273 |
# File 'lib/platform/config.rb', line 271 def self.site_layout site_info[:platform_layout] end |
.site_logo_url ⇒ Object
259 260 261 |
# File 'lib/platform/config.rb', line 259 def self.site_logo_url site_info[:logo_url] end |
.site_media_class ⇒ Object
460 461 462 463 |
# File 'lib/platform/config.rb', line 460 def self.site_media_class return "Platform::Media::Image" unless site_media_enabled? site_media_info[:class_name] end |
.site_media_enabled? ⇒ Boolean
456 457 458 |
# File 'lib/platform/config.rb', line 456 def self.site_media_enabled? site_media_info[:enabled] end |
.site_media_info ⇒ Object
site media info The following methods could be overloaded in the initializer
452 453 454 |
# File 'lib/platform/config.rb', line 452 def self.site_media_info site_info[:media_info] end |
.site_media_write_method ⇒ Object
465 466 467 |
# File 'lib/platform/config.rb', line 465 def self.site_media_write_method site_media_info[:write_method] end |
.site_title ⇒ Object
Site Info
255 256 257 |
# File 'lib/platform/config.rb', line 255 def self.site_title site_info[:title] end |
.site_user_info ⇒ Object
site user info The following methods could be overloaded in the initializer
336 337 338 |
# File 'lib/platform/config.rb', line 336 def self.site_user_info site_info[:user_info] end |
.site_user_info_disabled? ⇒ Boolean
360 361 362 |
# File 'lib/platform/config.rb', line 360 def self.site_user_info_disabled? !site_user_info_enabled? end |
.site_user_info_enabled? ⇒ Boolean
356 357 358 |
# File 'lib/platform/config.rb', line 356 def self.site_user_info_enabled? site_user_info[:enabled].nil? ? true : site_user_info[:enabled] end |
.skip_before_filters ⇒ Object
317 318 319 320 |
# File 'lib/platform/config.rb', line 317 def self.skip_before_filters return [] unless site_info[:skip_before_filters] @skip_before_filters ||= site_info[:skip_before_filters].collect{|filter| filter.to_sym} end |
.suggested_apps_per_page ⇒ Object
521 522 523 |
# File 'lib/platform/config.rb', line 521 def self.suggested_apps_per_page 20 end |
.suggested_apps_per_row ⇒ Object
517 518 519 |
# File 'lib/platform/config.rb', line 517 def self.suggested_apps_per_row 5 end |
.suggested_apps_title ⇒ Object
513 514 515 |
# File 'lib/platform/config.rb', line 513 def self.suggested_apps_title "Applications You May Like" end |
.system_developer ⇒ Object
101 102 103 |
# File 'lib/platform/config.rb', line 101 def self.system_developer @system_developer ||= Platform::Developer.find_or_create(Platform::Config.system_user) end |
.system_user ⇒ Object
96 97 98 99 |
# File 'lib/platform/config.rb', line 96 def self.system_user return nil unless site_info[:system_user_id] @system_user ||= user_class_name.constantize.find_by_id(site_info[:system_user_id]) end |
.user_class ⇒ Object
369 370 371 |
# File 'lib/platform/config.rb', line 369 def self.user_class user_class_name.constantize end |
.user_class_name ⇒ Object
364 365 366 367 |
# File 'lib/platform/config.rb', line 364 def self.user_class_name return site_user_info[:class_name] if site_user_info_enabled? "Platform::PlatformUser" end |
.user_email(user = current_user) ⇒ Object
387 388 389 390 391 392 |
# File 'lib/platform/config.rb', line 387 def self.user_email(user = current_user) user.send(site_user_info[:methods][:email]) rescue Exception => ex Platform::Logger.error("Failed to fetch #{user_class_name} name: #{ex.to_s}") nil end |
.user_gender(user = current_user) ⇒ Object
394 395 396 397 398 399 |
# File 'lib/platform/config.rb', line 394 def self.user_gender(user = current_user) user.send(site_user_info[:methods][:gender]) rescue Exception => ex Platform::Logger.error("Failed to fetch #{user_class_name} name: #{ex.to_s}") "unknown" end |
.user_id(user = current_user) ⇒ Object
373 374 375 376 377 378 |
# File 'lib/platform/config.rb', line 373 def self.user_id(user = current_user) user.send(site_user_info[:methods][:id]) rescue Exception => ex Platform::Logger.error("Failed to fetch user id: #{ex.to_s}") 0 end |
.user_link(user = current_user) ⇒ Object
410 411 412 413 414 415 |
# File 'lib/platform/config.rb', line 410 def self.user_link(user = current_user) user.send(site_user_info[:methods][:link]) rescue Exception => ex Platform::Logger.error("Failed to fetch #{user_class_name} link: #{ex.to_s}") "/tr8n" end |
.user_locale(user = current_user) ⇒ Object
417 418 419 420 421 422 |
# File 'lib/platform/config.rb', line 417 def self.user_locale(user = current_user) user.send(site_user_info[:methods][:locale]) rescue Exception => ex Platform::Logger.error("Failed to fetch #{user_class_name} locale: #{ex.to_s}") default_locale end |
.user_mugshot(user = current_user) ⇒ Object
401 402 403 404 405 406 407 408 |
# File 'lib/platform/config.rb', line 401 def self.user_mugshot(user = current_user) mugshot_image = user.send(site_user_info[:methods][:mugshot]) return silhouette_image(user) if mugshot_image.blank? mugshot_image rescue Exception => ex Platform::Logger.error("Failed to fetch #{user_class_name} image: #{ex.to_s}") silhouette_image end |
.user_name(user = current_user) ⇒ Object
380 381 382 383 384 385 |
# File 'lib/platform/config.rb', line 380 def self.user_name(user = current_user) user.send(site_user_info[:methods][:name]) rescue Exception => ex Platform::Logger.error("Failed to fetch #{user_class_name} name: #{ex.to_s}") "Unknown user" end |