Sha256: cda5f04c4b9358a65a955d96142c35bb40a48b540f06c53b542e8cb65ba35119

Contents?: true

Size: 1.39 KB

Versions: 10

Compression:

Stored size: 1.39 KB

Contents

module Spud::ApplicationHelper

  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

  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

  def current_site_id
    config = Spud::Core.site_config_for_host(request.host_with_port)
    return config[:site_id] unless config.blank?
  end

  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

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
tb_core-1.3.0.beta2 app/helpers/spud/application_helper.rb
tb_core-1.3.0.beta1 app/helpers/spud/application_helper.rb
tb_core-1.2.8 app/helpers/spud/application_helper.rb
tb_core-1.2.7 app/helpers/spud/application_helper.rb
tb_core-1.2.6 app/helpers/spud/application_helper.rb
tb_core-1.2.4 app/helpers/spud/application_helper.rb
tb_core-1.2.3 app/helpers/spud/application_helper.rb
tb_core-1.2.2 app/helpers/spud/application_helper.rb
tb_core-1.2.1 app/helpers/spud/application_helper.rb
tb_core-1.2.0 app/helpers/spud/application_helper.rb