Skip to content

Commit 8b5b7d0

Browse files
committed
* Added configuration option for importing/exporting pages from admin: config.allow_import_export = true|false, true is the default at the moment
* Reworked the UI for import/export a little bit * Added LINK option to `test_harness` rake task to symlink the comatose plugin directory instead of copying it * Updated manifest and gemspec
1 parent 484adfe commit 8b5b7d0

14 files changed

+99
-25
lines changed

CHANGELOG

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
- version: 2.0.5 (beta)
2+
- Added configuration option for importing/exporting pages from admin: `config.allow_import_export = true|false`, `true` is the default at the moment
3+
- Reworked the UI for import/export a little bit
4+
- Added LINK option to `test_harness` rake task to symlink the comatose plugin directory instead of copying it
5+
- Updated manifest and gemspec
6+
17
- version: 2.0.4 (beta)
28
- Added a rake task to generate a test_harness (for use in development). From the comatose directory, run: `rake test_harness TARGET=../comatose_test_harness`. This will create an empty rails app, copy this working folder over to vendor/plugins/comatose, install acts_as_list and acts_as_tree, and run any setup needed, like script/generate comatose_migration and rake db:migrate.
39
- Bugfix in tasks/comatose.rake

MANIFEST

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ LICENSE
5555
MANIFEST
5656
rails/init.rb
5757
Rakefile
58-
README.rdoc
58+
README.markdown
5959
resources/layouts/comatose_admin_template.html.erb
6060
resources/public/images/collapsed.gif
6161
resources/public/images/expanded.gif

README.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Comatose
22

3-
* Version: 2.0.4 (beta)
3+
* Version: 2.0.5 (beta)
44
* Author: M@ McCray
55
* Website: comatose.rubyforge.org
66
* Email: matt at elucidata dot net

Rakefile

+6-1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ end
125125
desc "Creates an empty rails application for use as a test harness"
126126
task :test_harness do
127127
target = ENV['TARGET']
128+
sym_link = (ENV['LINK'].to_s == 'true')
128129
if target.nil?
129130
puts "You must specify a TARGET for the test harness"
130131
exit(1)
@@ -139,7 +140,11 @@ task :test_harness do
139140

140141
puts "Creating test harness at #{ target }"
141142
run_sh "rails -d sqlite3 #{target}"
142-
run_sh "cp -r #{ File.dirname(__FILE__) }/ #{ comatose_plugin_path }"
143+
if sym_link
144+
run_sh "ln -s #{ File.dirname(__FILE__) } #{ comatose_plugin_path }"
145+
else
146+
run_sh "cp -r #{ File.dirname(__FILE__) }/ #{ comatose_plugin_path }"
147+
end
143148
run_sh "ruby #{ comatose_plugin_path / 'install.rb' }"
144149
run_sh "ruby #{ target / 'script' / 'generate' } comatose_migration"
145150
run_sh "ruby #{ comatose_plugin_path / 'bin' / 'comatose' } --plugin #{ target }"

about.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ summary: A micro CMS for embedding in Rails applications.
33
homepage: http://comatose.rubyforge.org
44
plugin: git://github.com/darthapo/comatose.git
55
license: MIT
6-
version: 2.0.4
6+
version: 2.0.5
77
rails_version: 2+

bin/comatose

+3
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ Comatose.configure do |config|
9797
# current_user.login
9898
#end
9999
100+
# Allows users to import and export pages (in YAML format)
101+
#config.allow_import_export = true
102+
100103
# See the getting started guide at http://comatose.rubyforge.org for more...
101104
end
102105
EOT

comatose.gemspec

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Generated on Tue May 20 20:13:12 -0500 2008
22
Gem::Specification.new do |s|
33
s.name = "comatose"
4-
s.version = "2.0.4"
5-
s.date = "2008-10-10" # 2008-05-20
4+
s.version = "2.0.5"
5+
s.date = "2008-10-31" # 2008-05-20
66
s.summary = "Micro CMS designed for being embedded into existing Rails applications"
77
s.email = "[email protected]"
88
s.rubyforge_project = 'comatose'
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
1717
"INSTALL",
1818
"LICENSE",
1919
"MANIFEST",
20-
"README.rdoc",
20+
"README.markdown",
2121
"Rakefile",
2222
"SPECS",
2323
"about.yml",
@@ -107,7 +107,7 @@ Gem::Specification.new do |s|
107107
"test/unit/processing_context_test.rb",
108108
"test/unit/text_filters_test.rb"]
109109

110-
s.rdoc_options = ["--main", "README.rdoc"]
111-
s.extra_rdoc_files = %w(README.rdoc CHANGELOG SPECS LICENSE)
110+
s.rdoc_options = ["--main", "README.markdown"]
111+
s.extra_rdoc_files = %w(README.markdown CHANGELOG SPECS LICENSE)
112112
#s.add_dependency("mime-types", ["> 0.0.0"])
113113
end

install.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'fileutils'
22

33
# Copy the images (*.gif) into RAILS_ROOT/public/images/comatose
4-
RAILS_ROOT = File.join(File.dirname(__FILE__), '../../../')
4+
RAILS_ROOT = File.expand_path( File.join(File.dirname(__FILE__), '../../../') )
55

66
unless FileTest.exist? File.join(RAILS_ROOT, 'public', 'images', 'comatose')
77
FileUtils.mkdir( File.join(RAILS_ROOT, 'public', 'images', 'comatose') )

lib/comatose/configuration.rb

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Configuration
3636
attr_accessor_with_default :hidden_meta_fields, []
3737
attr_accessor_with_default :helpers, []
3838
attr_accessor_with_default :includes, []
39+
attr_accessor_with_default :allow_import_export, true
3940

4041
# 'Blockable' setters
4142
blockable_attr_accessor :authorization

lib/comatose/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module Comatose
2-
VERSION = "2.0.4"
2+
VERSION = "2.0.5"
33
VERSION_STRING = "#{VERSION} (beta)"
44
end

lib/comatose_admin_controller.rb

+13-4
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,22 @@ def generate_page_cache
141141
end
142142

143143
def export
144-
send_data(page_to_hash(ComatosePage.root).to_yaml, :disposition => 'inline', :type => 'text/yaml', :filename => "comatose-pages.yml")
144+
if Comatose.config.allow_import_export
145+
send_data(page_to_hash(ComatosePage.root).to_yaml, :disposition => 'attachment', :type => 'text/yaml', :filename => "comatose-pages.yml")
146+
else
147+
flash[:notice] = "Export is not allowed"
148+
redirect_to :controller=>self.controller_name, :action=>'index'
149+
end
145150
end
146151

147152
def import
148-
data = YAML::load(params[:import_file])
149-
hash_to_page_tree(data, ComatosePage.root)
150-
flash[:notice] = "Pages Imported Successfully"
153+
if Comatose.config.allow_import_export
154+
data = YAML::load(params[:import_file])
155+
hash_to_page_tree(data, ComatosePage.root)
156+
flash[:notice] = "Pages Imported Successfully"
157+
else
158+
flash[:notice] = "Import isn't allowed"
159+
end
151160
redirect_to :controller=>self.controller_name, :action=>'index'
152161
end
153162

resources/public/stylesheets/comatose_admin.css

+25-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ BODY {
6060
#content .action A {
6161
font-weight: bold;
6262
text-decoration: none;
63-
color: darkgreen;
64-
border-bottom: 1px solid black;
63+
color: navy;
64+
border-bottom: 1px solid blue;
65+
margin-left: 15px;
6566
}
6667
#content .action A:hover {
6768
color: red;
@@ -70,6 +71,28 @@ BODY {
7071
#content .page-header {
7172
color: gray;
7273
}
74+
#import_form {
75+
position: fixed;
76+
right: 75px;
77+
border: 3px solid gray !important;
78+
-webkit-border-radius: 10px;
79+
-moz-border-radius: 10px;
80+
background: #FFF;
81+
padding: 15px;
82+
}
83+
#import_form FORM {
84+
display: inline;
85+
margin: 0px;
86+
padding: 0px;
87+
}
88+
#import_form A {
89+
color: maroon !important;
90+
border-bottom: 1px solid gray !important;
91+
}
92+
#import_form A:hover {
93+
color: red !important;
94+
border-bottom: 1px solid red !important;
95+
}
7396

7497
/* Page Listing */
7598
#content .tree-controller {

views/comatose_admin/index.html.erb

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<div class="action">
2-
<% form_tag(url_for(:action => 'import'), :multipart => true, :style => 'display: none;', :id => 'import_form') do %>
2+
<%= link_to 'Clear Page Cache', :controller=>controller.controller_name, :action=>'expire_page_cache' %>
3+
<% if Comatose.config.allow_import_export %>
4+
<%= link_to 'Import', '#', :id => 'import_link2', :onclick => "$('import_form').setStyle({display: 'inline'}); return false;" %>
5+
<%= link_to 'Export', :controller=>controller.controller_name, :action=>'export' %>
6+
<div id="import_form" style="display: none;">
7+
<% form_tag(url_for(:action => 'import'), :multipart => true) do %>
38
<%= file_field_tag 'import_file' %>
4-
<%= submit_tag 'Import' %>
9+
<%= submit_tag 'Upload and Import' %>
10+
<a href="#" onclick="$('import_form').hide(); return false;">Cancel</a>
511
<% 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' %>
9-
<%= link_to 'Clear Page Cache', :controller=>controller.controller_name, :action=>'expire_page_cache' %>
12+
</div>
13+
<% end %>
1014
</div>
1115

1216
<h1>

views/layouts/comatose_admin.html.erb

+25-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ BODY {
6767
#content .action A {
6868
font-weight: bold;
6969
text-decoration: none;
70-
color: darkgreen;
71-
border-bottom: 1px solid black;
70+
color: navy;
71+
border-bottom: 1px solid blue;
72+
margin-left: 15px;
7273
}
7374
#content .action A:hover {
7475
color: red;
@@ -77,6 +78,28 @@ BODY {
7778
#content .page-header {
7879
color: gray;
7980
}
81+
#import_form {
82+
position: fixed;
83+
right: 75px;
84+
border: 3px solid gray !important;
85+
-webkit-border-radius: 10px;
86+
-moz-border-radius: 10px;
87+
background: #FFF;
88+
padding: 15px;
89+
}
90+
#import_form FORM {
91+
display: inline;
92+
margin: 0px;
93+
padding: 0px;
94+
}
95+
#import_form A {
96+
color: maroon !important;
97+
border-bottom: 1px solid gray !important;
98+
}
99+
#import_form A:hover {
100+
color: red !important;
101+
border-bottom: 1px solid red !important;
102+
}
80103

81104
/* Page Listing */
82105
#content .tree-controller {

0 commit comments

Comments
 (0)