tb_cms 1.3.beta1 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +0 -9
- data/app/assets/javascripts/admin/cms/menu_items.js +12 -6
- data/app/assets/javascripts/admin/cms/pages.js +3 -0
- data/app/controllers/cms/sitemaps_controller.rb +1 -1
- data/app/controllers/pages_controller.rb +4 -4
- data/app/helpers/cms/application_helper.rb +4 -4
- data/app/models/spud_menu_item.rb +3 -3
- data/app/models/spud_page.rb +21 -10
- data/app/models/spud_page_partial.rb +3 -20
- data/app/models/spud_snippet.rb +1 -4
- data/app/views/admin/pages/show.html.erb +12 -15
- data/app/views/pages/show.html.erb +2 -2
- data/db/migrate/20120101192412_create_spud_pages.rb +1 -1
- data/db/migrate/20120101193138_create_spud_menus.rb +1 -1
- data/db/migrate/20120101193255_create_spud_menu_items.rb +1 -1
- data/db/migrate/20120101194124_create_spud_templates.rb +1 -1
- data/db/migrate/20120103034659_create_spud_page_partials.rb +1 -1
- data/db/migrate/20120104194032_add_visibility_to_spud_pages.rb +1 -1
- data/db/migrate/20120107181337_add_menu_name_to_spud_menu_items.rb +1 -1
- data/db/migrate/20120111134754_add_use_custom_url_name_to_spud_pages.rb +1 -1
- data/db/migrate/20120118141852_add_notes_to_spud_pages.rb +1 -1
- data/db/migrate/20120126232428_add_menu_id_to_spud_menu_items.rb +1 -1
- data/db/migrate/20120128163601_add_classes_to_spud_menu_items.rb +1 -1
- data/db/migrate/20120329132314_add_site_id_to_spud_pages.rb +1 -1
- data/db/migrate/20120329132322_add_site_id_to_spud_templates.rb +1 -1
- data/db/migrate/20120329132330_add_site_id_to_spud_menus.rb +1 -1
- data/db/migrate/20120510195151_create_spud_page_partial_revisions.rb +1 -1
- data/db/migrate/20120911190030_add_symbol_name_to_spud_page_partials.rb +1 -1
- data/db/migrate/20120912121313_modify_site_id_for_spud_pages.rb +1 -1
- data/db/migrate/20121016233715_add_content_processed_to_spud_page_partials.rb +1 -1
- data/db/migrate/20121112151110_add_layout_to_spud_pages.rb +1 -1
- data/db/migrate/20121119025608_create_spud_snippets.rb +1 -1
- data/db/migrate/20150108162839_remove_site_id_from_cms_tables.rb +1 -1
- data/db/migrate/20150622161403_add_title_tag_to_spud_page.rb +1 -1
- data/lib/spud_cms/engine.rb +4 -15
- data/lib/spud_cms/template_parser.rb +2 -2
- data/lib/spud_cms/version.rb +1 -1
- data/lib/tb_cms.rb +0 -1
- data/spec/controllers/admin/menu_items_controller_spec.rb +18 -18
- data/spec/controllers/admin/menus_controller_spec.rb +9 -9
- data/spec/controllers/admin/pages_controller_spec.rb +9 -9
- data/spec/controllers/pages_controller_spec.rb +5 -5
- data/spec/dummy/app/controllers/application_controller.rb +1 -1
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/config/database.yml +3 -6
- data/spec/dummy/config/environments/development.rb +2 -2
- data/spec/dummy/db/migrate/20141231214446_create_spud_admin_permissions.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20141231214447_create_spud_users.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20141231214448_add_time_zone_to_spud_user.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20141231214449_add_scope_to_spud_admin_permissions.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20141231214450_create_spud_user_settings.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20141231214451_create_spud_roles.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20141231214452_create_spud_permissions.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20141231214453_create_spud_role_permissions.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20141231214454_drop_spud_admin_permissions.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20141231214455_create_spud_permalinks.tb_permalinks.rb +1 -1
- data/spec/dummy/db/migrate/20141231214456_add_site_id_to_spud_permalinks.tb_permalinks.rb +1 -1
- data/spec/dummy/db/migrate/20141231214457_modify_site_id_for_spud_permalinks.tb_permalinks.rb +1 -1
- data/spec/dummy/db/migrate/20141231214459_create_spud_pages.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214460_create_spud_menus.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214461_create_spud_menu_items.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214462_create_spud_templates.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214463_create_spud_page_partials.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214464_add_visibility_to_spud_pages.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214465_add_menu_name_to_spud_menu_items.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214466_add_use_custom_url_name_to_spud_pages.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214467_add_notes_to_spud_pages.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214468_add_menu_id_to_spud_menu_items.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214469_add_classes_to_spud_menu_items.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214470_add_site_id_to_spud_pages.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214471_add_site_id_to_spud_templates.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214472_add_site_id_to_spud_menus.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214473_create_spud_page_partial_revisions.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214474_add_symbol_name_to_spud_page_partials.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214475_modify_site_id_for_spud_pages.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214476_add_content_processed_to_spud_page_partials.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214477_add_layout_to_spud_pages.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20141231214479_create_spud_snippets.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20150108164814_remove_site_id_from_cms_tables.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20150911185843_add_requires_password_change_to_spud_users.tb_core.rb +1 -1
- data/spec/dummy/db/migrate/20150911185844_add_title_tag_to_spud_page.tb_cms.rb +1 -1
- data/spec/dummy/db/migrate/20160215180157_create_tb_redirects.tb_redirects.rb +1 -1
- data/spec/dummy/db/schema.rb +138 -145
- data/spec/helpers/cms/application_helper_spec.rb +37 -37
- data/spec/models/spud_menu_item_spec.rb +4 -4
- data/spec/models/spud_page_partial_spec.rb +5 -5
- data/spec/models/spud_page_spec.rb +20 -12
- data/spec/rails_helper.rb +1 -1
- metadata +68 -95
- data/db/migrate/20121112212113_create_spud_page_liquid_tags.rb +0 -11
- data/db/migrate/20121119030136_change_liquid_tags_to_polymorphic.rb +0 -17
- data/db/migrate/20140110142037_drop_spud_page_liquid_tags.rb +0 -31
- data/lib/spud_cms/liquid_snippet.rb +0 -27
- data/spec/dummy/db/migrate/20141231214458_create_tb_liquid_spud_liquid_tags.tb_liquid.rb +0 -13
- data/spec/dummy/db/migrate/20141231214478_create_spud_page_liquid_tags.tb_cms.rb +0 -12
- data/spec/dummy/db/migrate/20141231214480_change_liquid_tags_to_polymorphic.tb_cms.rb +0 -18
- data/spec/dummy/db/migrate/20141231214481_drop_spud_page_liquid_tags.tb_cms.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d674e42a14812fcc99fc125a85514ba33f016752e5cdcc7c4d7319e841505ea3
|
4
|
+
data.tar.gz: 5b1669484dff7f06e78db700051107954229d95ec11819a3d05144d5929fe050
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b819655bcdbb65fc611da5ddbba4a159dcb9a495d05fbcbd46b7c8d04351d014b8d974b0889b2fb0b53162a089658b99cbe69a190b88916699fbfa97e9240a59
|
7
|
+
data.tar.gz: 6583b6a1d64056748b9252381e51d6cfda5949c7b119ed0a731e7b5e382cb9522e0e6355d1a9392ba36ed50509d2c3b9c233ed389f037a16a1d77e42f392e88a
|
data/README.md
CHANGED
@@ -72,12 +72,6 @@ Create a controller concern at `app/controllers/concerns/spud_cms_layout_actions
|
|
72
72
|
|
73
73
|
If you ran the `spud:cms:layout` generator described earlier, the concern and empty action would have been created for you automatically.
|
74
74
|
|
75
|
-
## Using Liquid Templates
|
76
|
-
|
77
|
-
Pages use the [liquid](https://github.com/Shopify/liquid) template syntax engine created by Shopify. This allows you to easily inject variables into your pages in the page editor. Example:
|
78
|
-
|
79
|
-
<h2>{{page.name}}</h2>
|
80
|
-
|
81
75
|
## Using Menus
|
82
76
|
|
83
77
|
A lot of cms engines allow you to render your navigation links in a ul block by using your page tree structure. In a lot of cases this is insufficient as some sites have urls that redirect to pages outside of your cms. This is where menus come in. They can be built in the admin control panel.
|
@@ -105,6 +99,3 @@ TB CMS uses RSpec for testing. Get the tests running with a few short commands:
|
|
105
99
|
rspec spec
|
106
100
|
|
107
101
|
After the tests have completed the current code coverage stats is available by opening ```/coverage/index.html``` in a browser.
|
108
|
-
|
109
|
-
|
110
|
-
|
@@ -3,7 +3,7 @@ spud.admin.cms.menu_items = {};
|
|
3
3
|
(function() {
|
4
4
|
var menu_items = spud.admin.cms.menu_items;
|
5
5
|
var val;
|
6
|
-
|
6
|
+
|
7
7
|
var setUrl = function(){
|
8
8
|
return '/admin/menus/'+ val +'/menu_items/update_sort';
|
9
9
|
};
|
@@ -35,25 +35,31 @@ spud.admin.cms.menu_items = {};
|
|
35
35
|
});
|
36
36
|
val = $("#menu-id").val();
|
37
37
|
//Update order of menuItems
|
38
|
-
$.ajax(setUrl(), {
|
39
|
-
method: 'PUT',
|
38
|
+
$.ajax(setUrl(), {
|
39
|
+
method: 'PUT',
|
40
40
|
data: {
|
41
41
|
order: sortArr
|
42
|
-
},
|
42
|
+
},
|
43
43
|
dataType: "json",
|
44
44
|
success: function(data, status, jqXHR) {
|
45
45
|
menu_items.updateStatus(200, '0px 0px 26px 2px rgba(4, 252, -49, 0.59)');
|
46
46
|
},
|
47
47
|
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
48
48
|
menu_items.updateStatus(100, '0px 0px 26px 2px rgba(255, 0, 40, 0.59)');
|
49
|
-
alert("Status: " + textStatus); alert("Error: " + errorThrown);
|
50
|
-
}
|
49
|
+
alert("Status: " + textStatus); alert("Error: " + errorThrown);
|
50
|
+
}
|
51
51
|
});
|
52
52
|
}
|
53
53
|
});
|
54
54
|
};
|
55
55
|
|
56
56
|
menu_items.init = function() {
|
57
|
+
return
|
58
|
+
|
59
|
+
// Sortable relies on jQuery UI, which has been removed
|
60
|
+
// This code needs to migrate to sortable.js
|
61
|
+
// See: https://bitbucket.org/moser-inc/tb_core/commits/e6252b6aa508e103b54df7e563ecfa2d2ec26c24
|
62
|
+
//
|
57
63
|
$("#sort tbody").sortable({
|
58
64
|
helper: fixHelper,
|
59
65
|
cursor: "move",
|
@@ -12,7 +12,7 @@ class PagesController < ApplicationController
|
|
12
12
|
end
|
13
13
|
|
14
14
|
url_name = !params[:id].blank? ? params[:id] : Spud::Cms.root_page_name
|
15
|
-
@page = SpudPage.published_pages.
|
15
|
+
@page = SpudPage.published_pages.find_ignoring_case(url_name)
|
16
16
|
|
17
17
|
if @page.blank?
|
18
18
|
render_404
|
@@ -34,11 +34,11 @@ class PagesController < ApplicationController
|
|
34
34
|
private
|
35
35
|
|
36
36
|
def render_404
|
37
|
-
raise
|
38
|
-
|
37
|
+
raise TbCore::NotFoundError, item: 'page'
|
38
|
+
end
|
39
39
|
|
40
40
|
def set_default_content_type
|
41
41
|
request.format = :html if params[:format].blank?
|
42
|
-
|
42
|
+
end
|
43
43
|
|
44
44
|
end
|
@@ -85,8 +85,8 @@ module Cms::ApplicationHelper
|
|
85
85
|
menu_id = menu.id
|
86
86
|
end
|
87
87
|
|
88
|
-
cache(['sp_list_menu', menu, options]) do
|
89
|
-
link_options = options[:link_options] if options.
|
88
|
+
Rails.cache.fetch(['sp_list_menu', menu, options]) do
|
89
|
+
link_options = options[:link_options] if options.has_key?(:link_options)
|
90
90
|
|
91
91
|
start_menu_item = options[:start_menu_item_id] if options.key?(:start_menu_item_id)
|
92
92
|
content = if options.key?(:id)
|
@@ -136,8 +136,8 @@ module Cms::ApplicationHelper
|
|
136
136
|
|
137
137
|
content += '</ul>'
|
138
138
|
|
139
|
-
|
140
|
-
end
|
139
|
+
content
|
140
|
+
end.html_safe
|
141
141
|
end
|
142
142
|
|
143
143
|
def sp_menu_with_seperator(options = {})
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class SpudMenuItem < ActiveRecord::Base
|
2
|
-
belongs_to :parent, polymorphic: true
|
3
|
-
belongs_to :spud_menu, touch: true
|
4
|
-
belongs_to :spud_page
|
2
|
+
belongs_to :parent, polymorphic: true, required: false
|
3
|
+
belongs_to :spud_menu, touch: true, required: false
|
4
|
+
belongs_to :spud_page, required: false
|
5
5
|
has_many :spud_menu_items, as: :parent, dependent: :destroy
|
6
6
|
|
7
7
|
validates :name, presence: true
|
data/app/models/spud_page.rb
CHANGED
@@ -2,13 +2,19 @@ class SpudPage < ActiveRecord::Base
|
|
2
2
|
include CmsDeprecatedMultisite
|
3
3
|
include TbRedirects::HasRedirects
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
belongs_to :spud_page,
|
6
|
+
required: false
|
7
7
|
has_many :spud_page_partial_revisions
|
8
8
|
has_many :spud_pages, dependent: :nullify
|
9
9
|
has_many :spud_page_partials, dependent: :destroy
|
10
|
-
belongs_to :created_by_user,
|
11
|
-
|
10
|
+
belongs_to :created_by_user,
|
11
|
+
class_name: 'SpudUser',
|
12
|
+
foreign_key: :created_by,
|
13
|
+
required: false
|
14
|
+
belongs_to :updated_by_user,
|
15
|
+
class_name: 'SpudUser',
|
16
|
+
foreign_key: :updated_by,
|
17
|
+
required: false
|
12
18
|
|
13
19
|
before_validation :generate_url_name
|
14
20
|
validates :name, presence: true, uniqueness: { scope: :spud_page_id }
|
@@ -22,11 +28,12 @@ class SpudPage < ActiveRecord::Base
|
|
22
28
|
scope :viewable, -> { where(visibility: 0) }
|
23
29
|
|
24
30
|
def full_content_processed
|
31
|
+
ActiveSupport::Deprecation.warn('#full_content_processed is deprecated; use #full_content instead.')
|
25
32
|
spud_page_partials.collect(&:content_processed).join(' ')
|
26
33
|
end
|
27
34
|
|
28
|
-
def
|
29
|
-
|
35
|
+
def full_content
|
36
|
+
spud_page_partials.collect(&:content).join(' ')
|
30
37
|
end
|
31
38
|
|
32
39
|
# Returns an array of pages in order of heirarchy
|
@@ -43,7 +50,7 @@ class SpudPage < ActiveRecord::Base
|
|
43
50
|
if filter.blank? || c.id != filter.id
|
44
51
|
list << [Array.new(level) { '- ' }.join('') + c.name, c[value]]
|
45
52
|
list += options_tree_for_page(collection: collection, parent_id: c.id, level: level + 1, filter: filter)
|
46
|
-
|
53
|
+
end
|
47
54
|
end
|
48
55
|
return list
|
49
56
|
end
|
@@ -52,6 +59,10 @@ class SpudPage < ActiveRecord::Base
|
|
52
59
|
return visibility == 1
|
53
60
|
end
|
54
61
|
|
62
|
+
def self.find_ignoring_case(url_name)
|
63
|
+
find_by(arel_table[:url_name].matches(url_name))
|
64
|
+
end
|
65
|
+
|
55
66
|
private
|
56
67
|
|
57
68
|
def generate_url_name
|
@@ -65,13 +76,13 @@ class SpudPage < ActiveRecord::Base
|
|
65
76
|
end
|
66
77
|
|
67
78
|
def create_redirect_if_necessary
|
68
|
-
if
|
69
|
-
TbRedirect.create_smart(source: "/#{
|
79
|
+
if saved_change_to_attribute?(:url_name)
|
80
|
+
TbRedirect.create_smart(source: "/#{attribute_before_last_save(:url_name)}",
|
70
81
|
destination: "/#{url_name}",
|
71
82
|
created_by: 'cms',
|
72
83
|
owner: self)
|
73
84
|
end
|
74
|
-
|
85
|
+
true
|
75
86
|
end
|
76
87
|
|
77
88
|
end
|
@@ -1,10 +1,8 @@
|
|
1
1
|
class SpudPagePartial < ActiveRecord::Base
|
2
2
|
belongs_to :spud_page, touch: true
|
3
|
-
has_many :spud_liquid_tags, as: :attachment, dependent: :destroy
|
4
3
|
validates :name, presence: true
|
5
4
|
before_save :maintain_revisions
|
6
5
|
before_save :update_symbol_name
|
7
|
-
acts_as_tb_liquid_content
|
8
6
|
|
9
7
|
def update_symbol_name
|
10
8
|
self.symbol_name = name.parameterize.underscore
|
@@ -14,24 +12,9 @@ class SpudPagePartial < ActiveRecord::Base
|
|
14
12
|
return @symbol_name || name.parameterize.underscore
|
15
13
|
end
|
16
14
|
|
17
|
-
def postprocess_content
|
18
|
-
@_template = Liquid::Template.parse(content)
|
19
|
-
self.content_processed = @_template.render('page' => spud_page)
|
20
|
-
end
|
21
|
-
|
22
|
-
def content_processed=(content)
|
23
|
-
self[:content_processed] = content
|
24
|
-
end
|
25
|
-
|
26
15
|
def content_processed
|
27
|
-
|
28
|
-
|
29
|
-
self.content_processed = postprocess_content()
|
30
|
-
else
|
31
|
-
update_column(:content_processed, postprocess_content)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
return self[:content_processed]
|
16
|
+
ActiveSupport::Deprecation.warn('#content_processed is deprecated; use #content instead.')
|
17
|
+
content
|
35
18
|
end
|
36
19
|
|
37
20
|
def maintain_revisions
|
@@ -44,7 +27,7 @@ class SpudPagePartial < ActiveRecord::Base
|
|
44
27
|
revision_bye = SpudPagePartialRevision.where(spud_page_id: spud_page_id, name: name).order('created_at ASC').first
|
45
28
|
revision_bye.destroy unless revision_bye.blank?
|
46
29
|
end
|
47
|
-
|
30
|
+
end
|
48
31
|
return true
|
49
32
|
end
|
50
33
|
end
|
data/app/models/spud_snippet.rb
CHANGED
@@ -4,11 +4,8 @@ class SpudSnippet < ActiveRecord::Base
|
|
4
4
|
validates :name, presence: true
|
5
5
|
validates :name, uniqueness: true
|
6
6
|
|
7
|
-
acts_as_tb_liquid_content
|
8
|
-
|
9
7
|
def postprocess_content
|
10
|
-
|
11
|
-
self.content_processed = template.render()
|
8
|
+
content
|
12
9
|
end
|
13
10
|
|
14
11
|
def content_processed=(content)
|
@@ -1,20 +1,17 @@
|
|
1
|
-
|
2
1
|
<%=content_for :head do%>
|
3
|
-
|
4
|
-
|
5
|
-
<meta name="keywords" content="<%=@page.meta_keywords%>" />
|
2
|
+
<meta name="description" content="<%=@page.meta_description%>" />
|
3
|
+
<meta name="keywords" content="<%=@page.meta_keywords%>" />
|
6
4
|
<% end %>
|
7
5
|
|
8
|
-
<%if !@inline.blank
|
9
|
-
|
6
|
+
<% if !@inline.blank? %>
|
7
|
+
<%= render :inline => @inline %>
|
10
8
|
<% end %>
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
<% end %>
|
9
|
+
<% @page.spud_page_partials.each do |page_partial| %>
|
10
|
+
<% if page_partial.name.downcase == 'body' && Spud::Cms.yield_body_as_content_block == false %>
|
11
|
+
<%= page_partial.content.html_safe %>
|
12
|
+
<% else %>
|
13
|
+
<%= content_for page_partial.name.parameterize.underscore.to_sym do %>
|
14
|
+
<%= page_partial.content.html_safe %>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
20
17
|
<% end %>
|
@@ -17,12 +17,12 @@
|
|
17
17
|
<% @page.spud_page_partials.each do |page_partial| %>
|
18
18
|
<% if(page_partial.name.match(/^body$/i) && Spud::Cms.yield_body_as_content_block == false) %>
|
19
19
|
<% cache(page_partial) do %>
|
20
|
-
<%= page_partial.
|
20
|
+
<%= page_partial.content.html_safe %>
|
21
21
|
<% end %>
|
22
22
|
<% else%>
|
23
23
|
<%= content_for page_partial.symbol_name.to_sym do %>
|
24
24
|
<% cache(page_partial) do %>
|
25
|
-
<%= page_partial.
|
25
|
+
<%= page_partial.content.html_safe %>
|
26
26
|
<% end %>
|
27
27
|
<% end %>
|
28
28
|
<% end %>
|