staugaard-comatose 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +6 -0
- data/comatose.gemspec +2 -2
- data/lib/comatose_admin_controller.rb +37 -0
- data/views/comatose_admin/index.html.erb +7 -0
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
- version: 2.0.3 (alpha)
|
2
|
+
- staugaard: Added import and export of pages in admin controller
|
3
|
+
|
4
|
+
- version: 2.0.2 (alpha)
|
5
|
+
- staugaard: Added "unloadable" to ComatoseController (problems with ActsAsAuthenticated-integration similar to http://tinyurl.com/6caz5r)
|
6
|
+
|
1
7
|
- version: 2.0.1 (alpha)
|
2
8
|
- Merged changes from andreas (http://github.com/andreas)...
|
3
9
|
- andreas: Fixed comatose:admin:customize raketask (seems plugin_path was wrong, and made use of mkdir_p to avoid "File exists"-errors.)
|
data/comatose.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Generated on Tue May 20 20:13:12 -0500 2008
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = "comatose"
|
4
|
-
s.version = "2.0.
|
5
|
-
s.date = "2008-
|
4
|
+
s.version = "2.0.3"
|
5
|
+
s.date = "2008-10-10" # 2008-05-20
|
6
6
|
s.summary = "Micro CMS designed for being embedded into existing Rails applications"
|
7
7
|
s.email = "matt@elucidata.net"
|
8
8
|
s.rubyforge_project = 'comatose'
|
@@ -140,6 +140,16 @@ class ComatoseAdminController < ActionController::Base
|
|
140
140
|
redirect_to :controller=>self.controller_name, :action=>'index'
|
141
141
|
end
|
142
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
|
143
153
|
|
144
154
|
protected
|
145
155
|
|
@@ -345,5 +355,32 @@ protected
|
|
345
355
|
end
|
346
356
|
end
|
347
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
|
348
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
|
+
|
349
386
|
end
|
@@ -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: staugaard-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-
|
12
|
+
date: 2008-10-10 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|