blob: 3d4ab49dfdc7aba708c8f040d740ea58d8af92dc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# -*- coding: utf-8 -*-
miquire :core, "userconfig"
class Skin
SKIN_ROOT = File.join(CHIConfig::CONFROOT, "skin")
USER_SKIN = if :vanilla == UserConfig[:skin_dir]
nil
else
UserConfig[:skin_dir] end
def self.default_dir
File.join(*[File.dirname(__FILE__), "skin", "data"].flatten)
end
def self.default_image
File.join(default_dir, "notfound.png")
end
def self.user_dir
if USER_SKIN
File.join(SKIN_ROOT, USER_SKIN)
else
nil
end
end
def self.get(filename, fallback_dirs = [])
search_path = [ user_dir, fallback_dirs, default_dir ].flatten.compact
valid_path = search_path.map { |_|
File.join(_, filename)
}.select { |_|
FileTest.exist?(_)
}.first
if valid_path
valid_path
else
default_image
end
end
end
|