Add reroute middleware hack

This commit is contained in:
Wen-Tien Chang committed 2010-01-11 17:09:50 +08:00
1 parent 9f1ba2ae66
commit 314f6d5219
14 files changed
+65 -47

No files matched your search

+2 -1
View File
@@ -2,11 +2,12 @@ class Announcement
include MongoMapper::Document
key :entry_name, String, :required => true, :index => true
key_i18n :title, String
key_i18n :content, String
def to_liquid
{ "id" => self.id, "title" => self.title, "content" => self.content }
{ "entry_name" => self.entry_name, "id" => self.id.to_s, "title" => self.title, "content" => self.content }
end
end
+1 -3
View File
@@ -2,9 +2,7 @@ class Layout
include MongoMapper::Document
key :name, String
key :name, String, :required => true, :index => true
key_i18n :content, String
validates_presence_of :name
end
+11 -23
View File
@@ -1,43 +1,31 @@
class Page
include MongoMapper::Document
key :name, String
key :parent_page_name, String
key :name, String, :required => true, :index => true
key :parent_page_name, String, :required => true, :index => true
key_i18n :title, String
key_i18n :title, String, :required => true
key_i18n :content, String
key :layout_id, String
key :layout_name, String
key :layout_name, String, :required => true
key :external_link, String
key :position, Integer
key :is_published, Boolean
key :position, Integer, :required => true
key :is_published, Boolean, :required => true, :default => true, :index => true
key :is_component, Boolean
key :component_name, String
belongs_to :layout
validates_presence_of :name
validates_presence_of :position
before_save :setup_layout_id
before_validation :setup_default_value
def self.find_by_name(page_name)
Page.find(:first, :conditions => { :name => page_name, :is_published => true })
end
protected
def setup_layout_id
if self.layout_name.blank?
self.layout_id = nil
else
self.layout_id = Layout.find_by_name( self.layout_name ).id
end
def layout
Layout.find_by_name(self.layout_name)
end
protected
def setup_default_value
if self.position.blank?
max_page = Page.find(:last, :order => 'position')
+1 -3
View File
@@ -2,9 +2,7 @@ class Snippet
include MongoMapper::Document
key :name, String
key :name, String, :required => true, :index => true
key_i18n :content, String
validates_presence_of :name
end