Module: Spud::ApplicationHelper
- Included in:
- ApplicationController
- Defined in:
- app/helpers/spud/application_helper.rb
Instance Method Summary collapse
- #cache_key_for_spud_collection(collection, key: 'view', cache_params: [], for_user: false) ⇒ Object
- #current_site_id ⇒ Object
- #current_site_name ⇒ Object
- #tb_page_title ⇒ Object
Instance Method Details
#cache_key_for_spud_collection(collection, key: 'view', cache_params: [], for_user: false) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/helpers/spud/application_helper.rb', line 27 def cache_key_for_spud_collection(collection, key:'view', cache_params:[], for_user:false) cache_keys = [controller_name, action_name, key] cache_keys << collection.collect(&:updated_at).max().try(:utc).try(:to_i) if for_user cache_keys << current_user_id end if cache_params.any? cache_keys += cache_params.collect{ |cache_param| params[cache_param] || 'nil' } end if Spud::Core.multisite_mode_enabled cache_keys.unshift(current_site_id) end cache_keys += collection.collect(&:id) cache_key = cache_keys.join('/') if cache_key.length > 250 return Digest::SHA1.hexdigest(cache_key) else return cache_key end end |
#current_site_id ⇒ Object
22 23 24 25 |
# File 'app/helpers/spud/application_helper.rb', line 22 def current_site_id config = Spud::Core.site_config_for_host(request.host_with_port) return config[:site_id] unless config.blank? end |
#current_site_name ⇒ Object
14 15 16 17 18 19 20 |
# File 'app/helpers/spud/application_helper.rb', line 14 def current_site_name return Spud::Core.site_name if !Spud::Core.multisite_mode_enabled config = Spud::Core.site_config_for_host(request.host_with_port) return Spud::Core.site_name if config.blank? return config[:site_name] end |
#tb_page_title ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'app/helpers/spud/application_helper.rb', line 3 def tb_page_title if content_for?(:title) title = content_for(:title) + ' : ' + Spud::Core.site_name elsif @page_title title = @page_title + ' : ' + Spud::Core.site_name else title = Spud::Core.site_name end return content_tag :title, title end |