knitkit 2.1.15 → 3.0.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 (209) hide show
  1. checksums.yaml +7 -0
  2. data/app/controllers/knitkit/base_controller.rb +1 -1
  3. data/app/controllers/knitkit/comments_controller.rb +7 -2
  4. data/app/controllers/knitkit/erp_app/desktop/app_controller.rb +78 -98
  5. data/app/controllers/knitkit/erp_app/desktop/articles_controller.rb +65 -45
  6. data/app/controllers/knitkit/erp_app/desktop/content_controller.rb +22 -12
  7. data/app/controllers/knitkit/erp_app/desktop/file_assets_controller.rb +1 -1
  8. data/app/controllers/knitkit/erp_app/desktop/image_assets_controller.rb +28 -16
  9. data/app/controllers/knitkit/erp_app/desktop/inquiries_controller.rb +15 -49
  10. data/app/controllers/knitkit/erp_app/desktop/online_document_sections_controller.rb +4 -3
  11. data/app/controllers/knitkit/erp_app/desktop/position_controller.rb +69 -11
  12. data/app/controllers/knitkit/erp_app/desktop/theme_controller.rb +63 -60
  13. data/app/controllers/knitkit/erp_app/desktop/website_controller.rb +98 -82
  14. data/app/controllers/knitkit/erp_app/desktop/website_host_controller.rb +77 -0
  15. data/app/controllers/knitkit/erp_app/desktop/website_nav_controller.rb +64 -44
  16. data/app/controllers/knitkit/erp_app/desktop/website_nav_item_controller.rb +147 -0
  17. data/app/controllers/knitkit/erp_app/desktop/website_section_controller.rb +81 -45
  18. data/app/controllers/knitkit/mobile_controller.rb +15 -0
  19. data/app/controllers/knitkit/online_document_sections_controller.rb +2 -1
  20. data/app/controllers/knitkit/unauthorized_controller.rb +0 -1
  21. data/app/controllers/knitkit/website_sections_controller.rb +7 -4
  22. data/app/mailers/website_inquiry_mailer.rb +8 -7
  23. data/app/models/content.rb +11 -2
  24. data/app/models/document.rb +2 -17
  25. data/app/models/published_website.rb +96 -59
  26. data/app/models/theme.rb +100 -14
  27. data/app/models/website.rb +260 -28
  28. data/app/models/website_inquiry.rb +5 -12
  29. data/app/models/website_section.rb +9 -1
  30. data/app/views/knitkit/blogs/_add_comment.html.erb +44 -23
  31. data/app/views/knitkit/blogs/_comment.html.erb +4 -6
  32. data/app/views/knitkit/blogs/index.html.erb +63 -49
  33. data/app/views/knitkit/blogs/show.html.erb +17 -12
  34. data/app/views/knitkit/mobile/index.html.erb +162 -0
  35. data/app/views/knitkit/online_document_sections/index.html.erb +7 -5
  36. data/app/views/knitkit/unauthorized/index.html.erb +8 -4
  37. data/app/views/knitkit/website_sections/index.html.erb +8 -4
  38. data/app/views/layouts/knitkit/base.html.erb +79 -63
  39. data/app/views/layouts/knitkit/online_document_sections.html.erb +74 -52
  40. data/app/views/menus/knitkit/_default_menu.html.erb +4 -4
  41. data/app/views/menus/knitkit/_default_section_menu.html.erb +22 -23
  42. data/app/views/shared/knitkit/_bread_crumb.html.erb +10 -7
  43. data/app/views/shared/knitkit/_footer.html.erb +2 -2
  44. data/app/views/website_inquiry_mailer/inquiry.erb +23 -2
  45. data/app/widgets/contact_us/base.rb +25 -50
  46. data/app/widgets/contact_us/javascript/contact_us.js +7 -7
  47. data/app/widgets/contact_us/views/error.html.erb +6 -8
  48. data/app/widgets/contact_us/views/index.html.erb +28 -1
  49. data/app/widgets/contact_us/views/layouts/base.html.erb +9 -6
  50. data/app/widgets/contact_us/views/success.html.erb +3 -3
  51. data/app/widgets/google_map/views/index.html.erb +36 -36
  52. data/app/widgets/login/base.rb +1 -0
  53. data/app/widgets/login/javascript/login.js +3 -3
  54. data/app/widgets/login/views/index.html.erb +46 -26
  55. data/app/widgets/login/views/layouts/base.html.erb +15 -13
  56. data/app/widgets/login/views/login_header.html.erb +7 -9
  57. data/app/widgets/manage_profile/base.rb +116 -164
  58. data/app/widgets/manage_profile/views/_address.html.erb +184 -0
  59. data/app/widgets/manage_profile/views/_contact_information_form.html.erb +23 -192
  60. data/app/widgets/manage_profile/views/_email_address.html.erb +163 -0
  61. data/app/widgets/manage_profile/views/_password_form.html.erb +23 -20
  62. data/app/widgets/manage_profile/views/_phone_number.html.erb +165 -0
  63. data/app/widgets/manage_profile/views/_user_information_form.html.erb +49 -33
  64. data/app/widgets/manage_profile/views/error.html.erb +6 -0
  65. data/app/widgets/manage_profile/views/index.html.erb +44 -46
  66. data/app/widgets/manage_profile/views/layouts/base.html.erb +3 -1
  67. data/app/widgets/manage_profile/views/success.html.erb +5 -0
  68. data/app/widgets/reset_password/views/index.html.erb +33 -28
  69. data/app/widgets/reset_password/views/layouts/base.html.erb +10 -1
  70. data/app/widgets/search/base.rb +37 -25
  71. data/app/widgets/search/views/_inline_search_form.html.erb +12 -0
  72. data/app/widgets/search/views/_search_form.html.erb +41 -0
  73. data/app/widgets/search/views/index.html.erb +5 -3
  74. data/app/widgets/search/views/layouts/base.html.erb +13 -23
  75. data/app/widgets/search/views/show.html.erb +32 -47
  76. data/app/widgets/signup/base.rb +1 -1
  77. data/app/widgets/signup/javascript/signup.js +7 -9
  78. data/app/widgets/signup/views/_signup_form.html.erb +34 -29
  79. data/app/widgets/signup/views/error.html.erb +11 -11
  80. data/app/widgets/signup/views/index.html.erb +3 -2
  81. data/app/widgets/signup/views/layouts/base.html.erb +8 -5
  82. data/app/widgets/signup/views/success.html.erb +5 -4
  83. data/config/routes.rb +39 -28
  84. data/db/data_migrations/20120809020508_update_website_and_configuration.rb +3 -0
  85. data/db/migrate/20110211002317_setup_knitkit.rb +0 -1
  86. data/db/migrate/20131112013052_add_knitkit_missing_indexes.rb +33 -0
  87. data/db/migrate/20140622212723_update_website_inquiries.rb +22 -0
  88. data/db/migrate/20140911185022_add_publishing_to_website.rb +5 -0
  89. data/db/migrate/20141013073349_add_custom_fields_to_documents.rb +12 -0
  90. data/db/migrate/20141016101936_upgrade_remove_dynamic_attributes.rb +13 -0
  91. data/lib/knitkit.rb +0 -1
  92. data/lib/knitkit/engine.rb +1 -0
  93. data/lib/knitkit/extensions.rb +4 -0
  94. data/lib/knitkit/extensions/active_record/acts_as_commentable.rb +33 -0
  95. data/lib/knitkit/extensions/active_record/acts_as_document.rb +0 -12
  96. data/lib/knitkit/extensions/active_record/acts_as_publishable.rb +7 -10
  97. data/lib/knitkit/extensions/compass_ae/widgets/base.rb +2 -4
  98. data/lib/knitkit/extensions/compass_ae/widgets/widget_proxy_controller.rb +4 -1
  99. data/lib/knitkit/extensions/railties/action_view/helpers/blog_helper.rb +16 -13
  100. data/lib/knitkit/extensions/railties/action_view/helpers/content_helper.rb +10 -8
  101. data/lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb +123 -108
  102. data/lib/knitkit/extensions/will_paginate/link_renderer.rb +67 -0
  103. data/lib/knitkit/routing_filter/section_router.rb +10 -8
  104. data/lib/knitkit/syntax_validator.rb +2 -2
  105. data/lib/knitkit/version.rb +7 -3
  106. data/public/images/inline_edit/close.png +0 -0
  107. data/public/images/knitkit/close_window.png +0 -0
  108. data/public/images/knitkit/logo.png +0 -0
  109. data/public/images/knitkit/splash/images/add-site.png +0 -0
  110. data/public/images/knitkit/splash/images/adjust-site.png +0 -0
  111. data/public/images/knitkit/splash/images/browse-site.png +0 -0
  112. data/public/images/knitkit/splash/images/find-themes.png +0 -0
  113. data/public/images/knitkit/splash/images/settings.png +0 -0
  114. data/public/images/knitkit/splash/images/tutorials.png +0 -0
  115. data/public/images/knitkit/splash/splash.png +0 -0
  116. data/public/javascripts/erp_app/desktop/applications/knitkit/articles_grid_panel.js +656 -627
  117. data/public/javascripts/erp_app/desktop/applications/knitkit/center_region.js +444 -333
  118. data/public/javascripts/erp_app/desktop/applications/knitkit/{east_region.js → east_region/east_region.js} +33 -33
  119. data/public/javascripts/erp_app/desktop/applications/knitkit/east_region/file_assets_panel.js +332 -0
  120. data/public/javascripts/erp_app/desktop/applications/knitkit/east_region/image_assets_data_view.js +144 -0
  121. data/public/javascripts/erp_app/desktop/applications/knitkit/east_region/image_assets_panel.js +335 -0
  122. data/public/javascripts/erp_app/desktop/applications/knitkit/{widgets_panel.js → east_region/widgets_panel.js} +55 -55
  123. data/public/javascripts/erp_app/desktop/applications/knitkit/inquiries_grid_panel.js +150 -37
  124. data/public/javascripts/erp_app/desktop/applications/knitkit/module.js +228 -96
  125. data/public/javascripts/erp_app/desktop/applications/knitkit/publish_window.js +89 -85
  126. data/public/javascripts/erp_app/desktop/applications/knitkit/published_grid_panel.js +238 -217
  127. data/public/javascripts/erp_app/desktop/applications/knitkit/select_roles_window.js +59 -54
  128. data/public/javascripts/erp_app/desktop/applications/knitkit/splash_screen.js +170 -0
  129. data/public/javascripts/erp_app/desktop/applications/knitkit/top_menu/main_menu.js +1168 -0
  130. data/public/javascripts/erp_app/desktop/applications/knitkit/top_menu/websites_combo.js +71 -0
  131. data/public/javascripts/erp_app/desktop/applications/knitkit/versions_grid_panel.js +301 -306
  132. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/article.js +216 -0
  133. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/document.js +182 -153
  134. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/host.js +48 -65
  135. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/menu.js +93 -94
  136. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/section.js +523 -197
  137. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/website_nav_items.js +20 -34
  138. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/hosts_tree_panel.js +74 -0
  139. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/menu_tree_panel.js +245 -0
  140. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/site_contents_tree_panel.js +360 -0
  141. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/themes_tree_panel.js +348 -0
  142. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/west_region.js +106 -1132
  143. data/public/javascripts/knitkit/bootstrap-datepicker.js +474 -0
  144. data/public/javascripts/knitkit/bootstrap.min.js +7 -0
  145. data/public/javascripts/knitkit/confirm-bootstrap.js +110 -0
  146. data/public/javascripts/knitkit/inline_editing.js +73 -50
  147. data/public/javascripts/knitkit/jquery.maskedinput.min.js +7 -0
  148. data/public/javascripts/knitkit/mobile/app/view/Main.js +108 -0
  149. data/public/javascripts/knitkit/mobile/ux/slidenavigation/View.js +734 -0
  150. data/public/javascripts/knitkit/theme.js +76 -0
  151. data/public/stylesheets/erp_app/desktop/applications/knitkit/knitkit.css +95 -35
  152. data/public/stylesheets/knitkit/bootstrap-responsive.min.css +10 -0
  153. data/public/stylesheets/knitkit/bootstrap.min.css +7 -0
  154. data/public/stylesheets/knitkit/custom.css +122 -0
  155. data/public/stylesheets/knitkit/datepicker.css +182 -0
  156. data/public/stylesheets/knitkit/inline_editing.css +58 -58
  157. data/spec/controllers/knitkit/erp_app/desktop/website_section_controller_spec.rb +1 -1
  158. data/spec/dummy/config/application.rb +1 -1
  159. data/spec/models/article_spec.rb +3 -3
  160. data/spec/models/content_spec.rb +9 -9
  161. data/spec/models/website_spec.rb +1 -1
  162. metadata +100 -114
  163. data/app/helpers/application_helper.rb +0 -134
  164. data/app/views/knitkit/articles/index.html.erb +0 -3
  165. data/app/views/knitkit/articles/show.html.erb +0 -4
  166. data/app/views/menus/knitkit/_default_sub_menu.html.erb +0 -43
  167. data/app/views/menus/knitkit/_default_sub_section_menu.html.erb +0 -47
  168. data/app/widgets/contact_us/views/_contact_form.html.erb +0 -36
  169. data/app/widgets/dynamic_forms/base.rb +0 -139
  170. data/app/widgets/dynamic_forms/javascript/dynamic_forms.js +0 -110
  171. data/app/widgets/dynamic_forms/views/error.html.erb +0 -5
  172. data/app/widgets/dynamic_forms/views/index.html.erb +0 -8
  173. data/app/widgets/dynamic_forms/views/success.html.erb +0 -4
  174. data/app/widgets/dynamic_grid/base.rb +0 -130
  175. data/app/widgets/dynamic_grid/helpers/controller/dynamic_grid_controller_helper.rb +0 -3
  176. data/app/widgets/dynamic_grid/helpers/view/dynamic_grid_view_helper.rb +0 -3
  177. data/app/widgets/dynamic_grid/javascript/dynamic_grid.js +0 -177
  178. data/app/widgets/dynamic_grid/views/index.html.erb +0 -14
  179. data/app/widgets/login/views/reset_password.html.erb +0 -26
  180. data/app/widgets/manage_profile/views/default_type_error.html.erb +0 -5
  181. data/app/widgets/scaffold/base.rb +0 -87
  182. data/app/widgets/scaffold/helpers/controller/scaffold_controller_helper.rb +0 -3
  183. data/app/widgets/scaffold/helpers/view/scaffold_view_helper.rb +0 -3
  184. data/app/widgets/scaffold/javascript/scaffold.js +0 -337
  185. data/app/widgets/scaffold/views/index.html.erb +0 -15
  186. data/app/widgets/search/views/_search.html.erb +0 -39
  187. data/public/images/knitkit/bullet.png +0 -0
  188. data/public/images/knitkit/close.png +0 -0
  189. data/public/images/knitkit/content.png +0 -0
  190. data/public/images/knitkit/footer.png +0 -0
  191. data/public/images/knitkit/graphic.png +0 -0
  192. data/public/images/knitkit/greyFadeDown.png +0 -0
  193. data/public/images/knitkit/link.png +0 -0
  194. data/public/images/knitkit/menu.png +0 -0
  195. data/public/images/knitkit/menu_select.png +0 -0
  196. data/public/images/knitkit/search.png +0 -0
  197. data/public/images/knitkit/tooltip.gif +0 -0
  198. data/public/javascripts/ajax_pagination.js +0 -33
  199. data/public/javascripts/datepicker.js +0 -445
  200. data/public/javascripts/erp_app/desktop/applications/knitkit/file_assets_panel.js +0 -341
  201. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_data_view.js +0 -31
  202. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_panel.js +0 -263
  203. data/public/javascripts/erp_app/desktop/applications/knitkit/section_articles_grid_panel.js +0 -722
  204. data/public/javascripts/erp_app/desktop/applications/knitkit/themes_tree_panel.js +0 -585
  205. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region/helpers/website.js +0 -155
  206. data/public/javascripts/knitkit/helpers.js +0 -26
  207. data/public/stylesheets/datepicker.css +0 -121
  208. data/public/stylesheets/extjs/resources/css/knitkit_extjs_4.css +0 -233
  209. data/public/stylesheets/knitkit/style.css +0 -426
@@ -17,6 +17,7 @@ module Knitkit
17
17
  include Knitkit::Extensions::ActiveRecord::ActsAsPublishable
18
18
  include Knitkit::Extensions::ActiveRecord::ThemeSupport::HasManyThemes
19
19
  include Knitkit::Extensions::ActiveRecord::ActsAsDocument
20
+ include Knitkit::Extensions::ActiveRecord::ActsAsCommentable
20
21
  end
21
22
 
22
23
  ActiveSupport.on_load(:action_controller) do
@@ -10,9 +10,13 @@ require 'knitkit/extensions/railties/theme_support/theme_file_resolver'
10
10
  require 'knitkit/extensions/active_record/acts_as_publishable'
11
11
  require 'knitkit/extensions/active_record/theme_support/has_many_themes'
12
12
  require 'knitkit/extensions/active_record/acts_as_document'
13
+ require 'knitkit/extensions/active_record/acts_as_commentable'
13
14
 
14
15
  #active_controller extensions
15
16
  require 'knitkit/extensions/action_controller/theme_support/acts_as_themed_controller'
16
17
 
17
18
  #action_mailer extensions
18
19
  require 'knitkit/extensions/action_mailer/theme_support/acts_as_themed_mailer'
20
+
21
+ #willpaginate
22
+ require 'knitkit/extensions/will_paginate/link_renderer'
@@ -0,0 +1,33 @@
1
+ module Knitkit
2
+ module Extensions
3
+ module ActiveRecord
4
+ module ActsAsCommentable
5
+ def self.included(base)
6
+ base.extend(ClassMethods)
7
+ end
8
+
9
+ module ClassMethods
10
+
11
+ def acts_as_commentable
12
+ has_many :comments, :as => :commented_record, :dependent => :destroy
13
+
14
+ extend ActsAsCommentable::SingletonMethods
15
+ include ActsAsCommentable::InstanceMethods
16
+ end
17
+
18
+ end
19
+
20
+ module SingletonMethods
21
+ end
22
+
23
+ module InstanceMethods
24
+
25
+ def add_comment(options={})
26
+ self.comments.create(options)
27
+ end
28
+
29
+ end
30
+ end # ActsAsCommentable
31
+ end # ActiveRecord
32
+ end # Extensions
33
+ end # Knitkit
@@ -21,18 +21,6 @@ module Knitkit
21
21
 
22
22
  #from Document / FileAssets
23
23
  [:add_file, :files].each { |m| delegate m, :to => :document }
24
-
25
- #from relational_dynamic_attributes
26
- [
27
- :add_dynamic_attribute,
28
- :update_or_create_dynamic_attribute,
29
- :update_first_dynamic_attribute_value_of_type,
30
- :get_dynamic_attributes,
31
- :get_dynamic_value_of_type,
32
- :get_dynamic_attribute_of_type,
33
- :has_dynamic_attribute_of_type?,
34
- :destroy_dynamic_attribute_of_type
35
- ].each { |m| delegate m, :to => :document }
36
24
  end
37
25
 
38
26
  end
@@ -9,7 +9,7 @@ module Knitkit
9
9
  module ClassMethods
10
10
 
11
11
  def can_be_published
12
- after_destroy :destroy_published_elements
12
+ after_destroy :delete_published_elements
13
13
 
14
14
  extend ActsAsPublishable::SingletonMethods
15
15
  include ActsAsPublishable::InstanceMethods
@@ -25,15 +25,12 @@ module Knitkit
25
25
  site.publish_element(comment, self, version, current_user)
26
26
  end
27
27
 
28
- def destroy_published_elements
29
- published_elements = PublishedElement.where('published_element_record_id = ? and (published_element_record_type = ? or published_element_record_type = ?)', self.id, self.class.to_s, self.class.superclass.to_s)
30
- published_elements.each do |published_element|
31
- published_element.destroy
32
- end
28
+ def delete_published_elements
29
+ PublishedElement.delete_all("published_element_record_id = '#{id}' and (published_element_record_type = '#{self.class.to_s}' or published_element_record_type = '#{self.class.superclass.to_s}')")
33
30
  end
34
31
  end
35
32
 
36
- end#ActsAsPublishable
37
- end#ActiveRecord
38
- end#Extensions
39
- end#Knitkit
33
+ end #ActsAsPublishable
34
+ end #ActiveRecord
35
+ end #Extensions
36
+ end #Knitkit
@@ -5,13 +5,11 @@
5
5
 
6
6
  website.themes.active.map{ |theme| {:path => theme.path.to_s, :url => theme.url.to_s}}.each do |theme|
7
7
  path = File.join(theme[:path],'widgets',self.widget_name,'views')
8
- paths << path unless paths.include?(path)
8
+ paths.unshift(path) unless paths.include?(path)
9
9
  end if website
10
-
11
- paths.reverse!
10
+
12
11
  ActionView::Base.new(paths).render(:template => view, :locals => locals)
13
12
  end
14
-
15
13
  end
16
14
 
17
15
  ::ErpApp::Widgets::Base.class_eval do
@@ -19,10 +19,13 @@ ErpApp::WidgetProxyController.class_eval do
19
19
  return if result.nil?
20
20
 
21
21
  if result.is_a?(Hash)
22
- render result
22
+ if !result[:send_file] and !result[:send_data] and !result[:redirect_to]
23
+ render result
24
+ end
23
25
  else
24
26
  render :inline => result
25
27
  end
28
+
26
29
  end
27
30
 
28
31
  protected
@@ -23,35 +23,38 @@ module Knitkit
23
23
 
24
24
  def blog_rss_links(link_title='RSS Feed')
25
25
  if params[:action] == 'tag'
26
- return link_to link_title, main_app.blog_tag_url(params[:section_id], params[:tag_id], :rss), :target => '_blank'
26
+ link_to link_title, main_app.blog_tag_url(params[:section_id], params[:tag_id], :rss), :target => '_blank'
27
27
  else
28
- return link_to link_title, main_app.blogs_url(params[:section_id], :rss), :target => '_blank'
28
+ link_to link_title, main_app.blogs_url(params[:section_id], :rss), :target => '_blank'
29
29
  end
30
30
  end
31
31
 
32
32
  def blog_recent_approved_comments
33
33
  if @published_content.content.comments.recent.approved.empty?
34
- return 'No Comments'
34
+ 'No Comments'
35
35
  else
36
36
  html = ''
37
37
 
38
38
  @published_content.content.comments.recent.approved.each do |comment|
39
- html += render :partial => 'comment', :locals => {:comment => comment}
39
+ html += (render :partial => 'comment', :locals => {:comment => comment})
40
40
  end
41
41
 
42
- return raw html
42
+ raw html
43
43
  end
44
44
  end
45
45
 
46
46
  def blog_pagination(css_class, params)
47
- return will_paginate @contents, :class => css_class, :params => {
48
- :section_id => params[:section_id],
49
- :per_page => params[:per_page],
50
- :format => params[:format],
51
- :only_path => true,
52
- :use_route => params[:use_route],
53
- :scope => main_app
54
- }
47
+ will_paginate @contents,
48
+ :renderer => Knitkit::Extensions::WillPaginate::LinkRenderer,
49
+ :class => css_class,
50
+ :params => {
51
+ :section_id => params[:section_id],
52
+ :per_page => 1,
53
+ :format => params[:format],
54
+ :only_path => true,
55
+ :use_route => params[:use_route],
56
+ :scope => main_app
57
+ }
55
58
  end
56
59
 
57
60
  end #BlogHelper
@@ -6,13 +6,15 @@ module Knitkit
6
6
  module ContentHelper
7
7
 
8
8
  def setup_inline_editing
9
- if can_inline_edit?
10
- raw "<script type='text/javascript'>
11
- jQuery(document).ready(function() {
12
- Knitkit.InlineEditing.setup(#{@website.id});
9
+ if can_inline_edit?
10
+ raw "<script type='text/javascript'>
11
+ jQuery(document).ready(function() {
12
+ new OnDemandLoadByAjax().load('/javascripts/erp_app/ckeditor/ckeditor.js', function(){
13
+ Knitkit.InlineEditing.setup(#{@website.id});
14
+ });
13
15
  });
14
16
  </script>"
15
- end
17
+ end
16
18
  end
17
19
 
18
20
  def render_editable_content(content_version, additional_css_classes=[])
@@ -41,8 +43,8 @@ module Knitkit
41
43
  html = ''
42
44
 
43
45
  section_contents = WebsiteSectionContent.includes(:content).
44
- where(:website_section_id => @website_section.id, :content_area => name.to_s).
45
- order(:position).all
46
+ where(:website_section_id => @website_section.id, :content_area => name.to_s).
47
+ order(:position).all
46
48
  published_contents = []
47
49
  section_contents.each do |sc|
48
50
  content_version = Content.get_published_version(@active_publication, sc.content) unless @active_publication.nil?
@@ -63,7 +65,7 @@ module Knitkit
63
65
  end
64
66
 
65
67
  private
66
-
68
+
67
69
  def can_inline_edit?
68
70
  result = false
69
71
  unless (current_user.nil? or current_user === false)
@@ -9,11 +9,17 @@ require 'action_view/helpers/asset_tag_helper'
9
9
  module ActionView
10
10
  module Helpers
11
11
  module AssetTagHelper
12
+
12
13
  def theme_javascript_path(theme, source)
13
14
  theme = controller.website.themes.find_by_theme_id(theme) unless theme.is_a?(Theme)
14
- file = theme.files.where('name = ? and directory = ?', source, "#{theme.url}/javascripts").first
15
+
16
+ name, directory = name_and_path_from_source(source, "#{theme.url}/javascripts")
17
+
18
+ file = theme.files.where('name = ? and directory = ?', name, directory).first
19
+
15
20
  file.nil? ? '' : file.data.url
16
21
  end
22
+
17
23
  alias_method :theme_path_to_javascript, :theme_javascript_path
18
24
 
19
25
  def theme_javascript_include_tag(theme_id, *sources)
@@ -21,61 +27,53 @@ module ActionView
21
27
  return("could not find theme with the id #{theme_id}") unless theme
22
28
 
23
29
  options = sources.extract_options!.stringify_keys
24
- cache = options.delete("cache")
30
+ cache = options.delete("cache")
25
31
  recursive = options.delete("recursive")
26
32
 
27
- # this caching appears to be deprecated, commenting out
28
- # if ActionController::Base.perform_caching && cache
29
- # joined_javascript_name = (cache == true ? "all" : cache) + ".js"
30
- # joined_javascript_path = File.join(theme.path + '/javascripts', joined_javascript_name)
31
-
32
- # paths = theme_compute_javascript_paths(theme, sources, recursive)
33
- # theme_write_asset_file_contents(theme, joined_javascript_path, paths) unless File.exists?(joined_javascript_path)
34
- # raw theme_javascript_src_tag(theme, joined_javascript_name, options)
35
- # else
36
- sources = theme_expand_javascript_sources(theme, sources, recursive).collect do |source|
37
- theme_javascript_src_tag(theme, source, options)
38
- end.join("\n")
39
- raw sources
33
+ sources = theme_expand_javascript_sources(theme, sources, recursive).collect do |source|
34
+ theme_javascript_src_tag(theme, source, options)
35
+ end.join("\n")
36
+ raw sources
40
37
  #end
41
38
  end
42
39
 
43
40
  def theme_stylesheet_path(theme, source)
44
41
  theme = controller.website.themes.find_by_theme_id(theme) unless theme.is_a?(Theme)
45
- file = theme.files.where('name = ? and directory = ?', source, "#{theme.url}/stylesheets").first
42
+
43
+ name, directory = name_and_path_from_source(source, "#{theme.url}/stylesheets")
44
+
45
+ file = theme.files.where('name = ? and directory = ?', name, directory).first
46
+
46
47
  file.nil? ? '' : file.data.url
47
48
  end
49
+
48
50
  alias_method :theme_path_to_stylesheet, :theme_stylesheet_path
49
51
 
50
52
  def theme_stylesheet_link_tag(theme_id, *sources)
51
53
  theme = controller.website.themes.find_by_theme_id(theme_id)
52
54
  return("could not find theme with the id #{theme_id}") unless theme
53
-
55
+
54
56
  options = sources.extract_options!.stringify_keys
55
- cache = options.delete("cache")
57
+ cache = options.delete("cache")
56
58
  recursive = options.delete("recursive")
57
-
58
- # this caching appears to be deprecated, commenting out
59
- # if ActionController::Base.perform_caching && cache
60
- # joined_stylesheet_name = (cache == true ? "all" : cache) + ".css"
61
- # joined_stylesheet_path = File.join(theme.path + '/stylesheets', joined_stylesheet_name)
62
-
63
- # paths = theme_compute_stylesheet_paths(theme, sources, recursive)
64
- # theme_write_asset_file_contents(theme, joined_stylesheet_path, paths) unless File.exists?(joined_stylesheet_path)
65
- # raw theme_stylesheet_tag(theme, joined_stylesheet_name, options)
66
- # else
67
- sources = theme_expand_stylesheet_sources(theme, sources, recursive).collect do |source|
68
- theme_stylesheet_tag(theme, source, options)
69
- end.join("\n")
70
- raw sources
59
+
60
+ sources = theme_expand_stylesheet_sources(theme, sources, recursive).collect do |source|
61
+ theme_stylesheet_tag(theme, source, options)
62
+ end.join("\n")
63
+ raw sources
71
64
  #end
72
65
  end
73
66
 
74
67
  def theme_image_path(theme, source)
75
68
  theme = controller.website.themes.find_by_theme_id(theme) unless theme.is_a?(Theme)
76
- file = theme.files.where('name = ? and directory = ?', source, "#{theme.url}/images").first
69
+
70
+ name, directory = name_and_path_from_source(source, "#{theme.url}/images")
71
+
72
+ file = theme.files.where('name = ? and directory = ?', name, directory).first
73
+
77
74
  file.nil? ? '' : file.data.url
78
75
  end
76
+
79
77
  alias_method :theme_path_to_image, :theme_image_path # aliased to avoid conflicts with an image_path named route
80
78
 
81
79
  def theme_image_tag(theme_id, source, options = {})
@@ -92,109 +90,126 @@ module ActionView
92
90
 
93
91
  if mouseover = options.delete(:mouseover)
94
92
  options[:onmouseover] = "this.src='#{theme_image_path(theme, mouseover)}'"
95
- options[:onmouseout] = "this.src='#{theme_image_path(theme, options[:src])}'"
93
+ options[:onmouseout] = "this.src='#{theme_image_path(theme, options[:src])}'"
96
94
  end
97
95
 
98
96
  tag("img", options)
99
97
  end
100
98
 
101
99
  private
102
- def theme_compute_public_path(theme, source, dir, ext = nil, include_host = true)
103
- has_request = controller.respond_to?(:request)
100
+ def theme_compute_public_path(theme, source, dir, ext = nil, include_host = true)
101
+ has_request = controller.respond_to?(:request)
104
102
 
105
- if ext && (File.extname(source).blank? || File.exist?(File.join(theme.path, dir, "#{source}.#{ext}")))
106
- source += ".#{ext}"
107
- end
103
+ if ext && (File.extname(source).blank? || File.exist?(File.join(theme.path, dir, "#{source}.#{ext}")))
104
+ source += ".#{ext}"
105
+ end
108
106
 
109
- unless source =~ %r{^[-a-z]+://}
110
- source = "/#{dir}/#{source}" unless source[0] == ?/
107
+ unless source =~ %r{^[-a-z]+://}
108
+ source = "/#{dir}/#{source}" unless source[0] == ?/
111
109
 
112
- source = theme_rewrite_asset_path(theme, source)
110
+ source = theme_rewrite_asset_path(theme, source)
113
111
 
114
- if has_request && include_host
115
- unless source =~ %r{^#{ActionController::Base.config.relative_url_root}/}
116
- source = "#{ActionController::Base.config.relative_url_root}#{source}"
117
- end
112
+ if has_request && include_host
113
+ unless source =~ %r{^#{ActionController::Base.config.relative_url_root}/}
114
+ source = "#{ActionController::Base.config.relative_url_root}#{source}"
118
115
  end
119
116
  end
120
-
121
- source
122
117
  end
123
118
 
124
- def theme_rails_asset_id(theme, source)
125
- if asset_id = ENV["RAILS_ASSET_ID"]
126
- asset_id
127
- else
128
- path = File.join(theme.path, source)
129
- asset_id = File.exist?(path) ? File.mtime(path).to_i.to_s : ''
130
- asset_id
131
- end
132
- end
119
+ source
120
+ end
133
121
 
134
- def theme_rewrite_asset_path(theme, source)
135
- asset_id = theme_rails_asset_id(theme, source)
136
- if asset_id.blank?
137
- source
138
- else
139
- source + "?#{asset_id}"
140
- end
122
+ def theme_rails_asset_id(theme, source)
123
+ if asset_id = ENV["RAILS_ASSET_ID"]
124
+ asset_id
125
+ else
126
+ path = File.join(theme.path, source)
127
+ asset_id = File.exist?(path) ? File.mtime(path).to_i.to_s : ''
128
+ asset_id
141
129
  end
130
+ end
142
131
 
143
- def theme_javascript_src_tag(theme, source, options)
144
- options = { "type" => Mime::JS, "src" => theme_path_to_javascript(theme, source) }.merge(options)
145
- content_tag("script", "", options)
132
+ def theme_rewrite_asset_path(theme, source)
133
+ asset_id = theme_rails_asset_id(theme, source)
134
+ if asset_id.blank?
135
+ source
136
+ else
137
+ source + "?#{asset_id}"
146
138
  end
139
+ end
147
140
 
148
- def theme_stylesheet_tag(theme, source, options)
149
- options = { "rel" => "stylesheet", "type" => Mime::CSS, "media" => "screen",
150
- "href" => html_escape(theme_path_to_stylesheet(theme, source)) }.merge(options)
151
- tag("link", options, false, false)
152
- end
141
+ def theme_javascript_src_tag(theme, source, options)
142
+ options = {"type" => Mime::JS, "src" => theme_path_to_javascript(theme, source)}.merge(options)
143
+ content_tag("script", "", options)
144
+ end
153
145
 
154
- def theme_compute_javascript_paths(theme, *args)
155
- theme_expand_javascript_sources(theme, *args).collect do |source|
156
- theme_compute_public_path(theme, source, theme.url + '/javascripts', 'js', false)
157
- end
158
- end
146
+ def theme_stylesheet_tag(theme, source, options)
147
+ options = {"rel" => "stylesheet", "type" => Mime::CSS, "media" => "screen",
148
+ "href" => html_escape(theme_path_to_stylesheet(theme, source))}.merge(options)
149
+ tag("link", options, false, false)
150
+ end
159
151
 
160
- def theme_compute_stylesheet_paths(theme, *args)
161
- theme_expand_stylesheet_sources(theme, *args).collect do |source|
162
- theme_compute_public_path(theme, source, theme.url + '/stylesheets', 'css', false)
163
- end
152
+ def theme_compute_javascript_paths(theme, *args)
153
+ theme_expand_javascript_sources(theme, *args).collect do |source|
154
+ theme_compute_public_path(theme, source, theme.url + '/javascripts', 'js', false)
164
155
  end
156
+ end
165
157
 
166
- def theme_expand_javascript_sources(theme, sources, recursive = false)
167
- if sources.include?(:all)
168
- all_javascript_files = collect_asset_files(theme.path + '/javascripts', ('**' if recursive), '*.js').uniq
169
- else
170
- sources.flatten
171
- end
158
+ def theme_compute_stylesheet_paths(theme, *args)
159
+ theme_expand_stylesheet_sources(theme, *args).collect do |source|
160
+ theme_compute_public_path(theme, source, theme.url + '/stylesheets', 'css', false)
172
161
  end
162
+ end
173
163
 
174
- def theme_expand_stylesheet_sources(theme, sources, recursive)
175
- if sources.first == :all
176
- collect_asset_files(theme.path + '/stylesheets', ('**' if recursive), '*.css')
177
- else
178
- sources.flatten
179
- end
164
+ def theme_expand_javascript_sources(theme, sources, recursive = false)
165
+ if sources.include?(:all)
166
+ all_javascript_files = collect_asset_files(theme.path + '/javascripts', ('**' if recursive), '*.js').uniq
167
+ else
168
+ sources.flatten
180
169
  end
170
+ end
181
171
 
182
- def theme_write_asset_file_contents(theme, joined_asset_path, asset_paths)
183
- FileUtils.mkdir_p(File.dirname(joined_asset_path))
184
- File.open(joined_asset_path, "w+") do |cache|
185
- cache.write(theme_join_asset_file_contents(theme, asset_paths))
186
- end
187
- mt = asset_paths.map { |p| File.mtime(theme_asset_file_path(theme, p)) }.max
188
- File.utime(mt, mt, joined_asset_path)
172
+ def theme_expand_stylesheet_sources(theme, sources, recursive)
173
+ if sources.first == :all
174
+ collect_asset_files(theme.path + '/stylesheets', ('**' if recursive), '*.css')
175
+ else
176
+ sources.flatten
189
177
  end
178
+ end
190
179
 
191
- def theme_join_asset_file_contents(theme, paths)
192
- paths.collect { |path| File.read(theme_asset_file_path(theme, path)) }.join("\n\n")
180
+ def theme_write_asset_file_contents(theme, joined_asset_path, asset_paths)
181
+ FileUtils.mkdir_p(File.dirname(joined_asset_path))
182
+ File.open(joined_asset_path, "w+") do |cache|
183
+ cache.write(theme_join_asset_file_contents(theme, asset_paths))
193
184
  end
185
+ mt = asset_paths.map { |p| File.mtime(theme_asset_file_path(theme, p)) }.max
186
+ File.utime(mt, mt, joined_asset_path)
187
+ end
194
188
 
195
- def theme_asset_file_path(theme, path)
196
- File.join(Theme.root_dir, path.split('?').first)
197
- end
198
- end
199
- end
200
- end
189
+ def theme_join_asset_file_contents(theme, paths)
190
+ paths.collect { |path| File.read(theme_asset_file_path(theme, path)) }.join("\n\n")
191
+ end
192
+
193
+ def theme_asset_file_path(theme, path)
194
+ File.join(Theme.root_dir, path.split('?').first)
195
+ end
196
+
197
+ def name_and_path_from_source(source, base_directory)
198
+ path = source.split('/')
199
+ name = path.last
200
+
201
+ directory = if path.length > 1
202
+ #remove last element
203
+ path.pop
204
+
205
+ "#{base_directory}/#{path.join('/')}"
206
+ else
207
+ base_directory
208
+ end
209
+
210
+ return name, directory
211
+ end
212
+
213
+ end # AssetTagHelper
214
+ end # Helpers
215
+ end # ActionView