diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1ffd740 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +nbproject diff --git a/comatose.gemspec b/comatose.gemspec index e2bb5e5..09d6b2c 100644 --- a/comatose.gemspec +++ b/comatose.gemspec @@ -1,7 +1,7 @@ # Generated on Tue May 20 20:13:12 -0500 2008 Gem::Specification.new do |s| - s.name = "comatose" - s.version = "2.0.5.8" + s.name = "aslakjo-comatose" + s.version = "2.0.5.9" s.date = "2008-10-31" # 2008-05-20 s.summary = "Micro CMS designed for being embedded into existing Rails applications" s.email = "matt@elucidata.net" diff --git a/generators/comatose_migration/templates/migration.rb b/generators/comatose_migration/templates/migration.rb index a24ef80..b0c6cdd 100644 --- a/generators/comatose_migration/templates/migration.rb +++ b/generators/comatose_migration/templates/migration.rb @@ -1,8 +1,3 @@ -class ComatosePage < ActiveRecord::Base - set_table_name 'comatose_pages' - acts_as_versioned :table_name=>'comatose_page_versions', :if_changed => [:title, :slug, :keywords, :body] -end - class <%= class_name %> < ActiveRecord::Migration @@ -24,7 +19,7 @@ def self.up end ComatosePage.create_versioned_table puts "Creating the default 'Home Page'..." - ComatosePage.create( :title=>'Home Page', :body=>"h1. Welcome\n\nYour content goes here...", :author=>'System' ) + Comatose.create_root_page( :title=>'Home Page', :body=>"h1. Welcome\n\nYour content goes here...", :author=>'System' ) end def self.down diff --git a/lib/comatose.rb b/lib/comatose.rb index 73fa9f6..30c13e4 100644 --- a/lib/comatose.rb +++ b/lib/comatose.rb @@ -35,13 +35,9 @@ def self.load_extensions module Comatose def self.create_root_page(options ={}) - unless ComatosePage.root - page = ComatosePage.create({:title=>'root page', :body=>"Welcome to comatose", :author=>'System', :parent_id=>nil}.merge(options)) - page.save(false) - else - raise "There exists a comatose root page, cant create another one" - end - rescue - true + raise "Root page already exists" if ComatosePage.root + root = ComatosePage.create({:title=>'root page', :body=>"Welcome to comatose", :author=>'System', :parent_id=>nil}.merge(options)) + root.save(false) + raise "Failed to save root page" if root.new_record? end end diff --git a/lib/comatose_page.rb b/lib/comatose_page.rb index de253df..77daf96 100644 --- a/lib/comatose_page.rb +++ b/lib/comatose_page.rb @@ -21,6 +21,7 @@ class ComatosePage < ActiveRecord::Base define_option :active_mount_info, {:root=>'', :index=>''} acts_as_tree :order => "position, title" + acts_as_list :scope => :parent_id #before_create :create_full_path @@ -101,6 +102,7 @@ def self.find_by_path( path ) def record_timestamps false end + def self.record_timestamps false end @@ -111,7 +113,6 @@ def after_save_hook instance_eval &Comatose.config.after_page_save end - # Creates a URI path based on the Page tree def create_full_path if parent_node = self.parent