Class: Redmine::Themes::Theme

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

Overview

Class used to represent a theme

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Theme

Returns a new instance of Theme.


47
48
49
50
51
52
53
# File 'lib/redmine/themes.rb', line 47

def initialize(path)
  @path = path
  @dir = File.basename(path)
  @name = @dir.humanize
  @stylesheets = nil
  @javascripts = nil
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir


45
46
47
# File 'lib/redmine/themes.rb', line 45

def dir
  @dir
end

#nameObject (readonly)

Returns the value of attribute name


45
46
47
# File 'lib/redmine/themes.rb', line 45

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path


45
46
47
# File 'lib/redmine/themes.rb', line 45

def path
  @path
end

Instance Method Details

#<=>(theme) ⇒ Object


62
63
64
# File 'lib/redmine/themes.rb', line 62

def <=>(theme)
  name <=> theme.name
end

#==(theme) ⇒ Object


58
59
60
# File 'lib/redmine/themes.rb', line 58

def ==(theme)
  theme.is_a?(Theme) && theme.dir == dir
end

#faviconObject


82
83
84
# File 'lib/redmine/themes.rb', line 82

def favicon
  favicons.first
end

#favicon?Boolean

Returns:

  • (Boolean)

86
87
88
# File 'lib/redmine/themes.rb', line 86

def favicon?
  favicon.present?
end

#favicon_pathObject


102
103
104
# File 'lib/redmine/themes.rb', line 102

def favicon_path
  "/themes/#{dir}/favicon/#{favicon}"
end

#faviconsObject


78
79
80
# File 'lib/redmine/themes.rb', line 78

def favicons
  @favicons ||= assets("favicon")
end

#idObject

Directory name used as the theme id


56
# File 'lib/redmine/themes.rb', line 56

def id; dir end

#image_path(source) ⇒ Object


94
95
96
# File 'lib/redmine/themes.rb', line 94

def image_path(source)
  "/themes/#{dir}/images/#{source}"
end

#imagesObject


70
71
72
# File 'lib/redmine/themes.rb', line 70

def images
  @images ||= assets("images")
end

#javascript_path(source) ⇒ Object


98
99
100
# File 'lib/redmine/themes.rb', line 98

def javascript_path(source)
  "/themes/#{dir}/javascripts/#{source}"
end

#javascriptsObject


74
75
76
# File 'lib/redmine/themes.rb', line 74

def javascripts
  @javascripts ||= assets("javascripts", "js")
end

#stylesheet_path(source) ⇒ Object


90
91
92
# File 'lib/redmine/themes.rb', line 90

def stylesheet_path(source)
  "/themes/#{dir}/stylesheets/#{source}"
end

#stylesheetsObject


66
67
68
# File 'lib/redmine/themes.rb', line 66

def stylesheets
  @stylesheets ||= assets("stylesheets", "css")
end