Class: Redmine::Themes::Theme
- Inherits:
-
Object
- Object
- Redmine::Themes::Theme
- Defined in:
- lib/redmine/themes.rb
Overview
Class used to represent a theme
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #<=>(theme) ⇒ Object
- #==(theme) ⇒ Object
- #asset_paths ⇒ Object
- #asset_prefix ⇒ Object
- #favicon ⇒ Object
- #favicon? ⇒ Boolean
- #favicon_path ⇒ Object
- #favicons ⇒ Object
-
#id ⇒ Object
Directory name used as the theme id.
- #image_path(source) ⇒ Object
- #images ⇒ Object
-
#initialize(path) ⇒ Theme
constructor
A new instance of Theme.
- #javascript_path(source) ⇒ Object
- #javascripts ⇒ Object
- #stylesheet_path(source) ⇒ Object
- #stylesheets ⇒ Object
Constructor Details
#initialize(path) ⇒ Theme
Returns a new instance of Theme.
48 49 50 51 52 53 54 |
# File 'lib/redmine/themes.rb', line 48 def initialize(path) @path = path @dir = File.basename(path) @name = @dir.humanize @stylesheets = nil @javascripts = nil end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
46 47 48 |
# File 'lib/redmine/themes.rb', line 46 def dir @dir end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
46 47 48 |
# File 'lib/redmine/themes.rb', line 46 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
46 47 48 |
# File 'lib/redmine/themes.rb', line 46 def path @path end |
Instance Method Details
#<=>(theme) ⇒ Object
63 64 65 66 67 |
# File 'lib/redmine/themes.rb', line 63 def <=>(theme) return nil unless theme.is_a?(Theme) name <=> theme.name end |
#==(theme) ⇒ Object
59 60 61 |
# File 'lib/redmine/themes.rb', line 59 def ==(theme) theme.is_a?(Theme) && theme.dir == dir end |
#asset_paths ⇒ Object
113 114 115 116 117 118 119 120 121 |
# File 'lib/redmine/themes.rb', line 113 def asset_paths base_dir = Pathname.new(path) paths = base_dir.children.select do |child| child.directory? && child.basename.to_s != 'src' && !child.basename.to_s.start_with?('.') end Redmine::AssetPath.new(base_dir, paths, asset_prefix) end |
#asset_prefix ⇒ Object
109 110 111 |
# File 'lib/redmine/themes.rb', line 109 def asset_prefix "themes/#{dir}/" end |
#favicon ⇒ Object
85 86 87 |
# File 'lib/redmine/themes.rb', line 85 def favicon favicons.first end |
#favicon? ⇒ Boolean
89 90 91 |
# File 'lib/redmine/themes.rb', line 89 def favicon? favicon.present? end |
#favicon_path ⇒ Object
105 106 107 |
# File 'lib/redmine/themes.rb', line 105 def favicon_path "#{asset_prefix}#{favicon}" end |
#favicons ⇒ Object
81 82 83 |
# File 'lib/redmine/themes.rb', line 81 def favicons @favicons ||= assets("favicon") end |
#id ⇒ Object
Directory name used as the theme id
57 |
# File 'lib/redmine/themes.rb', line 57 def id; dir end |
#image_path(source) ⇒ Object
97 98 99 |
# File 'lib/redmine/themes.rb', line 97 def image_path(source) "#{asset_prefix}#{source}" end |
#images ⇒ Object
73 74 75 |
# File 'lib/redmine/themes.rb', line 73 def images @images ||= assets("images") end |
#javascript_path(source) ⇒ Object
101 102 103 |
# File 'lib/redmine/themes.rb', line 101 def javascript_path(source) "#{asset_prefix}#{source}" end |
#javascripts ⇒ Object
77 78 79 |
# File 'lib/redmine/themes.rb', line 77 def javascripts @javascripts ||= assets("javascripts", "js") end |
#stylesheet_path(source) ⇒ Object
93 94 95 |
# File 'lib/redmine/themes.rb', line 93 def stylesheet_path(source) "#{asset_prefix}#{source}" end |
#stylesheets ⇒ Object
69 70 71 |
# File 'lib/redmine/themes.rb', line 69 def stylesheets @stylesheets ||= assets("stylesheets", "css") end |