knitkit 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +22 -0
- data/app/controllers/knitkit/base_controller.rb +15 -2
- data/app/controllers/knitkit/blogs_controller.rb +4 -4
- data/app/controllers/knitkit/erp_app/desktop/app_controller.rb +16 -2
- data/app/controllers/knitkit/erp_app/desktop/articles_controller.rb +198 -57
- data/app/controllers/knitkit/erp_app/desktop/content_controller.rb +25 -11
- data/app/controllers/knitkit/erp_app/desktop/file_assets_controller.rb +123 -44
- data/app/controllers/knitkit/erp_app/desktop/image_assets_controller.rb +83 -9
- data/app/controllers/knitkit/erp_app/desktop/online_document_sections_controller.rb +38 -0
- data/app/controllers/knitkit/erp_app/desktop/position_controller.rb +15 -6
- data/app/controllers/knitkit/erp_app/desktop/theme_controller.rb +185 -98
- data/app/controllers/knitkit/erp_app/desktop/versions_controller.rb +38 -16
- data/app/controllers/knitkit/erp_app/desktop/website_controller.rb +126 -68
- data/app/controllers/knitkit/erp_app/desktop/website_nav_controller.rb +154 -107
- data/app/controllers/knitkit/erp_app/desktop/website_section_controller.rb +113 -54
- data/app/controllers/knitkit/online_document_sections_controller.rb +45 -0
- data/app/controllers/knitkit/unauthorized_controller.rb +5 -0
- data/app/controllers/knitkit/website_sections_controller.rb +8 -9
- data/app/mailers/document_mailer.rb +10 -0
- data/app/models/article.rb +1 -1
- data/app/models/content.rb +35 -3
- data/app/models/document.rb +8 -0
- data/app/models/document_type.rb +3 -0
- data/app/models/documented_content.rb +29 -0
- data/app/models/documented_item.rb +31 -0
- data/app/models/extensions/configuration.rb +5 -0
- data/app/models/extensions/party.rb +13 -0
- data/app/models/online_document_section.rb +40 -0
- data/app/models/theme.rb +22 -26
- data/app/models/valid_document.rb +4 -0
- data/app/models/website.rb +158 -119
- data/app/models/website_inquiry.rb +7 -2
- data/app/models/website_inquiry_mailer.rb +4 -3
- data/app/models/website_party_role.rb +5 -0
- data/app/models/website_section.rb +76 -38
- data/app/views/document_mailer/email_document.html.erb +12 -0
- data/app/views/knitkit/blogs/_add_comment.html.erb +2 -2
- data/app/views/knitkit/online_document_sections/index.html.erb +149 -0
- data/app/views/knitkit/website_sections/index.html.erb +0 -1
- data/app/views/layouts/knitkit/base.html.erb +4 -2
- data/app/views/layouts/knitkit/online_document_sections.html.erb +59 -0
- data/app/views/menus/knitkit/_default_menu.html.erb +1 -1
- data/app/views/menus/knitkit/_default_section_menu.html.erb +1 -1
- data/app/views/menus/knitkit/_default_sub_menu.html.erb +2 -2
- data/app/views/menus/knitkit/_default_sub_section_menu.html.erb +1 -1
- data/app/widgets/contact_us/base.rb +5 -5
- data/app/widgets/contact_us/javascript/contact_us.js +2 -1
- data/app/widgets/google_map/base.rb +0 -4
- data/app/widgets/google_map/javascript/google_map.js +4 -3
- data/app/widgets/login/base.rb +0 -5
- data/app/widgets/login/javascript/login.js +155 -153
- data/app/widgets/login/views/index.html.erb +3 -3
- data/app/widgets/login/views/reset_password.html.erb +2 -2
- data/app/widgets/manage_profile/base.rb +46 -67
- data/app/widgets/manage_profile/javascript/manage_profile.js +2 -1
- data/app/widgets/manage_profile/views/_user_information_form.html.erb +5 -1
- data/app/widgets/reset_password/base.rb +4 -6
- data/app/widgets/reset_password/javascript/reset_password.js +2 -1
- data/app/widgets/reset_password/views/index.html.erb +4 -3
- data/app/widgets/search/base.rb +1 -5
- data/app/widgets/search/javascript/search.js +2 -1
- data/app/widgets/search/views/show.html.erb +2 -2
- data/app/widgets/signup/base.rb +7 -6
- data/app/widgets/signup/javascript/signup.js +2 -1
- data/app/widgets/signup/views/error.html.erb +1 -1
- data/config/routes.rb +6 -2
- data/db/data_migrations/20110509223702_add_publisher_role.rb +10 -0
- data/db/data_migrations/20111118182910_setup_knitkit_capabilities.rb +84 -0
- data/db/data_migrations/20120127144444_create_website_role_types.rb +13 -0
- data/db/data_migrations/20120127150505_create_website_default_configuration.rb +72 -0
- data/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.rb +33 -0
- data/db/data_migrations/20120316150424_add_is_template_to_default_website_config.rb +16 -0
- data/db/data_migrations/upgrade/20120210195616_add_website_configs.rb +19 -0
- data/db/data_migrations/upgrade/20120213205519_populate_website_iids.rb +17 -0
- data/db/migrate/20110211002317_setup_knitkit.rb +22 -5
- data/db/migrate/20111207161928_create_documented_items_table.rb +13 -0
- data/db/migrate/20111208180539_add_document_id_to_documented_item.rb +9 -0
- data/db/migrate/20120315163736_add_document.rb +32 -0
- data/db/migrate/20120503183431_create_valid_documents.rb +16 -0
- data/db/migrate/upgrade/20120116201510_add_render_base_layout_flag.rb +13 -0
- data/db/migrate/upgrade/20120127143745_create_website_party_roles.rb +24 -0
- data/db/migrate/upgrade/20120213184509_add_iid_to_websites.rb +14 -0
- data/lib/knitkit.rb +2 -0
- data/lib/knitkit/config.rb +31 -0
- data/lib/knitkit/engine.rb +12 -3
- data/lib/knitkit/extensions.rb +1 -3
- data/lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb +2 -3
- data/lib/knitkit/extensions/active_record/acts_as_document.rb +63 -0
- data/lib/knitkit/extensions/active_record/acts_as_publishable.rb +5 -4
- data/lib/knitkit/extensions/compass_ae/widgets/base.rb +70 -0
- data/lib/knitkit/extensions/railties/action_view.rb +22 -10
- data/lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb +3 -3
- data/lib/knitkit/extensions/railties/theme_support/theme_file_resolver.rb +8 -3
- data/lib/knitkit/routing_filter/section_router.rb +16 -6
- data/lib/knitkit/version.rb +7 -1
- data/public/images/check.png +0 -0
- data/public/images/credit_card.png +0 -0
- data/public/images/knitkit/tooltip.gif +0 -0
- data/public/javascripts/ajax_pagination.js +33 -0
- data/public/javascripts/datepicker.js +6 -1
- data/public/javascripts/erp_app/desktop/applications/knitkit/articles_grid_panel.js +731 -258
- data/public/javascripts/erp_app/desktop/applications/knitkit/center_region.js +289 -238
- data/public/javascripts/erp_app/desktop/applications/knitkit/comments_grid_panel.js +2 -4
- data/public/javascripts/erp_app/desktop/applications/knitkit/east_region.js +29 -3
- data/public/javascripts/erp_app/desktop/applications/knitkit/file_assets_panel.js +193 -21
- data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_data_view.js +27 -26
- data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_panel.js +167 -20
- data/public/javascripts/erp_app/desktop/applications/knitkit/inquiries_grid_panel.js +1 -2
- data/public/javascripts/erp_app/desktop/applications/knitkit/module.js +5 -1
- data/public/javascripts/erp_app/desktop/applications/knitkit/publish_window.js +2 -2
- data/public/javascripts/erp_app/desktop/applications/knitkit/published_grid_panel.js +20 -11
- data/public/javascripts/erp_app/desktop/applications/knitkit/section_articles_grid_panel.js +279 -228
- data/public/javascripts/erp_app/desktop/applications/knitkit/themes_tree_panel.js +40 -40
- data/public/javascripts/erp_app/desktop/applications/knitkit/versions_grid_panel.js +83 -76
- data/public/javascripts/erp_app/desktop/applications/knitkit/west_region.js +1961 -1397
- data/public/javascripts/erp_app/desktop/applications/knitkit/widgets_panel.js +47 -43
- data/public/javascripts/knitkit/helpers.js +26 -0
- data/public/stylesheets/erp_app/desktop/applications/knitkit/knitkit.css +1 -2
- data/public/stylesheets/knitkit/documentation.css +50 -0
- data/public/stylesheets/knitkit/style.css +23 -1
- data/spec/controllers/knitkit/erp_app/desktop/articles_controller_spec.rb +8 -0
- data/spec/controllers/knitkit/erp_app/desktop/website_controller_spec.rb +396 -0
- data/spec/controllers/knitkit/erp_app/desktop/website_nav_controller_spec.rb +260 -0
- data/spec/controllers/knitkit/erp_app/desktop/website_section_controller_spec.rb +222 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +43 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +8 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/spec.rb +27 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/workflow.yml +1 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/article.rb +4 -0
- data/spec/factories/basic.rb +3 -0
- data/spec/factories/blog.rb +5 -0
- data/spec/factories/documented_content.rb +4 -0
- data/spec/factories/documented_item.rb +4 -0
- data/spec/factories/online_document_section.rb +6 -0
- data/spec/factories/published_website.rb +4 -0
- data/spec/factories/theme.rb +6 -0
- data/spec/factories/website.rb +5 -0
- data/spec/factories/website_host.rb +4 -0
- data/spec/factories/website_nav.rb +5 -0
- data/spec/factories/website_nav_item.rb +4 -0
- data/spec/factories/website_section.rb +5 -0
- data/spec/models/article_spec.rb +35 -0
- data/spec/models/attribute_type_spec.rb +55 -0
- data/spec/models/attribute_value_spec.rb +114 -0
- data/spec/models/blog_spec.rb +16 -0
- data/spec/models/comment_spec.rb +11 -0
- data/spec/models/content_spec.rb +187 -0
- data/spec/models/documented_item_spec.rb +29 -0
- data/spec/models/online_document_section_spec.rb +34 -0
- data/spec/models/published_element_spec.rb +11 -0
- data/spec/models/published_website_spec.rb +11 -0
- data/spec/models/theme_spec.rb +12 -0
- data/spec/models/website_host_spec.rb +11 -0
- data/spec/models/website_inquiry_spec.rb +24 -0
- data/spec/models/website_nav_item_spec.rb +11 -0
- data/spec/models/website_nav_spec.rb +11 -0
- data/spec/models/website_section_content_spec.rb +11 -0
- data/spec/models/website_section_spec.rb +49 -0
- data/spec/models/website_spec.rb +146 -0
- data/spec/spec_helper.rb +61 -0
- metadata +391 -154
- data/app/controllers/knitkit/articles_controller.rb +0 -7
- data/lib/knitkit/extensions/compass/widgets/base.rb +0 -53
@@ -34,23 +34,44 @@ module Knitkit
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def new
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
37
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
38
|
+
begin
|
39
|
+
current_user.with_capability(model, 'view', 'Theme') do
|
40
|
+
unless params[:theme_data].blank?
|
41
|
+
@website.themes.import(params[:theme_data], @website)
|
42
|
+
else
|
43
|
+
theme = Theme.create(:website => @website, :name => params[:name], :theme_id => params[:theme_id])
|
44
|
+
theme.version = params[:version]
|
45
|
+
theme.author = params[:author]
|
46
|
+
theme.homepage = params[:homepage]
|
47
|
+
theme.summary = params[:summary]
|
48
|
+
theme.save
|
49
|
+
theme.create_theme_files!
|
50
|
+
end
|
48
51
|
|
49
|
-
|
52
|
+
render :inline => {:success => true}.to_json
|
53
|
+
end
|
54
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
55
|
+
render :json => {:success => false, :message => ex.message}
|
56
|
+
end
|
50
57
|
end
|
51
58
|
|
52
59
|
def delete
|
53
|
-
|
60
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
61
|
+
begin
|
62
|
+
current_user.with_capability(model, 'view', 'Theme') do
|
63
|
+
if @theme.destroy
|
64
|
+
#clear resolver cache
|
65
|
+
path = File.join("#{@theme[:url]}","templates")
|
66
|
+
cached_resolver = ThemeSupport::Cache.theme_resolvers.find{|cached_resolver| cached_resolver.to_path == path}
|
67
|
+
render :json => {:success => true}
|
68
|
+
else
|
69
|
+
render :json => {:success => false}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
73
|
+
render :json => {:success => false, :message => ex.message}
|
74
|
+
end
|
54
75
|
end
|
55
76
|
|
56
77
|
def export
|
@@ -62,11 +83,18 @@ module Knitkit
|
|
62
83
|
end
|
63
84
|
|
64
85
|
def change_status
|
65
|
-
|
66
|
-
|
67
|
-
|
86
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
87
|
+
begin
|
88
|
+
current_user.with_capability(model, 'view', 'Theme') do
|
89
|
+
#clear active themes
|
90
|
+
@website.deactivate_themes! if (params[:active] == 'true')
|
91
|
+
(params[:active] == 'true') ? @theme.activate! : @theme.deactivate!
|
68
92
|
|
69
|
-
|
93
|
+
render :json => {:success => true}
|
94
|
+
end
|
95
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
96
|
+
render :json => {:success => false, :message => ex.message}
|
97
|
+
end
|
70
98
|
end
|
71
99
|
|
72
100
|
##############################################################
|
@@ -76,60 +104,94 @@ module Knitkit
|
|
76
104
|
##############################################################
|
77
105
|
|
78
106
|
def create_file
|
79
|
-
|
80
|
-
|
107
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
108
|
+
begin
|
109
|
+
current_user.with_capability(model, 'view', 'Theme') do
|
110
|
+
path = File.join(@file_support.root,params[:path])
|
111
|
+
name = params[:name]
|
81
112
|
|
82
|
-
|
83
|
-
|
113
|
+
theme = get_theme(path)
|
114
|
+
theme.add_file('#Empty File', File.join(path, name))
|
84
115
|
|
85
|
-
|
116
|
+
render :json => {:success => true}
|
117
|
+
end
|
118
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
119
|
+
render :json => {:success => false, :message => ex.message}
|
120
|
+
end
|
86
121
|
end
|
87
122
|
|
88
123
|
def create_folder
|
89
|
-
|
90
|
-
|
124
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
125
|
+
begin
|
126
|
+
current_user.with_capability(model, 'view', 'Theme') do
|
127
|
+
path = File.join(@file_support.root,params[:path])
|
128
|
+
name = params[:name]
|
91
129
|
|
92
|
-
|
93
|
-
|
130
|
+
@file_support.create_folder(path, name)
|
131
|
+
render :json => {:success => true}
|
132
|
+
end
|
133
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
134
|
+
render :json => {:success => false, :message => ex.message}
|
135
|
+
end
|
94
136
|
end
|
95
137
|
|
96
138
|
def update_file
|
97
|
-
|
98
|
-
|
139
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
140
|
+
begin
|
141
|
+
current_user.with_capability(model, 'view', 'Theme') do
|
142
|
+
path = File.join(@file_support.root,params[:node])
|
143
|
+
content = params[:content]
|
99
144
|
|
100
|
-
|
101
|
-
|
145
|
+
type = File.extname(File.basename(path)).gsub(/^\.+/, '').to_sym
|
146
|
+
result = Knitkit::SyntaxValidator.validate_content(type, content)
|
102
147
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
148
|
+
unless result
|
149
|
+
@file_support.update_file(path, content)
|
150
|
+
render :json => {:success => true}
|
151
|
+
else
|
152
|
+
render :json => {:success => false, :message => result}
|
153
|
+
end
|
154
|
+
end
|
155
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
156
|
+
render :json => {:success => false, :message => ex.message}
|
108
157
|
end
|
109
158
|
end
|
110
159
|
|
111
160
|
def save_move
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
161
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
162
|
+
begin
|
163
|
+
current_user.with_capability(model, 'view', 'Theme') do
|
164
|
+
result = {}
|
165
|
+
path = File.join(@file_support.root, params[:node])
|
166
|
+
new_parent_path = File.join(@file_support.root, params[:parent_node])
|
116
167
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
168
|
+
unless @file_support.exists? path
|
169
|
+
result = {:success => false, :msg => 'File does not exist.'}
|
170
|
+
else
|
171
|
+
theme_file = get_theme_file(path)
|
172
|
+
theme_file.move(params[:parent_node])
|
173
|
+
result = {:success => true, :msg => "#{File.basename(path)} was moved to #{new_parent_path} successfully"}
|
174
|
+
end
|
124
175
|
|
125
|
-
|
176
|
+
render :json => result
|
177
|
+
end
|
178
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
179
|
+
render :json => {:success => false, :message => ex.message}
|
180
|
+
end
|
126
181
|
end
|
127
182
|
|
128
183
|
def download_file
|
129
|
-
|
130
|
-
|
184
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
185
|
+
begin
|
186
|
+
current_user.with_capability(model, 'view', 'Theme') do
|
187
|
+
path = File.join(@file_support.root,params[:path])
|
188
|
+
contents, message = @file_support.get_contents(path)
|
131
189
|
|
132
|
-
|
190
|
+
send_data contents, :filename => File.basename(path)
|
191
|
+
end
|
192
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
193
|
+
render :json => {:success => false, :message => ex.message}
|
194
|
+
end
|
133
195
|
end
|
134
196
|
|
135
197
|
def get_contents
|
@@ -144,58 +206,82 @@ module Knitkit
|
|
144
206
|
end
|
145
207
|
|
146
208
|
def upload_file
|
147
|
-
|
148
|
-
upload_path = request.env['HTTP_EXTRAPOSTDATA_DIRECTORY'].blank? ? params[:directory] : request.env['HTTP_EXTRAPOSTDATA_DIRECTORY']
|
149
|
-
name = request.env['HTTP_X_FILE_NAME'].blank? ? params[:file_data].original_filename : request.env['HTTP_X_FILE_NAME']
|
150
|
-
data = request.env['HTTP_X_FILE_NAME'].blank? ? params[:file_data] : request.raw_post
|
151
|
-
|
152
|
-
theme = get_theme(upload_path)
|
153
|
-
name = File.join(@file_support.root, upload_path, name)
|
154
|
-
|
209
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
155
210
|
begin
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
211
|
+
current_user.with_capability(model, 'view', 'Theme') do
|
212
|
+
result = {}
|
213
|
+
upload_path = request.env['HTTP_EXTRAPOSTDATA_DIRECTORY'].blank? ? params[:directory] : request.env['HTTP_EXTRAPOSTDATA_DIRECTORY']
|
214
|
+
name = request.env['HTTP_X_FILE_NAME'].blank? ? params[:file_data].original_filename : request.env['HTTP_X_FILE_NAME']
|
215
|
+
data = request.env['HTTP_X_FILE_NAME'].blank? ? params[:file_data] : request.raw_post
|
216
|
+
|
217
|
+
theme = get_theme(upload_path)
|
218
|
+
name = File.join(@file_support.root, upload_path, name)
|
219
|
+
|
220
|
+
begin
|
221
|
+
theme.add_file(data, name)
|
222
|
+
result = {:success => true}
|
223
|
+
rescue Exception=>ex
|
224
|
+
logger.error ex.message
|
225
|
+
logger.error ex.backtrace.join("\n")
|
226
|
+
result = {:success => false, :error => "Error uploading #{name}"}
|
227
|
+
end
|
163
228
|
|
164
|
-
|
229
|
+
render :inline => result.to_json
|
230
|
+
end
|
231
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
232
|
+
render :json => {:success => false, :message => ex.message}
|
233
|
+
end
|
165
234
|
end
|
166
235
|
|
167
236
|
def delete_file
|
168
|
-
|
169
|
-
result = {}
|
237
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
170
238
|
begin
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
239
|
+
current_user.with_capability(model, 'view', 'Theme') do
|
240
|
+
path = params[:node]
|
241
|
+
result = {}
|
242
|
+
begin
|
243
|
+
name = File.basename(path)
|
244
|
+
result, message, is_folder = @file_support.delete_file(File.join(@file_support.root,path))
|
245
|
+
if result && !is_folder
|
246
|
+
theme_file = get_theme_file(path)
|
247
|
+
theme_file.destroy
|
248
|
+
#clear resolver cache
|
249
|
+
path = File.join("#{@theme[:url]}","templates")
|
250
|
+
cached_resolver = ThemeSupport::Cache.theme_resolvers.find{|cached_resolver| cached_resolver.to_path == path}
|
251
|
+
end
|
252
|
+
result = {:success => result, :error => message}
|
253
|
+
rescue Exception=>ex
|
254
|
+
logger.error ex.message
|
255
|
+
logger.error ex.backtrace.join("\n")
|
256
|
+
result = {:success => false, :error => "Error deleting #{name}"}
|
257
|
+
end
|
258
|
+
render :json => result
|
176
259
|
end
|
177
|
-
|
178
|
-
|
179
|
-
logger.error ex.message
|
180
|
-
logger.error ex.backtrace.join("\n")
|
181
|
-
result = {:success => false, :error => "Error deleting #{name}"}
|
260
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
261
|
+
render :json => {:success => false, :message => ex.message}
|
182
262
|
end
|
183
|
-
render :json => result
|
184
263
|
end
|
185
264
|
|
186
265
|
def rename_file
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
266
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
267
|
+
begin
|
268
|
+
current_user.with_capability(model, 'view', 'Theme') do
|
269
|
+
result = {:success => true, :data => {:success => true}}
|
270
|
+
path = params[:node]
|
271
|
+
name = params[:file_name]
|
272
|
+
|
273
|
+
result, message = @file_support.rename_file(@file_support.root+path, name)
|
274
|
+
if result
|
275
|
+
theme_file = get_theme_file(path)
|
276
|
+
theme_file.name = name
|
277
|
+
theme_file.save
|
278
|
+
end
|
197
279
|
|
198
|
-
|
280
|
+
render :json => {:success => true, :message => message}
|
281
|
+
end
|
282
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
283
|
+
render :json => {:success => false, :message => ex.message}
|
284
|
+
end
|
199
285
|
end
|
200
286
|
|
201
287
|
protected
|
@@ -204,19 +290,20 @@ module Knitkit
|
|
204
290
|
sites_index = path.index('sites')
|
205
291
|
sites_path = path[sites_index..path.length]
|
206
292
|
site_name = sites_path.split('/')[1]
|
207
|
-
site = Website.
|
293
|
+
site = Website.find_by_internal_identifier(site_name)
|
208
294
|
|
209
295
|
themes_index = path.index('themes')
|
210
296
|
path = path[themes_index..path.length]
|
211
297
|
theme_name = path.split('/')[1]
|
212
|
-
theme = site.themes.find_by_theme_id(theme_name)
|
298
|
+
@theme = site.themes.find_by_theme_id(theme_name)
|
213
299
|
|
214
|
-
theme
|
300
|
+
@theme
|
215
301
|
end
|
216
302
|
|
217
303
|
def get_theme_file(path)
|
218
304
|
theme = get_theme(path)
|
219
|
-
|
305
|
+
file_dir = ::File.dirname(path).gsub(Regexp.new(Rails.root.to_s), '')
|
306
|
+
theme.files.where('name = ? and directory = ?', ::File.basename(path), file_dir).first
|
220
307
|
end
|
221
308
|
|
222
309
|
def setup_tree
|
@@ -234,16 +321,16 @@ module Knitkit
|
|
234
321
|
}
|
235
322
|
|
236
323
|
#handle themes
|
237
|
-
themes_hash = {:text => 'Themes', :contextMenuDisabled => true, :isThemeRoot => true, :siteId => site.id, :children => []}
|
324
|
+
themes_hash = {:text => 'Themes', :contextMenuDisabled => true, :iconCls => 'icon-content', :isThemeRoot => true, :siteId => site.id, :children => []}
|
238
325
|
site.themes.each do |theme|
|
239
|
-
theme_hash = {:text => "#{theme.name}[#{theme.theme_id}]", :handleContextMenu => true, :siteId => site.id, :isActive => (theme.active == 1), :isTheme => true, :id => theme.id, :children => []}
|
326
|
+
theme_hash = {:text => "#{theme.name}[#{theme.theme_id}]", :handleContextMenu => true, :siteId => site.id, :isActive => (theme.active == 1), :iconCls => 'icon-content', :isTheme => true, :id => theme.id, :children => []}
|
240
327
|
if theme.active == 1
|
241
328
|
theme_hash[:iconCls] = 'icon-add'
|
242
329
|
else
|
243
330
|
theme_hash[:iconCls] = 'icon-delete'
|
244
331
|
end
|
245
332
|
['stylesheets', 'javascripts', 'images', 'templates', 'widgets'].each do |resource_folder|
|
246
|
-
theme_hash[:children] << {:text => resource_folder, :
|
333
|
+
theme_hash[:children] << {:text => resource_folder, :iconCls => 'icon-content', :id => "#{theme.url}/#{resource_folder}"}
|
247
334
|
end
|
248
335
|
themes_hash[:children] << theme_hash
|
249
336
|
end
|
@@ -263,7 +350,7 @@ module Knitkit
|
|
263
350
|
end
|
264
351
|
|
265
352
|
def set_file_support
|
266
|
-
@file_support = ErpTechSvcs::FileSupport::Base.new(:storage => ErpTechSvcs::
|
353
|
+
@file_support = ErpTechSvcs::FileSupport::Base.new(:storage => ErpTechSvcs::Config.file_storage)
|
267
354
|
end
|
268
355
|
|
269
356
|
end#ThemeController
|
@@ -34,11 +34,14 @@ module Knitkit
|
|
34
34
|
def publisher
|
35
35
|
published_element.published_by_username if published
|
36
36
|
end
|
37
|
+
|
37
38
|
end
|
38
39
|
|
39
|
-
render :
|
40
|
-
|
41
|
-
|
40
|
+
render :json => {:totalCount => content.versions.count,
|
41
|
+
:data => versions.collect{|version|version.to_hash(
|
42
|
+
:only => [:id, :content_id, :version, :title, :body_html, :excerpt_html, :updated_at],
|
43
|
+
:methods => [:active, :published, :publisher])}
|
44
|
+
}
|
42
45
|
end
|
43
46
|
|
44
47
|
def non_published_content_versions
|
@@ -51,23 +54,40 @@ module Knitkit
|
|
51
54
|
|
52
55
|
versions = content.versions.order("#{sort} #{dir}").offset(start).limit(limit)
|
53
56
|
|
54
|
-
render :
|
57
|
+
render :json => {:totalCount => content.versions.count,
|
58
|
+
:data => versions.collect{|version|version.to_hash(
|
59
|
+
:only => [:id, :version, :title, :body_html, :excerpt_html, :updated_at])}
|
60
|
+
}
|
55
61
|
end
|
56
62
|
|
57
63
|
def publish_content
|
58
|
-
|
59
|
-
|
64
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
65
|
+
begin
|
66
|
+
current_user.with_capability(model, 'publish', 'Article') do
|
67
|
+
content = Content.find(Content::Version.find(params[:id]).content_id)
|
68
|
+
content.publish(Website.find(params[:site_id]), params[:comment], params[:version], current_user)
|
60
69
|
|
61
|
-
|
70
|
+
render :json => {:success => true}
|
71
|
+
end
|
72
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
73
|
+
render :json => {:success => false, :message => ex.message}
|
74
|
+
end
|
62
75
|
end
|
63
76
|
|
64
77
|
def revert_content
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
78
|
+
model = DesktopApplication.find_by_internal_identifier('knitkit')
|
79
|
+
begin
|
80
|
+
current_user.with_capability(model, 'revert_version', 'Article') do
|
81
|
+
content = Content.find(Content::Version.find(params[:id]).content_id)
|
82
|
+
version = params[:version]
|
83
|
+
content.revert_to(version)
|
84
|
+
content.save!
|
85
|
+
|
86
|
+
render :json => {:success => true}
|
87
|
+
end
|
88
|
+
rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
|
89
|
+
render :json => {:success => false, :message => ex.message}
|
90
|
+
end
|
71
91
|
end
|
72
92
|
|
73
93
|
#website section layouts
|
@@ -104,9 +124,11 @@ module Knitkit
|
|
104
124
|
end
|
105
125
|
end
|
106
126
|
|
107
|
-
render :
|
108
|
-
|
109
|
-
|
127
|
+
render :json => {:totalCount => website_section.versions.count,
|
128
|
+
:data => versions.collect{|version|version.to_hash(
|
129
|
+
:only => [:id, :version, :title, :updated_at],
|
130
|
+
:methods => [:active, :published, :publisher])}
|
131
|
+
}
|
110
132
|
end
|
111
133
|
|
112
134
|
def get_website_section_version
|