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
@@ -4,31 +4,65 @@ module Knitkit
|
|
4
4
|
class WebsiteController < Knitkit::ErpApp::Desktop::AppController
|
5
5
|
IGNORED_PARAMS = %w{action controller id}
|
6
6
|
|
7
|
-
before_filter :set_website, :only => [:
|
8
|
-
|
7
|
+
before_filter :set_website, :only => [:build_content_tree, :export, :exporttemplate, :website_publications, :set_viewing_version,
|
8
|
+
:build_host_hash, :activate_publication, :publish, :update, :delete]
|
9
|
+
|
9
10
|
def index
|
10
|
-
render :json => {:sites => Website.all
|
11
|
+
render :json => {:sites => Website.all.collect { |item| item.to_hash(:only => [:id, :name, :title, :subtitle],
|
12
|
+
:configuration_id => item.configurations.first.id,
|
13
|
+
:url => "http://#{item.config_value('primary_host')}") }}
|
14
|
+
end
|
15
|
+
|
16
|
+
def build_content_tree
|
17
|
+
nodes = []
|
18
|
+
|
19
|
+
if @website
|
20
|
+
if params[:record_type].blank?
|
21
|
+
@website.website_sections.positioned.each do |website_section|
|
22
|
+
nodes << build_section_hash(website_section)
|
23
|
+
end
|
24
|
+
else
|
25
|
+
case params[:record_type]
|
26
|
+
when 'WebsiteSection'
|
27
|
+
website_section = WebsiteSection.find(params[:record_id])
|
28
|
+
|
29
|
+
# get child sections
|
30
|
+
nodes = website_section.positioned_children.map { |child| build_section_hash(child) }
|
31
|
+
|
32
|
+
# get child articles
|
33
|
+
website_section.website_section_contents.order('position').each do |website_section_content|
|
34
|
+
nodes << build_article_hash(website_section_content, @website, website_section.is_blog?)
|
35
|
+
end
|
36
|
+
|
37
|
+
else
|
38
|
+
raise 'Unknown Node Type'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
render :json => nodes
|
11
44
|
end
|
12
45
|
|
13
46
|
def website_publications
|
14
47
|
sort_hash = params[:sort].blank? ? {} : Hash.symbolize_keys(JSON.parse(params[:sort]).first)
|
15
48
|
sort = sort_hash[:property] || 'version'
|
16
|
-
dir
|
49
|
+
dir = sort_hash[:direction] || 'DESC'
|
17
50
|
limit = params[:limit] || 9
|
18
51
|
start = params[:start] || 0
|
19
|
-
|
52
|
+
|
20
53
|
published_websites = @website.published_websites.order("#{sort} #{dir}").limit(limit).offset(start)
|
21
|
-
|
54
|
+
|
22
55
|
#set site_version. User can view different versions. Check if they are viewing another version
|
23
56
|
site_version = @website.active_publication.version
|
24
57
|
if !session[:website_version].blank? && !session[:website_version].empty?
|
25
|
-
site_version_hash = session[:website_version].find{|item| item[:website_id] == @website.id}
|
58
|
+
site_version_hash = session[:website_version].find { |item| item[:website_id] == @website.id }
|
26
59
|
site_version = site_version_hash[:version].to_f unless site_version_hash.nil?
|
27
60
|
end
|
28
61
|
|
29
62
|
PublishedWebsite.class_exec(site_version) do
|
30
63
|
cattr_accessor :site_version
|
31
64
|
self.site_version = site_version
|
65
|
+
|
32
66
|
def viewing
|
33
67
|
self.version == self.site_version
|
34
68
|
end
|
@@ -37,8 +71,8 @@ module Knitkit
|
|
37
71
|
render :inline => "{\"success\":true, \"results\":#{published_websites.count},
|
38
72
|
\"totalCount\":#{@website.published_websites.count},
|
39
73
|
\"data\":#{published_websites.to_json(
|
40
|
-
|
41
|
-
|
74
|
+
:only => [:comment, :id, :version, :created_at, :active],
|
75
|
+
:methods => [:viewing, :published_by_username])} }"
|
42
76
|
end
|
43
77
|
|
44
78
|
def activate_publication
|
@@ -48,7 +82,7 @@ module Knitkit
|
|
48
82
|
|
49
83
|
render :json => {:success => true}
|
50
84
|
end
|
51
|
-
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
85
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
|
52
86
|
render :json => {:success => false, :message => ex.message}
|
53
87
|
end
|
54
88
|
end
|
@@ -58,7 +92,7 @@ module Knitkit
|
|
58
92
|
session[:website_version] = []
|
59
93
|
session[:website_version] << {:website_id => @website.id, :version => params[:version]}
|
60
94
|
else
|
61
|
-
session[:website_version].delete_if{|item| item[:website_id] == @website.id}
|
95
|
+
session[:website_version].delete_if { |item| item[:website_id] == @website.id }
|
62
96
|
session[:website_version] << {:website_id => @website.id, :version => params[:version]}
|
63
97
|
end
|
64
98
|
|
@@ -72,7 +106,7 @@ module Knitkit
|
|
72
106
|
|
73
107
|
render :json => {:success => true}
|
74
108
|
end
|
75
|
-
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
109
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
|
76
110
|
render :json => {:success => false, :message => ex.message}
|
77
111
|
end
|
78
112
|
end
|
@@ -82,9 +116,9 @@ module Knitkit
|
|
82
116
|
Website.transaction do
|
83
117
|
current_user.with_capability('create', 'Website') do
|
84
118
|
website = Website.new
|
85
|
-
website.subtitle
|
86
|
-
website.title
|
87
|
-
website.name
|
119
|
+
website.subtitle = params[:subtitle]
|
120
|
+
website.title = params[:title]
|
121
|
+
website.name = params[:name]
|
88
122
|
|
89
123
|
# create homepage
|
90
124
|
website_section = WebsiteSection.new
|
@@ -108,10 +142,12 @@ module Knitkit
|
|
108
142
|
|
109
143
|
PublishedWebsite.activate(website, 1, current_user)
|
110
144
|
|
111
|
-
render :json => {:success => true
|
145
|
+
render :json => {:success => true, :website => website.to_hash(:only => [:id, :name],
|
146
|
+
:configuration_id => website.configurations.first.id,
|
147
|
+
:url => "http://#{website.config_value('primary_host')}")}
|
112
148
|
end
|
113
149
|
end
|
114
|
-
rescue
|
150
|
+
rescue => ex
|
115
151
|
Rails.logger.error("#{ex.message} + #{ex.backtrace.join("\n")}")
|
116
152
|
render :json => {:success => false, :message => ex.message}
|
117
153
|
end
|
@@ -121,100 +157,80 @@ module Knitkit
|
|
121
157
|
def update
|
122
158
|
begin
|
123
159
|
current_user.with_capability('edit', 'Website') do
|
124
|
-
@website.name
|
125
|
-
@website.title
|
126
|
-
@website.subtitle
|
160
|
+
@website.name = params[:name]
|
161
|
+
@website.title = params[:title]
|
162
|
+
@website.subtitle = params[:subtitle]
|
127
163
|
|
128
164
|
render :json => @website.save ? {:success => true} : {:success => false}
|
129
165
|
end
|
130
|
-
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
166
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
|
131
167
|
render :json => {:success => false, :message => ex.message}
|
132
168
|
end
|
133
169
|
end
|
134
|
-
|
135
|
-
|
170
|
+
|
136
171
|
def delete
|
137
172
|
begin
|
138
173
|
current_user.with_capability('delete', 'Website') do
|
139
174
|
render :json => @website.destroy ? {:success => true} : {:success => false}
|
140
175
|
end
|
141
|
-
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
176
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
|
142
177
|
render :json => {:success => false, :message => ex.message}
|
143
178
|
end
|
144
179
|
end
|
145
180
|
|
146
181
|
def export
|
147
182
|
zip_path = @website.export
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
result, message = Website.import(params[:website_data], current_user)
|
154
|
-
|
155
|
-
render :inline => {:success => result, :message => message}.to_json
|
156
|
-
ensure
|
157
|
-
FileUtils.rm_r File.dirname(zip_path) rescue nil
|
183
|
+
begin
|
184
|
+
send_file(zip_path.to_s, :stream => false)
|
185
|
+
rescue Exception => ex
|
186
|
+
raise "Error sending #{zip_path} file"
|
187
|
+
end
|
158
188
|
end
|
159
189
|
|
160
|
-
def
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
website.
|
167
|
-
|
168
|
-
render :json => {
|
169
|
-
:success => true,
|
170
|
-
:node => {
|
171
|
-
:text => website_host.attributes['host'],
|
172
|
-
:websiteHostId => website_host.id,
|
173
|
-
:host => website_host.attributes['host'],
|
174
|
-
:iconCls => 'icon-globe',
|
175
|
-
:url => "http://#{website_host.attributes['host']}",
|
176
|
-
:isHost => true,
|
177
|
-
:leaf => true,
|
178
|
-
:children => []}
|
179
|
-
}
|
190
|
+
def exporttemplate
|
191
|
+
zip_path = @website.export_template
|
192
|
+
if zip_path
|
193
|
+
begin
|
194
|
+
send_file(zip_path, :stream => false)
|
195
|
+
rescue Exception => ex
|
196
|
+
raise "Error sending file. Make sure you have a website and an active theme."
|
180
197
|
end
|
181
|
-
|
182
|
-
|
183
|
-
render :json => {:success => false, :message => ex.message}
|
198
|
+
else
|
199
|
+
render :inline => {:success => false, :message => 'test'}.to_json
|
184
200
|
end
|
185
201
|
end
|
186
202
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
website_host = WebsiteHost.find(params[:id])
|
191
|
-
website_host.host = params[:host]
|
192
|
-
website_host.save
|
203
|
+
# TODO add role restriction to this
|
204
|
+
def import
|
205
|
+
website, message = Website.import(params[:website_data], current_user)
|
193
206
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
render :
|
207
|
+
if website
|
208
|
+
render :inline => {:success => true, :website => website.to_hash(:only => [:id, :name])}.to_json
|
209
|
+
else
|
210
|
+
render :inline => {:success => false, :message => message}.to_json
|
198
211
|
end
|
212
|
+
ensure
|
213
|
+
FileUtils.rm_r File.dirname(zip_path) rescue nil
|
199
214
|
end
|
200
215
|
|
201
|
-
def
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
render :
|
216
|
+
def importtemplate
|
217
|
+
website, message = Website.import_template_director(params[:website_data], User.first)
|
218
|
+
|
219
|
+
if website
|
220
|
+
render :inline => {:success => true, :website => website.to_hash(:only => [:id, :name])}.to_json
|
221
|
+
else
|
222
|
+
render :inline => {:success => false, :message => message}.to_json
|
208
223
|
end
|
209
224
|
end
|
210
225
|
|
211
|
-
|
226
|
+
def has_active_theme
|
227
|
+
!!Website.find_by_id(params[:website_id]).themes.active.first ? response = 'true' : response = 'false'
|
228
|
+
render :json => {:success => true, :message => response}
|
212
229
|
|
213
|
-
|
214
|
-
@website = Website.find(params[:id])
|
230
|
+
# example found in knitkit module.js
|
215
231
|
end
|
216
|
-
|
217
|
-
end#WebsiteController
|
218
|
-
end#Desktop
|
219
|
-
end#ErpApp
|
220
|
-
end#Knitkit
|
232
|
+
|
233
|
+
end # WebsiteController
|
234
|
+
end # Desktop
|
235
|
+
end # ErpApp
|
236
|
+
end # Knitkit
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Knitkit
|
2
|
+
module ErpApp
|
3
|
+
module Desktop
|
4
|
+
class WebsiteHostController < Knitkit::ErpApp::Desktop::AppController
|
5
|
+
|
6
|
+
before_filter :set_website, :only => [:index]
|
7
|
+
|
8
|
+
def index
|
9
|
+
tree = []
|
10
|
+
|
11
|
+
if @website
|
12
|
+
@website.hosts.each do |website_host|
|
13
|
+
|
14
|
+
tree << {:text => website_host.attributes['host'], :websiteHostId => website_host.id,
|
15
|
+
:host => website_host.attributes['host'], :iconCls => 'icon-globe',
|
16
|
+
:url => "http://#{website_host.attributes['host']}", :leaf => true}
|
17
|
+
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
render :json => tree
|
23
|
+
end
|
24
|
+
|
25
|
+
def create
|
26
|
+
begin
|
27
|
+
current_user.with_capability('create', 'WebsiteHost') do
|
28
|
+
website = Website.find(params[:website_id])
|
29
|
+
website_host = WebsiteHost.create(:host => params[:host])
|
30
|
+
website.hosts << website_host
|
31
|
+
website.save
|
32
|
+
|
33
|
+
render :json => {
|
34
|
+
:success => true,
|
35
|
+
:node => {
|
36
|
+
:text => website_host.attributes['host'],
|
37
|
+
:websiteHostId => website_host.id,
|
38
|
+
:host => website_host.attributes['host'],
|
39
|
+
:iconCls => 'icon-globe',
|
40
|
+
:url => "http://#{website_host.attributes['host']}",
|
41
|
+
:leaf => true}
|
42
|
+
}
|
43
|
+
end
|
44
|
+
rescue => ex
|
45
|
+
Rails.logger.error("#{ex.message} + #{ex.backtrace}")
|
46
|
+
render :json => {:success => false, :message => ex.message}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def update
|
51
|
+
begin
|
52
|
+
current_user.with_capability('edit', 'WebsiteHost') do
|
53
|
+
website_host = WebsiteHost.find(params[:id])
|
54
|
+
website_host.host = params[:host]
|
55
|
+
website_host.save
|
56
|
+
|
57
|
+
render :json => {:success => true}
|
58
|
+
end
|
59
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
|
60
|
+
render :json => {:success => false, :message => ex.message}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def destroy
|
65
|
+
begin
|
66
|
+
current_user.with_capability('delete', 'WebsiteHost') do
|
67
|
+
render :json => WebsiteHost.destroy(params[:id]) ? {:success => true} : {:success => false}
|
68
|
+
end
|
69
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
|
70
|
+
render :json => {:success => false, :message => ex.message}
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end # WebsiteHostController
|
75
|
+
end # Desktop
|
76
|
+
end # ErpApp
|
77
|
+
end # Knitkit
|
@@ -2,10 +2,31 @@ module Knitkit
|
|
2
2
|
module ErpApp
|
3
3
|
module Desktop
|
4
4
|
class WebsiteNavController < Knitkit::ErpApp::Desktop::AppController
|
5
|
-
|
5
|
+
|
6
|
+
before_filter :set_website, :only => [:index]
|
7
|
+
|
8
|
+
def index
|
9
|
+
tree = []
|
10
|
+
|
11
|
+
if @website
|
12
|
+
@website.website_navs.each do |website_nav|
|
13
|
+
menu_hash = {:text => website_nav.name, :websiteNavId => website_nav.id, :canAddMenuItems => true,
|
14
|
+
:iconCls => 'icon-index', :isWebsiteNav => true, :leaf => false, :children => []}
|
15
|
+
|
16
|
+
menu_hash[:children] = website_nav.website_nav_items.positioned.map { |item| build_menu_item_hash(item) }
|
17
|
+
|
18
|
+
tree << menu_hash
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
render :json => tree
|
23
|
+
end
|
24
|
+
|
25
|
+
def create
|
6
26
|
begin
|
7
27
|
current_user.with_capability('create', 'WebsiteNavItem') do
|
8
28
|
result = {}
|
29
|
+
|
9
30
|
website = Website.find(params[:website_id])
|
10
31
|
website_nav = WebsiteNav.new(:name => params[:name])
|
11
32
|
website.website_navs << website_nav
|
@@ -13,20 +34,19 @@ module Knitkit
|
|
13
34
|
if website_nav.save
|
14
35
|
result[:success] = true
|
15
36
|
result[:node] = {:text => params[:name],
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
:children => []}
|
37
|
+
:websiteNavId => website_nav.id,
|
38
|
+
:iconCls => 'icon-index',
|
39
|
+
:canAddMenuItems => true,
|
40
|
+
:isWebsiteNav => true,
|
41
|
+
:leaf => false,
|
42
|
+
:children => []}
|
23
43
|
else
|
24
44
|
result[:success] = false
|
25
45
|
end
|
26
46
|
|
27
47
|
render :json => result
|
28
48
|
end
|
29
|
-
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
49
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
|
30
50
|
render :json => {:success => false, :message => ex.message}
|
31
51
|
end
|
32
52
|
end
|
@@ -34,22 +54,22 @@ module Knitkit
|
|
34
54
|
def update
|
35
55
|
begin
|
36
56
|
current_user.with_capability('edit', 'WebsiteNavItem') do
|
37
|
-
website_nav = WebsiteNav.find(params[:
|
57
|
+
website_nav = WebsiteNav.find(params[:id])
|
38
58
|
website_nav.name = params[:name]
|
39
59
|
|
40
60
|
render :json => (website_nav.save ? {:success => true} : {:success => false})
|
41
61
|
end
|
42
|
-
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
62
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
|
43
63
|
render :json => {:success => false, :message => ex.message}
|
44
64
|
end
|
45
65
|
end
|
46
66
|
|
47
|
-
def
|
67
|
+
def destroy
|
48
68
|
begin
|
49
69
|
current_user.with_capability('delete', 'WebsiteNavItem') do
|
50
70
|
render :json => (WebsiteNav.destroy(params[:id]) ? {:success => true} : {:success => false})
|
51
71
|
end
|
52
|
-
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
72
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
|
53
73
|
render :json => {:success => false, :message => ex.message}
|
54
74
|
end
|
55
75
|
end
|
@@ -64,7 +84,7 @@ module Knitkit
|
|
64
84
|
website_nav_item = WebsiteNavItem.new(:title => params[:title])
|
65
85
|
|
66
86
|
url = params[:url]
|
67
|
-
if(params[:link_to] != 'url')
|
87
|
+
if (params[:link_to] != 'url')
|
68
88
|
#user wants to see Section so this is needed
|
69
89
|
params[:link_to] = 'WebsiteSection' if params[:link_to] == 'website_section'
|
70
90
|
|
@@ -88,25 +108,25 @@ module Knitkit
|
|
88
108
|
|
89
109
|
result[:success] = true
|
90
110
|
result[:node] = {:text => params[:title],
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
111
|
+
:linkToType => params[:link_to].underscore,
|
112
|
+
:linkedToId => linked_to_id,
|
113
|
+
:websiteNavId => website_nav.id,
|
114
|
+
:url => url,
|
115
|
+
:isSecure => false,
|
116
|
+
:roles => [],
|
117
|
+
:canAddMenuItems => true,
|
118
|
+
:websiteNavItemId => website_nav_item.id,
|
119
|
+
:iconCls => 'icon-document',
|
120
|
+
:isWebsiteNavItem => true,
|
121
|
+
:leaf => false,
|
122
|
+
:children => []}
|
103
123
|
else
|
104
124
|
result[:success] = false
|
105
125
|
end
|
106
126
|
|
107
127
|
render :json => result
|
108
128
|
end
|
109
|
-
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
129
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
|
110
130
|
render :json => {:success => false, :message => ex.message}
|
111
131
|
end
|
112
132
|
end
|
@@ -120,7 +140,7 @@ module Knitkit
|
|
120
140
|
|
121
141
|
url = params[:url]
|
122
142
|
linked_to_id = nil
|
123
|
-
if(params[:link_to] != 'url')
|
143
|
+
if (params[:link_to] != 'url')
|
124
144
|
#user wants to see Section so this is needed
|
125
145
|
params[:link_to] = 'WebsiteSection' if params[:link_to] == 'website_section'
|
126
146
|
|
@@ -147,7 +167,17 @@ module Knitkit
|
|
147
167
|
|
148
168
|
render :json => result
|
149
169
|
end
|
150
|
-
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
170
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
|
171
|
+
render :json => {:success => false, :message => ex.message}
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
def delete_menu_item
|
176
|
+
begin
|
177
|
+
current_user.with_capability('delete', 'WebsiteNavItem') do
|
178
|
+
render :json => (WebsiteNavItem.destroy(params[:id]) ? {:success => true} : {:success => false})
|
179
|
+
end
|
180
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
|
151
181
|
render :json => {:success => false, :message => ex.message}
|
152
182
|
end
|
153
183
|
end
|
@@ -176,23 +206,13 @@ module Knitkit
|
|
176
206
|
end
|
177
207
|
end
|
178
208
|
|
179
|
-
render :json => {:success => true, :secured => website_nav_item.is_secured?, :roles => website_nav_item.roles.collect{|item| item.internal_identifier}}
|
209
|
+
render :json => {:success => true, :secured => website_nav_item.is_secured?, :roles => website_nav_item.roles.collect { |item| item.internal_identifier }}
|
180
210
|
else
|
181
211
|
render :json => {:success => false, :message => "User does not have capability."}
|
182
212
|
end
|
183
213
|
end
|
184
214
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
end
|
190
|
-
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
191
|
-
render :json => {:success => false, :message => ex.message}
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
end#WebsiteNavController
|
196
|
-
end#Desktop
|
197
|
-
end#ErpApp
|
198
|
-
end#Knitkit
|
215
|
+
end #WebsiteNavController
|
216
|
+
end #Desktop
|
217
|
+
end #ErpApp
|
218
|
+
end #Knitkit
|