knitkit 3.0.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/{public → app/assets}/images/check.png +0 -0
  3. data/{public → app/assets}/images/credit_card.png +0 -0
  4. data/{public → app/assets}/images/inline_edit/close.png +0 -0
  5. data/{public → app/assets}/images/knitkit/icons/document.png +0 -0
  6. data/{public → app/assets}/images/knitkit/icons/multi_doc.png +0 -0
  7. data/{public → app/assets}/images/knitkit/logo.png +0 -0
  8. data/{public → app/assets}/images/knitkit/splash/images/add-site.png +0 -0
  9. data/app/assets/images/knitkit/splash/images/add_website_105x105-active.png +0 -0
  10. data/app/assets/images/knitkit/splash/images/add_website_105x105.png +0 -0
  11. data/{public → app/assets}/images/knitkit/splash/images/adjust-site.png +0 -0
  12. data/{public → app/assets}/images/knitkit/splash/images/browse-site.png +0 -0
  13. data/app/assets/images/knitkit/splash/images/browse_db_105x105-active.png +0 -0
  14. data/app/assets/images/knitkit/splash/images/browse_db_105x105.png +0 -0
  15. data/app/assets/images/knitkit/splash/images/console_105x105-active.png +0 -0
  16. data/app/assets/images/knitkit/splash/images/console_105x105.png +0 -0
  17. data/{public → app/assets}/images/knitkit/splash/images/find-themes.png +0 -0
  18. data/app/assets/images/knitkit/splash/images/find_themes_105x105-active.png +0 -0
  19. data/app/assets/images/knitkit/splash/images/find_themes_105x105.png +0 -0
  20. data/app/assets/images/knitkit/splash/images/learn_more_105x105-active.png +0 -0
  21. data/app/assets/images/knitkit/splash/images/learn_more_105x105.png +0 -0
  22. data/{public → app/assets}/images/knitkit/splash/images/settings.png +0 -0
  23. data/{public → app/assets}/images/knitkit/splash/images/tutorials.png +0 -0
  24. data/app/assets/images/knitkit/splash/splash.png +0 -0
  25. data/app/assets/images/widgets/manage_profile/contact_information.png +0 -0
  26. data/app/assets/images/widgets/manage_profile/password.png +0 -0
  27. data/app/assets/images/widgets/manage_profile/user_information.png +0 -0
  28. data/app/assets/javascripts/erp_app/desktop/applications/knitkit/app.js +24 -0
  29. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/articles_grid_panel.js +15 -12
  30. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/center_region.js +69 -48
  31. data/app/assets/javascripts/erp_app/desktop/applications/knitkit/comments_grid_panel.js +214 -0
  32. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/east_region/east_region.js +0 -0
  33. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/east_region/file_assets_panel.js +17 -19
  34. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/east_region/image_assets_data_view.js +13 -3
  35. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/east_region/image_assets_panel.js +59 -48
  36. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/east_region/widgets_panel.js +0 -0
  37. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/inquiries_grid_panel.js +2 -2
  38. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/module.js +2 -2
  39. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/publish_window.js +0 -0
  40. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/published_grid_panel.js +1 -1
  41. data/app/assets/javascripts/erp_app/desktop/applications/knitkit/splash_screen.js +268 -0
  42. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/top_menu/main_menu.js +85 -33
  43. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/top_menu/websites_combo.js +0 -0
  44. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/versions_grid_panel.js +5 -28
  45. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/article.js +22 -8
  46. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/document.js +143 -25
  47. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/host.js +5 -1
  48. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/menu.js +2 -0
  49. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/section.js +181 -65
  50. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/website_nav_items.js +0 -0
  51. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/hosts_tree_panel.js +0 -0
  52. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/menu_tree_panel.js +0 -0
  53. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/site_contents_tree_panel.js +121 -116
  54. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/themes_tree_panel.js +101 -10
  55. data/{public → app/assets}/javascripts/erp_app/desktop/applications/knitkit/west_region/west_region.js +9 -5
  56. data/app/assets/javascripts/knitkit-web.js +22 -0
  57. data/app/assets/javascripts/knitkit/additional-methods.min.js +4 -0
  58. data/app/assets/javascripts/knitkit/bootstrap.min.js +7 -0
  59. data/app/assets/javascripts/knitkit/captcha.js +154 -0
  60. data/{public → app/assets}/javascripts/knitkit/confirm-bootstrap.js +1 -1
  61. data/{public → app/assets}/javascripts/knitkit/inline_editing.js +1 -1
  62. data/{public → app/assets}/javascripts/knitkit/jquery.maskedinput.min.js +0 -0
  63. data/app/assets/javascripts/knitkit/jquery.validate.min.js +4 -0
  64. data/app/assets/javascripts/knitkit/js.cookie.js +145 -0
  65. data/{public → app/assets}/javascripts/knitkit/theme.js +0 -0
  66. data/app/assets/stylesheets/erp_app/desktop/applications/knitkit/app.css +12 -0
  67. data/{public → app/assets}/stylesheets/erp_app/desktop/applications/knitkit/knitkit.css +23 -33
  68. data/app/assets/stylesheets/erp_app/shared/knitkit_shared.css +21 -0
  69. data/app/assets/stylesheets/fonts/glyphicons-halflings-regular.eot +0 -0
  70. data/app/assets/stylesheets/fonts/glyphicons-halflings-regular.svg +288 -0
  71. data/app/assets/stylesheets/fonts/glyphicons-halflings-regular.ttf +0 -0
  72. data/app/assets/stylesheets/fonts/glyphicons-halflings-regular.woff +0 -0
  73. data/app/assets/stylesheets/fonts/glyphicons-halflings-regular.woff2 +0 -0
  74. data/app/assets/stylesheets/knitkit-web.css +16 -0
  75. data/app/assets/stylesheets/knitkit/bootstrap.min.css +5 -0
  76. data/app/assets/stylesheets/knitkit/captcha.css +59 -0
  77. data/app/assets/stylesheets/knitkit/custom.css +144 -0
  78. data/{public → app/assets}/stylesheets/knitkit/inline_editing.css +0 -0
  79. data/app/assets/stylesheets/knitkit/submenu.css +93 -0
  80. data/app/controllers/api/v1/websites_controller.rb +14 -0
  81. data/app/controllers/captcha_controller.rb +53 -0
  82. data/app/controllers/knitkit/base_controller.rb +1 -5
  83. data/app/controllers/knitkit/erp_app/desktop/app_controller.rb +2 -9
  84. data/app/controllers/knitkit/erp_app/desktop/articles_controller.rb +20 -7
  85. data/app/controllers/knitkit/erp_app/desktop/file_assets_controller.rb +38 -28
  86. data/app/controllers/knitkit/erp_app/desktop/image_assets_controller.rb +16 -9
  87. data/app/controllers/knitkit/erp_app/desktop/online_document_sections_controller.rb +69 -15
  88. data/app/controllers/knitkit/erp_app/desktop/position_controller.rb +45 -58
  89. data/app/controllers/knitkit/erp_app/desktop/theme_controller.rb +64 -29
  90. data/app/controllers/knitkit/erp_app/desktop/website_controller.rb +36 -13
  91. data/app/controllers/knitkit/erp_app/desktop/website_host_controller.rb +12 -0
  92. data/app/controllers/knitkit/erp_app/desktop/website_nav_controller.rb +4 -11
  93. data/app/controllers/knitkit/erp_app/desktop/website_nav_item_controller.rb +2 -9
  94. data/app/controllers/knitkit/erp_app/desktop/website_section_controller.rb +56 -20
  95. data/app/controllers/knitkit/online_document_sections_controller.rb +9 -3
  96. data/app/mailers/website_inquiry_mailer.rb +11 -3
  97. data/app/models/content.rb +16 -6
  98. data/app/models/documented_item.rb +12 -1
  99. data/app/models/online_document_section.rb +54 -20
  100. data/app/models/published_website.rb +16 -0
  101. data/app/models/theme.rb +53 -47
  102. data/app/models/website.rb +172 -191
  103. data/app/models/website_section.rb +64 -30
  104. data/app/views/knitkit/blogs/show.html.erb +5 -2
  105. data/app/views/layouts/knitkit/base.html.erb +54 -51
  106. data/app/views/menus/knitkit/_default_menu.html.erb +11 -11
  107. data/app/views/menus/knitkit/_default_section_menu.html.erb +2 -2
  108. data/app/views/menus/knitkit/_default_sub_menu.erb +27 -0
  109. data/app/views/menus/knitkit/_default_sub_section_menu.html.erb +30 -0
  110. data/app/views/website_inquiry_mailer/inquiry.html.erb +266 -0
  111. data/app/widgets/contact_us/base.rb +26 -16
  112. data/app/widgets/contact_us/javascript/contact_us.js +1 -1
  113. data/app/widgets/contact_us/views/error.html.erb +7 -3
  114. data/app/widgets/contact_us/views/index.html.erb +36 -28
  115. data/app/widgets/google_map/javascript/google_map.js +1 -1
  116. data/app/widgets/google_map/views/index.html.erb +1 -1
  117. data/app/widgets/login/javascript/login.js +1 -1
  118. data/app/widgets/login/views/index.html.erb +1 -1
  119. data/app/widgets/manage_profile/base.rb +141 -112
  120. data/app/widgets/manage_profile/javascript/manage_profile.js +2 -2
  121. data/app/widgets/manage_profile/views/_password_form.html.erb +1 -1
  122. data/app/widgets/manage_profile/views/_user_information_form.html.erb +1 -30
  123. data/app/widgets/manage_profile/views/index.html.erb +42 -40
  124. data/app/widgets/reset_password/base.rb +39 -8
  125. data/app/widgets/reset_password/javascript/reset_password.js +1 -1
  126. data/app/widgets/reset_password/views/index.html.erb +3 -3
  127. data/app/widgets/reset_password/views/invalid_reset_token.html.erb +7 -0
  128. data/app/widgets/reset_password/views/layouts/base.html.erb +1 -1
  129. data/app/widgets/reset_password/views/reset_password.html.erb +39 -0
  130. data/app/widgets/reset_password/views/reset_success.html.erb +5 -0
  131. data/app/widgets/search/base.rb +5 -5
  132. data/app/widgets/search/javascript/search.js +6 -6
  133. data/app/widgets/search/views/_inline_search_form.html.erb +23 -12
  134. data/app/widgets/search/views/_search_form.html.erb +34 -30
  135. data/app/widgets/search/views/layouts/base.html.erb +6 -1
  136. data/app/widgets/signup/base.rb +73 -30
  137. data/app/widgets/signup/javascript/signup.js +1 -1
  138. data/app/widgets/signup/views/_signup_form.html.erb +2 -1
  139. data/app/widgets/signup/views/layouts/base.html.erb +1 -1
  140. data/app/widgets/signup/views/success.html.erb +2 -3
  141. data/config/routes.rb +25 -4
  142. data/db/data_migrations/20110509223702_add_publisher_role.rb +0 -2
  143. data/db/data_migrations/20110816153456_add_knitkit_application.rb +7 -15
  144. data/db/data_migrations/20120127150505_create_website_default_configuration.rb +63 -3
  145. data/db/data_migrations/20150118180450_add_website_member_roles.rb +12 -0
  146. data/db/data_migrations/20150414150359_nest_knitkit_security_roles.rb +35 -0
  147. data/db/data_migrations/20150414173437_move_website_roles_under_website_builder.rb +19 -0
  148. data/db/migrate/20110211002317_setup_knitkit.rb +86 -39
  149. data/lib/knitkit.rb +8 -2
  150. data/lib/knitkit/config.rb +2 -3
  151. data/lib/knitkit/engine.rb +35 -4
  152. data/lib/knitkit/extensions.rb +2 -1
  153. data/lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb +1 -1
  154. data/lib/knitkit/extensions/action_mailer/theme_support/acts_as_themed_mailer.rb +1 -1
  155. data/lib/knitkit/extensions/compass_ae/mailers/user_mailer.rb +31 -0
  156. data/lib/knitkit/extensions/compass_ae/widgets/base.rb +1 -1
  157. data/lib/knitkit/extensions/railties/action_controller/captcha_helper.rb +43 -0
  158. data/lib/knitkit/extensions/railties/action_view/helpers/content_helper.rb +1 -1
  159. data/lib/knitkit/extensions/railties/action_view/helpers/menu_helper.rb +11 -1
  160. data/lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb +83 -0
  161. data/lib/knitkit/routing_filter/section_router.rb +24 -14
  162. data/lib/knitkit/version.rb +1 -1
  163. data/lib/tasks/knitkit_tasks.rake +89 -4
  164. data/lib/tasks/theme_parser.rake +85 -0
  165. data/public/fonts/glyphicons-halflings-regular.eot +0 -0
  166. data/public/fonts/glyphicons-halflings-regular.svg +288 -0
  167. data/public/fonts/glyphicons-halflings-regular.ttf +0 -0
  168. data/public/fonts/glyphicons-halflings-regular.woff +0 -0
  169. data/public/fonts/glyphicons-halflings-regular.woff2 +0 -0
  170. data/public/paypal-button.min.js +7 -0
  171. metadata +161 -82
  172. data/app/assets/javascripts/knitkit/application.js +0 -9
  173. data/app/assets/stylesheets/knitkit/application.css +0 -7
  174. data/app/mailers/document_mailer.rb +0 -10
  175. data/app/views/document_mailer/email_document.html.erb +0 -12
  176. data/app/views/knitkit/mobile/index.html.erb +0 -162
  177. data/app/views/knitkit/online_document_sections/index.html.erb +0 -279
  178. data/app/views/layouts/knitkit/online_document_sections.html.erb +0 -80
  179. data/app/views/website_inquiry_mailer/inquiry.erb +0 -24
  180. data/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.rb +0 -33
  181. data/db/data_migrations/20120316150424_add_is_template_to_default_website_config.rb +0 -16
  182. data/db/data_migrations/20120809020508_update_website_and_configuration.rb +0 -82
  183. data/db/data_migrations/20121129185611_upgrade_website_role_iid.rb +0 -20
  184. data/db/migrate/20130405184234_add_use_markdown_to_section.rb +0 -19
  185. data/db/migrate/20131112013052_add_knitkit_missing_indexes.rb +0 -33
  186. data/db/migrate/20140622212723_update_website_inquiries.rb +0 -22
  187. data/db/migrate/20140911185022_add_publishing_to_website.rb +0 -5
  188. data/db/migrate/20141013073349_add_custom_fields_to_documents.rb +0 -12
  189. data/db/migrate/20141016101936_upgrade_remove_dynamic_attributes.rb +0 -13
  190. data/lib/knitkit/extensions/railties/theme_support/theme_file_resolver.rb +0 -49
  191. data/public/images/knitkit/close_window.png +0 -0
  192. data/public/images/knitkit/splash/splash.png +0 -0
  193. data/public/javascripts/erp_app/desktop/applications/knitkit/comments_grid_panel.js +0 -215
  194. data/public/javascripts/erp_app/desktop/applications/knitkit/select_roles_window.js +0 -108
  195. data/public/javascripts/erp_app/desktop/applications/knitkit/splash_screen.js +0 -170
  196. data/public/javascripts/knitkit/bootstrap-datepicker.js +0 -474
  197. data/public/javascripts/knitkit/bootstrap.min.js +0 -7
  198. data/public/javascripts/knitkit/mobile/app/view/Main.js +0 -108
  199. data/public/javascripts/knitkit/mobile/ux/slidenavigation/View.js +0 -734
  200. data/public/stylesheets/knitkit/bootstrap-responsive.min.css +0 -10
  201. data/public/stylesheets/knitkit/bootstrap.min.css +0 -7
  202. data/public/stylesheets/knitkit/custom.css +0 -122
  203. data/public/stylesheets/knitkit/datepicker.css +0 -182
@@ -37,12 +37,10 @@ module Knitkit
37
37
  end
38
38
 
39
39
  begin
40
- file_asset = if upload_path == 'root_node'
41
- @assets_model.add_file(data, File.join(base_path, name))
42
- else
43
- @assets_model.add_file(data, File.join(@file_support.root, upload_path, name))
44
- end
45
- result = {:success => true, :url => file_asset.data.url}
40
+ path = (upload_path == 'root_node') ? File.join(base_path, name) : File.join(@file_support.root, upload_path, name)
41
+ @assets_model.add_file(data, path)
42
+
43
+ result = {:success => true, :node => @file_support.find_node(path, :file_asset_holder => @assets_model)}
46
44
  rescue => ex
47
45
  logger.error ex.message
48
46
  logger.error ex.backtrace.join("\n")
@@ -83,9 +81,12 @@ module Knitkit
83
81
  file.destroy
84
82
  end
85
83
  messages << message
86
- rescue Exception => ex
84
+ rescue StandardError => ex
87
85
  Rails.logger.error ex.message
88
86
  Rails.logger.error ex.backtrace.join("\n")
87
+
88
+ ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier
89
+
89
90
  render :json => {:success => false, :error => "Error deleting #{name}"} and return
90
91
  end
91
92
  end # end current_user.with_capability
@@ -106,9 +107,15 @@ module Knitkit
106
107
  @root_node = nil
107
108
 
108
109
  if @context == :website
109
- @root_node = File.join(Rails.application.config.knitkit.images_base_path, "sites", @assets_model.iid, "images") unless @assets_model.nil?
110
+ @root_node = File.join('public',
111
+ 'sites',
112
+ @assets_model.iid,
113
+ 'images') unless @assets_model.nil?
110
114
  else
111
- @root_node = File.join(Rails.application.config.knitkit.images_base_path, 'images')
115
+ @root_node = File.join('public',
116
+ "dba_organizations",
117
+ current_user.party.dba_organization.id.to_s,
118
+ 'images')
112
119
  end
113
120
 
114
121
  @root_node
@@ -2,25 +2,25 @@ module Knitkit
2
2
  module ErpApp
3
3
  module Desktop
4
4
  class OnlineDocumentSectionsController < Knitkit::ErpApp::Desktop::AppController
5
-
6
- def new
5
+
6
+ def create
7
7
  @website = Website.find(params[:website_id])
8
8
  online_document_section = OnlineDocumentSection.new(:website_id => @website.id,
9
9
  :in_menu => params[:in_menu] == 'yes', :title => params[:title],
10
10
  :internal_identifier => params[:internal_identifier])
11
-
11
+
12
12
  if online_document_section.save
13
13
  if params[:website_section_id]
14
14
  parent_website_section = WebsiteSection.find(params[:website_section_id])
15
15
  online_document_section.move_to_child_of(parent_website_section)
16
- end
17
- online_document_section.update_path!
18
- if params[:documenttype] == "Content"
19
- documented_content = DocumentedContent.create(:title => online_document_section.title, :created_by => current_user, :body_html => online_document_section.title)
20
- DocumentedItem.create(:documented_content_id => documented_content.id, :online_document_section_id => online_document_section.id)
21
16
  end
22
-
23
- result = {:success => true, :node => build_section_hash(online_document_section),
17
+ online_document_section.update_path!
18
+
19
+ documented_content = DocumentedContent.create(:title => online_document_section.title, :created_by => current_user, :body_html => online_document_section.title)
20
+ DocumentedItem.create(:documented_content_id => documented_content.id, :online_document_section_id => online_document_section.id)
21
+
22
+ result = {:success => true,
23
+ :node => build_section_hash(online_document_section),
24
24
  :documented_content => documented_content.content_hash}
25
25
  else
26
26
  message = "<ul>"
@@ -32,8 +32,62 @@ module Knitkit
32
32
  end
33
33
 
34
34
  render :json => result
35
- end
36
- end
37
- end
38
- end
39
- end
35
+ end
36
+
37
+ def existing_documents
38
+ website = Website.find(params[:website_id])
39
+ OnlineDocumentSection.class_eval do
40
+ def title_permalink
41
+ "#{self.title} - #{self.path}"
42
+ end
43
+ end
44
+ render :inline => website.online_document_sections.to_json(:only => [:id], :methods => [:title_permalink])
45
+ end
46
+
47
+ def content
48
+ document_section = OnlineDocumentSection.find(params[:id])
49
+
50
+ render :json => {success: true, content: document_section.documented_item_content_html}
51
+ end
52
+
53
+ def copy
54
+ begin
55
+
56
+ @website = Website.find(params[:website_id])
57
+ parent_section = WebsiteSection.where('id = ?', params[:parent_section_id]).first
58
+ section_to_copy = OnlineDocumentSection.find(params[:id])
59
+
60
+ new_section = section_to_copy.copy(params[:title].strip, true, current_user)
61
+
62
+ if parent_section
63
+ new_section.move_to_child_of(parent_section)
64
+ new_section.save
65
+ end
66
+
67
+ # update all children paths after all are saved.
68
+ new_section.self_and_descendants.each do |section|
69
+ section.update_path!
70
+ end
71
+
72
+ result = {:success => true,
73
+ :parentNodeId => params[:parent_section_id],
74
+ :node => build_section_hash(new_section)}
75
+
76
+
77
+ rescue => ex
78
+ # TODO send error notification
79
+ Rails.logger.error ex.message
80
+ Rails.logger.error ex.backtrace.join("\n")
81
+
82
+ ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier
83
+
84
+ result = {:success => false, :message => 'Could not copy Document'}
85
+ end
86
+
87
+ render :json => result
88
+ end
89
+
90
+ end # OnlineDocumentSectionsController
91
+ end # Desktop
92
+ end # ErpApp
93
+ end # Knitkit
@@ -3,85 +3,72 @@ module Knitkit
3
3
  module Desktop
4
4
  class PositionController < Knitkit::ErpApp::Desktop::AppController
5
5
 
6
- def change_section_parent
7
- begin
8
- current_user.with_capability('drag_item', 'WebsiteTree') do
6
+ around_filter :wrap_in_transaction
9
7
 
10
- new_parent = WebsiteSection.where('id = ?', params[:parent_id]).first
11
- website_section = WebsiteSection.find(params[:section_id])
8
+ def update_section_position
9
+ params[:position_array].each do |position|
10
+ website_section = WebsiteSection.find(position['id'])
12
11
 
13
- if new_parent
14
- website_section.move_to_child_of(new_parent)
15
- else
16
- website_section.move_to_root
17
- end
12
+ if position['parent_id'].blank? || position['parent_id'] == 'root'
13
+ website_section.move_to_root
14
+ else
15
+ website_section.move_to_child_of(WebsiteSection.find(position['parent_id']))
16
+ end
18
17
 
19
- render :json => {:success => true}
18
+ website_section.position = position['position'].to_i
20
19
 
21
- end
22
- rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
23
- render :json => {:success => false, :message => ex.message}
20
+ website_section.save
24
21
  end
22
+
23
+ render :json => {:success => true}
25
24
  end
26
25
 
27
- def update_section_position
28
- begin
29
- current_user.with_capability('drag_item', 'WebsiteTree') do
26
+ def update_menu_item_position
27
+ params[:position_array].each do |position|
28
+ website_nav_item = WebsiteNavItem.find(position['id'])
29
+ website_nav_item.position = position['position'].to_i
30
+ website_nav_item.save
31
+ end
30
32
 
31
- params[:position_array].each do |position|
32
- model = WebsiteSection.find(position['id'])
33
- model.position = position['position'].to_i
34
- model.save
35
- end
33
+ render :json => {:success => true}
34
+ end
36
35
 
37
- render :json => {:success => true}
36
+ def update_article_position
37
+ website_section = WebsiteSection.find(params[:section_id])
38
38
 
39
- end
40
- rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
41
- render :json => {:success => false, :message => ex.message}
39
+ params[:position_array].each do |position|
40
+ article = website_section.website_section_contents.where('content_id = ?', position['id']).first
41
+ article.position = position['position'].to_i
42
+ article.save
42
43
  end
44
+
45
+ render :json => {:success => true}
43
46
  end
44
47
 
45
- def update_menu_item_position
46
- begin
47
- current_user.with_capability('drag_item', 'WebsiteTree') do
48
+ private
48
49
 
49
- params[:position_array].each do |position|
50
- model = WebsiteNavItem.find(position['id'])
51
- model.position = position['position'].to_i
52
- model.save
50
+ def wrap_in_transaction
51
+ begin
52
+ ActiveRecord::Base.transaction do
53
+ current_user.with_capability('drag_item', 'WebsiteTree') do
54
+ yield
53
55
  end
54
-
55
- render :json => {:success => true}
56
-
57
56
  end
58
57
  rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
59
58
  render :json => {:success => false, :message => ex.message}
60
- end
61
- end
62
59
 
63
- def update_article_position
64
- begin
65
- current_user.with_capability('drag_item', 'WebsiteTree') do
66
-
67
- website_section = WebsiteSection.find(params[:section_id])
68
-
69
- params[:position_array].each do |position|
70
- model = website_section.website_section_contents.where('content_id = ?', position['id']).first
71
- model.position = position['position'].to_i
72
- model.save
73
- end
60
+ rescue => ex
61
+ Rails.logger.error ex.message + "\n"
62
+ Rails.logger.error ex.backtrace.join("\n")
74
63
 
75
- render :json => {:success => true}
64
+ # email notification
65
+ ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier
76
66
 
77
- end
78
- rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
79
- render :json => {:success => false, :message => ex.message}
67
+ render :json => {success: false, message: 'Could not process request'}
80
68
  end
81
69
  end
82
70
 
83
- end #PositionController
84
- end #Desktop
85
- end #ErpApp
86
- end #Knitkit
87
-
71
+ end # PositionController
72
+ end # Desktop
73
+ end # ErpApp
74
+ end # Knitkit
@@ -39,7 +39,7 @@ module Knitkit
39
39
  begin
40
40
  current_user.with_capability('view', 'Theme') do
41
41
  unless params[:theme_data].blank?
42
- Theme.import(params[:theme_data], @website)
42
+ theme = Theme.import(params[:theme_data], @website)
43
43
  else
44
44
  theme = Theme.create(:website => @website, :name => params[:name], :theme_id => params[:theme_id])
45
45
  theme.version = params[:version]
@@ -49,8 +49,29 @@ module Knitkit
49
49
  theme.save
50
50
  theme.create_theme_files!
51
51
  end
52
+ render :inline => {:success => true, :node => build_tree_node(theme, @website)}.to_json
53
+ end
54
+ rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
55
+ render :json => {:success => false, :message => ex.message}
56
+ end
57
+ end
52
58
 
53
- render :inline => {:success => true}.to_json
59
+ def update
60
+ begin
61
+ current_user.with_capability('view', 'Theme') do
62
+ theme = Theme.find(params[:id])
63
+ theme.name = params[:name].strip
64
+ if theme.save
65
+ render :json => {
66
+ success: true,
67
+ theme: {
68
+ name: theme.name,
69
+ text: "#{theme.name}[#{theme.theme_id}]"
70
+ }
71
+ }
72
+ else
73
+ render :json => {success: false}
74
+ end
54
75
  end
55
76
  rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
56
77
  render :json => {:success => false, :message => ex.message}
@@ -106,7 +127,7 @@ module Knitkit
106
127
  theme = get_theme(path)
107
128
  theme.add_file('#Empty File', File.join(path, name))
108
129
 
109
- render :json => {:success => true}
130
+ render :json => {:success => true, :node => @file_support.find_node(File.join(path, name), {:file_asset_holder => theme})}
110
131
  end
111
132
  rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
112
133
  render :json => {:success => false, :message => ex.message}
@@ -120,7 +141,7 @@ module Knitkit
120
141
  name = params[:name]
121
142
 
122
143
  @file_support.create_folder(path, name)
123
- render :json => {:success => true}
144
+ render :json => {:success => true, :node => @file_support.find_node(File.join(path, name), {keep_full_path: false})}
124
145
  end
125
146
  rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
126
147
  render :json => {:success => false, :message => ex.message}
@@ -209,7 +230,7 @@ module Knitkit
209
230
 
210
231
  begin
211
232
  theme.add_file(data, name)
212
- result = {:success => true}
233
+ result = {:success => true, :node => @file_support.find_node(name, {:file_asset_holder => theme})}
213
234
  rescue => ex
214
235
  logger.error ex.message
215
236
  logger.error ex.backtrace.join("\n")
@@ -232,15 +253,18 @@ module Knitkit
232
253
  current_user.with_capability('view', 'Theme') do
233
254
  begin
234
255
  name = File.basename(path)
235
- result, message, is_folder = @file_support.delete_file(File.join(@file_support.root, path))
256
+ result, message, is_folder = @file_support.delete_file(File.join(@file_support.root, path), {force: true})
236
257
  if result && !is_folder
237
258
  theme_file = get_theme_file(path)
238
259
  theme_file.destroy
239
260
  end
240
261
  messages << message
241
- rescue Exception => ex
262
+ rescue StandardError => ex
242
263
  Rails.logger.error ex.message
243
264
  Rails.logger.error ex.backtrace.join("\n")
265
+
266
+ ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier
267
+
244
268
  render :json => {:success => false, :error => "Error deleting #{name}"} and return
245
269
  end
246
270
  end # end current_user.with_capability
@@ -262,7 +286,7 @@ module Knitkit
262
286
  path = params[:node]
263
287
  name = params[:file_name]
264
288
 
265
- result, message = @file_support.rename_file(@file_support.root+path, name)
289
+ result, message = @file_support.rename_file(File.join(@file_support.root, path), name)
266
290
  if result
267
291
  theme_file = get_theme_file(path)
268
292
  theme_file.name = name
@@ -311,33 +335,44 @@ module Knitkit
311
335
  theme.files.where('name = ? and directory = ?', ::File.basename(path), file_dir).first
312
336
  end
313
337
 
338
+ def build_tree_node(theme, website)
339
+
340
+ theme_hash = {
341
+ :name => theme.name,
342
+ :text => "#{theme.name}[#{theme.theme_id}]",
343
+ :handleContextMenu => true,
344
+ :siteId => website.id,
345
+ :isActive => (theme.active == 1), :iconCls => 'icon-content',
346
+ :isTheme => true,
347
+ :id => theme.id,
348
+ :children => []
349
+ }
350
+ if theme.active == 1
351
+ theme_hash[:iconCls] = 'icon-add'
352
+ else
353
+ theme_hash[:iconCls] = 'icon-delete'
354
+ end
355
+
356
+ ['stylesheets', 'javascripts', 'images', 'templates', 'widgets', 'fonts'].each do |resource_folder|
357
+ theme_hash[:children] << {
358
+ :themeId => theme.id,
359
+ :siteId => website.id,
360
+ :text => resource_folder.capitalize,
361
+ :iconCls => 'icon-content',
362
+ :handleContextMenu => (resource_folder == 'widgets'),
363
+ :id => "#{theme.url}/#{resource_folder}"
364
+ }
365
+ end
366
+ theme_hash
367
+ end
368
+
314
369
  def setup_tree
315
370
  tree = []
316
371
 
317
372
  if @website
318
373
  #handle themes
319
374
  @website.themes.each do |theme|
320
- theme_hash = {:text => "#{theme.name}[#{theme.theme_id}]", :handleContextMenu => true,
321
- :siteId => @website.id, :isActive => (theme.active == 1), :iconCls => 'icon-content',
322
- :isTheme => true, :id => theme.id, :children => []}
323
-
324
- if theme.active == 1
325
- theme_hash[:iconCls] = 'icon-add'
326
- else
327
- theme_hash[:iconCls] = 'icon-delete'
328
- end
329
-
330
- ['stylesheets', 'javascripts', 'images', 'templates', 'widgets'].each do |resource_folder|
331
- theme_hash[:children] << {
332
- :themeId => theme.id,
333
- :siteId => @website.id,
334
- :text => resource_folder.capitalize,
335
- :iconCls => 'icon-content',
336
- :handleContextMenu => (resource_folder == 'widgets'),
337
- :id => "#{theme.url}/#{resource_folder}"
338
- }
339
- end
340
-
375
+ theme_hash = build_tree_node(theme, @website)
341
376
  tree << theme_hash
342
377
  end
343
378
  end
@@ -8,9 +8,13 @@ module Knitkit
8
8
  :build_host_hash, :activate_publication, :publish, :update, :delete]
9
9
 
10
10
  def index
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')}") }}
11
+ websites = Website.joins(:website_party_roles)
12
+ .where('website_party_roles.party_id = ?', current_user.party.dba_organization.id)
13
+ .where('website_party_roles.role_type_id = ?', RoleType.iid('dba_org'))
14
+
15
+ render :json => {:sites => websites.all.collect { |item| item.to_hash(:only => [:id, :name, :title, :subtitle],
16
+ :configuration_id => item.configurations.first.id,
17
+ :url => "#{request.protocol}#{item.config_value('primary_host')}") }}
14
18
  end
15
19
 
16
20
  def build_content_tree
@@ -71,8 +75,8 @@ module Knitkit
71
75
  render :inline => "{\"success\":true, \"results\":#{published_websites.count},
72
76
  \"totalCount\":#{@website.published_websites.count},
73
77
  \"data\":#{published_websites.to_json(
74
- :only => [:comment, :id, :version, :created_at, :active],
75
- :methods => [:viewing, :published_by_username])} }"
78
+ :only => [:comment, :id, :version, :created_at, :active],
79
+ :methods => [:viewing, :published_by_username])} }"
76
80
  end
77
81
 
78
82
  def activate_publication
@@ -134,6 +138,12 @@ module Knitkit
134
138
  first_publication.published_by = current_user
135
139
  first_publication.save
136
140
 
141
+ website_host = WebsiteHost.find_by_host(params[:host])
142
+ if website_host
143
+ website_name = website_host.website.name
144
+ raise "Host #{website_host.host} already used by #{website_name}"
145
+ end
146
+
137
147
  website.hosts << WebsiteHost.create(:host => params[:host])
138
148
  website.configurations.first.update_configuration_item(ConfigurationItemType.find_by_internal_identifier('primary_host'), params[:host])
139
149
  website.save
@@ -142,6 +152,11 @@ module Knitkit
142
152
 
143
153
  PublishedWebsite.activate(website, 1, current_user)
144
154
 
155
+ # set the currents users dba_org as the dba_org for this website
156
+ WebsitePartyRole.create(website: website,
157
+ party: current_user.party.dba_organization,
158
+ role_type: RoleType.iid('dba_org'))
159
+
145
160
  render :json => {:success => true, :website => website.to_hash(:only => [:id, :name],
146
161
  :configuration_id => website.configurations.first.id,
147
162
  :url => "http://#{website.config_value('primary_host')}")}
@@ -151,7 +166,6 @@ module Knitkit
151
166
  Rails.logger.error("#{ex.message} + #{ex.backtrace.join("\n")}")
152
167
  render :json => {:success => false, :message => ex.message}
153
168
  end
154
-
155
169
  end
156
170
 
157
171
  def update
@@ -182,7 +196,7 @@ module Knitkit
182
196
  zip_path = @website.export
183
197
  begin
184
198
  send_file(zip_path.to_s, :stream => false)
185
- rescue Exception => ex
199
+ rescue StandardError => ex
186
200
  raise "Error sending #{zip_path} file"
187
201
  end
188
202
  end
@@ -192,7 +206,7 @@ module Knitkit
192
206
  if zip_path
193
207
  begin
194
208
  send_file(zip_path, :stream => false)
195
- rescue Exception => ex
209
+ rescue StandardError => ex
196
210
  raise "Error sending file. Make sure you have a website and an active theme."
197
211
  end
198
212
  else
@@ -209,17 +223,20 @@ module Knitkit
209
223
  else
210
224
  render :inline => {:success => false, :message => message}.to_json
211
225
  end
226
+ WebsitePartyRole.create(website: website,
227
+ party: current_user.party.dba_organization,
228
+ role_type: RoleType.iid('dba_org'))
212
229
  ensure
213
230
  FileUtils.rm_r File.dirname(zip_path) rescue nil
214
231
  end
215
232
 
216
- def importtemplate
217
- website, message = Website.import_template_director(params[:website_data], User.first)
233
+ def import_template
234
+ result = Website.import_template(params[:website_data], current_user)
218
235
 
219
- if website
220
- render :inline => {:success => true, :website => website.to_hash(:only => [:id, :name])}.to_json
236
+ if result[:success]
237
+ render :inline => {:success => true, :website => result[:website].to_hash(:only => [:id, :name])}.to_json
221
238
  else
222
- render :inline => {:success => false, :message => message}.to_json
239
+ render :inline => {:success => false, :message => result[:message]}.to_json
223
240
  end
224
241
  end
225
242
 
@@ -230,6 +247,12 @@ module Knitkit
230
247
  # example found in knitkit module.js
231
248
  end
232
249
 
250
+ def get_current_host
251
+ current_host = request.host_with_port
252
+ existing_website_host = WebsiteHost.find_by_host(current_host)
253
+ render :json => {:success => !existing_website_host.present?, :host => current_host}
254
+ end
255
+
233
256
  end # WebsiteController
234
257
  end # Desktop
235
258
  end # ErpApp