Class: Spina::Theme

Inherits:
Object
  • Object
show all
Defined in:
lib/spina/theme.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTheme

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

#configObject

Returns the value of attribute config.



4
5
6
# File 'lib/spina/theme.rb', line 4

def config
  @config
end

#custom_pagesObject

Returns the value of attribute custom_pages.



4
5
6
# File 'lib/spina/theme.rb', line 4

def custom_pages
  @custom_pages
end

#layout_partsObject

Returns the value of attribute layout_parts.



4
5
6
# File 'lib/spina/theme.rb', line 4

def layout_parts
  @layout_parts
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/spina/theme.rb', line 4

def name
  @name
end

Returns the value of attribute navigations.



4
5
6
# File 'lib/spina/theme.rb', line 4

def navigations
  @navigations
end

#page_partsObject

Returns the value of attribute page_parts.



4
5
6
# File 'lib/spina/theme.rb', line 4

def page_parts
  @page_parts
end

#pluginsObject

Returns the value of attribute plugins.



4
5
6
# File 'lib/spina/theme.rb', line 4

def plugins
  @plugins
end

#public_themeObject

Returns the value of attribute public_theme.



4
5
6
# File 'lib/spina/theme.rb', line 4

def public_theme
  @public_theme
end

#resourcesObject

Returns the value of attribute resources.



4
5
6
# File 'lib/spina/theme.rb', line 4

def resources
  @resources
end

#structuresObject

Returns the value of attribute structures.



4
5
6
# File 'lib/spina/theme.rb', line 4

def structures
  @structures
end

#titleObject

Returns the value of attribute title.



4
5
6
# File 'lib/spina/theme.rb', line 4

def title
  @title
end

#view_templatesObject

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

.allObject



8
9
10
# File 'lib/spina/theme.rb', line 8

def all
  ::Spina::THEMES
end

.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

Yields:

  • (theme)


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

Returns:

  • (Boolean)


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_templatesObject



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