knitkit 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. data/README.md +22 -0
  2. data/app/controllers/knitkit/base_controller.rb +15 -2
  3. data/app/controllers/knitkit/blogs_controller.rb +4 -4
  4. data/app/controllers/knitkit/erp_app/desktop/app_controller.rb +16 -2
  5. data/app/controllers/knitkit/erp_app/desktop/articles_controller.rb +198 -57
  6. data/app/controllers/knitkit/erp_app/desktop/content_controller.rb +25 -11
  7. data/app/controllers/knitkit/erp_app/desktop/file_assets_controller.rb +123 -44
  8. data/app/controllers/knitkit/erp_app/desktop/image_assets_controller.rb +83 -9
  9. data/app/controllers/knitkit/erp_app/desktop/online_document_sections_controller.rb +38 -0
  10. data/app/controllers/knitkit/erp_app/desktop/position_controller.rb +15 -6
  11. data/app/controllers/knitkit/erp_app/desktop/theme_controller.rb +185 -98
  12. data/app/controllers/knitkit/erp_app/desktop/versions_controller.rb +38 -16
  13. data/app/controllers/knitkit/erp_app/desktop/website_controller.rb +126 -68
  14. data/app/controllers/knitkit/erp_app/desktop/website_nav_controller.rb +154 -107
  15. data/app/controllers/knitkit/erp_app/desktop/website_section_controller.rb +113 -54
  16. data/app/controllers/knitkit/online_document_sections_controller.rb +45 -0
  17. data/app/controllers/knitkit/unauthorized_controller.rb +5 -0
  18. data/app/controllers/knitkit/website_sections_controller.rb +8 -9
  19. data/app/mailers/document_mailer.rb +10 -0
  20. data/app/models/article.rb +1 -1
  21. data/app/models/content.rb +35 -3
  22. data/app/models/document.rb +8 -0
  23. data/app/models/document_type.rb +3 -0
  24. data/app/models/documented_content.rb +29 -0
  25. data/app/models/documented_item.rb +31 -0
  26. data/app/models/extensions/configuration.rb +5 -0
  27. data/app/models/extensions/party.rb +13 -0
  28. data/app/models/online_document_section.rb +40 -0
  29. data/app/models/theme.rb +22 -26
  30. data/app/models/valid_document.rb +4 -0
  31. data/app/models/website.rb +158 -119
  32. data/app/models/website_inquiry.rb +7 -2
  33. data/app/models/website_inquiry_mailer.rb +4 -3
  34. data/app/models/website_party_role.rb +5 -0
  35. data/app/models/website_section.rb +76 -38
  36. data/app/views/document_mailer/email_document.html.erb +12 -0
  37. data/app/views/knitkit/blogs/_add_comment.html.erb +2 -2
  38. data/app/views/knitkit/online_document_sections/index.html.erb +149 -0
  39. data/app/views/knitkit/website_sections/index.html.erb +0 -1
  40. data/app/views/layouts/knitkit/base.html.erb +4 -2
  41. data/app/views/layouts/knitkit/online_document_sections.html.erb +59 -0
  42. data/app/views/menus/knitkit/_default_menu.html.erb +1 -1
  43. data/app/views/menus/knitkit/_default_section_menu.html.erb +1 -1
  44. data/app/views/menus/knitkit/_default_sub_menu.html.erb +2 -2
  45. data/app/views/menus/knitkit/_default_sub_section_menu.html.erb +1 -1
  46. data/app/widgets/contact_us/base.rb +5 -5
  47. data/app/widgets/contact_us/javascript/contact_us.js +2 -1
  48. data/app/widgets/google_map/base.rb +0 -4
  49. data/app/widgets/google_map/javascript/google_map.js +4 -3
  50. data/app/widgets/login/base.rb +0 -5
  51. data/app/widgets/login/javascript/login.js +155 -153
  52. data/app/widgets/login/views/index.html.erb +3 -3
  53. data/app/widgets/login/views/reset_password.html.erb +2 -2
  54. data/app/widgets/manage_profile/base.rb +46 -67
  55. data/app/widgets/manage_profile/javascript/manage_profile.js +2 -1
  56. data/app/widgets/manage_profile/views/_user_information_form.html.erb +5 -1
  57. data/app/widgets/reset_password/base.rb +4 -6
  58. data/app/widgets/reset_password/javascript/reset_password.js +2 -1
  59. data/app/widgets/reset_password/views/index.html.erb +4 -3
  60. data/app/widgets/search/base.rb +1 -5
  61. data/app/widgets/search/javascript/search.js +2 -1
  62. data/app/widgets/search/views/show.html.erb +2 -2
  63. data/app/widgets/signup/base.rb +7 -6
  64. data/app/widgets/signup/javascript/signup.js +2 -1
  65. data/app/widgets/signup/views/error.html.erb +1 -1
  66. data/config/routes.rb +6 -2
  67. data/db/data_migrations/20110509223702_add_publisher_role.rb +10 -0
  68. data/db/data_migrations/20111118182910_setup_knitkit_capabilities.rb +84 -0
  69. data/db/data_migrations/20120127144444_create_website_role_types.rb +13 -0
  70. data/db/data_migrations/20120127150505_create_website_default_configuration.rb +72 -0
  71. data/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.rb +33 -0
  72. data/db/data_migrations/20120316150424_add_is_template_to_default_website_config.rb +16 -0
  73. data/db/data_migrations/upgrade/20120210195616_add_website_configs.rb +19 -0
  74. data/db/data_migrations/upgrade/20120213205519_populate_website_iids.rb +17 -0
  75. data/db/migrate/20110211002317_setup_knitkit.rb +22 -5
  76. data/db/migrate/20111207161928_create_documented_items_table.rb +13 -0
  77. data/db/migrate/20111208180539_add_document_id_to_documented_item.rb +9 -0
  78. data/db/migrate/20120315163736_add_document.rb +32 -0
  79. data/db/migrate/20120503183431_create_valid_documents.rb +16 -0
  80. data/db/migrate/upgrade/20120116201510_add_render_base_layout_flag.rb +13 -0
  81. data/db/migrate/upgrade/20120127143745_create_website_party_roles.rb +24 -0
  82. data/db/migrate/upgrade/20120213184509_add_iid_to_websites.rb +14 -0
  83. data/lib/knitkit.rb +2 -0
  84. data/lib/knitkit/config.rb +31 -0
  85. data/lib/knitkit/engine.rb +12 -3
  86. data/lib/knitkit/extensions.rb +1 -3
  87. data/lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb +2 -3
  88. data/lib/knitkit/extensions/active_record/acts_as_document.rb +63 -0
  89. data/lib/knitkit/extensions/active_record/acts_as_publishable.rb +5 -4
  90. data/lib/knitkit/extensions/compass_ae/widgets/base.rb +70 -0
  91. data/lib/knitkit/extensions/railties/action_view.rb +22 -10
  92. data/lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb +3 -3
  93. data/lib/knitkit/extensions/railties/theme_support/theme_file_resolver.rb +8 -3
  94. data/lib/knitkit/routing_filter/section_router.rb +16 -6
  95. data/lib/knitkit/version.rb +7 -1
  96. data/public/images/check.png +0 -0
  97. data/public/images/credit_card.png +0 -0
  98. data/public/images/knitkit/tooltip.gif +0 -0
  99. data/public/javascripts/ajax_pagination.js +33 -0
  100. data/public/javascripts/datepicker.js +6 -1
  101. data/public/javascripts/erp_app/desktop/applications/knitkit/articles_grid_panel.js +731 -258
  102. data/public/javascripts/erp_app/desktop/applications/knitkit/center_region.js +289 -238
  103. data/public/javascripts/erp_app/desktop/applications/knitkit/comments_grid_panel.js +2 -4
  104. data/public/javascripts/erp_app/desktop/applications/knitkit/east_region.js +29 -3
  105. data/public/javascripts/erp_app/desktop/applications/knitkit/file_assets_panel.js +193 -21
  106. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_data_view.js +27 -26
  107. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_panel.js +167 -20
  108. data/public/javascripts/erp_app/desktop/applications/knitkit/inquiries_grid_panel.js +1 -2
  109. data/public/javascripts/erp_app/desktop/applications/knitkit/module.js +5 -1
  110. data/public/javascripts/erp_app/desktop/applications/knitkit/publish_window.js +2 -2
  111. data/public/javascripts/erp_app/desktop/applications/knitkit/published_grid_panel.js +20 -11
  112. data/public/javascripts/erp_app/desktop/applications/knitkit/section_articles_grid_panel.js +279 -228
  113. data/public/javascripts/erp_app/desktop/applications/knitkit/themes_tree_panel.js +40 -40
  114. data/public/javascripts/erp_app/desktop/applications/knitkit/versions_grid_panel.js +83 -76
  115. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region.js +1961 -1397
  116. data/public/javascripts/erp_app/desktop/applications/knitkit/widgets_panel.js +47 -43
  117. data/public/javascripts/knitkit/helpers.js +26 -0
  118. data/public/stylesheets/erp_app/desktop/applications/knitkit/knitkit.css +1 -2
  119. data/public/stylesheets/knitkit/documentation.css +50 -0
  120. data/public/stylesheets/knitkit/style.css +23 -1
  121. data/spec/controllers/knitkit/erp_app/desktop/articles_controller_spec.rb +8 -0
  122. data/spec/controllers/knitkit/erp_app/desktop/website_controller_spec.rb +396 -0
  123. data/spec/controllers/knitkit/erp_app/desktop/website_nav_controller_spec.rb +260 -0
  124. data/spec/controllers/knitkit/erp_app/desktop/website_section_controller_spec.rb +222 -0
  125. data/spec/dummy/Rakefile +7 -0
  126. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  127. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  128. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  129. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  130. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  131. data/spec/dummy/config.ru +4 -0
  132. data/spec/dummy/config/application.rb +43 -0
  133. data/spec/dummy/config/boot.rb +10 -0
  134. data/spec/dummy/config/database.yml +8 -0
  135. data/spec/dummy/config/environment.rb +5 -0
  136. data/spec/dummy/config/environments/spec.rb +27 -0
  137. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  138. data/spec/dummy/config/initializers/inflections.rb +10 -0
  139. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  140. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  141. data/spec/dummy/config/initializers/session_store.rb +8 -0
  142. data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
  143. data/spec/dummy/config/locales/en.yml +5 -0
  144. data/spec/dummy/config/routes.rb +4 -0
  145. data/spec/dummy/config/workflow.yml +1 -0
  146. data/spec/dummy/public/404.html +26 -0
  147. data/spec/dummy/public/422.html +26 -0
  148. data/spec/dummy/public/500.html +26 -0
  149. data/spec/dummy/public/favicon.ico +0 -0
  150. data/spec/dummy/script/rails +6 -0
  151. data/spec/factories/article.rb +4 -0
  152. data/spec/factories/basic.rb +3 -0
  153. data/spec/factories/blog.rb +5 -0
  154. data/spec/factories/documented_content.rb +4 -0
  155. data/spec/factories/documented_item.rb +4 -0
  156. data/spec/factories/online_document_section.rb +6 -0
  157. data/spec/factories/published_website.rb +4 -0
  158. data/spec/factories/theme.rb +6 -0
  159. data/spec/factories/website.rb +5 -0
  160. data/spec/factories/website_host.rb +4 -0
  161. data/spec/factories/website_nav.rb +5 -0
  162. data/spec/factories/website_nav_item.rb +4 -0
  163. data/spec/factories/website_section.rb +5 -0
  164. data/spec/models/article_spec.rb +35 -0
  165. data/spec/models/attribute_type_spec.rb +55 -0
  166. data/spec/models/attribute_value_spec.rb +114 -0
  167. data/spec/models/blog_spec.rb +16 -0
  168. data/spec/models/comment_spec.rb +11 -0
  169. data/spec/models/content_spec.rb +187 -0
  170. data/spec/models/documented_item_spec.rb +29 -0
  171. data/spec/models/online_document_section_spec.rb +34 -0
  172. data/spec/models/published_element_spec.rb +11 -0
  173. data/spec/models/published_website_spec.rb +11 -0
  174. data/spec/models/theme_spec.rb +12 -0
  175. data/spec/models/website_host_spec.rb +11 -0
  176. data/spec/models/website_inquiry_spec.rb +24 -0
  177. data/spec/models/website_nav_item_spec.rb +11 -0
  178. data/spec/models/website_nav_spec.rb +11 -0
  179. data/spec/models/website_section_content_spec.rb +11 -0
  180. data/spec/models/website_section_spec.rb +49 -0
  181. data/spec/models/website_spec.rb +146 -0
  182. data/spec/spec_helper.rb +61 -0
  183. metadata +391 -154
  184. data/app/controllers/knitkit/articles_controller.rb +0 -7
  185. data/lib/knitkit/extensions/compass/widgets/base.rb +0 -53
@@ -0,0 +1,13 @@
1
+ class CreateDocumentedItemsTable < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :documented_items, :force => true do |t|
4
+ t.string :documented_klass, :null => true
5
+ t.integer :documented_content_id, :null => true
6
+ t.timestamps
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ drop_table :documented_items
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ class AddDocumentIdToDocumentedItem < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :documented_items, :online_document_section_id, :integer
4
+ end
5
+
6
+ def self.down
7
+ remove_column :documented_items, :online_document_section_id
8
+ end
9
+ end
@@ -0,0 +1,32 @@
1
+ class AddDocument < ActiveRecord::Migration
2
+ def up
3
+ create_table :documents do |t|
4
+ t.string :external_identifier
5
+ t.string :internal_identifier
6
+ t.string :description
7
+ t.datetime :document_date
8
+
9
+ t.references :document_record, :polymorphic => true
10
+ t.references :document_type
11
+
12
+ t.timestamps
13
+ end
14
+
15
+ add_index :documents, [:document_record_type, :document_record_id], :name => 'document_record_poly_idx'
16
+ add_index :documents, :document_type_id, :name => 'document_type_idx'
17
+
18
+ create_table :document_types do |t|
19
+ t.string :external_identifier
20
+ t.string :internal_identifier
21
+ t.string :description
22
+
23
+ t.timestamps
24
+ end
25
+ end
26
+
27
+ def down
28
+ [:documents, :document_types].each do |table|
29
+ drop_table table
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,16 @@
1
+ class CreateValidDocuments < ActiveRecord::Migration
2
+ def up
3
+ unless table_exists?(:valid_documents)
4
+ create_table :valid_documents do |t|
5
+ t.references :document
6
+ t.references :documented_model, :polymorphic => true
7
+ end
8
+
9
+ add_index :valid_documents, :document_id
10
+ add_index :valid_documents, [:documented_model_id, :documented_model_type], :name => 'valid_documents_model_idx'
11
+ end
12
+ end
13
+
14
+ def down
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ class AddRenderBaseLayoutFlag < ActiveRecord::Migration
2
+ def self.up
3
+ unless columns(:website_sections).collect {|c| c.name}.include?('render_base_layout')
4
+ add_column :website_sections, :render_base_layout, :string, :default => true
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ if columns(:website_sections).collect {|c| c.name}.include?('render_base_layout')
10
+ remove_column :website_sections, :render_base_layout
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,24 @@
1
+ class CreateWebsitePartyRoles < ActiveRecord::Migration
2
+ def up
3
+ unless table_exists? :website_party_roles
4
+ create_table :website_party_roles do |t|
5
+ #foreign keys
6
+ t.references :website
7
+ t.references :role_type
8
+ t.references :party
9
+
10
+ t.timestamps
11
+ end
12
+
13
+ add_index :website_party_roles, :website_id
14
+ add_index :website_party_roles, :role_type_id
15
+ add_index :website_party_roles, :party_id
16
+ end
17
+ end
18
+
19
+ def down
20
+ unless table_exists? :website_party_roles
21
+ drop_table :website_party_roles
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,14 @@
1
+ class AddIidToWebsites < ActiveRecord::Migration
2
+ def up
3
+ unless columns(:websites).collect {|c| c.name}.include?('internal_identifier')
4
+ add_column :websites, :internal_identifier, :string
5
+ add_index :websites, :internal_identifier
6
+ end
7
+ end
8
+
9
+ def down
10
+ if columns(:websites).collect {|c| c.name}.include?('internal_identifier')
11
+ remove_column :websites, :internal_identifier
12
+ end
13
+ end
14
+ end
data/lib/knitkit.rb CHANGED
@@ -3,9 +3,11 @@ require 'erp_app'
3
3
  require 'erp_forms'
4
4
 
5
5
  require 'routing_filter'
6
+ require "knitkit/version"
6
7
  require "knitkit/routing_filter/section_router.rb"
7
8
  require 'knitkit/extensions'
8
9
  require "knitkit/syntax_validator"
10
+ require "knitkit/config"
9
11
  require "knitkit/engine"
10
12
 
11
13
  module Knitkit
@@ -0,0 +1,31 @@
1
+ module Knitkit
2
+ module Config
3
+ class << self
4
+ attr_accessor :unauthorized_url, :ignored_prefix_paths, :file_assets_location
5
+
6
+ def init!
7
+ @defaults = {
8
+ :@unauthorized_url => '/unauthorized',
9
+ :@ignored_prefix_paths => [],
10
+ :@file_assets_location => 'knitkit_assets'
11
+ }
12
+ end
13
+
14
+ def reset!
15
+ @defaults.each do |k,v|
16
+ instance_variable_set(k,v)
17
+ end
18
+ end
19
+
20
+ def configure(&blk)
21
+ @configure_blk = blk
22
+ end
23
+
24
+ def configure!
25
+ @configure_blk.call(self) if @configure_blk
26
+ end
27
+ end
28
+ init!
29
+ reset!
30
+ end
31
+ end
@@ -7,20 +7,29 @@ require 'zip/zipfilesystem'
7
7
  module Knitkit
8
8
  class Engine < Rails::Engine
9
9
  isolate_namespace Knitkit
10
+
11
+ config.knitkit = Knitkit::Config
10
12
 
11
13
  initializer "knikit.merge_public" do |app|
12
14
  app.middleware.insert_before Rack::Lock, ::ActionDispatch::Static, "#{root}/public"
13
15
  end
14
-
16
+
15
17
  ActiveSupport.on_load(:active_record) do
16
18
  include Knitkit::Extensions::ActiveRecord::ActsAsCommentable
17
19
  include Knitkit::Extensions::ActiveRecord::ActsAsPublishable
18
20
  include Knitkit::Extensions::ActiveRecord::ThemeSupport::HasManyThemes
21
+ include Knitkit::Extensions::ActiveRecord::ActsAsDocument
19
22
  end
20
-
23
+
21
24
  ActiveSupport.on_load(:action_controller) do
22
25
  include Knitkit::Extensions::ActionController::ThemeSupport::ActsAsThemedController
23
26
  end
27
+
28
+ engine = self
29
+ config.to_prepare do
30
+ ErpBaseErpSvcs.register_compass_ae_engine(engine)
31
+ ::ErpApp::Widgets::Loader.load_compass_ae_widgets(engine)
32
+ end
24
33
 
25
34
  end#Engine
26
- end#Knitkit
35
+ end#Knitkit
@@ -10,9 +10,7 @@ require 'knitkit/extensions/railties/theme_support/theme_file_resolver'
10
10
  require 'knitkit/extensions/active_record/acts_as_commentable'
11
11
  require 'knitkit/extensions/active_record/acts_as_publishable'
12
12
  require 'knitkit/extensions/active_record/theme_support/has_many_themes'
13
+ require 'knitkit/extensions/active_record/acts_as_document'
13
14
 
14
15
  #active_controller extensions
15
16
  require 'knitkit/extensions/action_controller/theme_support/acts_as_themed_controller'
16
-
17
- #compass extensions
18
- require 'knitkit/extensions/compass/widgets/base'
@@ -40,10 +40,9 @@ module Knitkit
40
40
  ThemeSupport::Cache.theme_resolvers = [] if ThemeSupport::Cache.theme_resolvers.nil?
41
41
  if respond_to?(:current_theme_paths)
42
42
  current_theme_paths.each do |theme|
43
- resolver = case ErpTechSvcs::FileSupport.options[:storage]
43
+ resolver = case Rails.application.config.erp_tech_svcs.file_storage
44
44
  when :s3
45
- ErpTechSvcs::FileSupport::S3Manager.reload
46
- path = "/#{theme[:url]}/templates"
45
+ path = File.join(theme[:url], "templates")
47
46
  cached_resolver = ThemeSupport::Cache.theme_resolvers.find{|cached_resolver| cached_resolver.to_path == path}
48
47
  if cached_resolver.nil?
49
48
  resolver = ActionView::S3Resolver.new(path)
@@ -0,0 +1,63 @@
1
+ module Knitkit
2
+ module Extensions
3
+ module ActiveRecord
4
+ module ActsAsDocument
5
+ def self.included(base)
6
+ base.extend(ClassMethods)
7
+ end
8
+
9
+ module ClassMethods
10
+
11
+ def acts_as_document
12
+ extend ActsAsDocument::SingletonMethods
13
+ include ActsAsDocument::InstanceMethods
14
+
15
+ after_initialize :initialize_document
16
+ after_create :save_document
17
+ after_update :save_document
18
+ after_destroy :destroy_document
19
+
20
+ has_one :document, :as => :document_record
21
+
22
+ #from Document / FileAssets
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
+ end
37
+
38
+ end
39
+
40
+ module SingletonMethods
41
+ end
42
+
43
+ module InstanceMethods
44
+ def save_document
45
+ self.document.save
46
+ end
47
+
48
+ def destroy_document
49
+ self.document.destroy
50
+ end
51
+
52
+ def initialize_document
53
+ if (self.document.nil?)
54
+ self.document = Document.new
55
+ self.document.document_record = self
56
+ end
57
+ end
58
+ end
59
+
60
+ end#ActsAsDocument
61
+ end#ActiveRecord
62
+ end#Extensions
63
+ end#Knitkit
@@ -32,7 +32,8 @@ module Knitkit
32
32
  end
33
33
  end
34
34
  end
35
- end
36
- end
37
- end
38
- end
35
+
36
+ end#ActsAsPublishable
37
+ end#ActiveRecord
38
+ end#Extensions
39
+ end#Knitkit
@@ -0,0 +1,70 @@
1
+ ErpApp::Widgets::Base.instance_eval do
2
+ def render_template(view, website=nil, locals={})
3
+ widget = Rails.application.config.erp_app.widgets.find{|item| item[:name] == self.widget_name}
4
+ paths = widget[:view_paths]
5
+
6
+ website.themes.active.map{ |theme| {:path => theme.path.to_s, :url => theme.url.to_s}}.each do |theme|
7
+ paths << File.join(theme[:url],'widgets',self.widget_name,'views')
8
+ end if website
9
+
10
+ paths.reverse!
11
+ ActionView::Base.new(paths).render(:template => view, :locals => locals)
12
+ end
13
+
14
+ end
15
+
16
+ ::ErpApp::Widgets::Base.class_eval do
17
+ private
18
+
19
+ def add_view_paths
20
+ widget = Rails.application.config.erp_app.widgets.find{|item| item[:name] == self.name}
21
+
22
+ widget[:view_paths].each do |view_path|
23
+ cached_resolver = ErpApp::Widgets::Base.view_resolver_cache.find{|resolver| resolver.to_path == view_path}
24
+ if cached_resolver.nil?
25
+ resolver = ActionView::OptimizedFileSystemResolver.new(view_path)
26
+ prepend_view_path(resolver)
27
+ ErpApp::Widgets::Base.view_resolver_cache << resolver
28
+ else
29
+ prepend_view_path(cached_resolver)
30
+ end
31
+ end
32
+
33
+ #set overrides by themes
34
+ current_theme_paths.each do |theme|
35
+ resolver = case Rails.application.config.erp_tech_svcs.file_storage
36
+ when :s3
37
+ path = File.join(theme[:url],'widgets',self.name,'views')
38
+ cached_resolver = ErpApp::Widgets::Base.view_resolver_cache.find{|cached_resolver| cached_resolver.to_path == path}
39
+ if cached_resolver.nil?
40
+ resolver = ActionView::S3Resolver.new(path)
41
+ ErpApp::Widgets::Base.view_resolver_cache << resolver
42
+ resolver
43
+ else
44
+ cached_resolver
45
+ end
46
+ when :filesystem
47
+ path = File.join(theme[:path],'widgets',self.name,'views')
48
+ cached_resolver = ErpApp::Widgets::Base.view_resolver_cache.find{|cached_resolver| cached_resolver.to_path == path}
49
+ if cached_resolver.nil?
50
+ resolver = ActionView::ThemeFileResolver.new(path)
51
+ ErpApp::Widgets::Base.view_resolver_cache << resolver
52
+ resolver
53
+ else
54
+ cached_resolver
55
+ end
56
+ end
57
+ prepend_view_path(resolver)
58
+ end
59
+ end
60
+
61
+ def current_themes
62
+ @website = Website.find_by_host(request.host_with_port) if @website.nil?
63
+ @website.themes.active if @website
64
+ end
65
+
66
+ def current_theme_paths
67
+ current_themes ? current_themes.map { |theme| {:path => theme.path.to_s, :url => theme.url.to_s}} : []
68
+ end
69
+
70
+ end
@@ -6,20 +6,20 @@ ActionView::Base.class_eval do
6
6
 
7
7
  def blog_add_comment_form
8
8
  render :partial => 'add_comment' unless current_user.nil?
9
- end
9
+ end
10
10
 
11
11
  def blog_topics(css_class='tag_link')
12
12
  html = ''
13
13
 
14
14
  @website_section.get_topics.each do |tag|
15
15
  html += '<div class="'+css_class+'">'
16
- html += link_to(tag.name, main_app.blog_tag_path(@website_section.id, tag.id))
16
+ html += link_to(tag.name, main_app.blog_tag_path(@website_section.id, tag.id))
17
17
  html += '</div>'
18
18
  end
19
-
19
+
20
20
  raw html
21
21
  end
22
-
22
+
23
23
  def blog_rss_links(link_title='RSS Feed')
24
24
  if params[:action] == 'tag'
25
25
  return link_to link_title, main_app.blog_tag_url(params[:section_id], params[:tag_id], :rss)
@@ -33,17 +33,17 @@ ActionView::Base.class_eval do
33
33
  return 'No Comments'
34
34
  else
35
35
  html = ''
36
-
36
+
37
37
  @published_content.content.comments.recent.approved.each do |comment|
38
38
  html += render :partial => 'comment', :locals => {:comment => comment}
39
39
  end
40
-
40
+
41
41
  return raw html
42
42
  end
43
43
  end
44
44
 
45
45
  def blog_pagination(css_class, params)
46
- return will_paginate @contents, :class => css_class, :params => {
46
+ return will_paginate @contents, :class => css_class, :params => {
47
47
  :section_id => params[:section_id],
48
48
  :per_page => params[:per_page],
49
49
  :format => params[:format],
@@ -52,12 +52,18 @@ ActionView::Base.class_eval do
52
52
  :scope => main_app
53
53
  }
54
54
  end
55
-
55
+
56
56
  # render a piece of content by internal identifier regardless if it belongs to a section or not
57
57
  def render_content(iid)
58
58
  content = Content.find_by_internal_identifier(iid)
59
- content_version = Content.get_published_version(@active_publication, content)
60
- raw content_version.body_html.nil? ? '' : content_version.body_html
59
+ content_version = Content.get_published_version(@active_publication, content) unless @active_publication.nil?
60
+ content_version = content if @active_publication.nil? or content_version.nil?
61
+
62
+ if content_version.nil?
63
+ return ''
64
+ else
65
+ return raw content_version.body_html.nil? ? '' : content_version.body_html
66
+ end
61
67
  end
62
68
 
63
69
  def render_content_area(name)
@@ -184,4 +190,10 @@ ActionView::Base.class_eval do
184
190
 
185
191
  render :partial => layout, :locals => locals
186
192
  end
193
+
194
+ def tool_tip(message, img_src=nil)
195
+ img_src = img_src || '/images/knitkit/tooltip.gif'
196
+ raw "<a href='#' class='tooltip'>&nbsp;<img src='#{img_src}' alt='ToolTip' /><span>#{message}</span></a>"
197
+ end
198
+
187
199
  end