Sha256: 8cfe1c987214ffe7d9759e83f1edec007e4720e01aacaefb58f6df7e67b29769

Contents?: true

Size: 762 Bytes

Versions: 1

Compression:

Stored size: 762 Bytes

Contents

module Compartment
  class Theme < ActiveRecord::Base

    # used for registering a theme
    def self.info
      info = Struct.new(:name, :author).new
      yield(info)
      Compartment.config.registered_themes << info
    end

    belongs_to :site
    attr_accessible :name

    validates_presence_of :name

    def self.default
      Theme.new(:name => 'default')
    end

    def filepath
      File.join(Compartment.config.themes_path, name)
    end

    def path_to_template(template)
      case template
      when :page_not_found, 404
        template = 'error_404'
      end
      File.join(filepath, 'templates', template)
    end
    
    def url
      "/assets/themes/#{name}/"
    end

    def url_to_file(name)
      url + name
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
compartment-0.0.0 app/models/compartment/theme.rb