darthapo-comatose 2.0 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,16 @@
1
+ - version: 2.0.3 (beta)
2
+ - Moving from alpha to beta!
3
+ - staugaard: Added import and export of pages in admin controller
4
+
5
+ - version: 2.0.2 (alpha)
6
+ - staugaard: Added "unloadable" to ComatoseController (problems with ActsAsAuthenticated-integration similar to http://tinyurl.com/6caz5r)
7
+ - jcnetdev: Tweaking gemspec
8
+
9
+ - version: 2.0.1 (alpha)
10
+ - Merged changes from andreas (http://github.com/andreas)...
11
+ - andreas: Fixed comatose:admin:customize raketask (seems plugin_path was wrong, and made use of mkdir_p to avoid "File exists"-errors.)
12
+ - andreas: Added "unloadable" to ComatoseAdminController (problems with ActsAsAuthenticated-integration similar to http://tinyurl.com/6caz5r)
13
+
1
14
  - version: 2.0 (uber alpha)
2
15
  - Removed controllers, models, and helpers from Comatose module. It was causing odd issues
3
16
  - Initial support for Rails 2.1(ish)
data/INSTALL CHANGED
@@ -3,6 +3,8 @@
3
3
  Welcome to Comatose!
4
4
  ======================
5
5
 
6
+ Be sure and install the acts_as_tree and acts_as_list plugins!
7
+
6
8
  From here you'll want to run:
7
9
 
8
10
  $ ./script/generate comatose_migration
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = Comatose
2
2
 
3
- Version:: 2.0 (uber-alpha)
3
+ Version:: 2.0.3 (beta)
4
4
  Author:: M@ McCray
5
5
  Website:: comatose.rubyforge.org
6
6
  Email:: matt at elucidata dot net
@@ -144,5 +144,5 @@ project site: http://comatose.rubyforge.org/getting-started-guide
144
144
 
145
145
  If you like it, hate it, or have some ideas for new features, let me know!
146
146
 
147
- darthapo at gmail dot com
147
+ matt at elucidata dot net
148
148
 
data/about.yml CHANGED
@@ -3,5 +3,5 @@ summary: A micro CMS for embedding in Rails applications.
3
3
  homepage: http://comatose.rubyforge.org
4
4
  plugin: git://github.com/darthapo/comatose.git
5
5
  license: MIT
6
- version: 2.0
6
+ version: 2.0.3
7
7
  rails_version: 2+
data/bin/comatose CHANGED
@@ -1,20 +1,109 @@
1
1
  #!/usr/bin/env ruby
2
- # Command line
3
-
4
- puts "It's still early, so this doesn't really do anything -- yet."
5
- puts
6
- puts "Soon, you will be able to initialize comatose support in your app by running:"
7
- puts
8
- puts " $> comatose --rails ."
9
- puts
10
- puts "Or, upgrade you're current install:"
11
- puts
12
- puts " $> comatose --update ."
13
- puts
14
- puts "Or, freeze as plugin:"
15
- puts
16
- puts " $> comatose --freeze ."
17
- puts
18
- puts "And maybe other wacky things too... Not sure yet. :-)"
19
- puts
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 "GEM"
17
+ end
18
+
19
+ opts.on("-p", "--plugin", "Install as plugin") do |s|
20
+ options[:action] = :plugin
21
+ puts "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
+ # See the getting started guide at http://comatose.rubyforge.org for more...
101
+ end
102
+ EOT
103
+ end
104
+ else
105
+ puts "Comatose initializer already exists (at #{comatose_initializer_path})"
106
+ end
107
+
108
+ puts "Done."
20
109
 
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.3"
5
+ s.date = "2008-10-10" # 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.rdoc",
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.rdoc"]
111
+ s.extra_rdoc_files = %w(README.rdoc CHANGELOG SPECS LICENSE)
112
+ #s.add_dependency("mime-types", ["> 0.0.0"])
113
+ end
data/init.rb CHANGED
@@ -1,10 +1,2 @@
1
- require 'support/class_options'
2
- require 'acts_as_versioned'
3
- require 'redcloth' unless defined?(RedCloth)
4
- require 'liquid' unless defined?(Liquid)
5
-
6
1
  require 'comatose'
7
- require 'text_filters'
8
2
 
9
- require 'support/inline_rendering'
10
- require 'support/route_mapper'
@@ -1,6 +1,6 @@
1
1
  module Comatose
2
2
 
3
- class ComatoseDrop < Liquid::Drop
3
+ class ComatoseDrop < ::Liquid::Drop
4
4
 
5
5
  private :initialize
6
6
 
@@ -55,9 +55,9 @@ module Comatose
55
55
 
56
56
  def validate!
57
57
  # Rips through the config and validates it's, er, valid
58
- raise ConfigurationError.new "admin_get_author must be a Proc or Symbol" unless @admin_get_author.is_a? Proc or @admin_get_author.is_a? Symbol
59
- raise ConfigurationError.new "admin_authorization must be a Proc or Symbol" unless @admin_authorization.is_a? Proc or @admin_authorization.is_a? Symbol
60
- raise ConfigurationError.new "authorization must be a Proc or Symbol" unless @authorization.is_a? Proc or @authorization.is_a? Symbol
58
+ raise ConfigurationError.new( "admin_get_author must be a Proc or Symbol" ) unless @admin_get_author.is_a? Proc or @admin_get_author.is_a? Symbol
59
+ raise ConfigurationError.new( "admin_authorization must be a Proc or Symbol" ) unless @admin_authorization.is_a? Proc or @admin_authorization.is_a? Symbol
60
+ raise ConfigurationError.new( "authorization must be a Proc or Symbol" ) unless @authorization.is_a? Proc or @authorization.is_a? Symbol
61
61
  true
62
62
  end
63
63
 
@@ -10,7 +10,7 @@ namespace :comatose do
10
10
  desc "Create Comatose views, layouts, and public files..."
11
11
  task :customize do
12
12
  puts "Copying public files..."
13
- plugin_dir = File.join(File.dirname(__FILE__), '..')
13
+ plugin_dir = File.join(File.dirname(__FILE__), '../../..')
14
14
  FileUtils.cp(
15
15
  Dir[File.join(plugin_dir, 'resources', 'public', 'stylesheets', '*.css')],
16
16
  File.join(RAILS_ROOT, 'public', 'stylesheets'),
@@ -22,7 +22,7 @@ namespace :comatose do
22
22
  :verbose => true
23
23
  )
24
24
  puts "Copying application views..."
25
- FileUtils.mkdir(File.join(RAILS_ROOT, 'app', 'views', 'comatose_admin'))
25
+ FileUtils.mkdir_p(File.join(RAILS_ROOT, 'app', 'views', 'comatose_admin'))
26
26
  FileUtils.cp(
27
27
  Dir[File.join(plugin_dir, 'views', 'comatose_admin', '*.html.erb')],
28
28
  File.join(RAILS_ROOT, 'app', 'views', 'comatose_admin'),
@@ -57,4 +57,4 @@ namespace :comatose do
57
57
  )
58
58
  end
59
59
  end
60
- end
60
+ end
data/lib/comatose.rb CHANGED
@@ -11,12 +11,22 @@ module Comatose
11
11
 
12
12
  end
13
13
 
14
+ require 'acts_as_versioned'
15
+ require 'redcloth' unless defined?(RedCloth)
16
+ require 'liquid' unless defined?(Liquid)
17
+
18
+ require 'support/class_options'
19
+ require 'text_filters'
20
+
14
21
  require 'comatose/configuration'
15
22
  require 'comatose/comatose_drop'
16
23
  require 'comatose/processing_context'
17
24
  require 'comatose/page_wrapper'
18
25
  require 'comatose/version'
19
26
 
27
+ require 'support/inline_rendering'
28
+ require 'support/route_mapper'
29
+
20
30
  require 'dispatcher' unless defined?(::Dispatcher)
21
31
  ::Dispatcher.to_prepare :comatose do
22
32
  Comatose.config.after_setup.call
@@ -1,5 +1,6 @@
1
1
  # The controller for serving cms content...
2
2
  class ComatoseAdminController < ActionController::Base
3
+ unloadable
3
4
 
4
5
  define_option :original_template_root, nil
5
6
  define_option :plugin_layout_path, File.join( '..', '..', '..', 'vendor', 'plugins', 'comatose', 'views', 'layouts' )
@@ -139,6 +140,16 @@ class ComatoseAdminController < ActionController::Base
139
140
  redirect_to :controller=>self.controller_name, :action=>'index'
140
141
  end
141
142
 
143
+ def export
144
+ send_data(page_to_hash(ComatosePage.root).to_yaml, :disposition => 'inline', :type => 'text/yaml', :filename => "comatose-pages.yml")
145
+ end
146
+
147
+ def import
148
+ data = YAML::load(params[:import_file])
149
+ hash_to_page_tree(data, ComatosePage.root)
150
+ flash[:notice] = "Pages Imported Successfully"
151
+ redirect_to :controller=>self.controller_name, :action=>'index'
152
+ end
142
153
 
143
154
  protected
144
155
 
@@ -344,5 +355,32 @@ protected
344
355
  end
345
356
  end
346
357
 
358
+ private
359
+
360
+ def page_to_hash(page)
361
+ data = page.attributes.clone
362
+ # Pull out the specific, or unnecessary fields
363
+ %w(id parent_id updated_on author position version created_on full_path).each {|key| data.delete(key)}
364
+ if !page.children.empty?
365
+ data['children'] = []
366
+ page.children.each do |child|
367
+ data['children'] << page_to_hash(child)
368
+ end
369
+ end
370
+ data
371
+ end
347
372
 
373
+ def hash_to_page_tree(hsh, page)
374
+ child_ary = hsh.delete 'children'
375
+ page.update_attributes(hsh)
376
+ page.save
377
+ child_ary.each do |child_hsh|
378
+ if child_pg = page.children.find_by_slug( child_hsh['slug'] )
379
+ hash_to_page_tree( child_hsh, child_pg )
380
+ else
381
+ hash_to_page_tree( child_hsh, page.children.create )
382
+ end
383
+ end if child_ary
384
+ end
385
+
348
386
  end
@@ -1,5 +1,6 @@
1
1
  # The controller for serving cms content...
2
2
  class ComatoseController < ActionController::Base
3
+ unloadable
3
4
 
4
5
  before_filter :handle_authorization, :set_content_type
5
6
  after_filter :cache_cms_page
data/rails/init.rb CHANGED
@@ -1,12 +1,3 @@
1
1
  # Init for gem version of Comatose
2
2
 
3
- require 'support/class_options'
4
- require 'acts_as_versioned'
5
- require 'redcloth' unless defined?(RedCloth)
6
- require 'liquid' unless defined?(Liquid)
7
-
8
3
  require 'comatose'
9
- require 'text_filters'
10
-
11
- require 'support/inline_rendering'
12
- require 'support/route_mapper'
@@ -1,4 +1,11 @@
1
1
  <div class="action">
2
+ <% form_tag(url_for(:action => 'import'), :multipart => true, :style => 'display: none;', :id => 'import_form') do %>
3
+ <%= file_field_tag 'import_file' %>
4
+ <%= submit_tag 'Import' %>
5
+ <% end %>
6
+
7
+ <%= link_to 'Import', '#', :id => 'import_link2', :onclick => "$('import_form').setStyle({display: 'inline'}); this.hide();" %>
8
+ <%= link_to 'Export', :controller=>controller.controller_name, :action=>'export' %>
2
9
  <%= link_to 'Clear Page Cache', :controller=>controller.controller_name, :action=>'expire_page_cache' %>
3
10
  </div>
4
11
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: darthapo-comatose
3
3
  version: !ruby/object:Gem::Version
4
- version: "2.0"
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - M@ McCray
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-20 00:00:00 -07:00
12
+ date: 2008-10-10 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -25,9 +25,16 @@ extra_rdoc_files:
25
25
  - SPECS
26
26
  - LICENSE
27
27
  files:
28
+ - CHANGELOG
29
+ - INSTALL
30
+ - LICENSE
31
+ - MANIFEST
32
+ - README.rdoc
33
+ - Rakefile
34
+ - SPECS
28
35
  - about.yml
29
36
  - bin/comatose
30
- - CHANGELOG
37
+ - comatose.gemspec
31
38
  - generators/comatose_migration/comatose_migration_generator.rb
32
39
  - generators/comatose_migration/templates/migration.rb
33
40
  - generators/comatose_migration/templates/v4_upgrade.rb
@@ -35,7 +42,6 @@ files:
35
42
  - generators/comatose_migration/templates/v7_upgrade.rb
36
43
  - generators/comatose_migration/USAGE
37
44
  - init.rb
38
- - INSTALL
39
45
  - install.rb
40
46
  - lib/acts_as_versioned.rb
41
47
  - lib/comatose/comatose_drop.rb
@@ -78,11 +84,7 @@ files:
78
84
  - lib/text_filters/simple.rb
79
85
  - lib/text_filters/textile.rb
80
86
  - lib/text_filters.rb
81
- - LICENSE
82
- - MANIFEST
83
87
  - rails/init.rb
84
- - Rakefile
85
- - README.rdoc
86
88
  - resources/layouts/comatose_admin_template.html.erb
87
89
  - resources/public/images/collapsed.gif
88
90
  - resources/public/images/expanded.gif
@@ -92,19 +94,7 @@ files:
92
94
  - resources/public/images/title-hover-bg.gif
93
95
  - resources/public/javascripts/comatose_admin.js
94
96
  - resources/public/stylesheets/comatose_admin.css
95
- - SPECS
96
97
  - tasks/comatose.rake
97
- - test/behaviors.rb
98
- - test/fixtures/comatose_pages.yml
99
- - test/functional/comatose_admin_controller_test.rb
100
- - test/functional/comatose_controller_test.rb
101
- - test/javascripts/test.html
102
- - test/javascripts/test_runner.js
103
- - test/test_helper.rb
104
- - test/unit/class_options_test.rb
105
- - test/unit/comatose_page_test.rb
106
- - test/unit/processing_context_test.rb
107
- - test/unit/text_filters_test.rb
108
98
  - views/comatose_admin/_form.html.erb
109
99
  - views/comatose_admin/_page_list_item.html.erb
110
100
  - views/comatose_admin/delete.html.erb
@@ -139,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
129
  requirements: []
140
130
 
141
131
  rubyforge_project: comatose
142
- rubygems_version: 1.0.1
132
+ rubygems_version: 1.2.0
143
133
  signing_key:
144
134
  specification_version: 2
145
135
  summary: Micro CMS designed for being embedded into existing Rails applications