lucy_cms 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (245) hide show
  1. data/Gemfile +19 -0
  2. data/Gemfile.lock +88 -0
  3. data/LICENSE +24 -0
  4. data/README.md +161 -0
  5. data/Rakefile +26 -0
  6. data/VERSION +1 -0
  7. data/app/controllers/application_controller.rb +5 -0
  8. data/app/controllers/cms_admin/base_controller.rb +43 -0
  9. data/app/controllers/cms_admin/layouts_controller.rb +66 -0
  10. data/app/controllers/cms_admin/pages_controller.rb +111 -0
  11. data/app/controllers/cms_admin/sessions_controller.rb +25 -0
  12. data/app/controllers/cms_admin/sites_controller.rb +69 -0
  13. data/app/controllers/cms_admin/snippets_controller.rb +62 -0
  14. data/app/controllers/cms_admin/upload_dirs_controller.rb +79 -0
  15. data/app/controllers/cms_admin/users_controller.rb +129 -0
  16. data/app/controllers/cms_content_controller.rb +51 -0
  17. data/app/models/cms_block.rb +28 -0
  18. data/app/models/cms_layout.rb +118 -0
  19. data/app/models/cms_page.rb +163 -0
  20. data/app/models/cms_site.rb +38 -0
  21. data/app/models/cms_snippet.rb +70 -0
  22. data/app/models/cms_upload.rb +19 -0
  23. data/app/models/cms_upload_dir.rb +11 -0
  24. data/app/models/cms_user.rb +93 -0
  25. data/app/views/cms_admin/layouts/_form.html.erb +10 -0
  26. data/app/views/cms_admin/layouts/_index_branch.html.erb +24 -0
  27. data/app/views/cms_admin/layouts/edit.html.erb +6 -0
  28. data/app/views/cms_admin/layouts/index.html.erb +6 -0
  29. data/app/views/cms_admin/layouts/new.html.erb +6 -0
  30. data/app/views/cms_admin/pages/_form.html.erb +37 -0
  31. data/app/views/cms_admin/pages/_form_blocks.html.erb +7 -0
  32. data/app/views/cms_admin/pages/_index_branch.html.erb +40 -0
  33. data/app/views/cms_admin/pages/edit.html.erb +5 -0
  34. data/app/views/cms_admin/pages/form_blocks.js.erb +2 -0
  35. data/app/views/cms_admin/pages/index.html.erb +6 -0
  36. data/app/views/cms_admin/pages/new.html.erb +5 -0
  37. data/app/views/cms_admin/pages/toggle_branch.js.erb +11 -0
  38. data/app/views/cms_admin/sessions/new.html.erb +12 -0
  39. data/app/views/cms_admin/sites/_form.html.erb +16 -0
  40. data/app/views/cms_admin/sites/edit.html.erb +6 -0
  41. data/app/views/cms_admin/sites/new.html.erb +6 -0
  42. data/app/views/cms_admin/sites/setup.html.erb +16 -0
  43. data/app/views/cms_admin/snippets/_form.html.erb +4 -0
  44. data/app/views/cms_admin/snippets/edit.html.erb +6 -0
  45. data/app/views/cms_admin/snippets/index.html.erb +23 -0
  46. data/app/views/cms_admin/snippets/new.html.erb +6 -0
  47. data/app/views/cms_admin/upload_dirs/_file.html.erb +15 -0
  48. data/app/views/cms_admin/upload_dirs/_form.html.erb +2 -0
  49. data/app/views/cms_admin/upload_dirs/conflict.html.erb +12 -0
  50. data/app/views/cms_admin/upload_dirs/index.html.erb +23 -0
  51. data/app/views/cms_admin/upload_dirs/new.html.erb +6 -0
  52. data/app/views/cms_admin/upload_dirs/show.html.erb +26 -0
  53. data/app/views/cms_admin/upload_dirs/uploads_destroy.js.erb +3 -0
  54. data/app/views/cms_admin/users/_form.html.erb +9 -0
  55. data/app/views/cms_admin/users/_index_branch.html.erb +16 -0
  56. data/app/views/cms_admin/users/change_password.html.erb +14 -0
  57. data/app/views/cms_admin/users/edit.html.erb +17 -0
  58. data/app/views/cms_admin/users/index.html.erb +6 -0
  59. data/app/views/cms_admin/users/new.html.erb +14 -0
  60. data/app/views/layouts/cms_admin.html.erb +52 -0
  61. data/config/application.rb +48 -0
  62. data/config/boot.rb +13 -0
  63. data/config/database.yml +22 -0
  64. data/config/environment.rb +5 -0
  65. data/config/environments/development.rb +22 -0
  66. data/config/environments/production.rb +49 -0
  67. data/config/environments/test.rb +35 -0
  68. data/config/initializers/LucyCMS.rb +37 -0
  69. data/config/initializers/mime_types.rb +5 -0
  70. data/config/locales/en.yml +5 -0
  71. data/config/routes.rb +45 -0
  72. data/config.ru +4 -0
  73. data/db/cms_seeds/example.local/layouts/default.yml +8 -0
  74. data/db/cms_seeds/example.local/layouts/nested.yml +6 -0
  75. data/db/cms_seeds/example.local/pages/child/subchild.yml +14 -0
  76. data/db/cms_seeds/example.local/pages/child.yml +10 -0
  77. data/db/cms_seeds/example.local/pages/index.yml +11 -0
  78. data/db/cms_seeds/example.local/snippets/example.yml +4 -0
  79. data/db/migrate/01_create_cms.rb +114 -0
  80. data/db/seeds.rb +7 -0
  81. data/lib/LucyCMS/acts_as_tree.rb +102 -0
  82. data/lib/LucyCMS/cms_tag/field_datetime.rb +26 -0
  83. data/lib/LucyCMS/cms_tag/field_integer.rb +26 -0
  84. data/lib/LucyCMS/cms_tag/field_string.rb +26 -0
  85. data/lib/LucyCMS/cms_tag/field_text.rb +26 -0
  86. data/lib/LucyCMS/cms_tag/helper.rb +20 -0
  87. data/lib/LucyCMS/cms_tag/page_datetime.rb +22 -0
  88. data/lib/LucyCMS/cms_tag/page_integer.rb +22 -0
  89. data/lib/LucyCMS/cms_tag/page_rich_text.rb +22 -0
  90. data/lib/LucyCMS/cms_tag/page_string.rb +22 -0
  91. data/lib/LucyCMS/cms_tag/page_text.rb +22 -0
  92. data/lib/LucyCMS/cms_tag/partial.rb +21 -0
  93. data/lib/LucyCMS/cms_tag/snippet.rb +22 -0
  94. data/lib/LucyCMS/cms_tag.rb +119 -0
  95. data/lib/LucyCMS/configuration.rb +36 -0
  96. data/lib/LucyCMS/controller_methods.rb +42 -0
  97. data/lib/LucyCMS/engine.rb +12 -0
  98. data/lib/LucyCMS/form_builder.rb +129 -0
  99. data/lib/LucyCMS/rails_extensions.rb +22 -0
  100. data/lib/LucyCMS/site_form_builder.rb +129 -0
  101. data/lib/LucyCMS/view_hooks.rb +30 -0
  102. data/lib/LucyCMS/view_methods.rb +68 -0
  103. data/lib/LucyCMS.rb +40 -0
  104. data/lib/generators/README +17 -0
  105. data/lib/generators/cms_generator.rb +44 -0
  106. data/lib/tasks/LucyCMS.rake +283 -0
  107. data/lucy_cms.gemspec +100 -0
  108. data/public/404.html +26 -0
  109. data/public/422.html +26 -0
  110. data/public/500.html +26 -0
  111. data/public/favicon.ico +0 -0
  112. data/public/images/LucyCMS/arrow_bottom.gif +0 -0
  113. data/public/images/LucyCMS/arrow_right.gif +0 -0
  114. data/public/images/LucyCMS/icon_folder.png +0 -0
  115. data/public/images/LucyCMS/icon_layout.gif +0 -0
  116. data/public/images/LucyCMS/icon_move.gif +0 -0
  117. data/public/images/LucyCMS/icon_regular.gif +0 -0
  118. data/public/images/LucyCMS/icon_snippet.gif +0 -0
  119. data/public/images/LucyCMS/icon_upload.png +0 -0
  120. data/public/images/LucyCMS/icon_user.jpg +0 -0
  121. data/public/javascripts/LucyCMS/cms.js +204 -0
  122. data/public/javascripts/LucyCMS/codemirror/codemirror.css +102 -0
  123. data/public/javascripts/LucyCMS/codemirror/codemirror.js +23 -0
  124. data/public/javascripts/LucyCMS/codemirror/codemirror_base.js +88 -0
  125. data/public/javascripts/LucyCMS/codemirror/parse_css.js +4 -0
  126. data/public/javascripts/LucyCMS/codemirror/parse_html_mixed.js +3 -0
  127. data/public/javascripts/LucyCMS/codemirror/parse_js.js +12 -0
  128. data/public/javascripts/LucyCMS/codemirror/parse_xml.js +7 -0
  129. data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  130. data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  131. data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  132. data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  133. data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  134. data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  135. data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  136. data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  137. data/public/javascripts/LucyCMS/jquery-ui/images/ui-icons_222222_256x240.png +0 -0
  138. data/public/javascripts/LucyCMS/jquery-ui/images/ui-icons_2e83ff_256x240.png +0 -0
  139. data/public/javascripts/LucyCMS/jquery-ui/images/ui-icons_454545_256x240.png +0 -0
  140. data/public/javascripts/LucyCMS/jquery-ui/images/ui-icons_888888_256x240.png +0 -0
  141. data/public/javascripts/LucyCMS/jquery-ui/images/ui-icons_cd0a0a_256x240.png +0 -0
  142. data/public/javascripts/LucyCMS/jquery-ui/jquery-ui.css +362 -0
  143. data/public/javascripts/LucyCMS/jquery-ui/jquery-ui.js +190 -0
  144. data/public/javascripts/LucyCMS/jquery.js +154 -0
  145. data/public/javascripts/LucyCMS/plupload/plupload.full.min.js +1 -0
  146. data/public/javascripts/LucyCMS/plupload/plupload.html5.min.js +1 -0
  147. data/public/javascripts/LucyCMS/plupload/plupload.min.js +1 -0
  148. data/public/javascripts/LucyCMS/rails.js +132 -0
  149. data/public/javascripts/LucyCMS/tiny_mce/jquery.tinymce.js +1 -0
  150. data/public/javascripts/LucyCMS/tiny_mce/langs/en.js +170 -0
  151. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/about.htm +54 -0
  152. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/anchor.htm +26 -0
  153. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/charmap.htm +52 -0
  154. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/color_picker.htm +73 -0
  155. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/editor_template.js +1 -0
  156. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/image.htm +80 -0
  157. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/img/colorpicker.jpg +0 -0
  158. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/img/icons.gif +0 -0
  159. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/about.js +72 -0
  160. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/anchor.js +37 -0
  161. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/charmap.js +335 -0
  162. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/color_picker.js +253 -0
  163. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/image.js +245 -0
  164. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/link.js +156 -0
  165. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/source_editor.js +56 -0
  166. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/langs/en.js +62 -0
  167. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/langs/en_dlg.js +51 -0
  168. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/link.htm +58 -0
  169. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/content.css +36 -0
  170. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/dialog.css +117 -0
  171. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/buttons.png +0 -0
  172. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/items.gif +0 -0
  173. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/menu_arrow.gif +0 -0
  174. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/menu_check.gif +0 -0
  175. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/progress.gif +0 -0
  176. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/tabs.gif +0 -0
  177. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/ui.css +213 -0
  178. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/source_editor.htm +25 -0
  179. data/public/javascripts/LucyCMS/tiny_mce/tiny_mce.js +1 -0
  180. data/public/javascripts/LucyCMS/tiny_mce/tiny_mce_popup.js +5 -0
  181. data/public/robots.txt +5 -0
  182. data/public/stylesheets/LucyCMS/content.css +196 -0
  183. data/public/stylesheets/LucyCMS/form.css +125 -0
  184. data/public/stylesheets/LucyCMS/reset.css +1 -0
  185. data/public/stylesheets/LucyCMS/site_form.css +82 -0
  186. data/public/stylesheets/LucyCMS/structure.css +125 -0
  187. data/public/stylesheets/LucyCMS/typography.css +25 -0
  188. data/script/rails +6 -0
  189. data/test/cms_seeds/test.host/layouts/broken.yml +1 -0
  190. data/test/cms_seeds/test.host/layouts/default.yml +3 -0
  191. data/test/cms_seeds/test.host/layouts/nested.yml +4 -0
  192. data/test/cms_seeds/test.host/pages/broken.yml +1 -0
  193. data/test/cms_seeds/test.host/pages/child/subchild.yml +10 -0
  194. data/test/cms_seeds/test.host/pages/child.yml +10 -0
  195. data/test/cms_seeds/test.host/pages/index.yml +10 -0
  196. data/test/cms_seeds/test.host/snippets/broken.yml +1 -0
  197. data/test/cms_seeds/test.host/snippets/default.yml +3 -0
  198. data/test/fixtures/cms_blocks.yml +12 -0
  199. data/test/fixtures/cms_layouts.yml +36 -0
  200. data/test/fixtures/cms_pages.yml +39 -0
  201. data/test/fixtures/cms_sites.yml +3 -0
  202. data/test/fixtures/cms_snippets.yml +5 -0
  203. data/test/fixtures/cms_upload_dirs.yml +9 -0
  204. data/test/fixtures/cms_uploads.yml +4 -0
  205. data/test/fixtures/cms_users.yml +11 -0
  206. data/test/fixtures/files/invalid_file.gif +9 -0
  207. data/test/fixtures/files/valid_image.jpg +0 -0
  208. data/test/fixtures/views/_nav_hook.html.erb +1 -0
  209. data/test/fixtures/views/_nav_hook_2.html.erb +1 -0
  210. data/test/functional/cms_admin/layouts_controller_test.rb +103 -0
  211. data/test/functional/cms_admin/pages_controller_test.rb +334 -0
  212. data/test/functional/cms_admin/sites_controller_test.rb +99 -0
  213. data/test/functional/cms_admin/snippets_controller_test.rb +102 -0
  214. data/test/functional/cms_admin/uploads_controller_test.rb +26 -0
  215. data/test/functional/cms_content_controller_test.rb +134 -0
  216. data/test/integration/rake_tasks_test.rb +65 -0
  217. data/test/integration/render_cms_seed_test.rb +34 -0
  218. data/test/integration/render_cms_test.rb +81 -0
  219. data/test/integration/sites_test.rb +63 -0
  220. data/test/integration/view_hooks_test.rb +33 -0
  221. data/test/test_helper.rb +86 -0
  222. data/test/unit/cms_block_test.rb +43 -0
  223. data/test/unit/cms_configuration_test.rb +17 -0
  224. data/test/unit/cms_layout_test.rb +146 -0
  225. data/test/unit/cms_page_test.rb +257 -0
  226. data/test/unit/cms_site_test.rb +41 -0
  227. data/test/unit/cms_snippet_test.rb +77 -0
  228. data/test/unit/cms_tag_test.rb +206 -0
  229. data/test/unit/cms_tags/field_datetime_test.rb +34 -0
  230. data/test/unit/cms_tags/field_integer_test.rb +33 -0
  231. data/test/unit/cms_tags/field_string_test.rb +34 -0
  232. data/test/unit/cms_tags/field_text_test.rb +32 -0
  233. data/test/unit/cms_tags/helper_test.rb +38 -0
  234. data/test/unit/cms_tags/page_datetime_test.rb +34 -0
  235. data/test/unit/cms_tags/page_integer_test.rb +33 -0
  236. data/test/unit/cms_tags/page_rich_text.rb +33 -0
  237. data/test/unit/cms_tags/page_string_test.rb +33 -0
  238. data/test/unit/cms_tags/page_text_test.rb +34 -0
  239. data/test/unit/cms_tags/partial_test.rb +44 -0
  240. data/test/unit/cms_tags/snippet_test.rb +33 -0
  241. data/test/unit/cms_upload_dir_test.rb +8 -0
  242. data/test/unit/cms_upload_test.rb +26 -0
  243. data/test/unit/cms_user_test.rb +8 -0
  244. data/test/unit/view_methods_test.rb +21 -0
  245. metadata +488 -0
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rails', '>=3.0.3'
4
+ gem 'active_link_to', '>=0.0.6'
5
+ gem 'paperclip', '>=2.3.8'
6
+ gem 'mime-types', :require => 'mime/types'
7
+ gem 'net-ldap', '>=0.1.1'
8
+
9
+ # If you wish to use sqlite in production
10
+ # gem 'sqlite3'
11
+
12
+ group :development do
13
+ gem 'sqlite3'
14
+ end
15
+
16
+ group :test do
17
+ gem 'sqlite3'
18
+ gem 'jeweler', '>=1.4.0'
19
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,88 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ abstract (1.0.0)
5
+ actionmailer (3.0.3)
6
+ actionpack (= 3.0.3)
7
+ mail (~> 2.2.9)
8
+ actionpack (3.0.3)
9
+ activemodel (= 3.0.3)
10
+ activesupport (= 3.0.3)
11
+ builder (~> 2.1.2)
12
+ erubis (~> 2.6.6)
13
+ i18n (~> 0.4)
14
+ rack (~> 1.2.1)
15
+ rack-mount (~> 0.6.13)
16
+ rack-test (~> 0.5.6)
17
+ tzinfo (~> 0.3.23)
18
+ active_link_to (0.0.6)
19
+ activemodel (3.0.3)
20
+ activesupport (= 3.0.3)
21
+ builder (~> 2.1.2)
22
+ i18n (~> 0.4)
23
+ activerecord (3.0.3)
24
+ activemodel (= 3.0.3)
25
+ activesupport (= 3.0.3)
26
+ arel (~> 2.0.2)
27
+ tzinfo (~> 0.3.23)
28
+ activeresource (3.0.3)
29
+ activemodel (= 3.0.3)
30
+ activesupport (= 3.0.3)
31
+ activesupport (3.0.3)
32
+ arel (2.0.6)
33
+ builder (2.1.2)
34
+ erubis (2.6.6)
35
+ abstract (>= 1.0.0)
36
+ git (1.2.5)
37
+ i18n (0.5.0)
38
+ jeweler (1.5.1)
39
+ bundler (~> 1.0.0)
40
+ git (>= 1.2.5)
41
+ rake
42
+ mail (2.2.12)
43
+ activesupport (>= 2.3.6)
44
+ i18n (>= 0.4.0)
45
+ mime-types (~> 1.16)
46
+ treetop (~> 1.4.8)
47
+ mime-types (1.16)
48
+ net-ldap (0.1.1)
49
+ paperclip (2.3.8)
50
+ activerecord
51
+ activesupport
52
+ polyglot (0.3.1)
53
+ rack (1.2.1)
54
+ rack-mount (0.6.13)
55
+ rack (>= 1.0.0)
56
+ rack-test (0.5.6)
57
+ rack (>= 1.0)
58
+ rails (3.0.3)
59
+ actionmailer (= 3.0.3)
60
+ actionpack (= 3.0.3)
61
+ activerecord (= 3.0.3)
62
+ activeresource (= 3.0.3)
63
+ activesupport (= 3.0.3)
64
+ bundler (~> 1.0)
65
+ railties (= 3.0.3)
66
+ railties (3.0.3)
67
+ actionpack (= 3.0.3)
68
+ activesupport (= 3.0.3)
69
+ rake (>= 0.8.7)
70
+ thor (~> 0.14.4)
71
+ rake (0.8.7)
72
+ sqlite3 (1.3.3)
73
+ thor (0.14.6)
74
+ treetop (1.4.9)
75
+ polyglot (>= 0.3.1)
76
+ tzinfo (0.3.23)
77
+
78
+ PLATFORMS
79
+ ruby
80
+
81
+ DEPENDENCIES
82
+ active_link_to (>= 0.0.6)
83
+ jeweler (>= 1.4.0)
84
+ mime-types
85
+ net-ldap (>= 0.1.1)
86
+ paperclip (>= 2.3.8)
87
+ rails (>= 3.0.3)
88
+ sqlite3
data/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ Original Comfortable Mexican Sofa:
2
+ Copyright (c) 2010-2011 Oleg Khabarov, The Working Group Inc
3
+
4
+ LucyCMS:
5
+ Copyright (c) 2011 LucySoft
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ "Software"), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,161 @@
1
+ LucyCMS
2
+ ===================================
3
+
4
+ LucyCMS is a tiny and powerful Rails 3 CMS. This CMS is a plugin for your application, not the other way around. This allow's you to have one codebase for both your application and CMS.
5
+
6
+ It is based on [Comfortable Mexican Sofa](https://github.com/twg/comfortable-mexican-sofa) by Oleg Khabarov at [The Working Group Inc](http://www.twg.ca)
7
+
8
+ Installation
9
+ ------------
10
+ Add gem definition to your Gemfile:
11
+
12
+ gem 'lucy_cms'
13
+
14
+ Then from the Rails project's root run:
15
+
16
+ bundle install
17
+ rails g cms
18
+ rake db:migrate
19
+
20
+
21
+ Usage
22
+ -----
23
+ After finishing installation you should be able to navigate to http://yoursite/cms-admin
24
+
25
+ First you must setup the site. LucyCMS will ask you for a title for the site, the hostname, and if you want to authenticate via a local database or LDAP. If you choose LDAP, some further settings are needed.
26
+
27
+ After you set up your site, you must create one Admin User. After this user is created, LucyCMS will require you to login from here on out. Relogin as the user you just created and you can create more users.
28
+
29
+ Before creating pages and populating them with content you need to create a layout. A layout is the template of your pages; it defines some reusable content (like header and footer, for example) and places where the content goes. A very simple layout can look like this:
30
+
31
+ <html>
32
+ <body>
33
+ <h1>{{ cms:page:header:string }}</h1>
34
+ {{ cms:page:content:text }}
35
+ </body>
36
+ </html>
37
+
38
+ Once you have a layout, you may start creating pages and populating content. It's that easy.
39
+
40
+ Many options can be found and changed in the cms initializer: /config/initializers/LucyCMS.rb
41
+
42
+ CMS Tags
43
+ --------
44
+ There are a number of cms tags that define where the content goes and how it's populated. **Page** and **Field** tags are used during layout creation. **Snippet**, **Helper** and **Partial** tags can be peppered pretty much anywhere. Tag is structured like so:
45
+
46
+ {{ cms:page:content:text }}
47
+ \ \ \ \
48
+ \ \ \ ‾ tag format or extra attributes
49
+ \ \ ‾‾‾‾‾‾‾ label/slug/path for the tag,
50
+ \ ‾‾‾‾‾‾‾‾‾‾‾‾ tag type (page, field, snippet, helper, partial)
51
+ ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ cms tag identifier
52
+
53
+ Here's a number of tag variations:
54
+
55
+ # Page tags are pieces of text content that will get rendered on the page. Format defines how form field
56
+ # gets rendered in the page editing/creation section of the admin area.
57
+
58
+ {{ cms:page:some_label:text }}
59
+ {{ cms:page:some_label }} # shorthand for above. 'text' is default format for pages
60
+ {{ cms:page:some_label:string }} # in admin area text field is displayed instead of textarea
61
+ {{ cms:page:some_label:datetime }} # similarly, datetime widget in the admin area
62
+ {{ cms:page:some_label:integer }} # a number field
63
+ {{ cms:page:some_label:rich_text }} # TinyMCE wysiwyg editor will be used to edit this content
64
+
65
+ # Field tags are pieces of text content that are NOT rendered on the page. They can be accessed via
66
+ # your application's layout / helpers / partials etc. Useful for populating this like <meta> tags.
67
+ # Field formats are exactly the same as for Page tags.
68
+
69
+ {{ cms:field:some_label:string }}
70
+ {{ cms:field:some_label }} # same as above. 'string' is default format for fields
71
+
72
+ # Snippet tags are bits or reusable content that can be used anywhere. Imagine creating content like
73
+ # a sharing widget, or business address that you want to randomly use across your site.
74
+
75
+ {{ cms:snippet:some_label }}
76
+
77
+ # Helper is a wrapper for your regular helpers. Normally you cannot have IRB in CMS content, so there are
78
+ # tags that allow calling helpers and partials.
79
+
80
+ {{ cms:helper:method_name }} # same as <%= method_name() %>
81
+ {{ cms:helper:method_name:x:y:z }} # same as <%= method_name('x', 'y', 'z') %>
82
+
83
+ # Partial tags are wrappers just like above helper ones.
84
+
85
+ {{ cms:partial:path/to/partial }} # same as <%= render :partial => 'path/to/partial' %>
86
+ {{ cms:partial:path/to/partial:a:b }} # same as <%= render :partial => 'path/to/partial',
87
+ # :locals => { :param_1 => 'a', :param_1 => 'b' } %>
88
+
89
+ Uploads
90
+ -------
91
+ Uploads is where LucyCMS differs heavily from it's original code base at [Comfortable Mexican Sofa](https://github.com/twg/comfortable-mexican-sofa)
92
+
93
+ By default all uploads go into the public/common/ directory (although this can be changed in the /config/initializers/LucyCMS.rb file). From the uploads tab, you can now create subfolders and upload your content. This way you can add the common directory to your .gitignore file and your CMS content will not be affected by any canges in your code.
94
+
95
+ Integrating CMS with your app
96
+ -----------------------------
97
+ LucyCMS is a plugin, so it allows you to easily access content it manages. Here's some things you can do.
98
+
99
+ You can use CMS pages as regular views:
100
+
101
+ def show
102
+ @dinosaur = Dinosaur.find(params[:id])
103
+ # CMS page probably should have either helper or partial tag to display @dinosaur details
104
+ render :cms_page => '/dinosaur
105
+ end
106
+
107
+ Actually, you don't need to explicitly render a CMS page like that. LucyCMS will try to rescue a TemplateNotFound by providing a matching CMS page.
108
+
109
+ You can access **Page** or **Field** tag content directly from your application (layouts/helpers/partials) via `cms_page_content` method. This is how you can pull things like meta tags into your application layout.
110
+
111
+ # if @cms_page is available (meaning LucyCMS is doing the rendering)
112
+ cms_page_content(:page_or_field_label)
113
+
114
+ # anywhere else
115
+ cms_page_content(:page_or_field_label, CmsPage.find_by_slug(...))
116
+
117
+ Similarly you can access **Snippet** content:
118
+
119
+ cms_snippet_content(:snippet_slug)
120
+
121
+ Extending Admin Area
122
+ --------------------
123
+
124
+ If you wish, you can re-use LucyCMS's admin area for things you need to administer in your application. To do this, first you will need to make your admin controllers to inherit from CmsAdmin::BaseController. This way, your admin views will be using LucyCMS's admin layout and it's Authentication.
125
+
126
+ class Admin::CategoriesController < CmsAdmin::BaseController
127
+ # your code goes here
128
+ end
129
+
130
+ Working with seeds
131
+ ------------------
132
+ LucyCMS has seeds, functionality that helps manage content during development phase. It's very different from Rails seeds as LucyCMS's seeds are loaded with each page load. The database is completely bypassed when seeds are active. This way, you can source-control content before going live, disabling seeds and dumping everything into the database.
133
+
134
+ First, you will need to set a path where fixture files will be found (inside LucyCMS's initializer):
135
+
136
+ if Rails.env.development? || Rails.env.test?
137
+ LucyCMS.config.seed_data_path = File.expand_path('db/cms_seeds', Rails.root)
138
+ end
139
+
140
+ If you ran `rails g cms`, you should find an example set of seeds in /db/cms\_seeds directory. Please note that seeds are nested in the folder that is the hostname of your site. Each file is an YAML representation of a database entry for that layout/page/snippet.
141
+
142
+ There's a rake task that makes moving seeds into database (and vice-versa) easy:
143
+
144
+ # from seeds into database
145
+ rake LucyCMS:import:all FROM=your-site.local TO=your-site.com SEED_PATH=/path/to/seeds
146
+
147
+ # from database to seeds
148
+ rake LucyCMS:export:all FROM=your-site.com TO=your-site.local SEED_PATH=/path/to/seeds
149
+
150
+ Active Components
151
+ -----------------
152
+ LucyCMS utilizes the following:
153
+
154
+ * **[https://github.com/rails/rails](https://github.com/rails/rails)** - Ruby on Rails 3.*, of course
155
+ * **[https://github.com/thoughtbot/paperclip](https://github.com/thoughtbot/paperclip)** - Paperclip to handle file uploads
156
+ * **[https://github.com/twg/active_link_to](https://github.com/twg/active_link_to)** - Easy method to handle logic behind 'active' links
157
+
158
+ * * *
159
+
160
+ LucyCMS is released under the MIT licence
161
+ ComfortableMexicanSofa is released under the [MIT license](https://github.com/twg/comfortable-mexican-sofa/raw/master/LICENSE)
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+ require 'rubygems'
6
+ require 'rake'
7
+
8
+ LucyCMS::Application.load_tasks
9
+
10
+ begin
11
+ require 'jeweler'
12
+ Jeweler::Tasks.new do |gem|
13
+ gem.name = 'lucy_cms'
14
+ gem.summary = 'LucyCMS is a Rails 3 CMS that lives inside your Rails App, but does not interfere with it'
15
+ gem.description = ''
16
+ gem.email = 'lucy@lucysoft.com'
17
+ gem.authors = ['Lucysoft']
18
+ gem.add_dependency('rails', '>=3.0.3')
19
+ gem.add_dependency('active_link_to', '>=0.0.6')
20
+ gem.add_dependency('paperclip', '>=2.3.8')
21
+ gem.add_dependency('net-ldap', '>=0.1.1')
22
+ end
23
+ Jeweler::GemcutterTasks.new
24
+ rescue LoadError
25
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
26
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+
3
+ protect_from_forgery
4
+
5
+ end
@@ -0,0 +1,43 @@
1
+ class CmsAdmin::BaseController < ActionController::Base
2
+
3
+ protect_from_forgery
4
+
5
+ before_filter :fetch_cms_logged_in_user,
6
+ :load_admin_cms_site
7
+
8
+ unless CmsSite.count == 0 || CmsUser.find(:all, :conditions => {:admin => true, :disabled => false}).count == 0
9
+ before_filter :cms_login_required
10
+ end
11
+ layout 'cms_admin'
12
+
13
+ protected
14
+
15
+ def load_admin_cms_site
16
+ if CmsSite.count == 0
17
+ flash[:error] = 'To start you must setup your site'
18
+ redirect_to new_cms_admin_site_path
19
+ else
20
+ @cms_site = CmsSite.first
21
+ if @cms_site.version < LucyCMS.config.version
22
+ @cms_site.version = LucyCMS.config.version
23
+ @cms_site.save
24
+ end
25
+ end
26
+ end
27
+
28
+ def fetch_cms_logged_in_user
29
+ return unless session[:cms_user_id]
30
+ @cms_current_user = CmsUser.find_by_id(session[:cms_user_id])
31
+ end
32
+
33
+ def cms_logged_in?
34
+ ! @cms_current_user.nil?
35
+ end
36
+
37
+ helper_method :cms_logged_in?
38
+
39
+ def cms_login_required
40
+ return true if cms_logged_in?
41
+ redirect_to new_cms_admin_session_path and return false
42
+ end
43
+ end
@@ -0,0 +1,66 @@
1
+ class CmsAdmin::LayoutsController < CmsAdmin::BaseController
2
+
3
+ before_filter :check_for_admin
4
+ before_filter :build_cms_layout, :only => [:new, :create]
5
+ before_filter :load_cms_layout, :only => [:edit, :update, :destroy]
6
+
7
+ def index
8
+ return redirect_to :action => :new if @cms_site.cms_layouts.count == 0
9
+ @cms_layouts = @cms_site.cms_layouts.roots
10
+ end
11
+
12
+ def new
13
+ render
14
+ end
15
+
16
+ def edit
17
+ render
18
+ end
19
+
20
+ def create
21
+ @cms_layout.save!
22
+ flash[:notice] = 'Layout created'
23
+ redirect_to :action => :index
24
+ rescue ActiveRecord::RecordInvalid
25
+ flash.now[:error] = 'Failed to create layout'
26
+ render :action => :new
27
+ end
28
+
29
+ def update
30
+ @cms_layout.update_attributes!(params[:cms_layout])
31
+ flash[:notice] = 'Layout updated'
32
+ redirect_to :action => :index
33
+ rescue ActiveRecord::RecordInvalid
34
+ flash.now[:error] = 'Failed to update layout'
35
+ render :action => :edit
36
+ end
37
+
38
+ def destroy
39
+ @cms_layout.destroy
40
+ flash[:notice] = 'Layout deleted'
41
+ redirect_to :action => :index
42
+ end
43
+
44
+ protected
45
+
46
+ def check_for_admin
47
+ if CmsUser.find_by_admin_and_disabled(true,false).nil?
48
+ flash[:error] = 'You must create one Active Admin User to continue'
49
+ redirect_to new_cms_admin_user_path
50
+ end
51
+ end
52
+
53
+ def build_cms_layout
54
+ @cms_layout = @cms_site.cms_layouts.new(params[:cms_layout])
55
+ @cms_layout.parent ||= CmsLayout.find_by_id(params[:parent_id])
56
+ @cms_layout.content ||= '{{ cms:page:content:text }}'
57
+ end
58
+
59
+ def load_cms_layout
60
+ @cms_layout = @cms_site.cms_layouts.find(params[:id])
61
+ rescue ActiveRecord::RecordNotFound
62
+ flash[:error] = 'Layout not found'
63
+ redirect_to :action => :index
64
+ end
65
+
66
+ end
@@ -0,0 +1,111 @@
1
+ class CmsAdmin::PagesController < CmsAdmin::BaseController
2
+
3
+ before_filter :check_for_admin
4
+ before_filter :check_for_layouts, :only => [:new, :edit]
5
+ before_filter :build_cms_page, :only => [:new, :create]
6
+ before_filter :load_cms_page, :only => [:edit, :update, :destroy]
7
+ before_filter :preview_cms_page, :only => [:create, :update]
8
+ before_filter :build_upload_file, :only => [:new, :edit]
9
+
10
+ def index
11
+ return redirect_to :action => :new if @cms_site.cms_pages.count == 0
12
+ @cms_pages = [@cms_site.cms_pages.root].compact
13
+ end
14
+
15
+ def new
16
+ render
17
+ end
18
+
19
+ def edit
20
+ render
21
+ end
22
+
23
+ def create
24
+ @cms_page.save!
25
+ flash[:notice] = 'Page saved'
26
+ redirect_to :action => :index
27
+ rescue ActiveRecord::RecordInvalid
28
+ flash.now[:error] = 'Failed to create page'
29
+ render :action => :new
30
+ end
31
+
32
+ def update
33
+ @cms_page.save!
34
+ flash[:notice] = 'Page updated'
35
+ redirect_to :action => :index
36
+ rescue ActiveRecord::RecordInvalid
37
+ flash.now[:error] = 'Failed to update page'
38
+ render :action => :index
39
+ end
40
+
41
+ def destroy
42
+ @cms_page.destroy
43
+ flash[:notice] = 'Page deleted'
44
+ redirect_to :action => :index
45
+ end
46
+
47
+ def form_blocks
48
+ @cms_page = @cms_site.cms_pages.find_by_id(params[:id]) || CmsPage.new
49
+ @cms_page.cms_layout = @cms_site.cms_layouts.find_by_id(params[:layout_id])
50
+ end
51
+
52
+ def toggle_branch
53
+ @cms_page = @cms_site.cms_pages.find(params[:id])
54
+ s = (session[:cms_page_tree] ||= [])
55
+ id = @cms_page.id.to_s
56
+ s.member?(id) ? s.delete(id) : s << id
57
+ rescue ActiveRecord::RecordNotFound
58
+ # do nothing
59
+ end
60
+
61
+ def reorder
62
+ (params[:cms_page] || []).each_with_index do |id, index|
63
+ if (cms_page = CmsPage.find_by_id(id))
64
+ cms_page.update_attribute(:position, index)
65
+ end
66
+ end
67
+ render :nothing => true
68
+ end
69
+
70
+ protected
71
+
72
+ def check_for_admin
73
+ if CmsUser.find_by_admin_and_disabled(true,false).nil?
74
+ flash[:error] = 'You must create one Active Admin User to continue'
75
+ redirect_to new_cms_admin_user_path
76
+ end
77
+ end
78
+
79
+ def check_for_layouts
80
+ if CmsLayout.count == 0
81
+ flash[:error] = 'No Layouts found. Please create one.'
82
+ redirect_to new_cms_admin_layout_path
83
+ end
84
+ end
85
+
86
+ def build_cms_page
87
+ @cms_page = @cms_site.cms_pages.new(params[:cms_page])
88
+ @cms_page.parent ||= (CmsPage.find_by_id(params[:parent_id]) || @cms_site.cms_pages.root)
89
+ @cms_page.cms_layout ||= (@cms_page.parent && @cms_page.parent.cms_layout || @cms_site.cms_layouts.first)
90
+ end
91
+
92
+ def build_upload_file
93
+ @upload = CmsUpload.new
94
+ end
95
+
96
+ def load_cms_page
97
+ @cms_page = @cms_site.cms_pages.find(params[:id])
98
+ @cms_page.attributes = params[:cms_page]
99
+ @cms_page.cms_layout ||= (@cms_page.parent && @cms_page.parent.cms_layout || @cms_site.cms_layouts.first)
100
+ rescue ActiveRecord::RecordNotFound
101
+ flash[:error] = 'Page not found'
102
+ redirect_to :action => :index
103
+ end
104
+
105
+ def preview_cms_page
106
+ if params[:preview]
107
+ layout = @cms_page.cms_layout.app_layout.blank?? false : @cms_page.cms_layout.app_layout
108
+ render :inline => @cms_page.content(true), :layout => layout
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,25 @@
1
+ class CmsAdmin::SessionsController < CmsAdmin::BaseController
2
+
3
+ skip_before_filter :cms_login_required
4
+
5
+ def new
6
+ @cms_user = CmsUser.new
7
+ end
8
+
9
+ def create
10
+ @cms_current_user = CmsUser.authenticate(params[:login], params[:password])
11
+ if @cms_current_user
12
+ session[:cms_user_id] = @cms_current_user.id
13
+ redirect_to cms_admin_pages_path
14
+ else
15
+ flash[:error] = 'Incorrect Login or Password'
16
+ render :action => :new
17
+ end
18
+ end
19
+
20
+ def destroy
21
+ session[:cms_user_id] = @cms_current_user = nil
22
+ redirect_to :action => :new
23
+ end
24
+
25
+ end
@@ -0,0 +1,69 @@
1
+ class CmsAdmin::SitesController < CmsAdmin::BaseController
2
+
3
+ skip_before_filter :load_admin_cms_site, :only => [:new, :create]
4
+ before_filter :check_admin, :except => [:new, :create, :setup]
5
+
6
+ def new
7
+ if CmsSite.count > 0
8
+ flash[:error] = 'You can only have one site'
9
+ redirect_to :action => :edit
10
+ else
11
+ @cms_site = CmsSite.new
12
+ render
13
+ end
14
+ end
15
+
16
+ def edit
17
+ render
18
+ end
19
+
20
+ def create
21
+ @cms_site = CmsSite.new(params[:cms_site])
22
+ if @cms_site.authentication != 'LDAP'
23
+ @cms_site.ldap_hostname = ''
24
+ @cms_site.ldap_base_DN = ''
25
+ @cms_site.ldap_uid = ''
26
+ end
27
+ if @cms_site.save
28
+ redirect_to :controller => 'cms_admin/pages', :action => :new
29
+ else
30
+ flash[:error] = 'Not able to save setup'
31
+ render :action => :new
32
+ end
33
+ end
34
+
35
+ def update
36
+ @cms_site.update_attributes(params[:cms_site])
37
+ if @cms_site.authentication != 'LDAP'
38
+ @cms_site.ldap_hostname = ''
39
+ @cms_site.ldap_base_DN = ''
40
+ end
41
+ if @cms_site.save
42
+ flash[:notice] = 'Site updated'
43
+ redirect_to :action => :edit, :id => @cms_site
44
+ else
45
+ flash.now[:error] = 'Failed to update site'
46
+ render :action => :edit
47
+ end
48
+ end
49
+
50
+ def destroy
51
+ @cms_site.destroy
52
+ flash[:notice] = 'Site deleted'
53
+ redirect_to :action => :index
54
+ end
55
+
56
+ def blank
57
+ render
58
+ end
59
+
60
+ protected
61
+
62
+ def check_admin
63
+ if ! CmsUser.find_by_id(session[:cms_user_id]).admin?
64
+ flash[:error] = 'You must be an Admin to change the Setup'
65
+ redirect_to :action => 'setup'
66
+ end
67
+ end
68
+
69
+ end