Module: Knitkit::Extensions::ActionController::ThemeSupport::ActsAsThemedController::InstanceMethods
- Defined in:
- lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb
Instance Method Summary collapse
- #add_theme_view_paths ⇒ Object
- #allowed_template_type?(ext) ⇒ Boolean
- #authorize_template_extension!(template, ext) ⇒ Object
- #current_theme_paths ⇒ Object
- #current_themes ⇒ Object
Instance Method Details
#add_theme_view_paths ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb', line 42 def add_theme_view_paths ThemeSupport::Cache.theme_resolvers = [] if ThemeSupport::Cache.theme_resolvers.nil? if respond_to?(:current_theme_paths) current_theme_paths.each do |theme| resolver = case Rails.application.config.erp_tech_svcs.file_storage when :s3 path = File.join(theme[:url], "templates") cached_resolver = ThemeSupport::Cache.theme_resolvers.find { |cached_resolver| cached_resolver.to_path == path } if cached_resolver.nil? resolver = ActionView::S3Resolver.new(path) ThemeSupport::Cache.theme_resolvers << resolver resolver else cached_resolver end when :filesystem path = "#{theme[:path]}/templates" cached_resolver = ThemeSupport::Cache.theme_resolvers.find { |cached_resolver| cached_resolver.to_path == path } if cached_resolver.nil? resolver = ActionView::ThemeFileResolver.new(path) ThemeSupport::Cache.theme_resolvers << resolver resolver else cached_resolver end end prepend_view_path(resolver) end end end |
#allowed_template_type?(ext) ⇒ Boolean
82 83 84 |
# File 'lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb', line 82 def allowed_template_type?(ext) force_template_types.blank? || force_template_types.include?(ext) end |
#authorize_template_extension!(template, ext) ⇒ Object
77 78 79 80 |
# File 'lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb', line 77 def (template, ext) return if allowed_template_type?(ext) raise ThemeSupport::TemplateTypeError.new(template, force_template_types) end |
#current_theme_paths ⇒ Object
73 74 75 |
# File 'lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb', line 73 def current_theme_paths current_themes ? current_themes.map { |theme| {:path => theme.path.to_s, :url => theme.url.to_s} } : [] end |
#current_themes ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb', line 31 def current_themes @current_themes ||= case accessor = self.class.read_inheritable_attribute(:current_themes) when Symbol then accessor == :current_themes ? raise("screwed") : send(accessor) when Proc then accessor.call(self) else accessor end end |