aslakjo-comatose 2.0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +195 -0
- data/INSTALL +20 -0
- data/LICENSE +20 -0
- data/MANIFEST +91 -0
- data/README.markdown +159 -0
- data/Rakefile +176 -0
- data/SPECS +61 -0
- data/about.yml +7 -0
- data/bin/comatose +112 -0
- data/comatose.gemspec +113 -0
- data/generators/comatose_migration/USAGE +15 -0
- data/generators/comatose_migration/comatose_migration_generator.rb +74 -0
- data/generators/comatose_migration/templates/migration.rb +35 -0
- data/generators/comatose_migration/templates/v4_upgrade.rb +15 -0
- data/generators/comatose_migration/templates/v6_upgrade.rb +23 -0
- data/generators/comatose_migration/templates/v7_upgrade.rb +22 -0
- data/init.rb +2 -0
- data/install.rb +18 -0
- data/lib/acts_as_versioned.rb +543 -0
- data/lib/comatose/comatose_drop.rb +79 -0
- data/lib/comatose/configuration.rb +69 -0
- data/lib/comatose/page_wrapper.rb +119 -0
- data/lib/comatose/processing_context.rb +69 -0
- data/lib/comatose/tasks/admin.rb +60 -0
- data/lib/comatose/tasks/data.rb +82 -0
- data/lib/comatose/tasks/setup.rb +52 -0
- data/lib/comatose/version.rb +4 -0
- data/lib/comatose.rb +33 -0
- data/lib/comatose_admin_controller.rb +395 -0
- data/lib/comatose_admin_helper.rb +37 -0
- data/lib/comatose_controller.rb +138 -0
- data/lib/comatose_helper.rb +3 -0
- data/lib/comatose_page.rb +141 -0
- data/lib/liquid/block.rb +96 -0
- data/lib/liquid/context.rb +190 -0
- data/lib/liquid/document.rb +17 -0
- data/lib/liquid/drop.rb +48 -0
- data/lib/liquid/errors.rb +7 -0
- data/lib/liquid/extensions.rb +53 -0
- data/lib/liquid/file_system.rb +62 -0
- data/lib/liquid/htmltags.rb +64 -0
- data/lib/liquid/standardfilters.rb +111 -0
- data/lib/liquid/standardtags.rb +399 -0
- data/lib/liquid/strainer.rb +42 -0
- data/lib/liquid/tag.rb +25 -0
- data/lib/liquid/template.rb +88 -0
- data/lib/liquid/variable.rb +39 -0
- data/lib/liquid.rb +52 -0
- data/lib/redcloth.rb +1129 -0
- data/lib/support/class_options.rb +36 -0
- data/lib/support/inline_rendering.rb +48 -0
- data/lib/support/route_mapper.rb +50 -0
- data/lib/text_filters/markdown.rb +14 -0
- data/lib/text_filters/markdown_smartypants.rb +15 -0
- data/lib/text_filters/none.rb +8 -0
- data/lib/text_filters/rdoc.rb +13 -0
- data/lib/text_filters/simple.rb +8 -0
- data/lib/text_filters/textile.rb +15 -0
- data/lib/text_filters.rb +140 -0
- data/rails/init.rb +3 -0
- data/resources/layouts/comatose_admin_template.html.erb +28 -0
- data/resources/public/images/collapsed.gif +0 -0
- data/resources/public/images/expanded.gif +0 -0
- data/resources/public/images/no-children.gif +0 -0
- data/resources/public/images/page.gif +0 -0
- data/resources/public/images/spinner.gif +0 -0
- data/resources/public/images/title-hover-bg.gif +0 -0
- data/resources/public/javascripts/comatose_admin.js +401 -0
- data/resources/public/stylesheets/comatose_admin.css +404 -0
- data/tasks/comatose.rake +9 -0
- data/test/behaviors.rb +106 -0
- data/test/fixtures/comatose_pages.yml +96 -0
- data/test/functional/comatose_admin_controller_test.rb +114 -0
- data/test/functional/comatose_controller_test.rb +44 -0
- data/test/javascripts/test.html +26 -0
- data/test/javascripts/test_runner.js +307 -0
- data/test/test_helper.rb +55 -0
- data/test/unit/class_options_test.rb +52 -0
- data/test/unit/comatose_page_test.rb +136 -0
- data/test/unit/processing_context_test.rb +108 -0
- data/test/unit/text_filters_test.rb +52 -0
- data/views/comatose_admin/_form.html.erb +96 -0
- data/views/comatose_admin/_page_list_item.html.erb +60 -0
- data/views/comatose_admin/delete.html.erb +18 -0
- data/views/comatose_admin/edit.html.erb +5 -0
- data/views/comatose_admin/index.html.erb +29 -0
- data/views/comatose_admin/new.html.erb +5 -0
- data/views/comatose_admin/reorder.html.erb +30 -0
- data/views/comatose_admin/versions.html.erb +40 -0
- data/views/layouts/comatose_admin.html.erb +837 -0
- data/views/layouts/comatose_admin_customize.html.erb +28 -0
- data/views/layouts/comatose_content.html.erb +17 -0
- metadata +148 -0
data/SPECS
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
Comatose Admin Controller should:
|
2
|
+
- show the index action
|
3
|
+
- show the new action
|
4
|
+
- successfully create pages
|
5
|
+
- create a page with an empty body
|
6
|
+
- not create a page with a missing title
|
7
|
+
- not create a page associated to an invalid parent
|
8
|
+
- contain all the correct options for filter_type
|
9
|
+
- show the edit action
|
10
|
+
- update pages with valid data
|
11
|
+
- not update pages with invalid data
|
12
|
+
- delete a page
|
13
|
+
- reorder pages
|
14
|
+
- set runtime mode
|
15
|
+
|
16
|
+
Comatose Controller should:
|
17
|
+
- show pages based on path_info
|
18
|
+
|
19
|
+
Class Options should:
|
20
|
+
- allow nil as a default
|
21
|
+
- allow boolean defaults
|
22
|
+
- allow string defaults
|
23
|
+
- allow numeric defaults
|
24
|
+
- allow symbolic defaults
|
25
|
+
- allow array literals as defaults
|
26
|
+
- allow hash literals as defaults
|
27
|
+
|
28
|
+
Comatose Page should:
|
29
|
+
- create page
|
30
|
+
- create a new version of an updated page
|
31
|
+
- render content through textile and liquid processors
|
32
|
+
- not allow creation of page when missing a title
|
33
|
+
- have good fixtures for this to work out
|
34
|
+
- generate slugs correctly
|
35
|
+
- generate page paths correctly
|
36
|
+
- update page paths when pages are moved
|
37
|
+
- set an AR error with processor syntax error info
|
38
|
+
- render body text accurately
|
39
|
+
- render data from parameterized calls too
|
40
|
+
- render data from a Drop
|
41
|
+
|
42
|
+
Processing Context should:
|
43
|
+
- process liquid tags with no filters correctly
|
44
|
+
- process erb tags correctly
|
45
|
+
- support text translation and processing with ERB
|
46
|
+
- support text translation and processing with Liquid
|
47
|
+
- allow access to safe properties and methods when processing with ERB
|
48
|
+
- prevent access to protected properties and methods when processing with ERB
|
49
|
+
- allow access to safe properties and methods when processing with Liquid
|
50
|
+
- prevent access to protected properties and methods when processing with Liquid
|
51
|
+
- allow referenceing of defined ComatoseDrops
|
52
|
+
- let ComatoseDrop errors bubble upward
|
53
|
+
|
54
|
+
Text Filters should:
|
55
|
+
- not alter output when using filter :none
|
56
|
+
- convert newlines into <br/>s when using :simple filter
|
57
|
+
- support Textile, if it's available, using :textile or 'Textile' as a key
|
58
|
+
- support Markdown, if it's available, using :markdown or 'Markdown' as a key
|
59
|
+
- support RDoc, if it's available, using :rdoc or 'RDoc' as a key
|
60
|
+
- support transformation of parameters via ERB
|
61
|
+
- support transformation of parameters via Liquid
|
data/about.yml
ADDED
data/bin/comatose
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
args = ARGV
|
6
|
+
options = {
|
7
|
+
:action => :gem
|
8
|
+
}
|
9
|
+
|
10
|
+
begin
|
11
|
+
OptionParser.new do |opts|
|
12
|
+
opts.banner = "Usage: comatose [options] RAILS_ROOT"
|
13
|
+
|
14
|
+
opts.on("-g", "--gem", "Initialize to run from gem (DEFAULT)") do |s|
|
15
|
+
options[:action] = :gem
|
16
|
+
puts "Configuring to run from GEM..."
|
17
|
+
end
|
18
|
+
|
19
|
+
opts.on("-p", "--plugin", "Install as plugin") do |s|
|
20
|
+
options[:action] = :plugin
|
21
|
+
puts "Configuring to run from PLUGIN..."
|
22
|
+
end
|
23
|
+
|
24
|
+
# opts.on("-u", "--update", "Update current installation (CURRENTLY UNIMPLEMENTED)") do |s|
|
25
|
+
# options[:action] = :update
|
26
|
+
# puts "UPDATE"
|
27
|
+
# end
|
28
|
+
|
29
|
+
opts.separator ""
|
30
|
+
opts.separator "Common options:"
|
31
|
+
|
32
|
+
# No argument, shows at tail. This will print an options summary.
|
33
|
+
# Try it and see!
|
34
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
35
|
+
puts opts
|
36
|
+
exit
|
37
|
+
end
|
38
|
+
|
39
|
+
# Another typical switch to print the version.
|
40
|
+
opts.on_tail("--version", "Show version") do
|
41
|
+
require 'comatose/version'
|
42
|
+
puts Comatose::VERSION_STRING
|
43
|
+
exit
|
44
|
+
end
|
45
|
+
|
46
|
+
end.parse!(args)
|
47
|
+
rescue OptionParser::ParseError => e
|
48
|
+
puts e
|
49
|
+
end
|
50
|
+
|
51
|
+
if args.length == 0
|
52
|
+
puts "No action taken."
|
53
|
+
exit
|
54
|
+
end
|
55
|
+
|
56
|
+
RAILS_ROOT = File.expand_path( args.last )
|
57
|
+
|
58
|
+
class String
|
59
|
+
def /(string)
|
60
|
+
File.join(self, string)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
unless File.directory?(RAILS_ROOT) and File.exists?( RAILS_ROOT / 'config'/ 'boot.rb' )
|
65
|
+
puts "Not a valid rails application path."
|
66
|
+
exit
|
67
|
+
end
|
68
|
+
|
69
|
+
comatose_initializer_path = RAILS_ROOT / 'config' / 'initializers' / 'comatose.rb'
|
70
|
+
|
71
|
+
unless File.exists?( comatose_initializer_path )
|
72
|
+
File.open(comatose_initializer_path, 'w') do |f|
|
73
|
+
f.write <<-EOT
|
74
|
+
require 'comatose'
|
75
|
+
|
76
|
+
# 1.) You should add the following snippet to your environment.rb too, probably...
|
77
|
+
#
|
78
|
+
# gem 'comatose'
|
79
|
+
#
|
80
|
+
# 2.) Following is an example configuration block for Comatose:
|
81
|
+
#
|
82
|
+
Comatose.configure do |config|
|
83
|
+
# Includes AuthenticationSystem in the ComatoseController
|
84
|
+
#config.includes << :authenticated_system
|
85
|
+
|
86
|
+
# admin
|
87
|
+
#config.admin_title = "My Content"
|
88
|
+
#config.admin_sub_title = "Content for the rest of us..."
|
89
|
+
|
90
|
+
# Includes AuthenticationSystem in the ComatoseAdminController
|
91
|
+
#config.admin_includes << :authenticated_system
|
92
|
+
|
93
|
+
# Calls :login_required as a before_filter
|
94
|
+
#config.admin_authorization = :login_required
|
95
|
+
# Returns the author name (login, in this case) for the current user
|
96
|
+
#config.admin_get_author do
|
97
|
+
# current_user.login
|
98
|
+
#end
|
99
|
+
|
100
|
+
# Allows users to import and export pages (in YAML format)
|
101
|
+
#config.allow_import_export = true
|
102
|
+
|
103
|
+
# See the getting started guide at http://comatose.rubyforge.org for more...
|
104
|
+
end
|
105
|
+
EOT
|
106
|
+
end
|
107
|
+
else
|
108
|
+
puts "Comatose initializer already exists (at #{comatose_initializer_path})"
|
109
|
+
end
|
110
|
+
|
111
|
+
puts "Done."
|
112
|
+
|
data/comatose.gemspec
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
# Generated on Tue May 20 20:13:12 -0500 2008
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.name = "comatose"
|
4
|
+
s.version = "2.0.5.2"
|
5
|
+
s.date = "2008-10-31" # 2008-05-20
|
6
|
+
s.summary = "Micro CMS designed for being embedded into existing Rails applications"
|
7
|
+
s.email = "matt@elucidata.net"
|
8
|
+
s.rubyforge_project = 'comatose'
|
9
|
+
s.homepage = "http://comatose.rubyforge.org"
|
10
|
+
s.description = "Comatose is a micro CMS designed for being embedded into existing Rails applications."
|
11
|
+
s.has_rdoc = true
|
12
|
+
s.authors = ["M@ McCray"]
|
13
|
+
s.bindir = 'bin'
|
14
|
+
s.executables = ['comatose']
|
15
|
+
|
16
|
+
s.files = ["CHANGELOG",
|
17
|
+
"INSTALL",
|
18
|
+
"LICENSE",
|
19
|
+
"MANIFEST",
|
20
|
+
"README.markdown",
|
21
|
+
"Rakefile",
|
22
|
+
"SPECS",
|
23
|
+
"about.yml",
|
24
|
+
"bin/comatose",
|
25
|
+
"comatose.gemspec",
|
26
|
+
"generators/comatose_migration/comatose_migration_generator.rb",
|
27
|
+
"generators/comatose_migration/templates/migration.rb",
|
28
|
+
"generators/comatose_migration/templates/v4_upgrade.rb",
|
29
|
+
"generators/comatose_migration/templates/v6_upgrade.rb",
|
30
|
+
"generators/comatose_migration/templates/v7_upgrade.rb",
|
31
|
+
"generators/comatose_migration/USAGE",
|
32
|
+
"init.rb",
|
33
|
+
"install.rb",
|
34
|
+
"lib/acts_as_versioned.rb",
|
35
|
+
"lib/comatose/comatose_drop.rb",
|
36
|
+
"lib/comatose/configuration.rb",
|
37
|
+
"lib/comatose/page_wrapper.rb",
|
38
|
+
"lib/comatose/processing_context.rb",
|
39
|
+
"lib/comatose/tasks/admin.rb",
|
40
|
+
"lib/comatose/tasks/data.rb",
|
41
|
+
"lib/comatose/tasks/setup.rb",
|
42
|
+
"lib/comatose/version.rb",
|
43
|
+
"lib/comatose.rb",
|
44
|
+
"lib/comatose_admin_controller.rb",
|
45
|
+
"lib/comatose_admin_helper.rb",
|
46
|
+
"lib/comatose_controller.rb",
|
47
|
+
"lib/comatose_helper.rb",
|
48
|
+
"lib/comatose_page.rb",
|
49
|
+
"lib/liquid/block.rb",
|
50
|
+
"lib/liquid/context.rb",
|
51
|
+
"lib/liquid/document.rb",
|
52
|
+
"lib/liquid/drop.rb",
|
53
|
+
"lib/liquid/errors.rb",
|
54
|
+
"lib/liquid/extensions.rb",
|
55
|
+
"lib/liquid/file_system.rb",
|
56
|
+
"lib/liquid/htmltags.rb",
|
57
|
+
"lib/liquid/standardfilters.rb",
|
58
|
+
"lib/liquid/standardtags.rb",
|
59
|
+
"lib/liquid/strainer.rb",
|
60
|
+
"lib/liquid/tag.rb",
|
61
|
+
"lib/liquid/template.rb",
|
62
|
+
"lib/liquid/variable.rb",
|
63
|
+
"lib/liquid.rb",
|
64
|
+
"lib/redcloth.rb",
|
65
|
+
"lib/support/class_options.rb",
|
66
|
+
"lib/support/inline_rendering.rb",
|
67
|
+
"lib/support/route_mapper.rb",
|
68
|
+
"lib/text_filters/markdown.rb",
|
69
|
+
"lib/text_filters/markdown_smartypants.rb",
|
70
|
+
"lib/text_filters/none.rb",
|
71
|
+
"lib/text_filters/rdoc.rb",
|
72
|
+
"lib/text_filters/simple.rb",
|
73
|
+
"lib/text_filters/textile.rb",
|
74
|
+
"lib/text_filters.rb",
|
75
|
+
"rails/init.rb",
|
76
|
+
"resources/layouts/comatose_admin_template.html.erb",
|
77
|
+
"resources/public/images/collapsed.gif",
|
78
|
+
"resources/public/images/expanded.gif",
|
79
|
+
"resources/public/images/no-children.gif",
|
80
|
+
"resources/public/images/page.gif",
|
81
|
+
"resources/public/images/spinner.gif",
|
82
|
+
"resources/public/images/title-hover-bg.gif",
|
83
|
+
"resources/public/javascripts/comatose_admin.js",
|
84
|
+
"resources/public/stylesheets/comatose_admin.css",
|
85
|
+
"tasks/comatose.rake",
|
86
|
+
"views/comatose_admin/_form.html.erb",
|
87
|
+
"views/comatose_admin/_page_list_item.html.erb",
|
88
|
+
"views/comatose_admin/delete.html.erb",
|
89
|
+
"views/comatose_admin/edit.html.erb",
|
90
|
+
"views/comatose_admin/index.html.erb",
|
91
|
+
"views/comatose_admin/new.html.erb",
|
92
|
+
"views/comatose_admin/reorder.html.erb",
|
93
|
+
"views/comatose_admin/versions.html.erb",
|
94
|
+
"views/layouts/comatose_admin.html.erb",
|
95
|
+
"views/layouts/comatose_admin_customize.html.erb",
|
96
|
+
"views/layouts/comatose_content.html.erb"]
|
97
|
+
|
98
|
+
s.test_files = ["test/behaviors.rb",
|
99
|
+
"test/fixtures/comatose_pages.yml",
|
100
|
+
"test/functional/comatose_admin_controller_test.rb",
|
101
|
+
"test/functional/comatose_controller_test.rb",
|
102
|
+
"test/javascripts/test.html",
|
103
|
+
"test/javascripts/test_runner.js",
|
104
|
+
"test/test_helper.rb",
|
105
|
+
"test/unit/class_options_test.rb",
|
106
|
+
"test/unit/comatose_page_test.rb",
|
107
|
+
"test/unit/processing_context_test.rb",
|
108
|
+
"test/unit/text_filters_test.rb"]
|
109
|
+
|
110
|
+
s.rdoc_options = ["--main", "README.markdown"]
|
111
|
+
s.extra_rdoc_files = %w(README.markdown CHANGELOG SPECS LICENSE)
|
112
|
+
#s.add_dependency("mime-types", ["> 0.0.0"])
|
113
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Description:
|
2
|
+
The comatose generator creates a migration for the comatose model.
|
3
|
+
|
4
|
+
The generator takes a migration name as its argument. The migration
|
5
|
+
name may be given in CamelCase or under_score. 'add_comatose_support'
|
6
|
+
is the default.
|
7
|
+
|
8
|
+
The generator creates a migration class in db/migrate prefixed by its
|
9
|
+
number in the queue.
|
10
|
+
|
11
|
+
Example:
|
12
|
+
./script/generate comatose add_comatose_support
|
13
|
+
|
14
|
+
With 4 existing migrations, this will create an Comatose migration in the
|
15
|
+
file db/migrate/005_add_comatose_support.rb
|
@@ -0,0 +1,74 @@
|
|
1
|
+
class Rails::Generator::Commands::Create
|
2
|
+
def new_route(name, options='')
|
3
|
+
sentinel = 'ActionController::Routing::Routes.draw do |map|'
|
4
|
+
logger.route "map.#{name} #{options}"
|
5
|
+
unless options[:pretend]
|
6
|
+
gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
7
|
+
"#{match}\n map.#{name} #{options}\n"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class ComatoseMigrationGenerator < Rails::Generator::Base
|
14
|
+
|
15
|
+
|
16
|
+
def initialize(runtime_args, runtime_options = {})
|
17
|
+
@mode = :new
|
18
|
+
if runtime_args.include? '--upgrade' or runtime_args.include? '-u'
|
19
|
+
@mode = :upgrade
|
20
|
+
@upgrade_from = nil
|
21
|
+
runtime_args.delete '--upgrade'
|
22
|
+
runtime_args.delete '-u'
|
23
|
+
|
24
|
+
runtime_args.each do |arg|
|
25
|
+
if arg.starts_with? '--from'
|
26
|
+
@upgrade_from = arg[7..-1]
|
27
|
+
elsif arg.starts_with? '-f'
|
28
|
+
@upgrade_from = arg[3..-1]
|
29
|
+
end
|
30
|
+
runtime_args.delete arg
|
31
|
+
end
|
32
|
+
|
33
|
+
if @upgrade_from.nil? or @upgrade_from.empty?
|
34
|
+
puts ""
|
35
|
+
puts "Please specify which version of Comatose you're upgrading from:"
|
36
|
+
puts ""
|
37
|
+
puts " ./script/generate comatose_migration --upgrade --from=0.3"
|
38
|
+
puts ""
|
39
|
+
puts "Upgrade canceled"
|
40
|
+
exit(0)
|
41
|
+
end
|
42
|
+
|
43
|
+
puts "Upgrading from version #{ @upgrade_from }"
|
44
|
+
end
|
45
|
+
super
|
46
|
+
end
|
47
|
+
|
48
|
+
def manifest
|
49
|
+
record do |m|
|
50
|
+
case @mode
|
51
|
+
when :new
|
52
|
+
m.migration_template 'migration.rb', 'db/migrate', :migration_file_name=>'add_comatose_support', :assigns=>{:class_name=>'AddComatoseSupport'}
|
53
|
+
m.new_route 'comatose_root', "''"
|
54
|
+
m.new_route 'comatose_admin'
|
55
|
+
|
56
|
+
when :upgrade
|
57
|
+
from = @upgrade_from
|
58
|
+
if from == '0.3'
|
59
|
+
m.migration_template 'v4_upgrade.rb', 'db/migrate', :migration_file_name=>'upgrade_to_comatose_v04', :assigns=>{:class_name=>'UpgradeToComatoseV04'}
|
60
|
+
m.migration_template 'v6_upgrade.rb', 'db/migrate', :migration_file_name=>'upgrade_to_comatose_v06', :assigns=>{:class_name=>'UpgradeToComatoseV06'}
|
61
|
+
m.migration_template 'v7_upgrade.rb', 'db/migrate', :migration_file_name=>'upgrade_to_comatose_v07', :assigns=>{:class_name=>'UpgradeToComatoseV07'}
|
62
|
+
end
|
63
|
+
if from == '0.4' or from == '0.5'
|
64
|
+
m.migration_template 'v6_upgrade.rb', 'db/migrate', :migration_file_name=>'upgrade_to_comatose_v06', :assigns=>{:class_name=>'UpgradeToComatoseV06'}
|
65
|
+
m.migration_template 'v7_upgrade.rb', 'db/migrate', :migration_file_name=>'upgrade_to_comatose_v07', :assigns=>{:class_name=>'UpgradeToComatoseV07'}
|
66
|
+
end
|
67
|
+
if from == '0.6'
|
68
|
+
m.migration_template 'v7_upgrade.rb', 'db/migrate', :migration_file_name=>'upgrade_to_comatose_v07', :assigns=>{:class_name=>'UpgradeToComatoseV07'}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class ComatosePage < ActiveRecord::Base
|
2
|
+
set_table_name 'comatose_pages'
|
3
|
+
acts_as_versioned :table_name=>'comatose_page_versions', :if_changed => [:title, :slug, :keywords, :body]
|
4
|
+
end
|
5
|
+
|
6
|
+
|
7
|
+
class <%= class_name %> < ActiveRecord::Migration
|
8
|
+
|
9
|
+
# Schema for Comatose version 0.7+
|
10
|
+
def self.up
|
11
|
+
create_table :comatose_pages do |t|
|
12
|
+
t.integer "parent_id"
|
13
|
+
t.text "full_path", :default => ''
|
14
|
+
t.string "title", :limit => 255
|
15
|
+
t.string "slug", :limit => 255
|
16
|
+
t.string "keywords", :limit => 255
|
17
|
+
t.text "body"
|
18
|
+
t.string "filter_type", :limit => 25
|
19
|
+
t.string "author", :limit => 255
|
20
|
+
t.integer "position", :default => 0
|
21
|
+
t.integer "version"
|
22
|
+
t.datetime "updated_on"
|
23
|
+
t.datetime "created_on"
|
24
|
+
end
|
25
|
+
ComatosePage.create_versioned_table
|
26
|
+
puts "Creating the default 'Home Page'..."
|
27
|
+
ComatosePage.create( :title=>'Home Page', :body=>"h1. Welcome\n\nYour content goes here...", :author=>'System' )
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.down
|
31
|
+
ComatosePage.drop_versioned_table
|
32
|
+
drop_table :comatose_pages
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class <%= class_name %> < ActiveRecord::Migration
|
2
|
+
|
3
|
+
# Upgrades schema from version 0.3 to version 0.4
|
4
|
+
def self.up
|
5
|
+
add_column :comatose_pages, "filter_type", :string, :limit => 25, :default => "Textile"
|
6
|
+
add_column :comatose_pages, "keywords", :string, :limit => 1000
|
7
|
+
end
|
8
|
+
|
9
|
+
# Downgrades schema from version 0.4 to version 0.3
|
10
|
+
def self.down
|
11
|
+
remove_column :comatose_pages, "filter_type"
|
12
|
+
remove_column :comatose_pages, "keywords"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Comatose
|
2
|
+
class Page < ActiveRecord::Base
|
3
|
+
set_table_name 'comatose_pages'
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
class <%= class_name %> < ActiveRecord::Migration
|
8
|
+
|
9
|
+
# Upgrades schema from version 0.4 to version 0.6
|
10
|
+
def self.up
|
11
|
+
add_column :comatose_pages, "created_on", :datetime
|
12
|
+
puts "Setting created_on times..."
|
13
|
+
Comatose::Page.find(:all).each do |page|
|
14
|
+
page.update_attribute('created_on', page.updated_on || Time.now)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Downgrades schema from version 0.6 to version 0.4
|
19
|
+
def self.down
|
20
|
+
remove_column :comatose_pages, "created_on"
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Comatose
|
2
|
+
class Page < ActiveRecord::Base
|
3
|
+
set_table_name 'comatose_pages'
|
4
|
+
acts_as_versioned :if_changed => [:title, :slug, :keywords, :body]
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
class <%= class_name %> < ActiveRecord::Migration
|
9
|
+
|
10
|
+
# Upgrades schema from version 0.6 to version 0.7
|
11
|
+
def self.up
|
12
|
+
add_column :comatose_pages, "version", :integer
|
13
|
+
Comatose::Page.create_versioned_table
|
14
|
+
end
|
15
|
+
|
16
|
+
# Downgrades schema from version 0.7 to version 0.6
|
17
|
+
def self.down
|
18
|
+
Comatose::Page.drop_versioned_table
|
19
|
+
remove_column :comatose_pages, "version"
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
data/init.rb
ADDED
data/install.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
# Copy the images (*.gif) into RAILS_ROOT/public/images/comatose
|
4
|
+
RAILS_ROOT = File.expand_path( File.join(File.dirname(__FILE__), '../../../') )
|
5
|
+
|
6
|
+
unless FileTest.exist? File.join(RAILS_ROOT, 'public', 'images', 'comatose')
|
7
|
+
FileUtils.mkdir( File.join(RAILS_ROOT, 'public', 'images', 'comatose') )
|
8
|
+
end
|
9
|
+
|
10
|
+
FileUtils.cp(
|
11
|
+
Dir[File.join(File.dirname(__FILE__), 'resources', 'public', 'images', '*.gif')],
|
12
|
+
File.join(RAILS_ROOT, 'public', 'images', 'comatose'),
|
13
|
+
:verbose => true
|
14
|
+
)
|
15
|
+
|
16
|
+
# Show the INSTALL text file
|
17
|
+
puts IO.read(File.join(File.dirname(__FILE__), 'INSTALL'))
|
18
|
+
|