Class: Theme

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, path) ⇒ Theme

Returns a new instance of Theme.



6
7
8
9
# File 'lib/theme.rb', line 6

def initialize(name, path)
  @name = name
  @path = path
end

Instance Attribute Details

#description_htmlObject

Returns the value of attribute description_html.



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

def description_html
  @description_html
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

Class Method Details

.find(name) ⇒ Object

Find a theme, given the theme name



32
33
34
# File 'lib/theme.rb', line 32

def self.find(name)
  registered_themes[name]
end

.find_allObject

List all themes



37
38
39
# File 'lib/theme.rb', line 37

def self.find_all
  registered_themes.values
end

.register_theme(path) ⇒ Object



41
42
43
44
# File 'lib/theme.rb', line 41

def self.register_theme(path)
  theme = theme_from_path(path)
  registered_themes[theme.name] = theme
end

.register_themes(themes_root) ⇒ Object



46
47
48
49
50
# File 'lib/theme.rb', line 46

def self.register_themes(themes_root)
  search_theme_directory(themes_root).each do |path|
    register_theme path
  end
end

Instance Method Details

#descriptionObject



18
19
20
21
22
23
24
25
# File 'lib/theme.rb', line 18

def description
  about_file = "#{path}/about.markdown"
  if File.exist? about_file
    File.read about_file
  else
    "### #{name}"
  end
end

#layout(action = :default) ⇒ Object



11
12
13
14
15
16
# File 'lib/theme.rb', line 11

def layout(action = :default)
  if action.to_s == "view_page"
    return "layouts/pages" if File.exist? "#{view_path}/layouts/pages.html.erb"
  end
  "layouts/default"
end

#view_pathObject



27
28
29
# File 'lib/theme.rb', line 27

def view_path
  "#{path}/views"
end