Class: Spina::Theme
- Inherits:
-
Object
- Object
- Spina::Theme
- Defined in:
- lib/spina/theme.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#custom_pages ⇒ Object
Returns the value of attribute custom_pages.
-
#layout_parts ⇒ Object
Returns the value of attribute layout_parts.
-
#name ⇒ Object
Returns the value of attribute name.
-
#navigations ⇒ Object
Returns the value of attribute navigations.
-
#page_parts ⇒ Object
Returns the value of attribute page_parts.
-
#plugins ⇒ Object
Returns the value of attribute plugins.
-
#public_theme ⇒ Object
Returns the value of attribute public_theme.
-
#resources ⇒ Object
Returns the value of attribute resources.
-
#structures ⇒ Object
Returns the value of attribute structures.
-
#title ⇒ Object
Returns the value of attribute title.
-
#view_templates ⇒ Object
Returns the value of attribute view_templates.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Theme
constructor
A new instance of Theme.
-
#is_custom_undeletable_page?(view_template) ⇒ Boolean
Check if view_template is defined as a custom undeletable page.
- #new_page_templates ⇒ Object
Constructor Details
#initialize ⇒ Theme
Returns a new instance of Theme.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/spina/theme.rb', line 28 def initialize @page_parts = [] @structures = [] @layout_parts = [] @view_templates = [] @custom_pages = [] @navigations = [] @resources = [] @public_theme = false end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
4 5 6 |
# File 'lib/spina/theme.rb', line 4 def config @config end |
#custom_pages ⇒ Object
Returns the value of attribute custom_pages.
4 5 6 |
# File 'lib/spina/theme.rb', line 4 def custom_pages @custom_pages end |
#layout_parts ⇒ Object
Returns the value of attribute layout_parts.
4 5 6 |
# File 'lib/spina/theme.rb', line 4 def layout_parts @layout_parts end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/spina/theme.rb', line 4 def name @name end |
#navigations ⇒ Object
Returns the value of attribute navigations.
4 5 6 |
# File 'lib/spina/theme.rb', line 4 def @navigations end |
#page_parts ⇒ Object
Returns the value of attribute page_parts.
4 5 6 |
# File 'lib/spina/theme.rb', line 4 def page_parts @page_parts end |
#plugins ⇒ Object
Returns the value of attribute plugins.
4 5 6 |
# File 'lib/spina/theme.rb', line 4 def plugins @plugins end |
#public_theme ⇒ Object
Returns the value of attribute public_theme.
4 5 6 |
# File 'lib/spina/theme.rb', line 4 def public_theme @public_theme end |
#resources ⇒ Object
Returns the value of attribute resources.
4 5 6 |
# File 'lib/spina/theme.rb', line 4 def resources @resources end |
#structures ⇒ Object
Returns the value of attribute structures.
4 5 6 |
# File 'lib/spina/theme.rb', line 4 def structures @structures end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/spina/theme.rb', line 4 def title @title end |
#view_templates ⇒ Object
Returns the value of attribute view_templates.
4 5 6 |
# File 'lib/spina/theme.rb', line 4 def view_templates @view_templates end |
Class Method Details
.find_by_name(name) ⇒ Object
12 13 14 |
# File 'lib/spina/theme.rb', line 12 def find_by_name(name) all.find { |theme| theme.name == name } end |
.register {|theme| ... } ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/spina/theme.rb', line 16 def register theme = ::Spina::Theme.new yield theme raise 'Missing theme name' if theme.name.nil? if theme.plugins.nil? theme.plugins = ::Spina::Plugin.all.map { |plugin| plugin.name } end all << theme end |
Instance Method Details
#is_custom_undeletable_page?(view_template) ⇒ Boolean
Check if view_template is defined as a custom undeletable page
46 47 48 |
# File 'lib/spina/theme.rb', line 46 def is_custom_undeletable_page?(view_template) @custom_pages.any? { |page| page[:view_template] == view_template && !page[:deletable] } end |
#new_page_templates ⇒ Object
39 40 41 42 43 |
# File 'lib/spina/theme.rb', line 39 def new_page_templates @view_templates.map do |view_template| [view_template[:name], view_template[:title], view_template[:description], view_template[:usage]] unless is_custom_undeletable_page?(view_template[:name]) end.compact end |