Class: Refinery::Themes::Theme

Inherits:
Core::BaseModel
  • Object
show all
Extended by:
ActionController::DataStreaming
Defined in:
app/models/refinery/themes/theme.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.content_typeObject

Returns the value of attribute content_type.



23
24
25
# File 'app/models/refinery/themes/theme.rb', line 23

def content_type
  @content_type
end

.headersObject

Returns the value of attribute headers.



23
24
25
# File 'app/models/refinery/themes/theme.rb', line 23

def headers
  @headers
end

Class Method Details

.allObject



45
46
47
48
49
# File 'app/models/refinery/themes/theme.rb', line 45

def all
  Dir.glob(Rails.root.join("themes", "*")).collect { |dir|
    config_for(dir.split("/").last)
  }
end

.config_for(key) ⇒ Object



51
52
53
# File 'app/models/refinery/themes/theme.rb', line 51

def config_for(key)
  YAML::load(File.open(theme_path(key).join("config/config.yml")))
end

.current_theme_configObject



29
30
31
# File 'app/models/refinery/themes/theme.rb', line 29

def current_theme_config
  config_for(current_theme_key)
end

.current_theme_keyObject



25
26
27
# File 'app/models/refinery/themes/theme.rb', line 25

def current_theme_key
  ::Refinery::Setting.find_or_set(:current_theme, "default")
end

.default_layoutObject



33
34
35
# File 'app/models/refinery/themes/theme.rb', line 33

def default_layout
  ::Refinery::Setting.find_or_set(:default_layout, "site")
end

.layout_raw(file_name) ⇒ Object



41
42
43
# File 'app/models/refinery/themes/theme.rb', line 41

def layout_raw(file_name)
  File.read(theme_path.join("layouts/#{file_name}.liquid"))
end

.layoutsObject



55
56
57
# File 'app/models/refinery/themes/theme.rb', line 55

def layouts
  layouts_list(theme_path.join("views/layouts", "*.liquid"))
end

.templatesObject



59
60
61
# File 'app/models/refinery/themes/theme.rb', line 59

def templates
  templates_list(theme_path.join("views/refinery/pages/", "*.liquid"))
end

.theme_path(theme_dir = current_theme_key) ⇒ Object



37
38
39
# File 'app/models/refinery/themes/theme.rb', line 37

def theme_path(theme_dir=current_theme_key)
  Rails.root.join("themes/#{theme_dir}")
end

Instance Method Details

#default_assigns(str) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'app/models/refinery/themes/theme.rb', line 9

def default_assigns(str)
  yaml = YAML::load(str)["assigns"] || false
  return {} unless yaml
  assigns = extract_assigns(yaml, :vars)
  extract_assigns(yaml, :collections).each do |k, v|
    assigns[k] = Collection.find_by_key v
  end
  return assigns
end