knitkit 2.1.15 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/app/controllers/knitkit/base_controller.rb +1 -1
- data/app/controllers/knitkit/comments_controller.rb +7 -2
- data/app/controllers/knitkit/erp_app/desktop/app_controller.rb +78 -98
- data/app/controllers/knitkit/erp_app/desktop/articles_controller.rb +65 -45
- data/app/controllers/knitkit/erp_app/desktop/content_controller.rb +22 -12
- data/app/controllers/knitkit/erp_app/desktop/file_assets_controller.rb +1 -1
- data/app/controllers/knitkit/erp_app/desktop/image_assets_controller.rb +28 -16
- data/app/controllers/knitkit/erp_app/desktop/inquiries_controller.rb +15 -49
- data/app/controllers/knitkit/erp_app/desktop/online_document_sections_controller.rb +4 -3
- data/app/controllers/knitkit/erp_app/desktop/position_controller.rb +69 -11
- data/app/controllers/knitkit/erp_app/desktop/theme_controller.rb +63 -60
- data/app/controllers/knitkit/erp_app/desktop/website_controller.rb +98 -82
- data/app/controllers/knitkit/erp_app/desktop/website_host_controller.rb +77 -0
- data/app/controllers/knitkit/erp_app/desktop/website_nav_controller.rb +64 -44
- data/app/controllers/knitkit/erp_app/desktop/website_nav_item_controller.rb +147 -0
- data/app/controllers/knitkit/erp_app/desktop/website_section_controller.rb +81 -45
- data/app/controllers/knitkit/mobile_controller.rb +15 -0
- data/app/controllers/knitkit/online_document_sections_controller.rb +2 -1
- data/app/controllers/knitkit/unauthorized_controller.rb +0 -1
- data/app/controllers/knitkit/website_sections_controller.rb +7 -4
- data/app/mailers/website_inquiry_mailer.rb +8 -7
- data/app/models/content.rb +11 -2
- data/app/models/document.rb +2 -17
- data/app/models/published_website.rb +96 -59
- data/app/models/theme.rb +100 -14
- data/app/models/website.rb +260 -28
- data/app/models/website_inquiry.rb +5 -12
- data/app/models/website_section.rb +9 -1
- data/app/views/knitkit/blogs/_add_comment.html.erb +44 -23
- data/app/views/knitkit/blogs/_comment.html.erb +4 -6
- data/app/views/knitkit/blogs/index.html.erb +63 -49
- data/app/views/knitkit/blogs/show.html.erb +17 -12
- data/app/views/knitkit/mobile/index.html.erb +162 -0
- data/app/views/knitkit/online_document_sections/index.html.erb +7 -5
- data/app/views/knitkit/unauthorized/index.html.erb +8 -4
- data/app/views/knitkit/website_sections/index.html.erb +8 -4
- data/app/views/layouts/knitkit/base.html.erb +79 -63
- data/app/views/layouts/knitkit/online_document_sections.html.erb +74 -52
- data/app/views/menus/knitkit/_default_menu.html.erb +4 -4
- data/app/views/menus/knitkit/_default_section_menu.html.erb +22 -23
- data/app/views/shared/knitkit/_bread_crumb.html.erb +10 -7
- data/app/views/shared/knitkit/_footer.html.erb +2 -2
- data/app/views/website_inquiry_mailer/inquiry.erb +23 -2
- data/app/widgets/contact_us/base.rb +25 -50
- data/app/widgets/contact_us/javascript/contact_us.js +7 -7
- data/app/widgets/contact_us/views/error.html.erb +6 -8
- data/app/widgets/contact_us/views/index.html.erb +28 -1
- data/app/widgets/contact_us/views/layouts/base.html.erb +9 -6
- data/app/widgets/contact_us/views/success.html.erb +3 -3
- data/app/widgets/google_map/views/index.html.erb +36 -36
- data/app/widgets/login/base.rb +1 -0
- data/app/widgets/login/javascript/login.js +3 -3
- data/app/widgets/login/views/index.html.erb +46 -26
- data/app/widgets/login/views/layouts/base.html.erb +15 -13
- data/app/widgets/login/views/login_header.html.erb +7 -9
- data/app/widgets/manage_profile/base.rb +116 -164
- data/app/widgets/manage_profile/views/_address.html.erb +184 -0
- data/app/widgets/manage_profile/views/_contact_information_form.html.erb +23 -192
- data/app/widgets/manage_profile/views/_email_address.html.erb +163 -0
- data/app/widgets/manage_profile/views/_password_form.html.erb +23 -20
- data/app/widgets/manage_profile/views/_phone_number.html.erb +165 -0
- data/app/widgets/manage_profile/views/_user_information_form.html.erb +49 -33
- data/app/widgets/manage_profile/views/error.html.erb +6 -0
- data/app/widgets/manage_profile/views/index.html.erb +44 -46
- data/app/widgets/manage_profile/views/layouts/base.html.erb +3 -1
- data/app/widgets/manage_profile/views/success.html.erb +5 -0
- data/app/widgets/reset_password/views/index.html.erb +33 -28
- data/app/widgets/reset_password/views/layouts/base.html.erb +10 -1
- data/app/widgets/search/base.rb +37 -25
- data/app/widgets/search/views/_inline_search_form.html.erb +12 -0
- data/app/widgets/search/views/_search_form.html.erb +41 -0
- data/app/widgets/search/views/index.html.erb +5 -3
- data/app/widgets/search/views/layouts/base.html.erb +13 -23
- data/app/widgets/search/views/show.html.erb +32 -47
- data/app/widgets/signup/base.rb +1 -1
- data/app/widgets/signup/javascript/signup.js +7 -9
- data/app/widgets/signup/views/_signup_form.html.erb +34 -29
- data/app/widgets/signup/views/error.html.erb +11 -11
- data/app/widgets/signup/views/index.html.erb +3 -2
- data/app/widgets/signup/views/layouts/base.html.erb +8 -5
- data/app/widgets/signup/views/success.html.erb +5 -4
- data/config/routes.rb +39 -28
- data/db/data_migrations/20120809020508_update_website_and_configuration.rb +3 -0
- data/db/migrate/20110211002317_setup_knitkit.rb +0 -1
- data/db/migrate/20131112013052_add_knitkit_missing_indexes.rb +33 -0
- data/db/migrate/20140622212723_update_website_inquiries.rb +22 -0
- data/db/migrate/20140911185022_add_publishing_to_website.rb +5 -0
- data/db/migrate/20141013073349_add_custom_fields_to_documents.rb +12 -0
- data/db/migrate/20141016101936_upgrade_remove_dynamic_attributes.rb +13 -0
- data/lib/knitkit.rb +0 -1
- data/lib/knitkit/engine.rb +1 -0
- data/lib/knitkit/extensions.rb +4 -0
- data/lib/knitkit/extensions/active_record/acts_as_commentable.rb +33 -0
- data/lib/knitkit/extensions/active_record/acts_as_document.rb +0 -12
- data/lib/knitkit/extensions/active_record/acts_as_publishable.rb +7 -10
- data/lib/knitkit/extensions/compass_ae/widgets/base.rb +2 -4
- data/lib/knitkit/extensions/compass_ae/widgets/widget_proxy_controller.rb +4 -1
- data/lib/knitkit/extensions/railties/action_view/helpers/blog_helper.rb +16 -13
- data/lib/knitkit/extensions/railties/action_view/helpers/content_helper.rb +10 -8
- data/lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb +123 -108
- data/lib/knitkit/extensions/will_paginate/link_renderer.rb +67 -0
- data/lib/knitkit/routing_filter/section_router.rb +10 -8
- data/lib/knitkit/syntax_validator.rb +2 -2
- data/lib/knitkit/version.rb +7 -3
- data/public/images/inline_edit/close.png +0 -0
- data/public/images/knitkit/close_window.png +0 -0
- data/public/images/knitkit/logo.png +0 -0
- data/public/images/knitkit/splash/images/add-site.png +0 -0
- data/public/images/knitkit/splash/images/adjust-site.png +0 -0
- data/public/images/knitkit/splash/images/browse-site.png +0 -0
- data/public/images/knitkit/splash/images/find-themes.png +0 -0
- data/public/images/knitkit/splash/images/settings.png +0 -0
- data/public/images/knitkit/splash/images/tutorials.png +0 -0
- data/public/images/knitkit/splash/splash.png +0 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/articles_grid_panel.js +656 -627
- data/public/javascripts/erp_app/desktop/applications/knitkit/center_region.js +444 -333
- data/public/javascripts/erp_app/desktop/applications/knitkit/{east_region.js → east_region/east_region.js} +33 -33
- data/public/javascripts/erp_app/desktop/applications/knitkit/east_region/file_assets_panel.js +332 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/east_region/image_assets_data_view.js +144 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/east_region/image_assets_panel.js +335 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/{widgets_panel.js → east_region/widgets_panel.js} +55 -55
- data/public/javascripts/erp_app/desktop/applications/knitkit/inquiries_grid_panel.js +150 -37
- data/public/javascripts/erp_app/desktop/applications/knitkit/module.js +228 -96
- data/public/javascripts/erp_app/desktop/applications/knitkit/publish_window.js +89 -85
- data/public/javascripts/erp_app/desktop/applications/knitkit/published_grid_panel.js +238 -217
- data/public/javascripts/erp_app/desktop/applications/knitkit/select_roles_window.js +59 -54
- data/public/javascripts/erp_app/desktop/applications/knitkit/splash_screen.js +170 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/top_menu/main_menu.js +1168 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/top_menu/websites_combo.js +71 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/versions_grid_panel.js +301 -306
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/article.js +216 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/document.js +182 -153
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/host.js +48 -65
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/menu.js +93 -94
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/section.js +523 -197
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/website_nav_items.js +20 -34
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/hosts_tree_panel.js +74 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/menu_tree_panel.js +245 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/site_contents_tree_panel.js +360 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/themes_tree_panel.js +348 -0
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/west_region.js +106 -1132
- data/public/javascripts/knitkit/bootstrap-datepicker.js +474 -0
- data/public/javascripts/knitkit/bootstrap.min.js +7 -0
- data/public/javascripts/knitkit/confirm-bootstrap.js +110 -0
- data/public/javascripts/knitkit/inline_editing.js +73 -50
- data/public/javascripts/knitkit/jquery.maskedinput.min.js +7 -0
- data/public/javascripts/knitkit/mobile/app/view/Main.js +108 -0
- data/public/javascripts/knitkit/mobile/ux/slidenavigation/View.js +734 -0
- data/public/javascripts/knitkit/theme.js +76 -0
- data/public/stylesheets/erp_app/desktop/applications/knitkit/knitkit.css +95 -35
- data/public/stylesheets/knitkit/bootstrap-responsive.min.css +10 -0
- data/public/stylesheets/knitkit/bootstrap.min.css +7 -0
- data/public/stylesheets/knitkit/custom.css +122 -0
- data/public/stylesheets/knitkit/datepicker.css +182 -0
- data/public/stylesheets/knitkit/inline_editing.css +58 -58
- data/spec/controllers/knitkit/erp_app/desktop/website_section_controller_spec.rb +1 -1
- data/spec/dummy/config/application.rb +1 -1
- data/spec/models/article_spec.rb +3 -3
- data/spec/models/content_spec.rb +9 -9
- data/spec/models/website_spec.rb +1 -1
- metadata +100 -114
- data/app/helpers/application_helper.rb +0 -134
- data/app/views/knitkit/articles/index.html.erb +0 -3
- data/app/views/knitkit/articles/show.html.erb +0 -4
- data/app/views/menus/knitkit/_default_sub_menu.html.erb +0 -43
- data/app/views/menus/knitkit/_default_sub_section_menu.html.erb +0 -47
- data/app/widgets/contact_us/views/_contact_form.html.erb +0 -36
- data/app/widgets/dynamic_forms/base.rb +0 -139
- data/app/widgets/dynamic_forms/javascript/dynamic_forms.js +0 -110
- data/app/widgets/dynamic_forms/views/error.html.erb +0 -5
- data/app/widgets/dynamic_forms/views/index.html.erb +0 -8
- data/app/widgets/dynamic_forms/views/success.html.erb +0 -4
- data/app/widgets/dynamic_grid/base.rb +0 -130
- data/app/widgets/dynamic_grid/helpers/controller/dynamic_grid_controller_helper.rb +0 -3
- data/app/widgets/dynamic_grid/helpers/view/dynamic_grid_view_helper.rb +0 -3
- data/app/widgets/dynamic_grid/javascript/dynamic_grid.js +0 -177
- data/app/widgets/dynamic_grid/views/index.html.erb +0 -14
- data/app/widgets/login/views/reset_password.html.erb +0 -26
- data/app/widgets/manage_profile/views/default_type_error.html.erb +0 -5
- data/app/widgets/scaffold/base.rb +0 -87
- data/app/widgets/scaffold/helpers/controller/scaffold_controller_helper.rb +0 -3
- data/app/widgets/scaffold/helpers/view/scaffold_view_helper.rb +0 -3
- data/app/widgets/scaffold/javascript/scaffold.js +0 -337
- data/app/widgets/scaffold/views/index.html.erb +0 -15
- data/app/widgets/search/views/_search.html.erb +0 -39
- data/public/images/knitkit/bullet.png +0 -0
- data/public/images/knitkit/close.png +0 -0
- data/public/images/knitkit/content.png +0 -0
- data/public/images/knitkit/footer.png +0 -0
- data/public/images/knitkit/graphic.png +0 -0
- data/public/images/knitkit/greyFadeDown.png +0 -0
- data/public/images/knitkit/link.png +0 -0
- data/public/images/knitkit/menu.png +0 -0
- data/public/images/knitkit/menu_select.png +0 -0
- data/public/images/knitkit/search.png +0 -0
- data/public/images/knitkit/tooltip.gif +0 -0
- data/public/javascripts/ajax_pagination.js +0 -33
- data/public/javascripts/datepicker.js +0 -445
- data/public/javascripts/erp_app/desktop/applications/knitkit/file_assets_panel.js +0 -341
- data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_data_view.js +0 -31
- data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_panel.js +0 -263
- data/public/javascripts/erp_app/desktop/applications/knitkit/section_articles_grid_panel.js +0 -722
- data/public/javascripts/erp_app/desktop/applications/knitkit/themes_tree_panel.js +0 -585
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/website.js +0 -155
- data/public/javascripts/knitkit/helpers.js +0 -26
- data/public/stylesheets/datepicker.css +0 -121
- data/public/stylesheets/extjs/resources/css/knitkit_extjs_4.css +0 -233
- data/public/stylesheets/knitkit/style.css +0 -426
@@ -0,0 +1,147 @@
|
|
1
|
+
module Knitkit
|
2
|
+
module ErpApp
|
3
|
+
module Desktop
|
4
|
+
class WebsiteNavItemController < Knitkit::ErpApp::Desktop::AppController
|
5
|
+
|
6
|
+
def create
|
7
|
+
begin
|
8
|
+
current_user.with_capability('create', 'WebsiteNavItem') do
|
9
|
+
result = {}
|
10
|
+
klass = params[:klass].constantize
|
11
|
+
parent = klass.find(params[:parent_id])
|
12
|
+
website_nav = parent.is_a?(WebsiteNav) ? parent : parent.website_nav
|
13
|
+
website_nav_item = WebsiteNavItem.new(:title => params[:title])
|
14
|
+
|
15
|
+
url = params[:url]
|
16
|
+
if params[:link_to] != 'url'
|
17
|
+
#user wants to see Section so this is needed
|
18
|
+
params[:link_to] = 'WebsiteSection' if params[:link_to] == 'website_section'
|
19
|
+
|
20
|
+
#get link to item can be Article or Section
|
21
|
+
linked_to_id = params["#{params[:link_to].underscore}_id".to_sym]
|
22
|
+
link_to_item = params[:link_to].constantize.find(linked_to_id)
|
23
|
+
#setup link
|
24
|
+
website_nav_item.url = '/' + link_to_item.permalink
|
25
|
+
website_nav_item.linked_to_item = link_to_item
|
26
|
+
url = "http://#{website_nav.website.hosts.first.host}/" + link_to_item.permalink
|
27
|
+
else
|
28
|
+
website_nav_item.url = url
|
29
|
+
end
|
30
|
+
|
31
|
+
if website_nav_item.save
|
32
|
+
if parent.is_a?(WebsiteNav)
|
33
|
+
parent.website_nav_items << website_nav_item
|
34
|
+
else
|
35
|
+
website_nav_item.move_to_child_of(parent)
|
36
|
+
end
|
37
|
+
|
38
|
+
result[:success] = true
|
39
|
+
result[:node] = {:text => params[:title],
|
40
|
+
:linkToType => params[:link_to].underscore,
|
41
|
+
:linkedToId => linked_to_id,
|
42
|
+
:websiteNavId => website_nav.id,
|
43
|
+
:url => url,
|
44
|
+
:isSecure => false,
|
45
|
+
:roles => [],
|
46
|
+
:canAddMenuItems => true,
|
47
|
+
:websiteNavItemId => website_nav_item.id,
|
48
|
+
:iconCls => 'icon-document',
|
49
|
+
:isWebsiteNavItem => true,
|
50
|
+
:leaf => false,
|
51
|
+
:children => []}
|
52
|
+
else
|
53
|
+
result[:success] = false
|
54
|
+
end
|
55
|
+
|
56
|
+
render :json => result
|
57
|
+
end
|
58
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
|
59
|
+
render :json => {:success => false, :message => ex.message}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def update
|
64
|
+
begin
|
65
|
+
current_user.with_capability('edit', 'WebsiteNavItem') do
|
66
|
+
result = {}
|
67
|
+
website_nav_item = WebsiteNavItem.find(params[:id])
|
68
|
+
website_nav_item.title = params[:title]
|
69
|
+
|
70
|
+
url = params[:url]
|
71
|
+
linked_to_id = nil
|
72
|
+
if (params[:link_to] != 'url')
|
73
|
+
#user wants to see Section so this is needed
|
74
|
+
params[:link_to] = 'WebsiteSection' if params[:link_to] == 'website_section'
|
75
|
+
|
76
|
+
#get link to item can be Article or Section
|
77
|
+
linked_to_id = params["#{params[:link_to].underscore}_id".to_sym]
|
78
|
+
link_to_item = params[:link_to].constantize.find(linked_to_id)
|
79
|
+
#setup link
|
80
|
+
website_nav_item.url = '/' + link_to_item.permalink
|
81
|
+
website_nav_item.linked_to_item = link_to_item
|
82
|
+
url = "http://#{website_nav_item.website_nav.website.hosts.first.host}/" + link_to_item.permalink
|
83
|
+
else
|
84
|
+
website_nav_item.url = url
|
85
|
+
end
|
86
|
+
|
87
|
+
if website_nav_item.save
|
88
|
+
result[:success] = true
|
89
|
+
result[:title] = params[:title]
|
90
|
+
result[:linkedToId] = linked_to_id
|
91
|
+
result[:linkToType] = params[:link_to].underscore
|
92
|
+
result[:url] = url
|
93
|
+
else
|
94
|
+
result[:success] = false
|
95
|
+
end
|
96
|
+
|
97
|
+
render :json => result
|
98
|
+
end
|
99
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
|
100
|
+
render :json => {:success => false, :message => ex.message}
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def destroy
|
105
|
+
begin
|
106
|
+
current_user.with_capability('delete', 'WebsiteNavItem') do
|
107
|
+
render :json => (WebsiteNavItem.destroy(params[:id]) ? {:success => true} : {:success => false})
|
108
|
+
end
|
109
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
|
110
|
+
render :json => {:success => false, :message => ex.message}
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def update_security
|
115
|
+
if current_user.has_capability?('secure', 'WebsiteNavItem') or current_user.has_capability?('unsecure', 'WebsiteNavItem')
|
116
|
+
website_nav_item = WebsiteNavItem.find(params[:id])
|
117
|
+
|
118
|
+
roles = []
|
119
|
+
|
120
|
+
#get roles
|
121
|
+
params.each do |k, v|
|
122
|
+
if v == 'on'
|
123
|
+
roles.push(k)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
if roles.empty?
|
128
|
+
website_nav_item.remove_capability(:view)
|
129
|
+
else
|
130
|
+
capability = website_nav_item.add_capability(:view)
|
131
|
+
capability.remove_all_roles
|
132
|
+
roles.each do |r|
|
133
|
+
role = SecurityRole.find_by_internal_identifier(r)
|
134
|
+
role.add_capability(capability)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
render :json => {:success => true, :secured => website_nav_item.is_secured?, :roles => website_nav_item.roles.collect { |item| item.internal_identifier }}
|
139
|
+
else
|
140
|
+
render :json => {:success => false, :message => "User does not have capability."}
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
end # WebsiteNavItemController
|
145
|
+
end # Desktop
|
146
|
+
end # ErpApp
|
147
|
+
end # Knitkit
|
@@ -6,43 +6,56 @@ module Knitkit
|
|
6
6
|
|
7
7
|
def new
|
8
8
|
begin
|
9
|
-
|
10
|
-
website = Website.find(params[:website_id])
|
11
|
-
|
12
|
-
if params[:title].to_s.downcase == 'blog' && params[:type] == 'Blog'
|
13
|
-
result = {:success => false, :message => 'Blog can not be the title of a Blog'}
|
14
|
-
else
|
15
|
-
website_section = WebsiteSection.new
|
16
|
-
website_section.website_id = website.id
|
17
|
-
website_section.in_menu = params[:in_menu] == 'yes'
|
18
|
-
website_section.title = params[:title]
|
19
|
-
website_section.render_base_layout = params[:render_with_base_layout] == 'yes'
|
20
|
-
website_section.type = params[:type] unless params[:type] == 'Page'
|
21
|
-
website_section.internal_identifier = params[:internal_identifier]
|
22
|
-
website_section.position = 0 # explicitly set position null, MS SQL doesn't always honor column default
|
23
|
-
|
24
|
-
if website_section.save
|
25
|
-
if params[:website_section_id]
|
26
|
-
parent_website_section = WebsiteSection.find(params[:website_section_id])
|
27
|
-
website_section.move_to_child_of(parent_website_section)
|
28
|
-
end
|
9
|
+
result = {success: false}
|
29
10
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
11
|
+
current_user.with_capability('create', 'WebsiteSection') do
|
12
|
+
begin
|
13
|
+
ActiveRecord::Base.transaction do
|
14
|
+
|
15
|
+
@website = Website.find(params[:website_id])
|
16
|
+
@website_primary_host = @website.nil? ? nil : @website.config_value('primary_host')
|
17
|
+
|
18
|
+
if params[:title].to_s.downcase == 'blog' && params[:type] == 'Blog'
|
19
|
+
result = {:success => false, :message => 'Blog can not be the title of a Blog'}
|
20
|
+
else
|
21
|
+
website_section = WebsiteSection.new
|
22
|
+
website_section.website_id = @website.id
|
23
|
+
website_section.in_menu = params[:in_menu] == 'yes'
|
24
|
+
website_section.title = params[:title]
|
25
|
+
website_section.render_base_layout = params[:render_with_base_layout] == 'yes'
|
26
|
+
website_section.type = params[:type] unless params[:type] == 'Page'
|
27
|
+
website_section.internal_identifier = params[:internal_identifier]
|
28
|
+
website_section.position = 0 # explicitly set position null, MS SQL doesn't always honor column default
|
29
|
+
|
30
|
+
if website_section.save
|
31
|
+
if params[:website_section_id]
|
32
|
+
parent_website_section = WebsiteSection.find(params[:website_section_id])
|
33
|
+
website_section.move_to_child_of(parent_website_section)
|
34
|
+
end
|
35
|
+
|
36
|
+
if params[:type] == "OnlineDocumentSection"
|
37
|
+
documented_content = DocumentedContent.create(:title => website_section.title, :created_by => current_user, :body_html => website_section.title)
|
38
|
+
DocumentedItem.create(:documented_content_id => documented_content.id, :online_document_section_id => website_section.id)
|
39
|
+
end
|
40
|
+
|
41
|
+
website_section.update_path!
|
42
|
+
result = {:success => true, :node => build_section_hash(website_section)}
|
43
|
+
else
|
44
|
+
message = "<ul>"
|
45
|
+
website_section.errors.collect do |e, m|
|
46
|
+
message << "<li>#{e} #{m}</li>"
|
47
|
+
end
|
48
|
+
message << "</ul>"
|
49
|
+
result = {:success => false, :message => message}
|
50
|
+
end
|
34
51
|
|
35
|
-
website_section.update_path!
|
36
|
-
result = {:success => true, :node => build_section_hash(website_section, website_section.website)}
|
37
|
-
else
|
38
|
-
message = "<ul>"
|
39
|
-
website_section.errors.collect do |e, m|
|
40
|
-
message << "<li>#{e} #{m}</li>"
|
41
52
|
end
|
42
|
-
message << "</ul>"
|
43
|
-
result = {:success => false, :message => message}
|
44
53
|
end
|
45
|
-
|
54
|
+
rescue => ex
|
55
|
+
# TODO send error notification
|
56
|
+
Rails.logger.error ex.message
|
57
|
+
Rails.logger.error ex.backtrace.join("\n")
|
58
|
+
result = {:success => false, :message => 'Could not create Section'}
|
46
59
|
end
|
47
60
|
|
48
61
|
render :json => result
|
@@ -54,8 +67,17 @@ module Knitkit
|
|
54
67
|
|
55
68
|
def delete
|
56
69
|
begin
|
57
|
-
|
58
|
-
|
70
|
+
ActiveRecord::Base.transaction do
|
71
|
+
current_user.with_capability('delete', 'WebsiteSection') do
|
72
|
+
section = WebsiteSection.find(params[:id])
|
73
|
+
|
74
|
+
# we need to remove any content related to this section if it is an OnlineDocumentSection
|
75
|
+
if section.type == 'OnlineDocumentSection'
|
76
|
+
section.website_section_contents.destroy_all
|
77
|
+
end
|
78
|
+
|
79
|
+
render :json => section.destroy ? {:success => true} : {:success => false}
|
80
|
+
end
|
59
81
|
end
|
60
82
|
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
|
61
83
|
render :json => {:success => false, :message => ex.message}
|
@@ -89,7 +111,7 @@ module Knitkit
|
|
89
111
|
end
|
90
112
|
end
|
91
113
|
|
92
|
-
render :json => {:success => true, :secured => @website_section.is_secured?, :roles => @website_section.roles.collect{|item| item.internal_identifier}}
|
114
|
+
render :json => {:success => true, :secured => @website_section.is_secured?, :roles => @website_section.roles.collect { |item| item.internal_identifier }}
|
93
115
|
else
|
94
116
|
render :json => {:success => false, :message => "User does not have capability."}
|
95
117
|
end
|
@@ -103,20 +125,25 @@ module Knitkit
|
|
103
125
|
@website_section.render_base_layout = params[:render_with_base_layout] == 'yes'
|
104
126
|
@website_section.internal_identifier = params[:internal_identifier]
|
105
127
|
|
106
|
-
|
107
128
|
#check if this is a OnlineDocumentSection if so set markdown
|
108
129
|
if @website_section.is_a?(OnlineDocumentSection) || @website_section.type == 'OnlineDocumentSection'
|
109
130
|
@website_section.use_markdown = (params[:use_markdown] == 'yes')
|
110
131
|
end
|
111
132
|
|
112
|
-
|
113
|
-
if @website_section.
|
114
|
-
|
133
|
+
#TODO this should probably be moved into the view
|
134
|
+
if @website_section.altered?
|
135
|
+
website = @website_section.website
|
136
|
+
if @website_section.save
|
137
|
+
@website_section.publish(website, 'Auto Publish', @website_section.version, current_user) if website.publish_on_save?
|
115
138
|
|
116
|
-
|
139
|
+
render :json => {:success => true}
|
140
|
+
else
|
141
|
+
render :json => {:success => false}
|
142
|
+
end
|
117
143
|
else
|
118
|
-
render :json => {:success =>
|
144
|
+
render :json => {:success => true}
|
119
145
|
end
|
146
|
+
|
120
147
|
end
|
121
148
|
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
|
122
149
|
render :json => {:success => false, :message => ex.message}
|
@@ -151,9 +178,18 @@ module Knitkit
|
|
151
178
|
unless result
|
152
179
|
website = @website_section.website
|
153
180
|
@website_section.layout = params[:content]
|
154
|
-
|
155
|
-
|
156
|
-
|
181
|
+
|
182
|
+
#TODO this should probably be moved into the view
|
183
|
+
if @website_section.altered?
|
184
|
+
saved = @website_section.save
|
185
|
+
@website_section.publish(website, 'Auto Publish', @website_section.version, current_user) if saved and website.publish_on_save?
|
186
|
+
|
187
|
+
render :json => saved ? {:success => true} : {:success => false}
|
188
|
+
else
|
189
|
+
|
190
|
+
render :json => {:success => true}
|
191
|
+
end
|
192
|
+
|
157
193
|
else
|
158
194
|
render :json => {:success => false, :message => result}
|
159
195
|
end
|
@@ -31,7 +31,8 @@ module Knitkit
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def get_content
|
34
|
-
document_section = OnlineDocumentSection.where(:internal_identifier => params[:document_section_id])
|
34
|
+
document_section = OnlineDocumentSection.where(:internal_identifier => params[:document_section_id])
|
35
|
+
.where(:website_id => @website.id).first
|
35
36
|
content = document_section.documented_item_published_content(@active_publication) unless @active_publication.nil?
|
36
37
|
content = document_section.documented_item.content if @active_publication.nil? or content.nil?
|
37
38
|
|
@@ -2,14 +2,17 @@ module Knitkit
|
|
2
2
|
class WebsiteSectionsController < BaseController
|
3
3
|
|
4
4
|
def index
|
5
|
-
@current_user = current_user
|
6
5
|
@contents = Article.find_published_by_section(@active_publication, @website_section)
|
7
6
|
layout = @website_section.get_published_layout(@active_publication)
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
|
8
|
+
if params[:is_mobile]
|
9
|
+
layout.nil? ? (render :layout => false) : (render :inline => layout, :layout => false)
|
10
|
+
elsif layout.nil?
|
11
11
|
@website_section.render_base_layout? ? (render) : (render :layout => false)
|
12
|
+
else
|
13
|
+
@website_section.render_base_layout? ? (render :inline => layout, :layout => 'knitkit/base') : (render :inline => layout)
|
12
14
|
end
|
15
|
+
|
13
16
|
end
|
14
17
|
|
15
18
|
end
|
@@ -1,13 +1,14 @@
|
|
1
1
|
class WebsiteInquiryMailer < ActionMailer::Base
|
2
2
|
|
3
|
-
def inquiry(website_inquiry
|
4
|
-
subject = "#{website_inquiry.website.title} Inquiry"
|
3
|
+
def inquiry(website_inquiry)
|
4
|
+
subject = "#{website_inquiry.website.title} Inquiry"
|
5
5
|
@website_inquiry = website_inquiry
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
|
7
|
+
mail(:to => website_inquiry.website.configurations.first.get_item(ConfigurationItemType.find_by_internal_identifier('contact_us_email_address')).options.first.value,
|
8
|
+
:from => website_inquiry.email,
|
9
|
+
:subject => subject,
|
10
|
+
:content_type => 'text/html'
|
11
|
+
)
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
data/app/models/content.rb
CHANGED
@@ -16,7 +16,6 @@ class Content < ActiveRecord::Base
|
|
16
16
|
acts_as_commentable
|
17
17
|
acts_as_versioned :table_name => :content_versions
|
18
18
|
can_be_published
|
19
|
-
has_relational_dynamic_attributes
|
20
19
|
|
21
20
|
has_many :website_section_contents, :dependent => :destroy
|
22
21
|
has_many :website_sections, :through => :website_section_contents
|
@@ -119,6 +118,8 @@ class Content < ActiveRecord::Base
|
|
119
118
|
website_section_content.position = position
|
120
119
|
website_section_content.save
|
121
120
|
end
|
121
|
+
|
122
|
+
website_section_content
|
122
123
|
end
|
123
124
|
|
124
125
|
def content_area_by_website_section(section)
|
@@ -168,6 +169,10 @@ class Content < ActiveRecord::Base
|
|
168
169
|
!PublishedElement.where('published_element_record_id = ? and published_element_record_type = ? and published_elements.version = ?', self.id, 'Content', self.version).first.nil?
|
169
170
|
end
|
170
171
|
|
172
|
+
def pretty_tag_list
|
173
|
+
self.tag_list.join(", ")
|
174
|
+
end
|
175
|
+
|
171
176
|
protected
|
172
177
|
|
173
178
|
def self.build_search_results(results)
|
@@ -198,7 +203,11 @@ class Content < ActiveRecord::Base
|
|
198
203
|
def self.get_published_version(active_publication, content)
|
199
204
|
content_version = nil
|
200
205
|
published_website_id = active_publication.id
|
201
|
-
published_element = PublishedElement.includes([:published_website])
|
206
|
+
published_element = PublishedElement.includes([:published_website])
|
207
|
+
.where('published_websites.id = ?', published_website_id)
|
208
|
+
.where('published_element_record_id = ?', content.id)
|
209
|
+
.where('published_element_record_type = ?', 'Content').first
|
210
|
+
|
202
211
|
unless published_element.nil?
|
203
212
|
content_version = Content::Version.where('version = ? and content_id = ?', published_element.version, published_element.published_element_record_id).first
|
204
213
|
end
|
data/app/models/document.rb
CHANGED
@@ -1,27 +1,12 @@
|
|
1
1
|
class Document < ActiveRecord::Base
|
2
2
|
attr_protected :created_at, :updated_at
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
has_dynamic_attributes :dynamic_attribute_prefix => DOCUMENT_DYNAMIC_ATTRIBUTE_PREFIX, :destroy_dynamic_attribute_for_nil => false
|
4
|
+
# serialize custom attributes
|
5
|
+
is_json :custom_fields
|
7
6
|
|
8
7
|
has_file_assets
|
9
8
|
|
10
9
|
belongs_to :document_record, :polymorphic => true
|
11
10
|
belongs_to :document_type
|
12
11
|
|
13
|
-
class << self
|
14
|
-
def add_dyn_prefix(field)
|
15
|
-
"#{DOCUMENT_DYNAMIC_ATTRIBUTE_PREFIX}#{field}"
|
16
|
-
end
|
17
|
-
|
18
|
-
def remove_dyn_prefix(field)
|
19
|
-
field.gsub(DOCUMENT_DYNAMIC_ATTRIBUTE_PREFIX, '')
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def set_dyn_attribute(field, value)
|
24
|
-
self.send("#{Document.add_dyn_prefix(field)}=", value)
|
25
|
-
end
|
26
|
-
|
27
12
|
end
|