Class: Theme
- Inherits:
-
Object
- Object
- Theme
- Defined in:
- lib/theme.rb
Instance Attribute Summary collapse
-
#description_html ⇒ Object
Returns the value of attribute description_html.
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
-
.find(name) ⇒ Object
Find a theme, given the theme name.
-
.find_all ⇒ Object
List all themes.
- .register_theme(path) ⇒ Object
- .register_themes(themes_root) ⇒ Object
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(name, path) ⇒ Theme
constructor
A new instance of Theme.
- #layout(action = :default) ⇒ Object
- #view_path ⇒ Object
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_html ⇒ Object
Returns the value of attribute description_html.
4 5 6 |
# File 'lib/theme.rb', line 4 def description_html @description_html end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/theme.rb', line 4 def name @name end |
#path ⇒ Object
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_all ⇒ Object
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
#description ⇒ Object
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_path ⇒ Object
27 28 29 |
# File 'lib/theme.rb', line 27 def view_path "#{path}/views" end |