comfortable_mexican_sofa 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +83 -1
- data/VERSION +1 -1
- data/app/controllers/cms_admin/base_controller.rb +15 -0
- data/app/controllers/cms_admin/layouts_controller.rb +3 -3
- data/app/controllers/cms_admin/pages_controller.rb +8 -8
- data/app/controllers/cms_admin/sites_controller.rb +58 -0
- data/app/controllers/cms_admin/snippets_controller.rb +18 -14
- data/app/controllers/cms_admin/uploads_controller.rb +7 -5
- data/app/controllers/cms_content_controller.rb +17 -5
- data/app/models/cms_layout.rb +7 -7
- data/app/models/cms_page.rb +18 -4
- data/app/models/cms_site.rb +23 -0
- data/app/models/cms_snippet.rb +17 -12
- data/app/models/cms_upload.rb +4 -7
- data/app/views/cms_admin/layouts/_form.html.erb +1 -1
- data/app/views/cms_admin/layouts/index.html.erb +1 -1
- data/app/views/cms_admin/pages/_form.html.erb +3 -2
- data/app/views/cms_admin/pages/_form_blocks.html.erb +1 -1
- data/app/views/cms_admin/pages/_index_branch.html.erb +1 -1
- data/app/views/cms_admin/pages/index.html.erb +1 -1
- data/app/views/cms_admin/sites/_form.html.erb +2 -0
- data/app/views/cms_admin/sites/edit.html.erb +6 -0
- data/app/views/cms_admin/sites/index.html.erb +22 -0
- data/app/views/cms_admin/sites/new.html.erb +6 -0
- data/app/views/cms_admin/snippets/_form.html.erb +2 -1
- data/app/views/cms_admin/snippets/index.html.erb +20 -1
- data/app/views/layouts/cms_admin.html.erb +2 -1
- data/comfortable_mexican_sofa.gemspec +31 -9
- data/config/initializers/comfortable_mexican_sofa.rb +10 -0
- data/config/routes.rb +3 -1
- data/db/migrate/01_create_cms.rb +18 -4
- data/lib/comfortable_mexican_sofa.rb +28 -22
- data/lib/comfortable_mexican_sofa/acts_as_tree.rb +97 -0
- data/lib/comfortable_mexican_sofa/cms_tag/snippet.rb +4 -0
- data/lib/comfortable_mexican_sofa/configuration.rb +19 -0
- data/lib/comfortable_mexican_sofa/controller_methods.rb +41 -0
- data/lib/comfortable_mexican_sofa/{cms_engine.rb → engine.rb} +1 -1
- data/lib/comfortable_mexican_sofa/{cms_form_builder.rb → form_builder.rb} +1 -1
- data/lib/comfortable_mexican_sofa/http_auth.rb +17 -0
- data/lib/comfortable_mexican_sofa/rails_extensions.rb +11 -0
- data/lib/comfortable_mexican_sofa/view_methods.rb +33 -0
- data/lib/generators/cms_generator.rb +4 -0
- data/public/stylesheets/comfortable_mexican_sofa/structure.css +10 -12
- data/test/fixtures/cms_layouts.yml +3 -1
- data/test/fixtures/cms_pages.yml +6 -2
- data/test/fixtures/cms_sites.yml +3 -0
- data/test/fixtures/cms_snippets.yml +3 -1
- data/test/fixtures/cms_uploads.yml +1 -0
- data/test/functional/cms_admin/layouts_controller_test.rb +3 -1
- data/test/functional/cms_admin/pages_controller_test.rb +4 -2
- data/test/functional/cms_admin/sites_controller_test.rb +92 -0
- data/test/functional/cms_admin/snippets_controller_test.rb +62 -37
- data/test/functional/cms_content_controller_test.rb +32 -5
- data/test/integration/authentication_test.rb +27 -0
- data/test/integration/render_cms_test.rb +57 -0
- data/test/integration/sites_test.rb +30 -0
- data/test/test_helper.rb +46 -3
- data/test/unit/cms_block_test.rb +1 -0
- data/test/unit/cms_configuration_test.rb +16 -0
- data/test/unit/cms_layout_test.rb +3 -3
- data/test/unit/cms_page_test.rb +23 -13
- data/test/unit/cms_site_test.rb +41 -0
- data/test/unit/cms_snippet_test.rb +1 -1
- data/test/unit/cms_tags/snippet_test.rb +1 -1
- data/test/unit/cms_upload_test.rb +7 -6
- metadata +32 -10
- data/lib/comfortable_mexican_sofa/cms_acts_as_tree.rb +0 -101
- data/lib/comfortable_mexican_sofa/cms_rails_extensions.rb +0 -32
- data/test/functional/cms_admin/base_controller_test.rb +0 -9
@@ -0,0 +1,23 @@
|
|
1
|
+
class CmsSite < ActiveRecord::Base
|
2
|
+
|
3
|
+
# -- Relationships --------------------------------------------------------
|
4
|
+
has_many :cms_layouts, :dependent => :destroy
|
5
|
+
has_many :cms_pages, :dependent => :destroy
|
6
|
+
has_many :cms_snippets, :dependent => :destroy
|
7
|
+
has_many :cms_uploads, :dependent => :destroy
|
8
|
+
|
9
|
+
# -- Validations ----------------------------------------------------------
|
10
|
+
validates :label,
|
11
|
+
:presence => true,
|
12
|
+
:uniqueness => true
|
13
|
+
validates :hostname,
|
14
|
+
:presence => true,
|
15
|
+
:uniqueness => true,
|
16
|
+
:format => { :with => /^[\w\.\-]+$/ }
|
17
|
+
|
18
|
+
# -- Class Methods --------------------------------------------------------
|
19
|
+
def self.options_for_select
|
20
|
+
CmsSite.all.collect{|s| ["#{s.label} (#{s.hostname})", s.id]}
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/app/models/cms_snippet.rb
CHANGED
@@ -1,20 +1,25 @@
|
|
1
1
|
class CmsSnippet < ActiveRecord::Base
|
2
|
-
|
3
|
-
# -- Validations ----------------------------------------------------------
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
:uniqueness => true,
|
8
|
-
:format => { :with => /^\w[a-z0-9_-]*$/i }
|
3
|
+
# -- Relationships --------------------------------------------------------
|
4
|
+
belongs_to :cms_site
|
9
5
|
|
6
|
+
# -- Validations ----------------------------------------------------------
|
7
|
+
validates :cms_site_id,
|
8
|
+
:presence => true
|
9
|
+
validates :label,
|
10
|
+
:presence => true
|
11
|
+
validates :slug,
|
12
|
+
:presence => true,
|
13
|
+
:uniqueness => { :scope => :cms_site_id },
|
14
|
+
:format => { :with => /^\w[a-z0-9_-]*$/i }
|
15
|
+
|
10
16
|
# -- Class Methods --------------------------------------------------------
|
11
|
-
|
12
|
-
|
13
|
-
(s = find_by_label(label)) ? s.content : ''
|
17
|
+
def self.content_for(slug)
|
18
|
+
(s = find_by_slug(slug)) ? s.content : ''
|
14
19
|
end
|
15
20
|
|
16
|
-
def self.initialize_or_find(cms_page,
|
17
|
-
|
21
|
+
def self.initialize_or_find(cms_page, slug)
|
22
|
+
find_by_slug(slug) || new(:slug => slug)
|
18
23
|
end
|
19
|
-
|
24
|
+
|
20
25
|
end
|
data/app/models/cms_upload.rb
CHANGED
@@ -7,9 +7,11 @@ class CmsUpload < ActiveRecord::Base
|
|
7
7
|
before_post_process :image?
|
8
8
|
|
9
9
|
# -- Relationships --------------------------------------------------------
|
10
|
-
belongs_to :
|
10
|
+
belongs_to :cms_site
|
11
11
|
|
12
12
|
# -- Validations ----------------------------------------------------------
|
13
|
+
validates :cms_site_id,
|
14
|
+
:presence => true
|
13
15
|
validates_attachment_presence :file
|
14
16
|
|
15
17
|
# -- Instance Methods -----------------------------------------------------
|
@@ -25,12 +27,7 @@ class CmsUpload < ActiveRecord::Base
|
|
25
27
|
end
|
26
28
|
|
27
29
|
def icon
|
28
|
-
|
29
|
-
self.file.url(:thumb)
|
30
|
-
else
|
31
|
-
ext = self.file_file_name.split('.').last
|
32
|
-
FILE_ICONS.include?(ext) ? "cms/file_icons/#{ext}.png" : "cms/file_icons/_blank.png"
|
33
|
-
end
|
30
|
+
self.image?? self.file.url(:thumb) : 'TODO'
|
34
31
|
end
|
35
32
|
|
36
33
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<%= form.text_field :label, :label => 'Layout Name' %>
|
2
|
-
<%= form.select :parent_id, CmsLayout.options_for_select(@cms_layout), :include_blank => true %>
|
2
|
+
<%= form.select :parent_id, CmsLayout.options_for_select(@cms_site, @cms_layout), :include_blank => true %>
|
3
3
|
<%= form.select :app_layout, CmsLayout.app_layouts_for_select, :include_blank => true %>
|
4
4
|
<%= form.text_area :content %>
|
5
5
|
<%= form.text_area :css %>
|
@@ -2,8 +2,9 @@
|
|
2
2
|
|
3
3
|
<div class='page_form_extras'>
|
4
4
|
<%= form.text_field :slug, :id => 'slug' %>
|
5
|
-
<%= form.select :cms_layout_id, CmsLayout.options_for_select, {}, 'data-page-id' => @cms_page.id.to_i, :label => 'Layout' %>
|
6
|
-
<%= form.select :parent_id, CmsPage.options_for_select(@cms_page) %>
|
5
|
+
<%= form.select :cms_layout_id, CmsLayout.options_for_select(@cms_site), {}, 'data-page-id' => @cms_page.id.to_i, :label => 'Layout' %>
|
6
|
+
<%= form.select :parent_id, CmsPage.options_for_select(@cms_site, @cms_page) %>
|
7
|
+
<%= form.select :target_page_id, CmsPage.options_for_select(@cms_site, @cms_page, nil, 0, false), :include_blank => true, :label => 'Redirect To Page' %>
|
7
8
|
</div>
|
8
9
|
|
9
10
|
<%= render :partial => 'form_blocks' %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<div id='form_blocks'>
|
2
|
-
<%= fields_for :cms_blocks, :builder =>
|
2
|
+
<%= fields_for :cms_blocks, :builder => ComfortableMexicanSofa::FormBuilder do |cms_blocks| %>
|
3
3
|
<% @cms_page.cms_tags(true).each do |tag| %>
|
4
4
|
<%= cms_blocks.send(tag.class.to_s.underscore.downcase.idify, tag)%>
|
5
5
|
<% end %>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<%= link_to span_tag('Create New Site'), new_cms_admin_site_path, :class => 'big_button' %>
|
2
|
+
<h1>Sites</h1>
|
3
|
+
|
4
|
+
<ul class='list'>
|
5
|
+
<% @cms_sites.each do |cms_site| %>
|
6
|
+
<li id='cms_site_<%= cms_site.id %>'>
|
7
|
+
<div class='item'>
|
8
|
+
<div class='icon'></div>
|
9
|
+
<div class='action_links'>
|
10
|
+
<%= link_to 'Edit', edit_cms_admin_site_path(cms_site) %>
|
11
|
+
<%= link_to 'Delete', cms_admin_site_path(cms_site), :method => :delete, :confirm => 'Are you sure?' %>
|
12
|
+
</div>
|
13
|
+
<div class='label'>
|
14
|
+
<%= link_to cms_site.label, edit_cms_admin_site_path(cms_site) %>
|
15
|
+
<div class='sublabel'>
|
16
|
+
<%= link_to cms_site.hostname, "http://#{cms_site.hostname}/cms-admin" %>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
</li>
|
21
|
+
<% end %>
|
22
|
+
</ul>
|
@@ -1,3 +1,22 @@
|
|
1
|
+
<%= link_to span_tag('Create New Snippet'), new_cms_admin_snippet_path, :class => 'big_button' %>
|
1
2
|
<h1>Snippets</h1>
|
2
3
|
|
3
|
-
|
4
|
+
<ul class='list'>
|
5
|
+
<% @cms_snippets.each do |cms_snippet| %>
|
6
|
+
<li id='cms_snippet_<%= cms_snippet.id %>'>
|
7
|
+
<div class='item'>
|
8
|
+
<div class='icon'></div>
|
9
|
+
<div class='action_links'>
|
10
|
+
<%= link_to 'Edit', edit_cms_admin_snippet_path(cms_snippet) %>
|
11
|
+
<%= link_to 'Delete', cms_admin_snippet_path(cms_snippet), :method => :delete, :confirm => 'Are you sure?' %>
|
12
|
+
</div>
|
13
|
+
<div class='label'>
|
14
|
+
<%= link_to cms_snippet.label, edit_cms_admin_snippet_path(cms_snippet) %>
|
15
|
+
<div class='sublabel'>
|
16
|
+
<%= link_to cms_snippet.slug, edit_cms_admin_snippet_path(cms_snippet) %>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
</li>
|
21
|
+
<% end %>
|
22
|
+
</ul>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
5
|
-
<title
|
5
|
+
<title><%= ComfortableMexicanSofa.config.cms_title %></title>
|
6
6
|
<%= csrf_meta_tag %>
|
7
7
|
<%= stylesheet_link_tag :cms %>
|
8
8
|
<%= javascript_include_tag :cms %>
|
@@ -12,6 +12,7 @@
|
|
12
12
|
<div class='body_wrapper'>
|
13
13
|
<div class='left_column'>
|
14
14
|
<div class='left_column_content'>
|
15
|
+
<%= active_link_to 'Sites', cms_admin_sites_path %>
|
15
16
|
<%= active_link_to 'Layouts', cms_admin_layouts_path %>
|
16
17
|
<%= active_link_to 'Pages', cms_admin_pages_path %>
|
17
18
|
<%= active_link_to 'Snippets', cms_admin_snippets_path %>
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{comfortable_mexican_sofa}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Oleg Khabarov", "The Working Group Inc"]
|
12
|
-
s.date = %q{2010-10-
|
12
|
+
s.date = %q{2010-10-19}
|
13
13
|
s.description = %q{}
|
14
14
|
s.email = %q{oleg@theworkinggroup.ca}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -26,12 +26,14 @@ Gem::Specification.new do |s|
|
|
26
26
|
"app/controllers/cms_admin/base_controller.rb",
|
27
27
|
"app/controllers/cms_admin/layouts_controller.rb",
|
28
28
|
"app/controllers/cms_admin/pages_controller.rb",
|
29
|
+
"app/controllers/cms_admin/sites_controller.rb",
|
29
30
|
"app/controllers/cms_admin/snippets_controller.rb",
|
30
31
|
"app/controllers/cms_admin/uploads_controller.rb",
|
31
32
|
"app/controllers/cms_content_controller.rb",
|
32
33
|
"app/models/cms_block.rb",
|
33
34
|
"app/models/cms_layout.rb",
|
34
35
|
"app/models/cms_page.rb",
|
36
|
+
"app/models/cms_site.rb",
|
35
37
|
"app/models/cms_snippet.rb",
|
36
38
|
"app/models/cms_upload.rb",
|
37
39
|
"app/views/cms_admin/layouts/_form.html.erb",
|
@@ -46,6 +48,10 @@ Gem::Specification.new do |s|
|
|
46
48
|
"app/views/cms_admin/pages/form_blocks.js.erb",
|
47
49
|
"app/views/cms_admin/pages/index.html.erb",
|
48
50
|
"app/views/cms_admin/pages/new.html.erb",
|
51
|
+
"app/views/cms_admin/sites/_form.html.erb",
|
52
|
+
"app/views/cms_admin/sites/edit.html.erb",
|
53
|
+
"app/views/cms_admin/sites/index.html.erb",
|
54
|
+
"app/views/cms_admin/sites/new.html.erb",
|
49
55
|
"app/views/cms_admin/snippets/_form.html.erb",
|
50
56
|
"app/views/cms_admin/snippets/edit.html.erb",
|
51
57
|
"app/views/cms_admin/snippets/index.html.erb",
|
@@ -64,6 +70,7 @@ Gem::Specification.new do |s|
|
|
64
70
|
"config/environments/development.rb",
|
65
71
|
"config/environments/production.rb",
|
66
72
|
"config/environments/test.rb",
|
73
|
+
"config/initializers/comfortable_mexican_sofa.rb",
|
67
74
|
"config/initializers/mime_types.rb",
|
68
75
|
"config/initializers/paperclip.rb",
|
69
76
|
"config/locales/en.yml",
|
@@ -72,10 +79,7 @@ Gem::Specification.new do |s|
|
|
72
79
|
"db/seeds.rb",
|
73
80
|
"doc/README_FOR_APP",
|
74
81
|
"lib/comfortable_mexican_sofa.rb",
|
75
|
-
"lib/comfortable_mexican_sofa/
|
76
|
-
"lib/comfortable_mexican_sofa/cms_engine.rb",
|
77
|
-
"lib/comfortable_mexican_sofa/cms_form_builder.rb",
|
78
|
-
"lib/comfortable_mexican_sofa/cms_rails_extensions.rb",
|
82
|
+
"lib/comfortable_mexican_sofa/acts_as_tree.rb",
|
79
83
|
"lib/comfortable_mexican_sofa/cms_tag.rb",
|
80
84
|
"lib/comfortable_mexican_sofa/cms_tag/field_datetime.rb",
|
81
85
|
"lib/comfortable_mexican_sofa/cms_tag/field_integer.rb",
|
@@ -87,6 +91,13 @@ Gem::Specification.new do |s|
|
|
87
91
|
"lib/comfortable_mexican_sofa/cms_tag/page_text.rb",
|
88
92
|
"lib/comfortable_mexican_sofa/cms_tag/partial.rb",
|
89
93
|
"lib/comfortable_mexican_sofa/cms_tag/snippet.rb",
|
94
|
+
"lib/comfortable_mexican_sofa/configuration.rb",
|
95
|
+
"lib/comfortable_mexican_sofa/controller_methods.rb",
|
96
|
+
"lib/comfortable_mexican_sofa/engine.rb",
|
97
|
+
"lib/comfortable_mexican_sofa/form_builder.rb",
|
98
|
+
"lib/comfortable_mexican_sofa/http_auth.rb",
|
99
|
+
"lib/comfortable_mexican_sofa/rails_extensions.rb",
|
100
|
+
"lib/comfortable_mexican_sofa/view_methods.rb",
|
90
101
|
"lib/generators/README",
|
91
102
|
"lib/generators/cms_generator.rb",
|
92
103
|
"public/404.html",
|
@@ -113,20 +124,26 @@ Gem::Specification.new do |s|
|
|
113
124
|
"test/fixtures/cms_blocks.yml",
|
114
125
|
"test/fixtures/cms_layouts.yml",
|
115
126
|
"test/fixtures/cms_pages.yml",
|
127
|
+
"test/fixtures/cms_sites.yml",
|
116
128
|
"test/fixtures/cms_snippets.yml",
|
117
129
|
"test/fixtures/cms_uploads.yml",
|
118
130
|
"test/fixtures/files/invalid_file.gif",
|
119
131
|
"test/fixtures/files/valid_image.jpg",
|
120
|
-
"test/functional/cms_admin/base_controller_test.rb",
|
121
132
|
"test/functional/cms_admin/layouts_controller_test.rb",
|
122
133
|
"test/functional/cms_admin/pages_controller_test.rb",
|
134
|
+
"test/functional/cms_admin/sites_controller_test.rb",
|
123
135
|
"test/functional/cms_admin/snippets_controller_test.rb",
|
124
136
|
"test/functional/cms_admin/uploads_controller_test.rb",
|
125
137
|
"test/functional/cms_content_controller_test.rb",
|
138
|
+
"test/integration/authentication_test.rb",
|
139
|
+
"test/integration/render_cms_test.rb",
|
140
|
+
"test/integration/sites_test.rb",
|
126
141
|
"test/test_helper.rb",
|
127
142
|
"test/unit/cms_block_test.rb",
|
143
|
+
"test/unit/cms_configuration_test.rb",
|
128
144
|
"test/unit/cms_layout_test.rb",
|
129
145
|
"test/unit/cms_page_test.rb",
|
146
|
+
"test/unit/cms_site_test.rb",
|
130
147
|
"test/unit/cms_snippet_test.rb",
|
131
148
|
"test/unit/cms_tag_test.rb",
|
132
149
|
"test/unit/cms_tags/field_datetime_test.rb",
|
@@ -148,16 +165,21 @@ Gem::Specification.new do |s|
|
|
148
165
|
s.rubygems_version = %q{1.3.7}
|
149
166
|
s.summary = %q{ComfortableMexicanSofa is a Rails Engine CMS gem}
|
150
167
|
s.test_files = [
|
151
|
-
"test/functional/cms_admin/
|
152
|
-
"test/functional/cms_admin/layouts_controller_test.rb",
|
168
|
+
"test/functional/cms_admin/layouts_controller_test.rb",
|
153
169
|
"test/functional/cms_admin/pages_controller_test.rb",
|
170
|
+
"test/functional/cms_admin/sites_controller_test.rb",
|
154
171
|
"test/functional/cms_admin/snippets_controller_test.rb",
|
155
172
|
"test/functional/cms_admin/uploads_controller_test.rb",
|
156
173
|
"test/functional/cms_content_controller_test.rb",
|
174
|
+
"test/integration/authentication_test.rb",
|
175
|
+
"test/integration/render_cms_test.rb",
|
176
|
+
"test/integration/sites_test.rb",
|
157
177
|
"test/test_helper.rb",
|
158
178
|
"test/unit/cms_block_test.rb",
|
179
|
+
"test/unit/cms_configuration_test.rb",
|
159
180
|
"test/unit/cms_layout_test.rb",
|
160
181
|
"test/unit/cms_page_test.rb",
|
182
|
+
"test/unit/cms_site_test.rb",
|
161
183
|
"test/unit/cms_snippet_test.rb",
|
162
184
|
"test/unit/cms_tag_test.rb",
|
163
185
|
"test/unit/cms_tags/field_datetime_test.rb",
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Comfortable Mexican Sofa initializer. Change defaults to whatever you require
|
2
|
+
|
3
|
+
ComfortableMexicanSofa.configure do |config|
|
4
|
+
config.cms_title = 'ComfortableMexicanSofa'
|
5
|
+
config.authentication = 'ComfortableMexicanSofa::HttpAuth'
|
6
|
+
end
|
7
|
+
|
8
|
+
# Credentials for CmsHttpAuthentication
|
9
|
+
ComfortableMexicanSofa::HttpAuth.username = 'username'
|
10
|
+
ComfortableMexicanSofa::HttpAuth.password = 'password'
|
data/config/routes.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
2
|
|
3
3
|
namespace :cms_admin, :path => 'cms-admin', :except => :show do
|
4
|
-
|
4
|
+
get '/' => redirect('/cms-admin/pages')
|
5
5
|
resources :pages do
|
6
6
|
member do
|
7
7
|
match :form_blocks
|
8
8
|
end
|
9
9
|
end
|
10
|
+
resources :sites
|
11
|
+
resources :layouts
|
10
12
|
resources :snippets
|
11
13
|
resources :uploads
|
12
14
|
end
|
data/db/migrate/01_create_cms.rb
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
class CreateCms < ActiveRecord::Migration
|
2
2
|
|
3
3
|
def self.up
|
4
|
+
# -- Sites --------------------------------------------------------------
|
5
|
+
create_table :cms_sites do |t|
|
6
|
+
t.string :label
|
7
|
+
t.string :hostname
|
8
|
+
end
|
9
|
+
add_index :cms_sites, :hostname
|
4
10
|
|
5
11
|
# -- Layouts ------------------------------------------------------------
|
6
12
|
create_table :cms_layouts do |t|
|
13
|
+
t.integer :cms_site_id
|
7
14
|
t.integer :parent_id
|
8
15
|
t.string :app_layout
|
9
16
|
t.string :label
|
@@ -13,13 +20,15 @@ class CreateCms < ActiveRecord::Migration
|
|
13
20
|
t.integer :position, :null => false, :default => 0
|
14
21
|
t.timestamps
|
15
22
|
end
|
16
|
-
add_index :cms_layouts, :label
|
23
|
+
add_index :cms_layouts, [:cms_site_id, :label]
|
17
24
|
add_index :cms_layouts, [:parent_id, :position]
|
18
25
|
|
19
26
|
# -- Pages --------------------------------------------------------------
|
20
27
|
create_table :cms_pages do |t|
|
28
|
+
t.integer :cms_site_id
|
21
29
|
t.integer :cms_layout_id
|
22
30
|
t.integer :parent_id
|
31
|
+
t.integer :target_page_id
|
23
32
|
t.string :label
|
24
33
|
t.string :slug
|
25
34
|
t.string :full_path
|
@@ -28,7 +37,7 @@ class CreateCms < ActiveRecord::Migration
|
|
28
37
|
t.integer :children_count, :null => false, :default => 0
|
29
38
|
t.timestamps
|
30
39
|
end
|
31
|
-
add_index :cms_pages, :full_path
|
40
|
+
add_index :cms_pages, [:cms_site_id, :full_path]
|
32
41
|
add_index :cms_pages, [:parent_id, :position]
|
33
42
|
|
34
43
|
# -- Page Blocks --------------------------------------------------------
|
@@ -43,27 +52,32 @@ class CreateCms < ActiveRecord::Migration
|
|
43
52
|
t.timestamps
|
44
53
|
end
|
45
54
|
add_index :cms_blocks, [:cms_page_id, :type, :label]
|
46
|
-
# TODO: index this
|
47
55
|
|
48
56
|
# -- Snippets -----------------------------------------------------------
|
49
57
|
create_table :cms_snippets do |t|
|
58
|
+
t.integer :cms_site_id
|
50
59
|
t.string :label
|
60
|
+
t.string :slug
|
51
61
|
t.text :content
|
52
62
|
t.timestamps
|
53
63
|
end
|
54
|
-
add_index :cms_snippets, :
|
64
|
+
add_index :cms_snippets, [:cms_site_id, :slug], :unique => true
|
55
65
|
|
56
66
|
# -- Assets -------------------------------------------------------------
|
57
67
|
create_table :cms_uploads do |t|
|
68
|
+
t.integer :cms_site_id
|
58
69
|
t.string :file_file_name
|
59
70
|
t.string :file_content_type
|
60
71
|
t.integer :file_file_size
|
61
72
|
t.timestamps
|
62
73
|
end
|
74
|
+
add_index :cms_uploads, [:cms_site_id, :file_file_name]
|
63
75
|
|
64
76
|
end
|
65
77
|
|
66
78
|
def self.down
|
79
|
+
drop_table :cms_sites
|
80
|
+
drop_table :cms_hosts
|
67
81
|
drop_table :cms_layouts
|
68
82
|
drop_table :cms_pages
|
69
83
|
drop_table :cms_snippets
|