Sha256: ee51b4cd340140c8fa7165206973bbb1eb674c8de4c3fe7b14807daee9401ca3
Contents?: true
Size: 1.79 KB
Versions: 1
Compression:
Stored size: 1.79 KB
Contents
# frozen_string_literal: true module PagesHelper def trackable_key(structure) key = structure.track_key if defined? structure.track_key key ||= "trackable_key[#{[structure.class.name, structure.id].join('|').hash}]" key end def trackable_value(structure) value = structure.track_value if defined? structure.track_value value ||= "track_#{(structure.updated_at || structure.created_at).to_i}".hash value end def trackable_tag(structure, html_options = {}, &block) html_options = (html_options || {}).stringify_keys html_options[:style] ||= 'display:none;' html_options[:data] ||= {} html_options[:data][:set_key] ||= trackable_key(structure) html_options[:data][:set_value] ||= trackable_value(structure) content_tag(:span, nil, html_options, &block) end TranslationCms.term_pages.each_with_index do |kind, index| define_method "#{kind}_page_path" do Rails.cache.fetch "#{kind}_page_path_#{I18n.locale}", expires_in: 4.hours do str = structure_by(id: Settings["#{kind}_page_id"]) str ||= Settings["#{kind}_page_id"] if Settings["#{kind}_page_id"].present? str ||= Structure.with_position(PositionType.bottom).offset(index).first str ||= Structure.with_position(PositionType.bottom).first return page_path(slug: str.slug, locale: I18n.locale) if str&.is_a?(Structure) return str if str.present? '#' end end end def agreement_text(key) Rails.cache.fetch "terms_text_#{key}_#{I18n.locale}", expires_in: 4.hours do # id = Settings["#{key}_id".gsub(/(?:_id)+$/, '_id')] data = { link: try(:terms_page_path) } TranslationCms.term_pages.each do |kind| data[kind.to_sym] = try("#{kind}_page_path") end I18n.t(key, data) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
translation_cms-0.1.5 | app/helpers/pages_helper.rb |