knitkit 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. data/GPL-3-LICENSE +674 -0
  2. data/README.md +6 -0
  3. data/Rakefile +30 -0
  4. data/app/assets/javascripts/knitkit/application.js +9 -0
  5. data/app/assets/stylesheets/knitkit/application.css +7 -0
  6. data/app/controllers/knitkit/articles_controller.rb +7 -0
  7. data/app/controllers/knitkit/base_controller.rb +45 -0
  8. data/app/controllers/knitkit/blogs_controller.rb +27 -0
  9. data/app/controllers/knitkit/comments_controller.rb +18 -0
  10. data/app/controllers/knitkit/erp_app/desktop/app_controller.rb +135 -0
  11. data/app/controllers/knitkit/erp_app/desktop/articles_controller.rb +144 -0
  12. data/app/controllers/knitkit/erp_app/desktop/comments_controller.rb +43 -0
  13. data/app/controllers/knitkit/erp_app/desktop/content_controller.rb +27 -0
  14. data/app/controllers/knitkit/erp_app/desktop/file_assets_controller.rb +145 -0
  15. data/app/controllers/knitkit/erp_app/desktop/image_assets_controller.rb +28 -0
  16. data/app/controllers/knitkit/erp_app/desktop/inquiries_controller.rb +68 -0
  17. data/app/controllers/knitkit/erp_app/desktop/position_controller.rb +20 -0
  18. data/app/controllers/knitkit/erp_app/desktop/theme_controller.rb +272 -0
  19. data/app/controllers/knitkit/erp_app/desktop/versions_controller.rb +135 -0
  20. data/app/controllers/knitkit/erp_app/desktop/website_controller.rb +177 -0
  21. data/app/controllers/knitkit/erp_app/desktop/website_nav_controller.rb +143 -0
  22. data/app/controllers/knitkit/erp_app/desktop/website_section_controller.rb +116 -0
  23. data/app/controllers/knitkit/unauthorized_controller.rb +8 -0
  24. data/app/controllers/knitkit/website_sections_controller.rb +17 -0
  25. data/app/helpers/application_helper.rb +132 -0
  26. data/app/models/article.rb +14 -0
  27. data/app/models/blog.rb +21 -0
  28. data/app/models/comment.rb +24 -0
  29. data/app/models/content.rb +158 -0
  30. data/app/models/extensions/user.rb +5 -0
  31. data/app/models/published_element.rb +9 -0
  32. data/app/models/published_website.rb +118 -0
  33. data/app/models/theme.rb +239 -0
  34. data/app/models/website.rb +457 -0
  35. data/app/models/website_host.rb +3 -0
  36. data/app/models/website_inquiry.rb +11 -0
  37. data/app/models/website_inquiry_mailer.rb +12 -0
  38. data/app/models/website_nav.rb +17 -0
  39. data/app/models/website_nav_item.rb +21 -0
  40. data/app/models/website_section.rb +152 -0
  41. data/app/models/website_section_content.rb +4 -0
  42. data/app/views/knitkit/articles/index.html.erb +3 -0
  43. data/app/views/knitkit/articles/show.html.erb +4 -0
  44. data/app/views/knitkit/blogs/_add_comment.html.erb +28 -0
  45. data/app/views/knitkit/blogs/_comment.html.erb +8 -0
  46. data/app/views/knitkit/blogs/index.html.erb +51 -0
  47. data/app/views/knitkit/blogs/index.rss.builder +23 -0
  48. data/app/views/knitkit/blogs/show.html.erb +22 -0
  49. data/app/views/knitkit/unauthorized/index.html.erb +4 -0
  50. data/app/views/knitkit/website_sections/index.html.erb +6 -0
  51. data/app/views/layouts/knitkit/base.html.erb +59 -0
  52. data/app/views/menus/knitkit/_default_menu.html.erb +23 -0
  53. data/app/views/menus/knitkit/_default_section_menu.html.erb +27 -0
  54. data/app/views/menus/knitkit/_default_sub_menu.html.erb +45 -0
  55. data/app/views/menus/knitkit/_default_sub_section_menu.html.erb +49 -0
  56. data/app/views/shared/knitkit/_bread_crumb.html.erb +7 -0
  57. data/app/views/shared/knitkit/_footer.html.erb +3 -0
  58. data/app/views/website_inquiry_mailer/inquiry.erb +3 -0
  59. data/app/widgets/contact_us/base.rb +86 -0
  60. data/app/widgets/contact_us/javascript/contact_us.js +13 -0
  61. data/app/widgets/contact_us/views/_contact_form.html.erb +36 -0
  62. data/app/widgets/contact_us/views/error.html.erb +10 -0
  63. data/app/widgets/contact_us/views/index.html.erb +1 -0
  64. data/app/widgets/contact_us/views/layouts/base.html.erb +7 -0
  65. data/app/widgets/contact_us/views/success.html.erb +4 -0
  66. data/app/widgets/google_map/base.rb +48 -0
  67. data/app/widgets/google_map/javascript/google_map.js +174 -0
  68. data/app/widgets/google_map/views/index.html.erb +41 -0
  69. data/app/widgets/login/base.rb +61 -0
  70. data/app/widgets/login/javascript/login.js +162 -0
  71. data/app/widgets/login/views/index.html.erb +37 -0
  72. data/app/widgets/login/views/layouts/base.html.erb +14 -0
  73. data/app/widgets/login/views/login_header.html.erb +9 -0
  74. data/app/widgets/login/views/reset_password.html.erb +26 -0
  75. data/app/widgets/manage_profile/base.rb +327 -0
  76. data/app/widgets/manage_profile/javascript/manage_profile.js +11 -0
  77. data/app/widgets/manage_profile/views/_contact_information_form.html.erb +180 -0
  78. data/app/widgets/manage_profile/views/_password_form.html.erb +20 -0
  79. data/app/widgets/manage_profile/views/_user_information_form.html.erb +30 -0
  80. data/app/widgets/manage_profile/views/contact_type_in_use.html.erb +4 -0
  81. data/app/widgets/manage_profile/views/default_type_error.html.erb +5 -0
  82. data/app/widgets/manage_profile/views/error.html.erb +3 -0
  83. data/app/widgets/manage_profile/views/index.html.erb +46 -0
  84. data/app/widgets/manage_profile/views/layouts/base.html.erb +1 -0
  85. data/app/widgets/manage_profile/views/password_blank.html.erb +4 -0
  86. data/app/widgets/manage_profile/views/password_invalid.html.erb +4 -0
  87. data/app/widgets/manage_profile/views/password_success.html.erb +3 -0
  88. data/app/widgets/manage_profile/views/success.html.erb +3 -0
  89. data/app/widgets/reset_password/base.rb +42 -0
  90. data/app/widgets/reset_password/javascript/reset_password.js +13 -0
  91. data/app/widgets/reset_password/views/index.html.erb +31 -0
  92. data/app/widgets/reset_password/views/layouts/base.html.erb +1 -0
  93. data/app/widgets/search/base.rb +80 -0
  94. data/app/widgets/search/javascript/search.js +31 -0
  95. data/app/widgets/search/views/_search.html.erb +39 -0
  96. data/app/widgets/search/views/index.html.erb +3 -0
  97. data/app/widgets/search/views/layouts/base.html.erb +24 -0
  98. data/app/widgets/search/views/show.html.erb +48 -0
  99. data/app/widgets/signup/base.rb +72 -0
  100. data/app/widgets/signup/javascript/signup.js +13 -0
  101. data/app/widgets/signup/views/_signup_form.html.erb +36 -0
  102. data/app/widgets/signup/views/error.html.erb +11 -0
  103. data/app/widgets/signup/views/index.html.erb +1 -0
  104. data/app/widgets/signup/views/layouts/base.html.erb +7 -0
  105. data/app/widgets/signup/views/success.html.erb +4 -0
  106. data/config/environment.rb +0 -0
  107. data/config/routes.rb +41 -0
  108. data/db/data_migrations/20110509223702_add_publisher_role.rb +11 -0
  109. data/db/data_migrations/20110816153456_add_knitkit_application.rb +31 -0
  110. data/db/data_migrations/upgrade/20111011203718_create_paths_for_sections.rb +13 -0
  111. data/db/data_migrations/upgrade/20111216192114_add_secured_models_to_menu_items.rb +18 -0
  112. data/db/data_migrations/upgrade/20111216202819_set_contents_iid_to_permalink_where_null.rb +12 -0
  113. data/db/migrate/20110211002317_setup_knitkit.rb +259 -0
  114. data/db/migrate/upgrade/20111014190442_update_contents.rb +25 -0
  115. data/db/migrate/upgrade/20111014201502_add_published_by_to_published_elements.rb +22 -0
  116. data/db/migrate/upgrade/20111017133851_add_iid_to_section.rb +21 -0
  117. data/db/migrate/upgrade/20111027145006_add_in_menu_to_section.rb +19 -0
  118. data/lib/knitkit.rb +12 -0
  119. data/lib/knitkit/engine.rb +26 -0
  120. data/lib/knitkit/extensions.rb +18 -0
  121. data/lib/knitkit/extensions/action_controller/theme_support/acts_as_themed_controller.rb +88 -0
  122. data/lib/knitkit/extensions/active_record/acts_as_commentable.rb +28 -0
  123. data/lib/knitkit/extensions/active_record/acts_as_publishable.rb +38 -0
  124. data/lib/knitkit/extensions/active_record/theme_support/has_many_themes.rb +34 -0
  125. data/lib/knitkit/extensions/compass/widgets/base.rb +53 -0
  126. data/lib/knitkit/extensions/core/array.rb +5 -0
  127. data/lib/knitkit/extensions/railties/action_view.rb +187 -0
  128. data/lib/knitkit/extensions/railties/theme_support/asset_tag_helper.rb +198 -0
  129. data/lib/knitkit/extensions/railties/theme_support/theme_file_resolver.rb +44 -0
  130. data/lib/knitkit/routing_filter/section_router.rb +55 -0
  131. data/lib/knitkit/syntax_validator.rb +32 -0
  132. data/lib/knitkit/version.rb +3 -0
  133. data/lib/tasks/knitkit_tasks.rake +4 -0
  134. data/public/images/knitkit/bullet.png +0 -0
  135. data/public/images/knitkit/content.png +0 -0
  136. data/public/images/knitkit/footer.png +0 -0
  137. data/public/images/knitkit/graphic.png +0 -0
  138. data/public/images/knitkit/greyFadeDown.png +0 -0
  139. data/public/images/knitkit/link.png +0 -0
  140. data/public/images/knitkit/logo.png +0 -0
  141. data/public/images/knitkit/menu.png +0 -0
  142. data/public/images/knitkit/menu_select.png +0 -0
  143. data/public/images/knitkit/search.png +0 -0
  144. data/public/javascripts/datepicker.js +440 -0
  145. data/public/javascripts/erp_app/desktop/applications/knitkit/articles_grid_panel.js +473 -0
  146. data/public/javascripts/erp_app/desktop/applications/knitkit/center_region.js +576 -0
  147. data/public/javascripts/erp_app/desktop/applications/knitkit/comments_grid_panel.js +217 -0
  148. data/public/javascripts/erp_app/desktop/applications/knitkit/east_region.js +26 -0
  149. data/public/javascripts/erp_app/desktop/applications/knitkit/file_assets_panel.js +109 -0
  150. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_data_view.js +30 -0
  151. data/public/javascripts/erp_app/desktop/applications/knitkit/image_assets_panel.js +160 -0
  152. data/public/javascripts/erp_app/desktop/applications/knitkit/inquiries_grid_panel.js +46 -0
  153. data/public/javascripts/erp_app/desktop/applications/knitkit/module.js +46 -0
  154. data/public/javascripts/erp_app/desktop/applications/knitkit/publish_window.js +92 -0
  155. data/public/javascripts/erp_app/desktop/applications/knitkit/published_grid_panel.js +220 -0
  156. data/public/javascripts/erp_app/desktop/applications/knitkit/section_articles_grid_panel.js +613 -0
  157. data/public/javascripts/erp_app/desktop/applications/knitkit/themes_tree_panel.js +573 -0
  158. data/public/javascripts/erp_app/desktop/applications/knitkit/versions_grid_panel.js +664 -0
  159. data/public/javascripts/erp_app/desktop/applications/knitkit/west_region.js +2161 -0
  160. data/public/javascripts/erp_app/desktop/applications/knitkit/widgets_panel.js +52 -0
  161. data/public/stylesheets/datepicker.css +121 -0
  162. data/public/stylesheets/erp_app/desktop/applications/knitkit/knitkit.css +114 -0
  163. data/public/stylesheets/extjs/resources/css/knitkit_extjs_4.css +219 -0
  164. data/public/stylesheets/knitkit/style.css +394 -0
  165. metadata +289 -0
@@ -0,0 +1,259 @@
1
+ class SetupKnitkit < ActiveRecord::Migration
2
+ def self.up
3
+
4
+ unless table_exists?(:websites)
5
+ create_table :websites do |t|
6
+ t.string :name
7
+ t.string :title
8
+ t.string :subtitle
9
+ t.string :email
10
+ t.boolean :auto_activate_publication
11
+ t.boolean :email_inquiries
12
+
13
+ t.timestamps
14
+ end
15
+ end
16
+
17
+ unless table_exists?(:website_hosts)
18
+ create_table :website_hosts do |t|
19
+ t.references :website
20
+ t.string :host
21
+
22
+ t.timestamps
23
+ end
24
+
25
+ add_index :website_hosts, :website_id
26
+ end
27
+
28
+ unless table_exists?(:website_inquiries)
29
+ create_table :website_inquiries do |t|
30
+ t.integer :website_id
31
+
32
+ t.timestamps
33
+ end
34
+
35
+ add_index :website_inquiries, :website_id
36
+ end
37
+
38
+ unless table_exists?(:website_sections)
39
+ create_table :website_sections do |t|
40
+ t.string :title
41
+ t.string :type
42
+ t.references :website
43
+ t.string :path
44
+ t.string :permalink
45
+ t.text :layout
46
+ t.boolean :in_menu
47
+ t.integer :position, :default => 0
48
+ t.string :internal_identifier
49
+ t.integer :version
50
+
51
+ #better nested set columns
52
+ t.integer :parent_id
53
+ t.integer :lft
54
+ t.integer :rgt
55
+
56
+ t.timestamps
57
+ end
58
+ #indexes
59
+ add_index :website_sections, :permalink
60
+ add_index :website_sections, :website_id
61
+ add_index :website_sections, :position
62
+ add_index :website_sections, :parent_id
63
+ add_index :website_sections, :lft
64
+ add_index :website_sections, :rgt
65
+ add_index :website_sections, :version
66
+ add_index :website_sections, :internal_identifier, :name => 'section_iid_idx'
67
+
68
+ WebsiteSection.create_versioned_table
69
+ end
70
+
71
+ unless table_exists?(:contents)
72
+ create_table :contents do |t|
73
+ t.string :type
74
+ t.string :title
75
+ t.string :permalink
76
+ t.text :excerpt_html
77
+ t.text :body_html
78
+ t.integer :created_by_id
79
+ t.integer :updated_by_id
80
+ t.string :internal_identifier
81
+ t.boolean :display_title
82
+ t.integer :version
83
+
84
+ t.timestamps
85
+ end
86
+ #indexes
87
+ add_index :contents, :type
88
+ add_index :contents, :created_by_id
89
+ add_index :contents, :updated_by_id
90
+ add_index :contents, :permalink
91
+ add_index :contents, :version
92
+ add_index :contents, :internal_identifier, :name => 'contents_iid_idx'
93
+
94
+ Content.create_versioned_table
95
+ end
96
+
97
+ unless table_exists?(:website_section_contents)
98
+ create_table :website_section_contents do |t|
99
+ t.integer :website_section_id
100
+ t.integer :content_id
101
+ t.string :content_area
102
+ t.integer :position, :default => 0
103
+
104
+ t.timestamps
105
+ end
106
+ #indexes
107
+ add_index :website_section_contents, :website_section_id
108
+ add_index :website_section_contents, :content_id
109
+ add_index :website_section_contents, :position
110
+ add_index :website_section_contents, :content_area
111
+ end
112
+
113
+ unless table_exists?(:themes)
114
+ create_table :themes do |t|
115
+ t.references :website
116
+ t.string :name
117
+ t.string :theme_id
118
+ t.string :author
119
+ t.integer :version
120
+ t.string :homepage
121
+ t.text :summary
122
+ t.integer :active
123
+
124
+ t.timestamps
125
+ end
126
+ #indexes
127
+ add_index :themes, :website_id
128
+ add_index :themes, :active
129
+ end
130
+
131
+ unless table_exists?(:published_websites)
132
+ create_table :published_websites do |t|
133
+ t.references :website
134
+ t.text :comment
135
+ t.decimal :version
136
+ t.boolean :active
137
+ t.integer :published_by_id
138
+
139
+ t.timestamps
140
+ end
141
+
142
+ #indexes
143
+ add_index :published_websites, :website_id
144
+ add_index :published_websites, :version
145
+ add_index :published_websites, :active
146
+ add_index :published_websites, :published_by_id
147
+ end
148
+
149
+ unless table_exists?(:published_elements)
150
+ create_table :published_elements do |t|
151
+ t.references :published_website
152
+ t.references :published_element_record, :polymorphic => true
153
+ t.integer :version
154
+ t.integer :published_by_id
155
+
156
+ t.timestamps
157
+ end
158
+
159
+ #indexes
160
+ add_index :published_elements, [:published_element_record_id, :published_element_record_type], :name => 'published_elm_idx'
161
+ add_index :published_elements, :published_website_id
162
+ add_index :published_elements, :version
163
+ add_index :published_elements, :published_by_id
164
+ end
165
+
166
+ unless table_exists?(:comments)
167
+ create_table :comments do |t|
168
+ t.string :commentor_name
169
+ t.string :email
170
+ t.text :comment
171
+ t.integer :approved
172
+ t.datetime :approved_at
173
+ t.references :user
174
+ t.references :commented_record, :polymorphic => true
175
+
176
+ t.timestamps
177
+ end
178
+
179
+ add_index :comments, [:commented_record_id, :commented_record_type], :name => 'commented_record_idx'
180
+ add_index :comments, [:approved]
181
+ add_index :comments, [:user_id]
182
+ end
183
+
184
+ unless table_exists?(:website_nav_items)
185
+ create_table :website_nav_items do |t|
186
+ t.references :website_nav
187
+ t.string :title
188
+ t.string :url
189
+ t.integer :position, :default => 0
190
+ t.references :linked_to_item, :polymorphic => true
191
+
192
+ #better nested set columns
193
+ t.integer :parent_id
194
+ t.integer :lft
195
+ t.integer :rgt
196
+
197
+ t.timestamps
198
+ end
199
+
200
+ add_index :website_nav_items, [:linked_to_item_id, :linked_to_item_type], :name => 'linked_to_idx'
201
+ add_index :website_nav_items, :website_nav_id
202
+ add_index :website_nav_items, :position
203
+ add_index :website_nav_items, :parent_id
204
+ add_index :website_nav_items, :lft
205
+ add_index :website_nav_items, :rgt
206
+ end
207
+
208
+ unless table_exists?(:website_navs)
209
+ create_table :website_navs do |t|
210
+ t.references :website
211
+ t.string :name
212
+
213
+ t.timestamps
214
+ end
215
+
216
+ add_index :website_navs, :website_id
217
+ end
218
+
219
+ unless table_exists?(:tags)
220
+ create_table :tags do |t|
221
+ t.column :name, :string
222
+ end
223
+ end
224
+
225
+ unless table_exists?(:taggings)
226
+ create_table :taggings do |t|
227
+ t.column :tag_id, :integer
228
+ t.column :taggable_id, :integer
229
+ t.column :tagger_id, :integer
230
+ t.column :tagger_type, :string
231
+
232
+ # You should make sure that the column created is
233
+ # long enough to store the required class names.
234
+ t.column :taggable_type, :string
235
+ t.column :context, :string
236
+
237
+ t.column :created_at, :datetime
238
+ end
239
+
240
+ add_index :taggings, :tag_id
241
+ add_index :taggings, [:taggable_id, :taggable_type, :context], :name => 'taggable_poly_idx'
242
+ end
243
+
244
+ end
245
+
246
+ def self.down
247
+ WebsiteSection.drop_versioned_table
248
+ Content.drop_versioned_table
249
+
250
+ # check that each table exists before trying to delete it.
251
+ [:websites, :website_sections, :contents, :website_section_contents,
252
+ :themes, :theme_files, :published_websites, :published_elements,
253
+ :comments,:website_hosts,:website_nav_items, :website_navs, :tags, :taggings].each do |tbl|
254
+ if table_exists?(tbl)
255
+ drop_table tbl
256
+ end
257
+ end
258
+ end
259
+ end
@@ -0,0 +1,25 @@
1
+ class UpdateContents < ActiveRecord::Migration
2
+ def self.up
3
+ unless columns(:contents).collect {|c| c.name}.include?('display_title')
4
+ add_column :contents, :display_title, :boolean
5
+ add_column :contents, :internal_identifier, :string
6
+
7
+ add_column :content_versions, :display_title, :boolean
8
+ add_column :content_versions, :internal_identifier, :string
9
+
10
+ add_index :contents, :internal_identifier, :name => 'contents_iid_idx'
11
+ end
12
+ end
13
+
14
+ def self.down
15
+ if columns(:contents).collect {|c| c.name}.include?('display_title')
16
+ remove_column :contents, :display_title
17
+ remove_column :contents, :internal_identifier
18
+
19
+ remove_column :content_versions, :display_title
20
+ remove_column :content_versions, :internal_identifier
21
+
22
+ remove_index :contents, :name => 'contents_iid_idx'
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,22 @@
1
+ class AddPublishedByToPublishedElements < ActiveRecord::Migration
2
+ def self.up
3
+ unless columns(:published_websites).collect {|c| c.name}.include?('published_by_id')
4
+ add_column :published_websites, :published_by_id, :integer
5
+ add_index :published_websites, :published_by_id
6
+ end
7
+
8
+ unless columns(:published_elements).collect {|c| c.name}.include?('published_by_id')
9
+ add_column :published_elements, :published_by_id, :integer
10
+ add_index :published_elements, :published_by_id
11
+ end
12
+ end
13
+
14
+ def self.down
15
+ if columns(:published_websites).collect {|c| c.name}.include?('published_by_id')
16
+ remove_column :published_websites, :published_by_id
17
+ end
18
+ if columns(:published_elements).collect {|c| c.name}.include?('published_by_id')
19
+ remove_column :published_elements, :published_by_id
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ class AddIidToSection < ActiveRecord::Migration
2
+ def self.up
3
+ unless columns(:website_sections).collect {|c| c.name}.include?('internal_identifier')
4
+ add_column :website_sections, :internal_identifier, :string
5
+
6
+ add_column :website_section_versions, :internal_identifier, :string
7
+
8
+ add_index :website_sections, :internal_identifier, :name => 'section_iid_idx'
9
+ end
10
+ end
11
+
12
+ def self.down
13
+ if columns(:website_sections).collect {|c| c.name}.include?('internal_identifier')
14
+ remove_column :website_sections, :internal_identifier
15
+
16
+ remove_column :website_section_versions, :internal_identifier
17
+
18
+ remove_index :website_sections, :internal_identifier, :name => 'section_iid_idx'
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ class AddInMenuToSection < ActiveRecord::Migration
2
+ def self.up
3
+ unless columns(:website_sections).collect {|c| c.name}.include?('in_menu')
4
+ add_column :website_sections, :in_menu, :boolean
5
+ end
6
+ unless columns(:website_section_versions).collect {|c| c.name}.include?('in_menu')
7
+ add_column :website_section_versions, :in_menu, :boolean
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ if columns(:website_sections).collect {|c| c.name}.include?('in_menu')
13
+ remove_column :website_sections, :in_menu
14
+ end
15
+ if columns(:website_section_versions).collect {|c| c.name}.include?('in_menu')
16
+ remove_column :website_section_versions, :in_menu
17
+ end
18
+ end
19
+ end
data/lib/knitkit.rb ADDED
@@ -0,0 +1,12 @@
1
+ #compass libraries
2
+ require 'erp_app'
3
+ require 'erp_forms'
4
+
5
+ require 'routing_filter'
6
+ require "knitkit/routing_filter/section_router.rb"
7
+ require 'knitkit/extensions'
8
+ require "knitkit/syntax_validator"
9
+ require "knitkit/engine"
10
+
11
+ module Knitkit
12
+ end
@@ -0,0 +1,26 @@
1
+ require 'nokogiri'
2
+ require 'permalink_fu'
3
+ require 'acts-as-taggable-on'
4
+ require 'zip/zip'
5
+ require 'zip/zipfilesystem'
6
+
7
+ module Knitkit
8
+ class Engine < Rails::Engine
9
+ isolate_namespace Knitkit
10
+
11
+ initializer "knikit.merge_public" do |app|
12
+ app.middleware.insert_before Rack::Lock, ::ActionDispatch::Static, "#{root}/public"
13
+ end
14
+
15
+ ActiveSupport.on_load(:active_record) do
16
+ include Knitkit::Extensions::ActiveRecord::ActsAsCommentable
17
+ include Knitkit::Extensions::ActiveRecord::ActsAsPublishable
18
+ include Knitkit::Extensions::ActiveRecord::ThemeSupport::HasManyThemes
19
+ end
20
+
21
+ ActiveSupport.on_load(:action_controller) do
22
+ include Knitkit::Extensions::ActionController::ThemeSupport::ActsAsThemedController
23
+ end
24
+
25
+ end#Engine
26
+ end#Knitkit
@@ -0,0 +1,18 @@
1
+ #core ruby extensions
2
+ require 'knitkit/extensions/core/array'
3
+
4
+ #railties
5
+ require 'knitkit/extensions/railties/action_view'
6
+ require 'knitkit/extensions/railties/theme_support/asset_tag_helper'
7
+ require 'knitkit/extensions/railties/theme_support/theme_file_resolver'
8
+
9
+ #active_record extensions
10
+ require 'knitkit/extensions/active_record/acts_as_commentable'
11
+ require 'knitkit/extensions/active_record/acts_as_publishable'
12
+ require 'knitkit/extensions/active_record/theme_support/has_many_themes'
13
+
14
+ #active_controller extensions
15
+ require 'knitkit/extensions/action_controller/theme_support/acts_as_themed_controller'
16
+
17
+ #compass extensions
18
+ require 'knitkit/extensions/compass/widgets/base'
@@ -0,0 +1,88 @@
1
+ module Knitkit
2
+ module Extensions
3
+ module ActionController
4
+ module ThemeSupport
5
+ class Cache
6
+ cattr_accessor :theme_resolvers
7
+ end
8
+ module ActsAsThemedController
9
+ def self.included(base)
10
+ base.class_eval do
11
+ extend ActMacro
12
+ delegate :acts_as_themed_controller?, :to => "self.class"
13
+ end
14
+ end
15
+
16
+ module ActMacro
17
+ def acts_as_themed_controller(options = {})
18
+ before_filter :add_theme_view_paths
19
+ write_inheritable_attribute :current_themes, options[:current_themes] || []
20
+
21
+ return if acts_as_themed_controller?
22
+ include InstanceMethods
23
+ end
24
+
25
+ def acts_as_themed_controller?
26
+ included_modules.include?(Knitkit::Extensions::ActionController::ThemeSupport::ActsAsThemedController::InstanceMethods)
27
+ end
28
+ end
29
+
30
+ module InstanceMethods
31
+ def current_themes
32
+ @current_themes ||= case accessor = self.class.read_inheritable_attribute(:current_themes)
33
+ when Symbol then accessor == :current_themes ? raise("screwed") : send(accessor)
34
+ when Proc then accessor.call(self)
35
+ else accessor
36
+ end
37
+ end
38
+
39
+ def add_theme_view_paths
40
+ ThemeSupport::Cache.theme_resolvers = [] if ThemeSupport::Cache.theme_resolvers.nil?
41
+ if respond_to?(:current_theme_paths)
42
+ current_theme_paths.each do |theme|
43
+ resolver = case ErpTechSvcs::FileSupport.options[:storage]
44
+ when :s3
45
+ ErpTechSvcs::FileSupport::S3Manager.reload
46
+ path = "/#{theme[:url]}/templates"
47
+ cached_resolver = ThemeSupport::Cache.theme_resolvers.find{|cached_resolver| cached_resolver.to_path == path}
48
+ if cached_resolver.nil?
49
+ resolver = ActionView::S3Resolver.new(path)
50
+ ThemeSupport::Cache.theme_resolvers << resolver
51
+ resolver
52
+ else
53
+ cached_resolver
54
+ end
55
+ when :filesystem
56
+ path = "#{theme[:path]}/templates"
57
+ cached_resolver = ThemeSupport::Cache.theme_resolvers.find{|cached_resolver| cached_resolver.to_path == path}
58
+ if cached_resolver.nil?
59
+ resolver = ActionView::ThemeFileResolver.new(path)
60
+ ThemeSupport::Cache.theme_resolvers << resolver
61
+ resolver
62
+ else
63
+ cached_resolver
64
+ end
65
+ end
66
+ prepend_view_path(resolver)
67
+ end
68
+ end
69
+ end
70
+
71
+ def current_theme_paths
72
+ current_themes ? current_themes.map { |theme| {:path => theme.path.to_s, :url => theme.url.to_s}} : []
73
+ end
74
+
75
+ def authorize_template_extension!(template, ext)
76
+ return if allowed_template_type?(ext)
77
+ raise ThemeSupport::TemplateTypeError.new(template, force_template_types)
78
+ end
79
+
80
+ def allowed_template_type?(ext)
81
+ force_template_types.blank? || force_template_types.include?(ext)
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end