module Skin

Constants

SKIN_ROOT
USER_SKIN

Public Instance Methods

[](filename, fallback_dirs=[])
Alias for: photo
default_dir() click to toggle source
# File core/skin.rb, line 18
def default_dir
  File.join(*[File.dirname(__FILE__), "skin", "data"].flatten)
end
default_image() click to toggle source
# File core/skin.rb, line 22
def default_image
  File.join(default_dir, "notfound.png")
end
get(filename, fallback_dirs = [])
Alias for: get_path
get_path(filename, fallback_dirs = []) click to toggle source
# File core/skin.rb, line 53
def get_path(filename, fallback_dirs = [])
  filename, fallback_dirs = Plugin.filtering(:skin_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
Also aliased as: get
path() click to toggle source
# File core/skin.rb, line 34
def path
  user_dir || default_dir
end
photo(filename, fallback_dirs=[]) click to toggle source

現在のSkinにおける、 filename の画像を示すPhoto Modelを取得する

Args

filename

画像ファイル名

fallback_dirs

スキンディレクトリのリスト

Return

Diva::Mixin::PhotoMixin

画像

Raises

Skin::FileNotFoundError

画像 filename が見つからなかった時

# File core/skin.rb, line 46
def photo(filename, fallback_dirs=[])
  result = Plugin::Skin::Image[get_path(filename, fallback_dirs)]
  raise FileNotFoundError, "File `#{filename}' does not exists." unless result
  result
end
Also aliased as: []
user_dir() click to toggle source
# File core/skin.rb, line 26
def user_dir
  if USER_SKIN
    File.join(SKIN_ROOT, USER_SKIN)
  else
    nil
  end
end