Sha256: 46cd02ddddb393e7c9100de7894db007e439fce3bb0c803f814914893930d9af

Contents?: true

Size: 971 Bytes

Versions: 14

Compression:

Stored size: 971 Bytes

Contents

class PageTemplate < DynamicView
  include Templates

  validates_format_of :name, :with => /\A[a-z]+[a-z0-9_]*\Z/, :message => "can only contain lowercase letters, numbers and underscores and must begin with a lowercase letter"

  def file_path
    File.join(self.class.file_path, file_name)
  end
  
  def self.relative_path
    File.join("layouts", "templates")
  end
  
  def self.file_path
    File.join(base_path, relative_path)
  end
  
  def self.display_name(file_name)
    name, format, handler = file_name.split('.')
    "#{name.titleize} (#{format}/#{handler})"
  end
  
  # This is a combination of file system page templates 
  # and database page templates
  def self.options
    file_system_templates = ActionController::Base.view_paths.map{|p| Dir["#{p}/#{relative_path}/*"]}.flatten.map{|f| File.basename(f)}
    page_templates = file_system_templates + all.map{|t| t.file_name }
    page_templates.map{|f| [display_name(f), f] }.sort.uniq
  end
  
end

Version data entries

14 entries across 14 versions & 3 rubygems

Version Path
browsercms-3.3.4 app/models/page_template.rb
browsercms-3.3.3 app/models/page_template.rb
browsercms-3.1.5 app/models/page_template.rb
browsercms-3.1.4 app/models/page_template.rb
browsercms-3.3.2 app/models/page_template.rb
browsercms-3.3.1 app/models/page_template.rb
browsercms-3.3.0 app/models/page_template.rb
browsercms-3.1.3 app/models/page_template.rb
browsercms-3.3.0.beta app/models/page_template.rb
drujensen-browsercms-3.2.0 app/models/page_template.rb
browsercms-3.1.2 app/models/page_template.rb
browsercms-3.1.1 app/models/page_template.rb
browsercms-3.1.0 app/models/page_template.rb
we5-browsercms-3.1.0 app/models/page_template.rb