Sha256: ac0040dd20757a36b498c984c3e76b18ade6ffcc16cd482e8c7753450a77efe8
Contents?: true
Size: 1.34 KB
Versions: 3
Compression:
Stored size: 1.34 KB
Contents
class Themesupport cattr_accessor :cache_theme_lookup @@cache_theme_lookup = false attr_accessor :name, :title, :description, :preview_image def initialize(name) @name = name @title = name.underscore.humanize.titleize @description_html = nil end def description if @description_html.nil? @description_html = RedCloth.new(File.read( File.join(Themesupport.path_to_theme(name), "about.markdown") )).to_html(:markdown, :textile) rescue "#{title}" end @description_html end def has_preview? File.exists?( File.join( Themesupport.path_to_theme(name), 'images', 'preview.png' ) ) rescue false end def preview_image 'preview.png' end def self.find_all installed_themes.inject([]) do |array, path| array << theme_from_path(path) end end private def self.themes_root File.join(Rails.root, "themes") end def self.path_to_theme(theme) File.join(themes_root, theme) end def self.theme_from_path(path) name = path.scan(/[-\w]+$/i).flatten.first self.new(name) end def self.installed_themes cache_theme_lookup ? @theme_cache ||= search_theme_directory : search_theme_directory end def self.search_theme_directory Dir.glob("#{themes_root}/[-_a-zA-Z0-9]*").collect do |file| file if File.directory?(file) end.compact end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
theme_support-3.0.7 | lib/theme_support/themesupport.rb |
theme_support-3.0.6 | lib/theme_support/themesupport.rb |
theme_support-3.0.5 | lib/theme_support/themesupport.rb |