knitkit 3.0.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,93 @@
1
+ /*!
2
+ * Start Bootstrap - Simple Sidebar HTML Template (http://startbootstrap.com)
3
+ * Code licensed under the Apache License v2.0.
4
+ * For details, see http://www.apache.org/licenses/LICENSE-2.0.
5
+ */
6
+
7
+ /* Toggle Styles */
8
+
9
+
10
+ #sidebar-wrapper {
11
+ z-index: 1000;
12
+ position: fixed;
13
+ left: 250px;
14
+ width: 0;
15
+ height: 100%;
16
+ margin-left: -250px;
17
+ overflow-y: auto;
18
+ background: #222;
19
+ -webkit-transition: all 0.5s ease;
20
+ -moz-transition: all 0.5s ease;
21
+ -o-transition: all 0.5s ease;
22
+ transition: all 0.5s ease;
23
+ }
24
+
25
+ /* Sidebar Styles */
26
+
27
+ .sidebar-nav {
28
+ position: absolute;
29
+ top: 0;
30
+ width: 10px;
31
+ margin: 0;
32
+ padding: 0;
33
+ list-style: none;
34
+ }
35
+
36
+ .sidebar-nav li {
37
+ text-indent: 20px;
38
+ line-height: 40px;
39
+ }
40
+
41
+ .sidebar-nav .active {
42
+ background-color: #525050;
43
+ }
44
+
45
+ .sidebar-nav .active a {
46
+ color: white;
47
+ }
48
+
49
+ .sidebar-nav li a {
50
+ display: block;
51
+ text-decoration: none;
52
+ color: #999999;
53
+ }
54
+
55
+ .sidebar-nav li a:hover {
56
+ text-decoration: none;
57
+ color: #fff;
58
+ background: rgba(255,255,255,0.2);
59
+ }
60
+
61
+ .sidebar-nav li a:active,
62
+ .sidebar-nav li a:focus {
63
+ text-decoration: none;
64
+ }
65
+
66
+ .sidebar-nav > .sidebar-brand {
67
+ height: 65px;
68
+ font-size: 18px;
69
+ line-height: 60px;
70
+ }
71
+
72
+ .sidebar-nav > .sidebar-brand a {
73
+ color: #999999;
74
+ }
75
+
76
+ .sidebar-nav > .sidebar-brand a:hover {
77
+ color: #fff;
78
+ background: none;
79
+ }
80
+
81
+ @media(min-width:768px) {
82
+ .sidebar-nav {
83
+ width: 250px;
84
+ }
85
+
86
+ .side-bar-content-wrapper {
87
+ margin-left: 250px !important;
88
+ }
89
+
90
+ #sidebar-wrapper {
91
+ width: 250px;
92
+ }
93
+ }
@@ -0,0 +1,14 @@
1
+ module Api
2
+ module V1
3
+ class WebsitesController < BaseController
4
+
5
+ def index
6
+ render json: {
7
+ success: true,
8
+ websites: Website.scope_by_dba_organization(current_user.party.dba_organization).all.collect { |w| w.to_data_hash }
9
+ }
10
+ end
11
+
12
+ end # WebsitesController
13
+ end # V1
14
+ end # Api
@@ -0,0 +1,53 @@
1
+ class CaptchaController < ActionController::Base
2
+
3
+ include Knitkit::Extensions::Railties::ActionController::CaptchaHelper
4
+
5
+ before_filter :setup_visual_captcha
6
+
7
+ def setup_visual_captcha
8
+ @session = VisualCaptcha::Session.new session
9
+ @headers = {
10
+ 'Access-Control-Allow-Origin' => '*'
11
+ }
12
+ end
13
+
14
+ def start
15
+ captcha = VisualCaptcha::Captcha.new @session
16
+
17
+ captcha.generate params[:how_many]
18
+
19
+ render json: captcha.frontend_data
20
+ end
21
+
22
+ def audio
23
+ captcha = VisualCaptcha::Captcha.new @session
24
+
25
+ type = params[:type]
26
+ type = 'mp3' if type != 'ogg'
27
+
28
+ if (body = captcha.stream_audio @headers, type)
29
+ send_data body, type: type, disposition: 'inline'
30
+ else
31
+ raise ActionController::RoutingError.new('Not Found')
32
+ end
33
+ end
34
+
35
+ def image
36
+ captcha = VisualCaptcha::Captcha.new @session
37
+
38
+ if (body = captcha.stream_image @headers, params[:index], params[:retina])
39
+ send_data body, type: 'image/png', disposition: 'inline'
40
+ else
41
+ raise ActionController::RoutingError.new('Not Found')
42
+ end
43
+ end
44
+
45
+ def validate
46
+ if captcha_valid?
47
+ render json: {success: true}
48
+ else
49
+ render json: {success: false}
50
+ end
51
+ end
52
+
53
+ end
@@ -1,6 +1,6 @@
1
1
  module Knitkit
2
2
  class BaseController < ::ErpApp::ApplicationController
3
- before_filter :set_website, :clear_widget_params
3
+ before_filter :set_website
4
4
  before_filter :set_login_path, :set_active_publication, :load_sections, :set_section, :except => [:view_current_publication]
5
5
  acts_as_themed_controller
6
6
 
@@ -23,10 +23,6 @@ module Knitkit
23
23
  def load_sections
24
24
  @website_sections = @website.website_sections.positioned
25
25
  end
26
-
27
- def clear_widget_params
28
- session[:widgets] = {}
29
- end
30
26
 
31
27
  def set_section
32
28
  unless params[:section_id].nil?
@@ -4,10 +4,6 @@ module Knitkit
4
4
  class AppController < ::ErpApp::Desktop::BaseController
5
5
  KNIT_KIT_ROOT = Knitkit::Engine.root.to_s
6
6
 
7
- def available_roles
8
- render :json => {:success => true, :availableRoles => SecurityRole.order('description ASC').all.collect { |role| role.to_hash(:only => [:internal_identifier, :description]) }}
9
- end
10
-
11
7
  protected
12
8
 
13
9
  def set_website
@@ -72,10 +68,8 @@ module Knitkit
72
68
  :inMenu => website_section.in_menu,
73
69
  :renderWithBaseLayout => website_section.render_base_layout?,
74
70
  :hasLayout => !website_section.layout.blank?,
75
- :id => "section_#{website_section.id}",
76
- :url => "http://#{@website_primary_host}#{website_section.path}",
71
+ :url => "#{request.protocol}#{@website_primary_host}#{website_section.path}",
77
72
  :internal_identifier => website_section.internal_identifier
78
-
79
73
  }
80
74
 
81
75
  if website_section.is_a?(OnlineDocumentSection) || website_section.type == 'OnlineDocumentSection'
@@ -108,9 +102,8 @@ module Knitkit
108
102
 
109
103
  {
110
104
  recordType: 'Article',
111
- recordId: website_section_content.id,
105
+ recordId: website_section_content.content.id,
112
106
  :objectType => "Article",
113
- :id => content.id,
114
107
  :siteId => website.id,
115
108
  :content_area => website_section_content.content_area,
116
109
  :parentItemId => website_section.id,
@@ -19,6 +19,9 @@ module Knitkit
19
19
  article.created_by = current_user
20
20
 
21
21
  if article.save
22
+ # set the currents users dba_org as the dba_org for this content
23
+ article.add_party_with_role(current_user.party.dba_organization, RoleType.iid('dba_org'))
24
+
22
25
  result[:node] = if website_section_id.blank?
23
26
  {:text => params[:title],
24
27
  :id => article.id,
@@ -31,9 +34,13 @@ module Knitkit
31
34
  else
32
35
  website_section = WebsiteSection.find(website_section_id)
33
36
  article.website_sections << website_section
34
- website_section_content = article.update_content_area_and_position_by_section(website_section, params['content_area'], params['position'])
37
+ website_section_content = article.update_content_area_and_position_by_section(website_section,
38
+ params['content_area'],
39
+ params['position'])
35
40
 
36
- build_article_hash(website_section_content, website_section.website, website_section.is_blog?)
41
+ build_article_hash(website_section_content,
42
+ website_section.website,
43
+ website_section.is_blog?)
37
44
  end
38
45
 
39
46
  result[:success] = true
@@ -65,7 +72,9 @@ module Knitkit
65
72
  if article.save
66
73
  unless website_section_id.blank?
67
74
  website_section = WebsiteSection.find(website_section_id)
68
- article.update_content_area_and_position_by_section(website_section, params['content_area'], params['position'])
75
+ article.update_content_area_and_position_by_section(website_section,
76
+ params['content_area'],
77
+ params['position'])
69
78
  end
70
79
 
71
80
  result[:success] = true
@@ -107,7 +116,8 @@ module Knitkit
107
116
  end
108
117
 
109
118
  def existing_articles
110
- render :inline => Article.all.to_json(:only => [:internal_identifier, :id])
119
+ render :inline => Article.with_party_role(current_user.party.dba_organization,
120
+ RoleType.iid('dba_org')).all.to_json(:only => [:internal_identifier, :id])
111
121
  end
112
122
 
113
123
  def show
@@ -133,7 +143,8 @@ module Knitkit
133
143
  limit = params[:limit] || 10
134
144
  start = params[:start] || 0
135
145
 
136
- articles = Article.joins("INNER JOIN website_section_contents ON website_section_contents.content_id = contents.id").where("website_section_id = #{website_section_id}")
146
+ articles = Article.joins("INNER JOIN website_section_contents ON website_section_contents.content_id = contents.id")
147
+ .where("website_section_id = #{website_section_id}")
137
148
  total_count = articles.count
138
149
  articles = articles.order("#{sort} #{dir}").limit(limit).offset(start)
139
150
 
@@ -171,7 +182,9 @@ module Knitkit
171
182
  limit = params[:limit] || 20
172
183
  start = params[:start] || 0
173
184
 
174
- articles = Article.includes(:website_section_contents)
185
+ articles = Article.with_party_role(current_user.party.dba_organization,
186
+ RoleType.iid('dba_org')).includes(:website_section_contents)
187
+
175
188
  articles = articles.where(:website_section_contents => {:content_id => nil}) if params[:show_orphaned] == 'true'
176
189
  articles = articles.where("UPPER(contents.internal_identifier) LIKE UPPER('%#{params[:iid]}%')") unless params[:iid].blank?
177
190
  articles = articles.where("UPPER(contents.title) LIKE UPPER('%#{params[:title]}%')") unless params[:title].blank?
@@ -201,7 +214,7 @@ module Knitkit
201
214
  articles_array << articles_hash
202
215
  end
203
216
 
204
- render :inline => "{total:#{total_count},data:#{articles_array.to_json}}"
217
+ render :json => {total: total_count, data: articles_array}
205
218
  end
206
219
 
207
220
  def article_attributes
@@ -7,11 +7,11 @@ module Knitkit
7
7
  before_filter :set_asset_model
8
8
  before_filter :set_root_node
9
9
 
10
- def base_path
10
+ def base_path
11
11
  if @root_node.nil?
12
12
  @base_path = nil
13
13
  else
14
- @base_path = File.join(@file_support.root, @root_node)
14
+ @base_path = File.join(@file_support.root, @root_node)
15
15
  end
16
16
 
17
17
  @base_path
@@ -32,17 +32,18 @@ module Knitkit
32
32
 
33
33
  @assets_model.add_file('#Empty File', File.join(path, name))
34
34
 
35
- render :json => {:success => true}
35
+ render :json => {:success => true, :node => @file_support.find_node(File.join(path, name), :file_asset_holder => @assets_model)}
36
36
  end
37
37
 
38
38
  def create_folder
39
39
  path = (params[:path] == 'root_node') ? base_path : params[:path]
40
40
  name = params[:name]
41
41
 
42
- path = File.join(@file_support.root,path) if path.index(@file_support.root).nil?
42
+ path = File.join(@file_support.root, path) if path.index(@file_support.root).nil?
43
43
 
44
44
  @file_support.create_folder(path, name)
45
- render :json => {:success => true}
45
+
46
+ render :json => {:success => true, :node => @file_support.find_node(File.join(path, name), {keep_full_path: false})}
46
47
  end
47
48
 
48
49
  def upload_file
@@ -55,7 +56,6 @@ module Knitkit
55
56
  capability_resource = "GlobalFileAsset"
56
57
  end
57
58
 
58
- model = DesktopApplication.find_by_internal_identifier('knitkit')
59
59
  begin
60
60
  current_user.with_capability(capability_type, capability_resource) do
61
61
  result = {}
@@ -64,8 +64,10 @@ module Knitkit
64
64
  data = request.raw_post
65
65
 
66
66
  begin
67
- upload_path == 'root_node' ? @assets_model.add_file(data, File.join(base_path,name)) : @assets_model.add_file(data, File.join(@file_support.root,upload_path,name))
68
- result = {:success => true}
67
+ path = (upload_path == 'root_node') ? File.join(base_path, name) : File.join(@file_support.root, upload_path, name)
68
+
69
+ @assets_model.add_file(data, path)
70
+ result = {:success => true, :node => @file_support.find_node(path, :file_asset_holder => @assets_model)}
69
71
  rescue => ex
70
72
  logger.error ex.message
71
73
  logger.error ex.backtrace.join("\n")
@@ -75,7 +77,7 @@ module Knitkit
75
77
  #the awesome uploader widget whats this to mime type text, leave it render :inline
76
78
  render :inline => result.to_json
77
79
  end
78
- rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
80
+ rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
79
81
  render :json => {:success => false, :message => ex.message}
80
82
  end
81
83
  end
@@ -86,7 +88,7 @@ module Knitkit
86
88
  path = params[:node]
87
89
  new_parent_path = params[:parent_node]
88
90
  new_parent_path = @root_node if new_parent_path == ROOT_NODE
89
-
91
+
90
92
  nodes_to_move = (params[:selected_nodes] ? JSON(params[:selected_nodes]) : [params[:node]])
91
93
  begin
92
94
  nodes_to_move.each do |path|
@@ -100,7 +102,7 @@ module Knitkit
100
102
  end
101
103
  render :json => {:success => true, :msg => messages.join(',')}
102
104
  rescue Exception => e
103
- render :json => {:success => false, :msg => e.message}
105
+ render :json => {:success => false, :msg => e.message}
104
106
  end
105
107
  end
106
108
 
@@ -121,18 +123,21 @@ module Knitkit
121
123
  result = false
122
124
  nodes_to_delete.each do |path|
123
125
  current_user.with_capability(capability_type, capability_resource) do
124
- path = "#{path}/" if params[:leaf] == 'false' and path.match(/\/$/).nil?
126
+ path = "#{path}/" if params[:leaf] == 'false' and path.match(/\/$/).nil?
125
127
  begin
126
128
  name = File.basename(path)
127
- result, message, is_folder = @file_support.delete_file(File.join(@file_support.root,path))
129
+ result, message, is_folder = @file_support.delete_file(File.join(@file_support.root, path))
128
130
  if result and !is_folder
129
131
  file = @assets_model.files.find(:first, :conditions => ['name = ? and directory = ?', ::File.basename(path), ::File.dirname(path)])
130
132
  file.destroy
131
133
  end
132
134
  messages << message
133
- rescue Exception=>ex
135
+ rescue StandardError => ex
134
136
  Rails.logger.error ex.message
135
137
  Rails.logger.error ex.backtrace.join("\n")
138
+
139
+ ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier
140
+
136
141
  render :json => {:success => false, :error => "Error deleting #{name}"} and return
137
142
  end
138
143
  end # end current_user.with_capability
@@ -142,7 +147,7 @@ module Knitkit
142
147
  else
143
148
  render :json => {:success => false, :error => messages.join(',')}
144
149
  end
145
- rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability=>ex
150
+ rescue ErpTechSvcs::Utils::CompassAccessNegotiator::Errors::UserDoesNotHaveCapability => ex
146
151
  render :json => {:success => false, :message => ex.message}
147
152
  end
148
153
  end
@@ -151,18 +156,18 @@ module Knitkit
151
156
  path = params[:node]
152
157
  name = params[:file_name]
153
158
 
154
- result, message = @file_support.rename_file(File.join(@file_support.root,path), name)
159
+ result, message = @file_support.rename_file(File.join(@file_support.root, path), name)
155
160
  if result
156
161
  file = @assets_model.files.find(:first, :conditions => ['name = ? and directory = ?', ::File.basename(path), ::File.dirname(path)])
157
162
  file.name = name
158
163
  file.save
159
164
  end
160
165
 
161
- render :json => {:success => true, :message => message}
166
+ render :json => {:success => true, :message => message}
162
167
  end
163
168
 
164
169
  def update_security
165
- path = params[:path]
170
+ path = params[:path]
166
171
  secure = params[:secure]
167
172
  roles = []
168
173
 
@@ -185,11 +190,11 @@ module Knitkit
185
190
  role.add_capability(capability)
186
191
  end
187
192
  end
188
-
193
+
189
194
  # if we're using S3, set file permissions to private or public_read
190
195
  @file_support.set_permissions(path, (file.is_secured? ? :private : :public_read)) if ErpTechSvcs::Config.file_storage == :s3
191
-
192
- render :json => {:success => true, :secured => file.is_secured?, :roles => file.roles.uniq.collect{|item| item.internal_identifier}}
196
+
197
+ render :json => {:success => true, :secured => file.is_secured?, :roles => file.roles.uniq.collect { |item| item.internal_identifier }}
193
198
  end
194
199
 
195
200
  protected
@@ -202,9 +207,14 @@ module Knitkit
202
207
  @root_node = nil
203
208
 
204
209
  if @context == :website
205
- @root_node = File.join(ErpTechSvcs::Config.file_assets_location,"sites",@assets_model.iid) unless @assets_model.nil?
210
+ @root_node = File.join(ErpTechSvcs::Config.file_assets_location,
211
+ 'sites',
212
+ @assets_model.iid)
206
213
  else
207
- @root_node = File.join(ErpTechSvcs::Config.file_assets_location,"shared_site_files")
214
+ @root_node = File.join(ErpTechSvcs::Config.file_assets_location,
215
+ "dba_organizations",
216
+ current_user.party.dba_organization.id.to_s,
217
+ "shared_site_files")
208
218
  end
209
219
 
210
220
  @root_node
@@ -222,8 +232,8 @@ module Knitkit
222
232
  @assets_model = CompassAeInstance.find_by_internal_identifier('base')
223
233
  end
224
234
  end
225
-
226
- end#FileAssetsController
227
- end#Desktop
228
- end#ErpApp
229
- end#Knitkit
235
+
236
+ end #FileAssetsController
237
+ end #Desktop
238
+ end #ErpApp
239
+ end #Knitkit