first go at page view, list of sections, wip
This commit is contained in:
@ -1,5 +0,0 @@
|
||||
module Cms
|
||||
def self.table_name_prefix
|
||||
"cms_"
|
||||
end
|
||||
end
|
@ -8,10 +8,6 @@ module Cms
|
||||
|
||||
attr_reader :name , :content
|
||||
|
||||
def id
|
||||
@name
|
||||
end
|
||||
|
||||
def persisted?
|
||||
false
|
||||
end
|
||||
@ -21,6 +17,10 @@ module Cms
|
||||
@content = YAML.load_file(Rails.root.join("cms" , file_name))
|
||||
end
|
||||
|
||||
def sections
|
||||
@content.collect{|section_data| Section.new(self , section_data)}
|
||||
end
|
||||
|
||||
def template
|
||||
@content[0]["template"]
|
||||
end
|
||||
|
36
app/models/cms/section.rb
Normal file
36
app/models/cms/section.rb
Normal file
@ -0,0 +1,36 @@
|
||||
module Cms
|
||||
class Section
|
||||
include ActiveModel::Model
|
||||
include ActiveModel::Conversion
|
||||
include ActiveModel::Dirty
|
||||
|
||||
attr_reader :name , :content , :page
|
||||
|
||||
def persisted?
|
||||
false
|
||||
end
|
||||
|
||||
def initialize(page , section_data)
|
||||
@page = page
|
||||
@content = section_data
|
||||
# id = SecureRandom.hex(10) if new or not there
|
||||
end
|
||||
|
||||
def template
|
||||
@content["template"]
|
||||
end
|
||||
|
||||
def save
|
||||
false
|
||||
end
|
||||
|
||||
def self.all
|
||||
@page.sections
|
||||
end
|
||||
|
||||
def self.find(page_name , section_id)
|
||||
Page.new(name + ".yaml")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user