comfortable_mexican_sofa 0.0.18 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (263) hide show
  1. data/.gitignore +8 -8
  2. data/Gemfile +11 -0
  3. data/Gemfile.lock +91 -0
  4. data/README.md +4 -0
  5. data/Rakefile +28 -57
  6. data/VERSION +1 -1
  7. data/app/controllers/application_controller.rb +5 -0
  8. data/app/controllers/cms_admin/base_controller.rb +1 -21
  9. data/app/controllers/cms_admin/layouts_controller.rb +23 -38
  10. data/app/controllers/cms_admin/pages_controller.rb +24 -40
  11. data/app/controllers/cms_admin/snippets_controller.rb +26 -34
  12. data/app/controllers/cms_admin/uploads_controller.rb +27 -0
  13. data/app/controllers/cms_content_controller.rb +22 -19
  14. data/app/models/cms_block.rb +20 -6
  15. data/app/models/cms_layout.rb +34 -80
  16. data/app/models/cms_page.rb +44 -102
  17. data/app/models/cms_snippet.rb +12 -7
  18. data/app/models/cms_upload.rb +36 -0
  19. data/app/views/cms_admin/layouts/_form.html.erb +6 -0
  20. data/app/views/cms_admin/layouts/_index_branch.html.erb +24 -0
  21. data/app/views/cms_admin/layouts/edit.html.erb +6 -0
  22. data/app/views/cms_admin/layouts/index.html.erb +6 -0
  23. data/app/views/cms_admin/layouts/new.html.erb +6 -0
  24. data/app/views/cms_admin/pages/_form.html.erb +14 -0
  25. data/app/views/cms_admin/pages/_form_blocks.html.erb +7 -0
  26. data/app/views/cms_admin/pages/_index_branch.html.erb +27 -0
  27. data/app/views/cms_admin/pages/edit.html.erb +6 -0
  28. data/app/views/cms_admin/pages/form_blocks.js.erb +1 -0
  29. data/app/views/cms_admin/pages/index.html.erb +6 -0
  30. data/app/views/cms_admin/pages/new.html.erb +6 -0
  31. data/app/views/cms_admin/snippets/_form.html.erb +2 -0
  32. data/app/views/cms_admin/snippets/edit.html.erb +6 -0
  33. data/app/views/cms_admin/snippets/index.html.erb +3 -0
  34. data/app/views/cms_admin/snippets/new.html.erb +6 -0
  35. data/app/views/cms_admin/uploads/_index.html.erb +8 -0
  36. data/app/views/cms_admin/uploads/_upload.html.erb +11 -0
  37. data/app/views/cms_admin/uploads/destroy.js.erb +3 -0
  38. data/app/views/cms_admin/uploads/index.html.erb +2 -0
  39. data/app/views/layouts/cms_admin.html.erb +36 -0
  40. data/comfortable_mexican_sofa.gemspec +141 -197
  41. data/config.ru +4 -0
  42. data/config/application.rb +44 -0
  43. data/config/boot.rb +13 -0
  44. data/{test/rails_root/config → config}/database.yml +0 -0
  45. data/config/environment.rb +5 -0
  46. data/config/environments/development.rb +22 -0
  47. data/config/environments/production.rb +49 -0
  48. data/config/environments/test.rb +35 -0
  49. data/{test/rails_root/config → config}/initializers/backtrace_silencers.rb +2 -2
  50. data/{test/rails_root/config → config}/initializers/inflections.rb +1 -1
  51. data/{test/rails_root/config → config}/initializers/mime_types.rb +0 -0
  52. data/config/initializers/paperclip.rb +3 -0
  53. data/config/initializers/secret_token.rb +7 -0
  54. data/config/initializers/session_store.rb +8 -0
  55. data/{test/rails_root/config → config}/locales/en.yml +1 -1
  56. data/config/routes.rb +20 -0
  57. data/db/migrate/01_create_cms.rb +73 -0
  58. data/db/seeds.rb +7 -0
  59. data/doc/README_FOR_APP +95 -0
  60. data/lib/comfortable_mexican_sofa.rb +34 -39
  61. data/lib/comfortable_mexican_sofa/cms_acts_as_tree.rb +42 -49
  62. data/lib/comfortable_mexican_sofa/cms_form_builder.rb +107 -0
  63. data/lib/comfortable_mexican_sofa/cms_rails_extensions.rb +25 -5
  64. data/lib/comfortable_mexican_sofa/cms_tag.rb +90 -85
  65. data/lib/comfortable_mexican_sofa/cms_tag/field_datetime.rb +26 -0
  66. data/lib/comfortable_mexican_sofa/cms_tag/field_integer.rb +26 -0
  67. data/lib/comfortable_mexican_sofa/cms_tag/field_string.rb +26 -0
  68. data/lib/comfortable_mexican_sofa/cms_tag/field_text.rb +26 -0
  69. data/lib/comfortable_mexican_sofa/cms_tag/page_datetime.rb +22 -0
  70. data/lib/comfortable_mexican_sofa/cms_tag/page_integer.rb +22 -0
  71. data/lib/comfortable_mexican_sofa/cms_tag/page_string.rb +22 -0
  72. data/lib/comfortable_mexican_sofa/cms_tag/page_text.rb +22 -0
  73. data/lib/comfortable_mexican_sofa/cms_tag/partial.rb +20 -0
  74. data/lib/comfortable_mexican_sofa/cms_tag/snippet.rb +18 -0
  75. data/{generators/cms/templates → lib/generators}/README +0 -20
  76. data/lib/generators/cms_generator.rb +28 -0
  77. data/public/404.html +26 -0
  78. data/public/422.html +26 -0
  79. data/public/500.html +26 -0
  80. data/{test/rails_root/public → public}/favicon.ico +0 -0
  81. data/public/images/comfortable_mexican_sofa/body_bg.jpg +0 -0
  82. data/{generators/cms/templates/images → public/images/comfortable_mexican_sofa}/icon_regular.gif +0 -0
  83. data/public/javascripts/comfortable_mexican_sofa/cms.js +53 -0
  84. data/public/javascripts/comfortable_mexican_sofa/jquery-ui.js +325 -0
  85. data/public/javascripts/comfortable_mexican_sofa/jquery.js +154 -0
  86. data/public/javascripts/comfortable_mexican_sofa/plupload/plupload.full.min.js +1 -0
  87. data/public/javascripts/comfortable_mexican_sofa/plupload/plupload.html4.min.js +1 -0
  88. data/public/javascripts/comfortable_mexican_sofa/plupload/plupload.html5.min.js +1 -0
  89. data/public/javascripts/comfortable_mexican_sofa/rails.js +132 -0
  90. data/public/javascripts/comfortable_mexican_sofa/uploader.js +47 -0
  91. data/{test/rails_root/public → public}/robots.txt +0 -0
  92. data/public/stylesheets/comfortable_mexican_sofa/jquery-ui.css +305 -0
  93. data/public/stylesheets/comfortable_mexican_sofa/reset.css +1 -0
  94. data/public/stylesheets/comfortable_mexican_sofa/structure.css +194 -0
  95. data/public/stylesheets/comfortable_mexican_sofa/typography.css +20 -0
  96. data/script/rails +6 -0
  97. data/test/fixtures/README.md +22 -0
  98. data/test/fixtures/cms_blocks.yml +10 -34
  99. data/test/fixtures/cms_layouts.yml +37 -33
  100. data/test/fixtures/cms_pages.yml +11 -32
  101. data/test/fixtures/cms_snippets.yml +2 -6
  102. data/test/fixtures/cms_uploads.yml +4 -0
  103. data/test/fixtures/files/invalid_file.gif +9 -0
  104. data/test/fixtures/files/valid_image.jpg +0 -0
  105. data/test/functional/cms_admin/base_controller_test.rb +9 -0
  106. data/test/functional/cms_admin/layouts_controller_test.rb +61 -46
  107. data/test/functional/cms_admin/pages_controller_test.rb +201 -102
  108. data/test/functional/cms_admin/snippets_controller_test.rb +46 -39
  109. data/test/functional/cms_admin/uploads_controller_test.rb +32 -0
  110. data/test/functional/cms_content_controller_test.rb +37 -32
  111. data/test/test_helper.rb +29 -9
  112. data/test/unit/cms_block_test.rb +60 -0
  113. data/test/unit/cms_layout_test.rb +48 -0
  114. data/test/unit/cms_page_test.rb +122 -0
  115. data/test/unit/cms_snippet_test.rb +23 -0
  116. data/test/unit/cms_tag_test.rb +149 -0
  117. data/test/unit/cms_tags/field_datetime_test.rb +36 -0
  118. data/test/unit/cms_tags/field_integer_test.rb +35 -0
  119. data/test/unit/cms_tags/field_string_test.rb +35 -0
  120. data/test/unit/cms_tags/field_text_test.rb +34 -0
  121. data/test/unit/cms_tags/page_datetime_test.rb +36 -0
  122. data/test/unit/cms_tags/page_integer_test.rb +35 -0
  123. data/test/unit/cms_tags/page_string_test.rb +35 -0
  124. data/test/unit/cms_tags/page_text_test.rb +36 -0
  125. data/test/unit/cms_tags/partial_test.rb +30 -0
  126. data/test/unit/cms_tags/snippet_test.rb +34 -0
  127. data/test/unit/cms_upload_test.rb +30 -0
  128. metadata +176 -215
  129. data/CHANGELOG.rdoc +0 -2
  130. data/LICENSE +0 -20
  131. data/README.rdoc +0 -55
  132. data/app/controllers/cms_admin/attachments_controller.rb +0 -55
  133. data/app/controllers/cms_admin/categories_controller.rb +0 -69
  134. data/app/controllers/cms_admin/sections_controller.rb +0 -17
  135. data/app/controllers/cms_common/render_page.rb +0 -47
  136. data/app/helpers/cms_helper.rb +0 -12
  137. data/app/models/cms_attachment.rb +0 -17
  138. data/app/models/cms_attachment_categorization.rb +0 -5
  139. data/app/models/cms_category.rb +0 -36
  140. data/app/models/cms_page_categorization.rb +0 -6
  141. data/app/views/cms_admin/attachments/_details.html.haml +0 -27
  142. data/app/views/cms_admin/attachments/_form.html.haml +0 -24
  143. data/app/views/cms_admin/attachments/edit.html.haml +0 -10
  144. data/app/views/cms_admin/attachments/index.html.haml +0 -36
  145. data/app/views/cms_admin/attachments/new.html.haml +0 -8
  146. data/app/views/cms_admin/categories/_category.html.haml +0 -21
  147. data/app/views/cms_admin/categories/_category_subform.html.haml +0 -12
  148. data/app/views/cms_admin/categories/_form.html.haml +0 -18
  149. data/app/views/cms_admin/categories/_new.html.haml +0 -7
  150. data/app/views/cms_admin/categories/_toggle_link.html.haml +0 -9
  151. data/app/views/cms_admin/categories/_tree_branch.html.haml +0 -36
  152. data/app/views/cms_admin/categories/children.js.rjs +0 -10
  153. data/app/views/cms_admin/categories/create.js.rjs +0 -9
  154. data/app/views/cms_admin/categories/edit.html.haml +0 -10
  155. data/app/views/cms_admin/categories/index.html.haml +0 -7
  156. data/app/views/cms_admin/categories/new.html.haml +0 -8
  157. data/app/views/cms_admin/categories/show.html.haml +0 -17
  158. data/app/views/cms_admin/layouts/_details.html.haml +0 -6
  159. data/app/views/cms_admin/layouts/_form.html.haml +0 -19
  160. data/app/views/cms_admin/layouts/_toggle_link.html.haml +0 -9
  161. data/app/views/cms_admin/layouts/_tree_branch.html.haml +0 -39
  162. data/app/views/cms_admin/layouts/children.js.rjs +0 -10
  163. data/app/views/cms_admin/layouts/edit.html.haml +0 -10
  164. data/app/views/cms_admin/layouts/index.html.haml +0 -7
  165. data/app/views/cms_admin/layouts/new.html.haml +0 -8
  166. data/app/views/cms_admin/pages/_details.html.haml +0 -25
  167. data/app/views/cms_admin/pages/_form.html.haml +0 -45
  168. data/app/views/cms_admin/pages/_form_blocks.html.haml +0 -48
  169. data/app/views/cms_admin/pages/_toggle_link.html.haml +0 -10
  170. data/app/views/cms_admin/pages/_tree_branch.html.haml +0 -41
  171. data/app/views/cms_admin/pages/children.js.rjs +0 -10
  172. data/app/views/cms_admin/pages/edit.html.haml +0 -11
  173. data/app/views/cms_admin/pages/form_blocks.js.rjs +0 -1
  174. data/app/views/cms_admin/pages/index.html.haml +0 -6
  175. data/app/views/cms_admin/pages/new.html.haml +0 -9
  176. data/app/views/cms_admin/sections/show.html.haml +0 -23
  177. data/app/views/cms_admin/snippets/_form.html.haml +0 -10
  178. data/app/views/cms_admin/snippets/edit.html.haml +0 -10
  179. data/app/views/cms_admin/snippets/index.html.haml +0 -26
  180. data/app/views/cms_admin/snippets/new.html.haml +0 -8
  181. data/app/views/cms_content/show.xml.rxml +0 -27
  182. data/app/views/cms_content/sitemap.xml.rxml +0 -16
  183. data/app/views/layouts/cms_admin.html.haml +0 -44
  184. data/config/cms_routes.rb +0 -25
  185. data/generators/cms/cms_generator.rb +0 -55
  186. data/generators/cms/templates/images/arrow_bottom.gif +0 -0
  187. data/generators/cms/templates/images/arrow_right.gif +0 -0
  188. data/generators/cms/templates/images/icon_attachment.gif +0 -0
  189. data/generators/cms/templates/images/icon_category.gif +0 -0
  190. data/generators/cms/templates/images/icon_draft.gif +0 -0
  191. data/generators/cms/templates/images/icon_layout.gif +0 -0
  192. data/generators/cms/templates/images/icon_move.gif +0 -0
  193. data/generators/cms/templates/images/icon_snippet.gif +0 -0
  194. data/generators/cms/templates/images/logo.png +0 -0
  195. data/generators/cms/templates/initializers/cms.rb +0 -14
  196. data/generators/cms/templates/initializers/paperclip.rb +0 -14
  197. data/generators/cms/templates/javascripts/codemirror_init.js +0 -16
  198. data/generators/cms/templates/javascripts/mce_init.js +0 -17
  199. data/generators/cms/templates/javascripts/utilities.js +0 -27
  200. data/generators/cms/templates/migrations/create_cms.rb +0 -113
  201. data/generators/cms/templates/stylesheets/cms_master.sass +0 -414
  202. data/init.rb +0 -1
  203. data/lib/comfortable_mexican_sofa/acts_as_categorized.rb +0 -87
  204. data/lib/comfortable_mexican_sofa/acts_as_published.rb +0 -60
  205. data/lib/comfortable_mexican_sofa/cms_tags/attachment.rb +0 -3
  206. data/lib/comfortable_mexican_sofa/cms_tags/block.rb +0 -117
  207. data/lib/comfortable_mexican_sofa/cms_tags/helper.rb +0 -3
  208. data/lib/comfortable_mexican_sofa/cms_tags/page_block.rb +0 -119
  209. data/lib/comfortable_mexican_sofa/cms_tags/partial.rb +0 -19
  210. data/lib/comfortable_mexican_sofa/cms_tags/snippet.rb +0 -19
  211. data/rails/init.rb +0 -1
  212. data/test/fixtures/cms_attachment_categorizations.yml +0 -7
  213. data/test/fixtures/cms_attachments.yml +0 -6
  214. data/test/fixtures/cms_categories.yml +0 -19
  215. data/test/fixtures/cms_page_categorizations.yml +0 -15
  216. data/test/fixtures/files/upload_file.txt +0 -1
  217. data/test/functional/cms_admin/attachments_controller_test.rb +0 -63
  218. data/test/functional/cms_admin/categories_controller_test.rb +0 -86
  219. data/test/functional/cms_admin/sections_controller_test.rb +0 -9
  220. data/test/models/cms_attachment_test.rb +0 -16
  221. data/test/models/cms_block_test.rb +0 -11
  222. data/test/models/cms_categorization_test.rb +0 -39
  223. data/test/models/cms_category_test.rb +0 -71
  224. data/test/models/cms_layout_test.rb +0 -44
  225. data/test/models/cms_page_test.rb +0 -55
  226. data/test/models/cms_snippet_test.rb +0 -16
  227. data/test/models/cms_tag_test.rb +0 -70
  228. data/test/rails_root/README +0 -243
  229. data/test/rails_root/Rakefile +0 -10
  230. data/test/rails_root/app/controllers/application_controller.rb +0 -10
  231. data/test/rails_root/app/helpers/application_helper.rb +0 -3
  232. data/test/rails_root/app/views/cms/under-development.html.haml +0 -1
  233. data/test/rails_root/app/views/complex_page/_example.html.erb +0 -1
  234. data/test/rails_root/config/boot.rb +0 -110
  235. data/test/rails_root/config/environment.rb +0 -48
  236. data/test/rails_root/config/environments/development.rb +0 -17
  237. data/test/rails_root/config/environments/production.rb +0 -28
  238. data/test/rails_root/config/environments/test.rb +0 -28
  239. data/test/rails_root/config/initializers/new_rails_defaults.rb +0 -19
  240. data/test/rails_root/config/initializers/session_store.rb +0 -15
  241. data/test/rails_root/config/routes.rb +0 -43
  242. data/test/rails_root/doc/README_FOR_APP +0 -2
  243. data/test/rails_root/public/404.html +0 -30
  244. data/test/rails_root/public/422.html +0 -30
  245. data/test/rails_root/public/500.html +0 -30
  246. data/test/rails_root/public/images/rails.png +0 -0
  247. data/test/rails_root/public/index.html +0 -275
  248. data/test/rails_root/public/javascripts/application.js +0 -2
  249. data/test/rails_root/public/javascripts/controls.js +0 -963
  250. data/test/rails_root/public/javascripts/dragdrop.js +0 -973
  251. data/test/rails_root/public/javascripts/effects.js +0 -1128
  252. data/test/rails_root/public/javascripts/prototype.js +0 -4320
  253. data/test/rails_root/public/stylesheets/sass/cms_master.sass +0 -414
  254. data/test/rails_root/script/about +0 -4
  255. data/test/rails_root/script/console +0 -3
  256. data/test/rails_root/script/dbconsole +0 -3
  257. data/test/rails_root/script/destroy +0 -3
  258. data/test/rails_root/script/generate +0 -3
  259. data/test/rails_root/script/performance/benchmarker +0 -3
  260. data/test/rails_root/script/performance/profiler +0 -3
  261. data/test/rails_root/script/plugin +0 -3
  262. data/test/rails_root/script/runner +0 -3
  263. data/test/rails_root/script/server +0 -3
data/CHANGELOG.rdoc DELETED
@@ -1,2 +0,0 @@
1
- == 0.0.15
2
- * First release
data/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2009 Oleg Khabarov and The Working Group
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc DELETED
@@ -1,55 +0,0 @@
1
- = Comfortable Mexican Sofa
2
-
3
- ComfortableMexicanSofa is a CMS engine that provides CMS functionality to any Rails app.
4
- It is not intended for users that would put <% ActiveRecord::Base.connection.execute('DROP DATABASE;') %> as content of a page.
5
-
6
- == Install
7
-
8
- From local gem:
9
- rake manifest && rake install
10
-
11
- In your Rails project:
12
- # config/envionment.rb
13
- config.gem 'comfortable_mexican_sofa'
14
-
15
- Run the follwing in your console to generate migrations and update your database:
16
- script/generate cms
17
- rake db:migrate
18
-
19
- Navigate to the following address to access CMS admin page:
20
- http://your_application/cms-admin
21
-
22
- == Sample CMS Configuration
23
-
24
- ComfortableMexicanSofa.config do |config|
25
- config.http_auth_username = 'username'
26
- config.http_auth_password = 'secret_password'
27
- end
28
-
29
- == Setting Up Layouts and Writing CMS Content
30
-
31
- Here's some available type of tags that allow construction and insertion of page content:
32
-
33
- cms_page_block - block that gets rendered in the actual content of the page
34
- cms_block - block that is not automatically rendered
35
- cms_snippet - it's a snippet
36
- cms_helper - it's a helper method of some sort
37
- cms_partial - sometimes all we need is a partial
38
-
39
- Here are the different formats for page blocks and what they will generate in the CMS page editing form:
40
-
41
- string - a single-line text input
42
- text - a textarea
43
- rich_text - if TinyMCE is installed in the app, this will generate a TinyMCE enhanced textarea
44
- code - if CodeMirror is installed in the app, this will generate a CodeMirror editor with syntax highlighting for HTML, JavaScript and CSS
45
-
46
- == Installing CodeMirror Support
47
-
48
- Download CodeMirror from: http://marijn.haverbeke.nl/codemirror
49
-
50
- To get CodeMirror support properly working, you need to place the CodeMirror files in specific folders in your app. The JavaScript initializer expects the CodeMirror .js files to be at /publib/javascripts/codemirrror/ and the CSS files at /public/stylesheets/codemirror/.
51
-
52
- To properly generate the .sass files, use the following command:
53
-
54
- css2sass -a file.css > file.sass
55
-
@@ -1,55 +0,0 @@
1
- class CmsAdmin::AttachmentsController < CmsAdmin::BaseController
2
-
3
- before_filter :load_attachment, :only => [:edit, :update, :destroy]
4
-
5
- def index
6
- @category_id = params[:filter][:category_id] rescue nil
7
- unless @category_id.blank?
8
- @cms_attachments = CmsAttachment.in_category(@category_id).paginate(:page => params[:page])
9
- else
10
- @cms_attachments = CmsAttachment.paginate(:page => params[:page])
11
- end
12
- end
13
-
14
- def new
15
- @cms_attachment = CmsAttachment.new
16
- end
17
-
18
- def edit
19
- end
20
-
21
- def create
22
- @cms_attachment = CmsAttachment.new(params[:cms_attachment])
23
- @cms_attachment.save!
24
-
25
- flash[:notice] = 'Attachment created'
26
- redirect_to :action => :edit, :id => @cms_attachment
27
-
28
- rescue ActiveRecord::RecordInvalid
29
- render :action => :new
30
- end
31
-
32
- def update
33
- @cms_attachment.update_attributes!(params[:cms_attachment])
34
-
35
- flash[:notice] = 'Attachment updated'
36
- redirect_to :action => :edit, :id => @cms_attachment
37
-
38
- rescue ActiveRecord::RecordInvalid
39
- render :action => :edit
40
- end
41
-
42
- def destroy
43
- @cms_attachment.destroy
44
-
45
- flash[:notice] = 'Attachment removed'
46
- redirect_to :action => :index
47
- end
48
-
49
- protected
50
-
51
- def load_attachment
52
- @cms_attachment = CmsAttachment.find_by_id(params[:id])
53
- end
54
-
55
- end
@@ -1,69 +0,0 @@
1
- class CmsAdmin::CategoriesController < CmsAdmin::BaseController
2
- before_filter :load_category, :except => [:create, :new, :index]
3
-
4
- def index
5
- @cms_categories = CmsCategory.roots
6
- end
7
-
8
- def children
9
- manage_session_array(:cms_category_tree, (params[:state] == 'open' ? :remove : :add), params[:id])
10
- end
11
-
12
- def new
13
- @cms_category = CmsCategory.new(params.slice(:parent_id))
14
- end
15
-
16
- def create
17
- @cms_category = CmsCategory.new(params[:cms_category])
18
- @cms_category.save!
19
-
20
- flash[:notice] = 'Category created'
21
- respond_to do |format|
22
- format.html { redirect_to :action => :edit, :id => @cms_category}
23
- format.js
24
- end
25
-
26
- rescue ActiveRecord::RecordInvalid
27
- respond_to do |format|
28
- format.html { render :action => 'new' }
29
- format.js
30
- end
31
- end
32
-
33
- def edit
34
- # ...
35
- end
36
-
37
- def update
38
- @cms_category.update_attributes!(params[:cms_category])
39
- flash[:notice] = 'Category updated'
40
- respond_to do |format|
41
- format.html { redirect_to :action => :edit, :id => @cms_category }
42
- format.js
43
- end
44
-
45
- rescue ActiveRecord::RecordInvalid
46
- respond_to do |format|
47
- format.html { render :action => 'edit' }
48
- format.js
49
- end
50
- end
51
-
52
- def show
53
- end
54
-
55
- def destroy
56
- @cms_category.destroy
57
- flash[:notice] = 'Category deleted'
58
- redirect_to cms_admin_categories_path
59
- end
60
-
61
- protected
62
-
63
- def load_category
64
- @cms_category = CmsCategory.find(params[:id])
65
- rescue ActiveRecord::RecordNotFound
66
- render :text => 'Item not found', :status => 404
67
- end
68
-
69
- end
@@ -1,17 +0,0 @@
1
- class CmsAdmin::SectionsController < CmsAdmin::BaseController
2
-
3
- def show
4
- @page = CmsPage.sections.find_by_id(params[:id])
5
- @pages = @page.children.paginate :page => params[:page]
6
-
7
- # attempt to singularize section name
8
- @section_label = @page.label.singularize
9
- end
10
-
11
- def test_get_show
12
- get :show, :id => cms_pages(:complex_page)
13
- assert_response :success
14
- assert assigns(:pages)
15
- end
16
-
17
- end
@@ -1,47 +0,0 @@
1
- module CmsCommon::RenderPage
2
-
3
- def render_page(options = {})
4
-
5
- @cms_page_preview_mode = options[:preview]
6
-
7
- # Rendering 404 page
8
- if !@cms_page
9
- @cms_page = CmsPage.published.find_by_full_path('404')
10
- if !@cms_page
11
- render :text => '404 Page Not Found', :status => 404
12
- else
13
- render :inline => @cms_page.content, :layout => (@cms_page.cms_layout.app_layout || false), :status => 404
14
- end
15
- return
16
- end
17
-
18
- respond_to do |format|
19
- format.html do
20
- if @cms_page.redirect_to_page
21
- redirect_to @cms_page.redirect_to_page.full_path
22
- else
23
-
24
- layout = (@cms_page.cms_layout.app_layout || false)
25
-
26
- if Rails.env.development? || Rails.env.test?
27
- # attempt to load content from the filesystem first
28
- begin
29
- @cms_page_slug = @cms_page_slug.blank? ? 'index' : @cms_page_slug
30
- render :template => "/cms/#{@cms_page_slug}", :layout => layout
31
- return
32
- rescue ActionView::MissingTemplate ; end
33
- end
34
-
35
- render :inline => @cms_page.content, :layout => layout
36
- end
37
- end
38
- format.xml do
39
- @cms_page_children = @cms_page.children[0...25].collect do |p|
40
- p.rendered_content = render_to_string(:inline => p.content, :layout => false)
41
- p
42
- end
43
- end
44
- end
45
- end
46
-
47
- end
@@ -1,12 +0,0 @@
1
- module CmsHelper
2
-
3
- CMS_C = %w( crazy cool colorful cremated creamed crusty clapping campy crude corky comfortable crappy cromulent childish crafty cruddy creaky cranky catatonic comatose circular curvaceous crabby cyan canned clobbered controlling candid cagey callous capable capricious ceaseless changeable cheerful chilly chivalrous chubby chunky clammy classy cloistered cloudy clumsy coherent cold colossal combative comfortable cooing cooperative courageous cowardly craven credible creepy crooked cuddly cultured curly curved cynical casual).freeze
4
- CMS_M = %w( massive monster mini mighty morbid mexican moses machine mucus murder macabre macho maddening madly magenta magical magnificent majestic makeshift malicious mammoth maniacal many marked massive materialistic mature measly meek melodic merciful mere mighty mindless miniature minor miscreant moaning modern moldy momentous muddled mundane murky mushy mysterious).freeze
5
- CMS_S = %w( scott sean sack sail salt sand scale scarecrow scarf scene scent school science scissors screw sea seashore seat secretary seed selection self sense servant shade shake shame shape sheep sheet shelf ship shirt shock shoe shoes shop show side sidewalk sign silk silver sink sister sisters size skate skin skirt sky slave sleep sleet slip slope smash smell smile smoke snail snails snake snakes sneeze snow soap society sock soda sofa son song songs sort sound soup space spade spark spiders sponge spoon spot spring spy square squirrel stage stamp star start statement station steam steel stem step stew stick sticks stitch stocking stomach stone stop store story stove stranger straw stream street stretch string structure substance sugar suggestion suit summer sun support surprise sweater swim swing system sangria).freeze
6
-
7
- def application_name
8
- ComfortableMexicanSofa::Config.cms_title ||
9
- [CMS_C, CMS_M, CMS_S].collect{|a| a.sort_by{rand}.first.capitalize}.join
10
- end
11
-
12
- end
@@ -1,17 +0,0 @@
1
- class CmsAttachment < ActiveRecord::Base
2
-
3
- # -- Relationships --------------------------------------------------------
4
-
5
- has_attached_file :file, ComfortableMexicanSofa::Config.paperclip_options
6
- acts_as_categorized
7
-
8
- # -- Validations ----------------------------------------------------------
9
-
10
- validates_attachment_presence :file
11
- validates_presence_of :label
12
-
13
- # -- Named Scopes ----------------------------------------------------------
14
-
15
- default_scope :order => 'created_at DESC'
16
-
17
- end
@@ -1,5 +0,0 @@
1
- class CmsAttachmentCategorization < ActiveRecord::Base
2
-
3
- acts_as_categorization
4
-
5
- end
@@ -1,36 +0,0 @@
1
- class CmsCategory < ActiveRecord::Base
2
-
3
- # -- Relationships --------------------------------------------------------
4
- acts_as_tree
5
-
6
- has_many :cms_page_categorizations, :dependent => :destroy
7
- has_many :cms_attachment_categorizations, :dependent => :destroy
8
-
9
- has_many :cms_pages, :through => :cms_page_categorizations
10
- has_many :cms_attachments, :through => :cms_attachment_categorizations
11
-
12
- # -- Validations ----------------------------------------------------------
13
- validates_presence_of :slug, :label
14
- validates_uniqueness_of :slug, :scope => :parent_id
15
-
16
- # -- Named Scopes ---------------------------------------------------------
17
- default_scope :order => 'label'
18
-
19
- # -- Callbacks ------------------------------------------------------------
20
- before_validation :set_slug_if_blank
21
-
22
- # -- Class Methods --------------------------------------------------------
23
- def set_slug_if_blank
24
- self.slug = self.label.slugify if self.slug.blank?
25
- end
26
-
27
- def self.categories_for_select(collection = CmsCategory.roots, level = 0)
28
- out = []
29
- collection.each do |category|
30
- out += [["#{". . " * level} #{category.label}", category.id]]
31
- out += self.categories_for_select(category.children, level+1) if category.children.count > 0
32
- end
33
- out
34
- end
35
-
36
- end
@@ -1,6 +0,0 @@
1
- class CmsPageCategorization < ActiveRecord::Base
2
-
3
- acts_as_categorization
4
-
5
- end
6
-
@@ -1,27 +0,0 @@
1
- - attachment ||= details
2
-
3
- .details
4
-
5
- = link_to_function '+ show details', "$('attachment_details_#{attachment.id}').show(); $(this).hide()"
6
-
7
- %div{:id => "attachment_details_#{attachment.id}", :style => 'display: none'}
8
- %table
9
- %tr
10
- %th Filename:
11
- %td= attachment.file.url
12
- %tr
13
- %th Type:
14
- %td= attachment.file_content_type
15
- %tr
16
- %th Filesize:
17
- %td= number_to_human_size(attachment.file_file_size)
18
- %tr
19
- %th Description:
20
- %td= h attachment.description
21
- %tr
22
- %th Created:
23
- %td= "#{time_ago_in_words(attachment.created_at)} ago"
24
- %tr
25
- %th Categories:
26
- %td
27
- = attachment.cms_categories.collect{|category| link_to(category.label, '')}.join(', ')
@@ -1,24 +0,0 @@
1
- = form.error_messages
2
-
3
- .form_right_column
4
- = render :partial => 'cms_admin/categories/category_subform', :locals => { :item => @cms_attachment }
5
-
6
- .form_left_column
7
- .form_element_group.horizontal
8
- .form_element.text.large
9
- .label= form.label :label, 'Label'
10
- .field= form.text_field :label
11
-
12
- - if @cms_attachment && @cms_attachment.file? && !@cms_attachment.new_record?
13
- .form_element
14
- .label
15
- %label Current File
16
- .field= link_to @cms_attachment.file_file_name, @cms_attachment.file.url
17
-
18
- .form_element.text
19
- .label= form.label :file, 'File'
20
- .field= form.file_field :file
21
-
22
- .form_element.text_area
23
- .label= form.label :description, 'Description'
24
- .field= form.text_area :description
@@ -1,10 +0,0 @@
1
- = link_to 'Add New Attachment', new_cms_admin_attachment_path, :class => 'big_button'
2
-
3
- %h2 Editing Attachment
4
-
5
- - form_for :cms_attachment, :url => {:action => :update}, :html => {:method => :put, :multipart => true} do |form|
6
- = render :partial => form
7
- .submit
8
- = form.submit 'Edit Attachment'
9
- or
10
- = link_to 'Return to List', cms_admin_attachments_path
@@ -1,36 +0,0 @@
1
- = link_to 'Add New Attachment', new_cms_admin_attachment_path, :class => 'big_button'
2
-
3
- %h2 Attachments
4
-
5
- - form_for :filter, :url => cms_admin_attachments_path, :html => {:method => :get, :class => 'filter_form'} do |f|
6
- = f.select :category_id, CmsCategory.categories_for_select, { :include_blank => '-- All Categories --', :selected => @category_id.to_i }
7
- = f.submit 'Filter'
8
-
9
- = will_paginate @cms_attachments
10
-
11
- %table.formatted
12
- %tr
13
- %th.first{:colspan => 2} Attachment Label
14
- %th Type
15
- %th Filesize
16
- %th.last
17
-
18
- - @cms_attachments.each do |attachment|
19
- %tr
20
- %td
21
- .icon
22
- %td.main
23
- = link_to attachment.label.titleize, edit_cms_admin_attachment_path(attachment), :class => 'label'
24
- %br
25
- = link_to attachment.file.url, attachment.file.url, :class => 'url'
26
- %td
27
- = attachment.file_content_type
28
- %td
29
- = number_to_human_size(attachment.file_file_size)
30
-
31
- %td.action_links
32
- = link_to 'Edit', edit_cms_admin_attachment_path(attachment)
33
- |
34
- = link_to 'Remove', cms_admin_attachment_path(attachment), :method => 'delete', :confirm => 'Are you sure you want to remove this attachment?'
35
-
36
- = will_paginate @cms_attachments