site_logic 1.9.0 → 1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/VERSION +1 -1
- data/app/controllers/admin/pages_controller.rb +19 -16
- data/app/models/page.rb +1 -1
- data/site_logic.gemspec +5 -5
- data/spec/models/page_spec.rb +11 -21
- metadata +8 -8
data/Gemfile
CHANGED
@@ -6,7 +6,7 @@ gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid'
|
|
6
6
|
gem 'ckeditor', :git => 'git://github.com/Bantik/rails-ckeditor.git', :branch => 'rails3_mongoid'
|
7
7
|
gem 'mongoid', '>= 2.0.0.beta.17'
|
8
8
|
gem 'mongoid-tree', :require => 'mongoid/tree'
|
9
|
-
gem 'rails', '
|
9
|
+
gem 'rails', '3.0.10'
|
10
10
|
gem 'rmagick', '2.12.2' # version compatible with heroku
|
11
11
|
gem 'scaffold_logic', '>= 1.0.3'
|
12
12
|
gem 'SystemTimer'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.9.
|
1
|
+
1.9.1
|
@@ -26,14 +26,14 @@ class Admin::PagesController < ApplicationController
|
|
26
26
|
|
27
27
|
def create
|
28
28
|
if params[:commit] == 'Preview'
|
29
|
-
@page = @site.pages.new
|
29
|
+
@page = @site.pages.new params[:page]
|
30
30
|
render :action => 'preview', :layout => @site.layout
|
31
31
|
else
|
32
|
-
@page = @site.pages.create
|
32
|
+
@page = @site.pages.create params[:page]
|
33
33
|
if @page.valid?
|
34
34
|
@page.publish! if params[:page][:state] == 'Published'
|
35
|
-
flash[:notice] =
|
36
|
-
if params[:page][:create_navigation_item] ==
|
35
|
+
flash[:notice] = 'Successfully created the page.'
|
36
|
+
if params[:page][:create_navigation_item] == 'true'
|
37
37
|
redirect_to new_admin_site_nav_item_path(
|
38
38
|
@site,
|
39
39
|
:nav_item => {
|
@@ -44,7 +44,7 @@ class Admin::PagesController < ApplicationController
|
|
44
44
|
:creating_page => true
|
45
45
|
)
|
46
46
|
else
|
47
|
-
|
47
|
+
redirect_after_write
|
48
48
|
end
|
49
49
|
else
|
50
50
|
render :action => 'new'
|
@@ -57,14 +57,14 @@ class Admin::PagesController < ApplicationController
|
|
57
57
|
|
58
58
|
def update
|
59
59
|
if params[:commit] == 'Preview'
|
60
|
-
@page = @site.pages.new
|
60
|
+
@page = @site.pages.new params[:page]
|
61
61
|
render :action => 'preview', :layout => @page.site.layout
|
62
62
|
else
|
63
|
-
if @page.update_attributes
|
63
|
+
if @page.update_attributes params[:page]
|
64
64
|
@page.publish! if params[:page][:state] == 'Published'
|
65
65
|
@page.unpublish! if params[:page][:state] == 'Draft'
|
66
|
-
flash[:notice] =
|
67
|
-
|
66
|
+
flash[:notice] = 'Successfully updated the page.'
|
67
|
+
redirect_after_write
|
68
68
|
else
|
69
69
|
render :action => 'edit'
|
70
70
|
end
|
@@ -73,23 +73,26 @@ class Admin::PagesController < ApplicationController
|
|
73
73
|
|
74
74
|
def destroy
|
75
75
|
@page.destroy
|
76
|
-
flash[:notice] =
|
77
|
-
|
76
|
+
flash[:notice] = 'Successfully destroyed the page.'
|
77
|
+
redirect_after_write
|
78
78
|
end
|
79
79
|
|
80
80
|
def preview
|
81
|
-
@page = @site.pages.new
|
81
|
+
@page = @site.pages.new params[:page]
|
82
82
|
render :layout => @page.site.layout
|
83
83
|
end
|
84
84
|
|
85
85
|
private
|
86
86
|
|
87
|
+
def redirect_after_write
|
88
|
+
redirect_to Site.count > 1 ? admin_site_path(@site) : admin_site_pages_path(@site)
|
89
|
+
end
|
90
|
+
|
87
91
|
def scope_site
|
88
|
-
@site = Site.find
|
92
|
+
@site = Site.find params[:site_id]
|
89
93
|
end
|
90
94
|
|
91
95
|
def scope_page
|
92
|
-
@page = @site.pages.find
|
96
|
+
@page = @site.pages.find params[:id]
|
93
97
|
end
|
94
|
-
|
95
|
-
end
|
98
|
+
end
|
data/app/models/page.rb
CHANGED
data/site_logic.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "site_logic"
|
8
|
-
s.version = "1.9.
|
8
|
+
s.version = "1.9.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Bantik"]
|
12
|
-
s.date = "2011-09-
|
12
|
+
s.date = "2011-09-27"
|
13
13
|
s.description = "An engine for search-engine-optimized content management."
|
14
14
|
s.email = "corey@seologic.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -832,7 +832,7 @@ Gem::Specification.new do |s|
|
|
832
832
|
s.add_runtime_dependency(%q<ckeditor>, [">= 0"])
|
833
833
|
s.add_runtime_dependency(%q<mongoid>, [">= 2.0.0.beta.17"])
|
834
834
|
s.add_runtime_dependency(%q<mongoid-tree>, [">= 0"])
|
835
|
-
s.add_runtime_dependency(%q<rails>, ["
|
835
|
+
s.add_runtime_dependency(%q<rails>, ["= 3.0.10"])
|
836
836
|
s.add_runtime_dependency(%q<rmagick>, ["= 2.12.2"])
|
837
837
|
s.add_runtime_dependency(%q<scaffold_logic>, [">= 1.0.3"])
|
838
838
|
s.add_runtime_dependency(%q<SystemTimer>, [">= 0"])
|
@@ -845,7 +845,7 @@ Gem::Specification.new do |s|
|
|
845
845
|
s.add_dependency(%q<ckeditor>, [">= 0"])
|
846
846
|
s.add_dependency(%q<mongoid>, [">= 2.0.0.beta.17"])
|
847
847
|
s.add_dependency(%q<mongoid-tree>, [">= 0"])
|
848
|
-
s.add_dependency(%q<rails>, ["
|
848
|
+
s.add_dependency(%q<rails>, ["= 3.0.10"])
|
849
849
|
s.add_dependency(%q<rmagick>, ["= 2.12.2"])
|
850
850
|
s.add_dependency(%q<scaffold_logic>, [">= 1.0.3"])
|
851
851
|
s.add_dependency(%q<SystemTimer>, [">= 0"])
|
@@ -859,7 +859,7 @@ Gem::Specification.new do |s|
|
|
859
859
|
s.add_dependency(%q<ckeditor>, [">= 0"])
|
860
860
|
s.add_dependency(%q<mongoid>, [">= 2.0.0.beta.17"])
|
861
861
|
s.add_dependency(%q<mongoid-tree>, [">= 0"])
|
862
|
-
s.add_dependency(%q<rails>, ["
|
862
|
+
s.add_dependency(%q<rails>, ["= 3.0.10"])
|
863
863
|
s.add_dependency(%q<rmagick>, ["= 2.12.2"])
|
864
864
|
s.add_dependency(%q<scaffold_logic>, [">= 1.0.3"])
|
865
865
|
s.add_dependency(%q<SystemTimer>, [">= 0"])
|
data/spec/models/page_spec.rb
CHANGED
@@ -1,19 +1,17 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
3
|
describe Page do
|
4
|
-
|
5
4
|
before :all do
|
6
5
|
Site.destroy_all
|
7
6
|
@site = Site.make
|
8
7
|
end
|
9
8
|
|
10
|
-
describe
|
11
|
-
|
12
|
-
it "should be invalid without required values" do
|
9
|
+
describe 'initialization' do
|
10
|
+
it 'should be invalid without required values' do
|
13
11
|
@site.pages.new.valid?.should be_false
|
14
12
|
end
|
15
13
|
|
16
|
-
it
|
14
|
+
it 'should be valid with required values' do
|
17
15
|
@site.pages.new(
|
18
16
|
:page_title => 'Home',
|
19
17
|
:desired_slug => 'home',
|
@@ -21,7 +19,7 @@ describe Page do
|
|
21
19
|
).should be_valid
|
22
20
|
end
|
23
21
|
|
24
|
-
it
|
22
|
+
it 'should not allow duplicate slugs' do
|
25
23
|
@site.pages.create(
|
26
24
|
:page_title => 'Foo',
|
27
25
|
:slug => 'foo',
|
@@ -41,11 +39,9 @@ describe Page do
|
|
41
39
|
it 'defaults its state to Draft' do
|
42
40
|
@site.pages.new.status.should == 'Draft'
|
43
41
|
end
|
44
|
-
|
45
42
|
end
|
46
43
|
|
47
44
|
describe 'publishing lifecycle' do
|
48
|
-
|
49
45
|
it 'defaults a new page to draft status' do
|
50
46
|
page = @site.pages.new
|
51
47
|
page.draft?.should be_true
|
@@ -75,11 +71,9 @@ describe Page do
|
|
75
71
|
page.draft?.should be_true
|
76
72
|
page.publication_date.should be_nil
|
77
73
|
end
|
78
|
-
|
79
74
|
end
|
80
75
|
|
81
76
|
describe 'slug' do
|
82
|
-
|
83
77
|
it 'is generated based on the desired_slug' do
|
84
78
|
page = @site.pages.create(
|
85
79
|
:page_title => 'Snakes',
|
@@ -106,31 +100,27 @@ describe Page do
|
|
106
100
|
)
|
107
101
|
page.slug.should == 'sinews-really'
|
108
102
|
end
|
109
|
-
|
110
103
|
end
|
111
104
|
|
112
|
-
describe '
|
113
|
-
|
105
|
+
describe 'normalizes its path' do
|
114
106
|
it 'defaulting to root' do
|
115
|
-
Page.new(:slug => nil).
|
107
|
+
Page.new(:slug => nil).path.should == '/'
|
116
108
|
end
|
117
109
|
|
118
110
|
it 'handling no slashes' do
|
119
|
-
Page.new(:slug => 'foo').
|
111
|
+
Page.new(:slug => 'foo').path.should == '/foo'
|
120
112
|
end
|
121
113
|
|
122
114
|
it 'handling leading slash' do
|
123
|
-
Page.new(:slug => '/foo').
|
115
|
+
Page.new(:slug => '/foo').path.should == '/foo'
|
124
116
|
end
|
125
117
|
|
126
118
|
it 'handling trailing slash' do
|
127
|
-
Page.new(:slug => 'foo/').
|
119
|
+
Page.new(:slug => 'foo/').path.should == '/foo/'
|
128
120
|
end
|
129
121
|
|
130
122
|
it 'handling all kindsa slash action' do
|
131
|
-
Page.new(:slug => '/foo/').
|
123
|
+
Page.new(:slug => '/foo/').path.should == '/foo/'
|
132
124
|
end
|
133
|
-
|
134
125
|
end
|
135
|
-
|
136
|
-
end
|
126
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: site_logic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 49
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 1.9.
|
9
|
+
- 1
|
10
|
+
version: 1.9.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bantik
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-09-
|
18
|
+
date: 2011-09-27 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: bson_ext
|
@@ -97,14 +97,14 @@ dependencies:
|
|
97
97
|
requirement: &id006 !ruby/object:Gem::Requirement
|
98
98
|
none: false
|
99
99
|
requirements:
|
100
|
-
- - "
|
100
|
+
- - "="
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
hash:
|
102
|
+
hash: 19
|
103
103
|
segments:
|
104
104
|
- 3
|
105
105
|
- 0
|
106
|
-
-
|
107
|
-
version: 3.0.
|
106
|
+
- 10
|
107
|
+
version: 3.0.10
|
108
108
|
type: :runtime
|
109
109
|
version_requirements: *id006
|
110
110
|
- !ruby/object:Gem::Dependency
|