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

Since:

  • 0.6.0



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

Since:

  • 0.6.0



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

def dir
  @dir
end

#nameObject (readonly)

Returns the value of attribute name

Since:

  • 0.6.0



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

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path

Since:

  • 1.1.0



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

def path
  @path
end

Instance Method Details

#<=>(theme) ⇒ Object

Since:

  • 0.6.0



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

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

#==(theme) ⇒ Object

Since:

  • 1.1.0



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

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

#faviconObject

Since:

  • 2.5.0



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

def favicon
  favicons.first
end

#favicon?Boolean

Returns:

  • (Boolean)

Since:

  • 2.5.0



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

def favicon?
  favicon.present?
end

#favicon_pathObject

Since:

  • 2.5.0



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

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

#faviconsObject

Since:

  • 2.5.0



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

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

#idObject

Directory name used as the theme id

Since:

  • 0.6.0



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

def id; dir end

#image_path(source) ⇒ Object

Since:

  • 2.0.0



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

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

#imagesObject

Since:

  • 2.0.0



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

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

#javascript_path(source) ⇒ Object

Since:

  • 1.1.0



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

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

#javascriptsObject

Since:

  • 1.1.0



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

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

#stylesheet_path(source) ⇒ Object

Since:

  • 1.1.0



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

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

#stylesheetsObject

Since:

  • 0.6.0



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

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