comfypress 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (289) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.travis.yml +22 -0
  4. data/Gemfile +22 -0
  5. data/Gemfile.lock +175 -0
  6. data/LICENSE +20 -0
  7. data/README.md +79 -0
  8. data/Rakefile +5 -0
  9. data/app/assets/images/comfypress/arrow_bottom.gif +0 -0
  10. data/app/assets/images/comfypress/arrow_right.gif +0 -0
  11. data/app/assets/images/comfypress/bootstrap/glyphicons-halflings-white.png +0 -0
  12. data/app/assets/images/comfypress/bootstrap/glyphicons-halflings.png +0 -0
  13. data/app/assets/images/comfypress/checkerboard.gif +0 -0
  14. data/app/assets/images/comfypress/icon_draft.gif +0 -0
  15. data/app/assets/images/comfypress/icon_file.gif +0 -0
  16. data/app/assets/images/comfypress/icon_layout.gif +0 -0
  17. data/app/assets/images/comfypress/icon_move.gif +0 -0
  18. data/app/assets/images/comfypress/icon_page.gif +0 -0
  19. data/app/assets/images/comfypress/icon_site.gif +0 -0
  20. data/app/assets/images/comfypress/icon_snippet.gif +0 -0
  21. data/app/assets/images/comfypress/nav_arrow.png +0 -0
  22. data/app/assets/javascripts/comfypress/admin/application.js +1 -0
  23. data/app/assets/javascripts/comfypress/application.js.coffee +175 -0
  24. data/app/assets/javascripts/comfypress/lib/bootstrap-datetimepicker.js +21 -0
  25. data/app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js +492 -0
  26. data/app/assets/javascripts/comfypress/lib/bootstrap.js +6 -0
  27. data/app/assets/javascripts/comfypress/lib/codemirror.js +10 -0
  28. data/app/assets/javascripts/comfypress/lib/wysihtml5.js +261 -0
  29. data/app/assets/stylesheets/comfypress/admin/application.css +1 -0
  30. data/app/assets/stylesheets/comfypress/application.css.sass +8 -0
  31. data/app/assets/stylesheets/comfypress/base.css.sass +333 -0
  32. data/app/assets/stylesheets/comfypress/bootstrap_overrides.css.sass +45 -0
  33. data/app/assets/stylesheets/comfypress/codemirror_overrides.css.sass +27 -0
  34. data/app/assets/stylesheets/comfypress/lib/bootstrap-datetimepicker.css +9 -0
  35. data/app/assets/stylesheets/comfypress/lib/bootstrap-wysihtml5.css +102 -0
  36. data/app/assets/stylesheets/comfypress/lib/bootstrap.css +9 -0
  37. data/app/assets/stylesheets/comfypress/lib/codemirror.css +240 -0
  38. data/app/assets/stylesheets/comfypress/wysihtml5_overrides.css.sass +5 -0
  39. data/app/controllers/application_controller.rb +5 -0
  40. data/app/controllers/cms_admin/base_controller.rb +51 -0
  41. data/app/controllers/cms_admin/categories_controller.rb +35 -0
  42. data/app/controllers/cms_admin/files_controller.rb +108 -0
  43. data/app/controllers/cms_admin/layouts_controller.rb +67 -0
  44. data/app/controllers/cms_admin/menu_items_controller.rb +65 -0
  45. data/app/controllers/cms_admin/menus_controller.rb +60 -0
  46. data/app/controllers/cms_admin/pages_controller.rb +112 -0
  47. data/app/controllers/cms_admin/revisions_controller.rb +57 -0
  48. data/app/controllers/cms_admin/sites_controller.rb +64 -0
  49. data/app/controllers/cms_admin/snippets_controller.rb +64 -0
  50. data/app/controllers/cms_content_controller.rb +79 -0
  51. data/app/helpers/application_helper.rb +16 -0
  52. data/app/models/cms/block.rb +48 -0
  53. data/app/models/cms/categorization.rb +21 -0
  54. data/app/models/cms/category.rb +30 -0
  55. data/app/models/cms/file.rb +75 -0
  56. data/app/models/cms/layout.rb +99 -0
  57. data/app/models/cms/menu.rb +26 -0
  58. data/app/models/cms/menu_item.rb +14 -0
  59. data/app/models/cms/page.rb +202 -0
  60. data/app/models/cms/revision.rb +17 -0
  61. data/app/models/cms/site.rb +113 -0
  62. data/app/models/cms/snippet.rb +58 -0
  63. data/app/models/cms.rb +5 -0
  64. data/app/views/cms_admin/categories/_categories.html.haml +3 -0
  65. data/app/views/cms_admin/categories/_edit.html.haml +6 -0
  66. data/app/views/cms_admin/categories/_form.html.haml +8 -0
  67. data/app/views/cms_admin/categories/_index.html.haml +24 -0
  68. data/app/views/cms_admin/categories/_show.html.haml +13 -0
  69. data/app/views/cms_admin/categories/create.js.erb +7 -0
  70. data/app/views/cms_admin/categories/destroy.js.erb +3 -0
  71. data/app/views/cms_admin/categories/edit.js.erb +3 -0
  72. data/app/views/cms_admin/categories/update.js.erb +6 -0
  73. data/app/views/cms_admin/files/_file.html.haml +13 -0
  74. data/app/views/cms_admin/files/_form.html.haml +14 -0
  75. data/app/views/cms_admin/files/_index.html.haml +14 -0
  76. data/app/views/cms_admin/files/_page_form.html.haml +9 -0
  77. data/app/views/cms_admin/files/destroy.js.coffee +2 -0
  78. data/app/views/cms_admin/files/edit.html.haml +5 -0
  79. data/app/views/cms_admin/files/index.html.haml +28 -0
  80. data/app/views/cms_admin/files/new.html.haml +5 -0
  81. data/app/views/cms_admin/layouts/_form.html.haml +17 -0
  82. data/app/views/cms_admin/layouts/_index_branch.html.haml +23 -0
  83. data/app/views/cms_admin/layouts/edit.html.haml +9 -0
  84. data/app/views/cms_admin/layouts/index.html.haml +9 -0
  85. data/app/views/cms_admin/layouts/new.html.haml +5 -0
  86. data/app/views/cms_admin/menu_items/_form.html.haml +22 -0
  87. data/app/views/cms_admin/menu_items/edit.html.haml +8 -0
  88. data/app/views/cms_admin/menu_items/index.html.haml +24 -0
  89. data/app/views/cms_admin/menu_items/new.html.haml +5 -0
  90. data/app/views/cms_admin/menus/_form.html.haml +8 -0
  91. data/app/views/cms_admin/menus/edit.html.haml +8 -0
  92. data/app/views/cms_admin/menus/index.html.haml +24 -0
  93. data/app/views/cms_admin/menus/new.html.haml +5 -0
  94. data/app/views/cms_admin/pages/_form.html.haml +38 -0
  95. data/app/views/cms_admin/pages/_form_blocks.html.haml +28 -0
  96. data/app/views/cms_admin/pages/_index_branch.html.haml +35 -0
  97. data/app/views/cms_admin/pages/edit.html.haml +9 -0
  98. data/app/views/cms_admin/pages/form_blocks.js.erb +2 -0
  99. data/app/views/cms_admin/pages/index.html.haml +11 -0
  100. data/app/views/cms_admin/pages/new.html.haml +5 -0
  101. data/app/views/cms_admin/pages/toggle_branch.js.erb +11 -0
  102. data/app/views/cms_admin/revisions/show.html.haml +28 -0
  103. data/app/views/cms_admin/sites/_form.html.haml +14 -0
  104. data/app/views/cms_admin/sites/_mirrors.html.haml +17 -0
  105. data/app/views/cms_admin/sites/edit.html.haml +5 -0
  106. data/app/views/cms_admin/sites/index.html.haml +24 -0
  107. data/app/views/cms_admin/sites/new.html.haml +5 -0
  108. data/app/views/cms_admin/snippets/_form.html.haml +11 -0
  109. data/app/views/cms_admin/snippets/edit.html.haml +9 -0
  110. data/app/views/cms_admin/snippets/index.html.haml +28 -0
  111. data/app/views/cms_admin/snippets/new.html.haml +5 -0
  112. data/app/views/cms_content/_menu.html.haml +5 -0
  113. data/app/views/cms_content/render_sitemap.xml.builder +15 -0
  114. data/app/views/layouts/cms_admin/_body.html.haml +16 -0
  115. data/app/views/layouts/cms_admin/_center.html.haml +7 -0
  116. data/app/views/layouts/cms_admin/_footer.html.haml +3 -0
  117. data/app/views/layouts/cms_admin/_footer_js.html.haml +7 -0
  118. data/app/views/layouts/cms_admin/_head.html.haml +12 -0
  119. data/app/views/layouts/cms_admin/_left.html.haml +11 -0
  120. data/app/views/layouts/cms_admin/_right.html.haml +1 -0
  121. data/app/views/layouts/cms_admin.html.haml +4 -0
  122. data/comfypress.gemspec +28 -0
  123. data/config/application.rb +69 -0
  124. data/config/boot.rb +6 -0
  125. data/config/database.sqlite.yml +47 -0
  126. data/config/database.yml +47 -0
  127. data/config/environment.rb +5 -0
  128. data/config/environments/development.rb +39 -0
  129. data/config/environments/production.rb +67 -0
  130. data/config/environments/test.rb +39 -0
  131. data/config/initializers/comfypress.rb +100 -0
  132. data/config/initializers/paperclip.rb +3 -0
  133. data/config/locales/de.yml +236 -0
  134. data/config/locales/en.yml +285 -0
  135. data/config/locales/es.yml +236 -0
  136. data/config/locales/fr.yml +236 -0
  137. data/config/locales/ja.yml +237 -0
  138. data/config/locales/pl.yml +236 -0
  139. data/config/locales/pt-BR.yml +236 -0
  140. data/config/locales/ru.yml +236 -0
  141. data/config/locales/sv.yml +236 -0
  142. data/config/locales/zh-CN.yml +236 -0
  143. data/config/routes.rb +10 -0
  144. data/config.ru +4 -0
  145. data/db/cms_fixtures/sample-site/layouts/default/_default.yml +1 -0
  146. data/db/cms_fixtures/sample-site/layouts/default/content.html +5 -0
  147. data/db/cms_fixtures/sample-site/layouts/default/css.css +1 -0
  148. data/db/cms_fixtures/sample-site/layouts/default/js.js +1 -0
  149. data/db/cms_fixtures/sample-site/layouts/default/nested/_nested.yml +2 -0
  150. data/db/cms_fixtures/sample-site/layouts/default/nested/content.html +2 -0
  151. data/db/cms_fixtures/sample-site/layouts/default/nested/css.css +1 -0
  152. data/db/cms_fixtures/sample-site/layouts/default/nested/js.js +1 -0
  153. data/db/cms_fixtures/sample-site/pages/index/_index.yml +2 -0
  154. data/db/cms_fixtures/sample-site/pages/index/child/_child.yml +3 -0
  155. data/db/cms_fixtures/sample-site/pages/index/child/left.html +1 -0
  156. data/db/cms_fixtures/sample-site/pages/index/child/right.html +1 -0
  157. data/db/cms_fixtures/sample-site/pages/index/content.html +2 -0
  158. data/db/cms_fixtures/sample-site/snippets/default/_default.yml +1 -0
  159. data/db/cms_fixtures/sample-site/snippets/default/content.html +1 -0
  160. data/db/migrate/01_create_cms.rb +163 -0
  161. data/db/seeds.rb +9 -0
  162. data/db/upgrade_migrations/02_upgrade_to_1_1_0.rb +19 -0
  163. data/db/upgrade_migrations/03_upgrade_to_1_2_0.rb +15 -0
  164. data/db/upgrade_migrations/04_upgrade_to_1_3_0.rb +23 -0
  165. data/db/upgrade_migrations/05_upgrade_to_1_4_0.rb +33 -0
  166. data/db/upgrade_migrations/06_upgrade_to_1_5_0.rb +21 -0
  167. data/db/upgrade_migrations/07_upgrade_to_1_6_0.rb +25 -0
  168. data/doc/preview.png +0 -0
  169. data/doc/sofa.png +0 -0
  170. data/lib/comfypress/authentication/dummy_auth.rb +8 -0
  171. data/lib/comfypress/authentication/http_auth.rb +18 -0
  172. data/lib/comfypress/configuration.rb +99 -0
  173. data/lib/comfypress/engine.rb +18 -0
  174. data/lib/comfypress/error.rb +24 -0
  175. data/lib/comfypress/extensions/acts_as_tree.rb +102 -0
  176. data/lib/comfypress/extensions/has_revisions.rb +64 -0
  177. data/lib/comfypress/extensions/is_categorized.rb +49 -0
  178. data/lib/comfypress/extensions/is_mirrored.rb +85 -0
  179. data/lib/comfypress/extensions/rails.rb +24 -0
  180. data/lib/comfypress/fixtures.rb +289 -0
  181. data/lib/comfypress/form_builder.rb +97 -0
  182. data/lib/comfypress/render_methods.rb +85 -0
  183. data/lib/comfypress/routing.rb +62 -0
  184. data/lib/comfypress/sitemap.rb +27 -0
  185. data/lib/comfypress/tag.rb +154 -0
  186. data/lib/comfypress/tags/asset.rb +25 -0
  187. data/lib/comfypress/tags/collection.rb +64 -0
  188. data/lib/comfypress/tags/field_datetime.rb +17 -0
  189. data/lib/comfypress/tags/field_integer.rb +17 -0
  190. data/lib/comfypress/tags/field_rich_text.rb +17 -0
  191. data/lib/comfypress/tags/field_string.rb +17 -0
  192. data/lib/comfypress/tags/field_text.rb +17 -0
  193. data/lib/comfypress/tags/file.rb +29 -0
  194. data/lib/comfypress/tags/helper.rb +24 -0
  195. data/lib/comfypress/tags/menu.rb +27 -0
  196. data/lib/comfypress/tags/page_datetime.rb +13 -0
  197. data/lib/comfypress/tags/page_file.rb +51 -0
  198. data/lib/comfypress/tags/page_files.rb +52 -0
  199. data/lib/comfypress/tags/page_integer.rb +13 -0
  200. data/lib/comfypress/tags/page_markdown.rb +22 -0
  201. data/lib/comfypress/tags/page_rich_text.rb +13 -0
  202. data/lib/comfypress/tags/page_string.rb +13 -0
  203. data/lib/comfypress/tags/page_text.rb +13 -0
  204. data/lib/comfypress/tags/partial.rb +23 -0
  205. data/lib/comfypress/tags/snippet.rb +19 -0
  206. data/lib/comfypress/version.rb +3 -0
  207. data/lib/comfypress/view_hooks.rb +32 -0
  208. data/lib/comfypress/view_methods.rb +52 -0
  209. data/lib/comfypress.rb +66 -0
  210. data/lib/generators/comfy/cms/README +10 -0
  211. data/lib/generators/comfy/cms/cms_generator.rb +57 -0
  212. data/lib/tasks/comfypress.rake +45 -0
  213. data/script/rails +6 -0
  214. data/test/fixtures/cms/blocks.yml +12 -0
  215. data/test/fixtures/cms/categories.yml +4 -0
  216. data/test/fixtures/cms/categorizations.yml +3 -0
  217. data/test/fixtures/cms/files.yml +9 -0
  218. data/test/fixtures/cms/layouts.yml +40 -0
  219. data/test/fixtures/cms/menu_items.yml +15 -0
  220. data/test/fixtures/cms/menus.yml +9 -0
  221. data/test/fixtures/cms/pages.yml +39 -0
  222. data/test/fixtures/cms/revisions.yml +21 -0
  223. data/test/fixtures/cms/sites.yml +6 -0
  224. data/test/fixtures/cms/snippets.yml +6 -0
  225. data/test/fixtures/files/data.zip +0 -0
  226. data/test/fixtures/files/document.pdf +0 -0
  227. data/test/fixtures/files/image.gif +0 -0
  228. data/test/fixtures/files/image.jpg +0 -0
  229. data/test/fixtures/views/_nav_hook.html.erb +1 -0
  230. data/test/fixtures/views/_nav_hook_2.html.erb +1 -0
  231. data/test/fixtures/views/render_test/_test.html.erb +1 -0
  232. data/test/fixtures/views/render_test/new.html.erb +1 -0
  233. data/test/fixtures/views/render_test/render_layout.html.erb +1 -0
  234. data/test/functional/cms_admin/base_controller_test.rb +18 -0
  235. data/test/functional/cms_admin/categories_controller_test.rb +70 -0
  236. data/test/functional/cms_admin/files_controller_test.rb +216 -0
  237. data/test/functional/cms_admin/layouts_controller_test.rb +123 -0
  238. data/test/functional/cms_admin/pages_controller_test.rb +450 -0
  239. data/test/functional/cms_admin/revisions_controller_test.rb +138 -0
  240. data/test/functional/cms_admin/sites_controller_test.rb +105 -0
  241. data/test/functional/cms_admin/snippets_controller_test.rb +140 -0
  242. data/test/functional/cms_content_controller_test.rb +205 -0
  243. data/test/gemfiles/Gemfile.rails.3.1 +16 -0
  244. data/test/gemfiles/Gemfile.rails.3.2 +16 -0
  245. data/test/gemfiles/Gemfile.rails.4.0 +16 -0
  246. data/test/integration/authentication_test.rb +48 -0
  247. data/test/integration/fixtures_test.rb +61 -0
  248. data/test/integration/mirrors_test.rb +72 -0
  249. data/test/integration/render_cms_test.rb +233 -0
  250. data/test/integration/sites_test.rb +120 -0
  251. data/test/integration/view_hooks_test.rb +43 -0
  252. data/test/test_helper.rb +124 -0
  253. data/test/unit/cms/menu_item_test.rb +7 -0
  254. data/test/unit/cms/menu_test.rb +7 -0
  255. data/test/unit/configuration_test.rb +42 -0
  256. data/test/unit/fixtures_test.rb +357 -0
  257. data/test/unit/mirrors_test.rb +242 -0
  258. data/test/unit/models/block_test.rb +199 -0
  259. data/test/unit/models/categorization_test.rb +76 -0
  260. data/test/unit/models/category_test.rb +39 -0
  261. data/test/unit/models/file_test.rb +89 -0
  262. data/test/unit/models/layout_test.rb +125 -0
  263. data/test/unit/models/page_test.rb +255 -0
  264. data/test/unit/models/site_test.rb +152 -0
  265. data/test/unit/models/snippet_test.rb +49 -0
  266. data/test/unit/revisions_test.rb +185 -0
  267. data/test/unit/sitemap_test.rb +20 -0
  268. data/test/unit/tag_test.rb +308 -0
  269. data/test/unit/tags/asset_test.rb +56 -0
  270. data/test/unit/tags/collection_test.rb +116 -0
  271. data/test/unit/tags/field_datetime_test.rb +50 -0
  272. data/test/unit/tags/field_integer_test.rb +49 -0
  273. data/test/unit/tags/field_rich_text_test.rb +49 -0
  274. data/test/unit/tags/field_string_test.rb +52 -0
  275. data/test/unit/tags/field_text_test.rb +48 -0
  276. data/test/unit/tags/file_test.rb +67 -0
  277. data/test/unit/tags/helper_test.rb +86 -0
  278. data/test/unit/tags/page_datetime_test.rb +50 -0
  279. data/test/unit/tags/page_file_test.rb +119 -0
  280. data/test/unit/tags/page_files_test.rb +113 -0
  281. data/test/unit/tags/page_integer_test.rb +49 -0
  282. data/test/unit/tags/page_markdown_test.rb +48 -0
  283. data/test/unit/tags/page_rich_text_test.rb +49 -0
  284. data/test/unit/tags/page_string_test.rb +49 -0
  285. data/test/unit/tags/page_text_test.rb +52 -0
  286. data/test/unit/tags/partial_test.rb +76 -0
  287. data/test/unit/tags/snippet_test.rb +45 -0
  288. data/test/unit/view_methods_test.rb +80 -0
  289. metadata +457 -0
@@ -0,0 +1,163 @@
1
+ class CreateCms < ActiveRecord::Migration
2
+
3
+ def self.up
4
+
5
+ text_limit = case ActiveRecord::Base.connection.adapter_name
6
+ when 'PostgreSQL'
7
+ { }
8
+ else
9
+ { :limit => 16777215 }
10
+ end
11
+
12
+ # -- Sites --------------------------------------------------------------
13
+ create_table :cms_sites do |t|
14
+ t.string :label, :null => false
15
+ t.string :identifier, :null => false
16
+ t.string :hostname, :null => false
17
+ t.string :path
18
+ t.string :locale, :null => false, :default => 'en'
19
+ t.boolean :is_mirrored, :null => false, :default => false
20
+ t.integer :menu_id
21
+ end
22
+ add_index :cms_sites, :hostname
23
+ add_index :cms_sites, :is_mirrored
24
+
25
+ # -- Layouts ------------------------------------------------------------
26
+ create_table :cms_layouts do |t|
27
+ t.integer :site_id, :null => false
28
+ t.integer :parent_id
29
+ t.string :app_layout
30
+ t.string :label, :null => false
31
+ t.string :identifier, :null => false
32
+ t.text :content, text_limit
33
+ t.text :css, text_limit
34
+ t.text :js, text_limit
35
+ t.integer :position, :null => false, :default => 0
36
+ t.boolean :is_shared, :null => false, :default => false
37
+ t.timestamps
38
+ end
39
+ add_index :cms_layouts, [:parent_id, :position]
40
+ add_index :cms_layouts, [:site_id, :identifier], :unique => true
41
+
42
+ # -- Pages --------------------------------------------------------------
43
+ create_table :cms_pages do |t|
44
+ t.integer :site_id, :null => false
45
+ t.integer :layout_id
46
+ t.integer :parent_id
47
+ t.integer :target_page_id
48
+ t.string :label, :null => false
49
+ t.string :slug
50
+ t.string :full_path, :null => false
51
+ t.text :content, text_limit
52
+ t.integer :position, :null => false, :default => 0
53
+ t.integer :children_count, :null => false, :default => 0
54
+ t.boolean :is_published, :null => false, :default => true
55
+ t.boolean :is_shared, :null => false, :default => false
56
+ t.integer :menu_id
57
+ t.timestamps
58
+ end
59
+ add_index :cms_pages, [:site_id, :full_path]
60
+ add_index :cms_pages, [:parent_id, :position]
61
+
62
+ # -- Page Blocks --------------------------------------------------------
63
+ create_table :cms_blocks do |t|
64
+ t.integer :page_id, :null => false
65
+ t.string :identifier, :null => false
66
+ t.text :content, text_limit
67
+ t.timestamps
68
+ end
69
+ add_index :cms_blocks, [:page_id, :identifier]
70
+
71
+ # -- Snippets -----------------------------------------------------------
72
+ create_table :cms_snippets do |t|
73
+ t.integer :site_id, :null => false
74
+ t.string :label, :null => false
75
+ t.string :identifier, :null => false
76
+ t.text :content, text_limit
77
+ t.integer :position, :null => false, :default => 0
78
+ t.boolean :is_shared, :null => false, :default => false
79
+ t.timestamps
80
+ end
81
+ add_index :cms_snippets, [:site_id, :identifier], :unique => true
82
+ add_index :cms_snippets, [:site_id, :position]
83
+
84
+ # -- Files --------------------------------------------------------------
85
+ create_table :cms_files do |t|
86
+ t.integer :site_id, :null => false
87
+ t.integer :block_id
88
+ t.string :label, :null => false
89
+ t.string :file_file_name, :null => false
90
+ t.string :file_content_type, :null => false
91
+ t.integer :file_file_size, :null => false
92
+ t.string :description, :limit => 2048
93
+ t.integer :position, :null => false, :default => 0
94
+ t.timestamps
95
+ end
96
+ add_index :cms_files, [:site_id, :label]
97
+ add_index :cms_files, [:site_id, :file_file_name]
98
+ add_index :cms_files, [:site_id, :position]
99
+ add_index :cms_files, [:site_id, :block_id]
100
+
101
+ # -- Revisions -----------------------------------------------------------
102
+ create_table :cms_revisions, :force => true do |t|
103
+ t.string :record_type, :null => false
104
+ t.integer :record_id, :null => false
105
+ t.text :data, text_limit
106
+ t.datetime :created_at
107
+ end
108
+ add_index :cms_revisions, [:record_type, :record_id, :created_at],
109
+ :name => 'index_cms_revisions_on_rtype_and_rid_and_created_at'
110
+
111
+ # -- Categories ---------------------------------------------------------
112
+ create_table :cms_categories, :force => true do |t|
113
+ t.integer :site_id, :null => false
114
+ t.string :label, :null => false
115
+ t.string :categorized_type, :null => false
116
+ end
117
+ add_index :cms_categories, [:site_id, :categorized_type, :label], :unique => true
118
+
119
+ create_table :cms_categorizations, :force => true do |t|
120
+ t.integer :category_id, :null => false
121
+ t.string :categorized_type, :null => false
122
+ t.integer :categorized_id, :null => false
123
+ end
124
+ add_index :cms_categorizations, [:category_id, :categorized_type, :categorized_id], :unique => true,
125
+ :name => 'index_cms_categorizations_on_cat_id_and_catd_type_and_catd_id'
126
+
127
+ # -- Menus ---------------------------------------------------------
128
+ create_table :cms_menus do |t|
129
+ t.integer :site_id
130
+ t.string :label
131
+ t.string :identifier
132
+ t.timestamps
133
+ end
134
+
135
+ # -- MenuItems ---------------------------------------------------------
136
+ create_table :cms_menu_items do |t|
137
+ t.integer :menu_id
138
+ t.string :label
139
+ t.integer :page_id
140
+ t.string :link
141
+ t.string :menu_item_type
142
+
143
+ t.timestamps
144
+ end
145
+
146
+
147
+ end
148
+
149
+ def self.down
150
+ drop_table :cms_sites
151
+ drop_table :cms_layouts
152
+ drop_table :cms_pages
153
+ drop_table :cms_snippets
154
+ drop_table :cms_blocks
155
+ drop_table :cms_files
156
+ drop_table :cms_revisions
157
+ drop_table :cms_categories
158
+ drop_table :cms_categorizations
159
+ drop_table :cms_menus
160
+ drop_table :cms_menu_items
161
+ end
162
+ end
163
+
data/db/seeds.rb ADDED
@@ -0,0 +1,9 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
7
+ # Mayor.create(:name => 'Daley', :city => cities.first)
8
+ Cms::Site.create( :label => 'testsite.com', :identifier => 'testsite.com', :hostname => 'testsite.com:3000',
9
+ :locale => 'en', :is_mirrored => 0)
@@ -0,0 +1,19 @@
1
+ class UpgradeTo110 < ActiveRecord::Migration
2
+ def self.up
3
+ rename_column :cms_layouts, :cms_site_id, :site_id
4
+ rename_column :cms_pages, :cms_site_id, :site_id
5
+ rename_column :cms_pages, :cms_layout_id, :layout_id
6
+ rename_column :cms_blocks, :cms_page_id, :page_id
7
+ rename_column :cms_snippets, :cms_site_id, :site_id
8
+ rename_column :cms_uploads, :cms_site_id, :site_id
9
+ end
10
+
11
+ def self.down
12
+ rename_column :cms_uploads, :site_id, :cms_site_id
13
+ rename_column :cms_snippets, :site_id, :cms_site_id
14
+ rename_column :cms_blocks, :page_id, :cms_page_id
15
+ rename_column :cms_layouts, :site_id, :cms_site_id
16
+ rename_column :cms_pages, :layout_id, :cms_layout_id
17
+ rename_column :cms_pages, :site_id, :cms_site_id
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ class UpgradeTo120 < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :cms_revisions, :force => true do |t|
4
+ t.string :record_type
5
+ t.integer :record_id
6
+ t.text :data
7
+ t.datetime :created_at
8
+ end
9
+ add_index :cms_revisions, [:record_type, :record_id, :created_at]
10
+ end
11
+
12
+ def self.down
13
+ drop_table :cms_revisions
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ class UpgradeTo130 < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :cms_sites, :is_mirrored, :boolean, :null => false, :default => false
4
+ add_column :cms_sites, :path, :string
5
+ add_column :cms_sites, :locale, :string, :null => false, :default => 'en'
6
+ add_index :cms_sites, :is_mirrored
7
+
8
+ add_column :cms_layouts, :is_shared, :boolean, :null => false, :default => false
9
+ add_column :cms_pages, :is_shared, :boolean, :null => false, :default => false
10
+ add_column :cms_snippets, :is_shared, :boolean, :null => false, :default => false
11
+ end
12
+
13
+ def self.down
14
+ remove_index :cms_sites, :is_mirrored
15
+ remove_column :cms_sites, :path
16
+ remove_column :cms_sites, :is_mirrored
17
+ remove_column :cms_sites, :locale
18
+
19
+ remove_column :cms_layouts, :is_shared
20
+ remove_column :cms_pages, :is_shared
21
+ remove_column :cms_snippets, :is_shared
22
+ end
23
+ end
@@ -0,0 +1,33 @@
1
+ class UpgradeTo140 < ActiveRecord::Migration
2
+ def self.up
3
+ rename_table :cms_uploads, :cms_files
4
+ add_column :cms_files, :label, :string
5
+ add_column :cms_files, :description, :string, :limit => 2048
6
+ add_index :cms_files, [:site_id, :label]
7
+
8
+ # -- Categories ---------------------------------------------------------
9
+ create_table :cms_categories, :force => true do |t|
10
+ t.string :label
11
+ t.string :categorized_type
12
+ end
13
+ add_index :cms_categories, [:categorized_type, :label], :unique => true
14
+
15
+ create_table :cms_categorizations, :force => true do |t|
16
+ t.integer :category_id
17
+ t.string :categorized_type
18
+ t.integer :categorized_id
19
+ end
20
+ add_index :cms_categorizations, [:category_id, :categorized_type, :categorized_id], :unique => true,
21
+ :name => 'index_cms_categorizations_on_cat_id_and_catd_type_and_catd_id'
22
+ end
23
+
24
+ def self.down
25
+ remove_index :cms_files, [:site_id, :label]
26
+ remove_column :cms_files, :description
27
+ remove_column :cms_files, :label
28
+ rename_table :cms_files, :cms_uploads
29
+
30
+ drop_table :cms_categories
31
+ drop_table :cms_categorizations
32
+ end
33
+ end
@@ -0,0 +1,21 @@
1
+ class UpgradeTo150 < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :cms_snippets, :position, :integer, :null => false, :default => 0
4
+ add_column :cms_files, :position, :integer, :null => false, :default => 0
5
+ add_column :cms_files, :block_id, :integer
6
+
7
+ add_index :cms_snippets, [:site_id, :position]
8
+ add_index :cms_files, [:site_id, :position]
9
+ add_index :cms_files, [:site_id, :block_id]
10
+ end
11
+
12
+ def self.down
13
+ remove_index :cms_snippets, [:site_id, :position]
14
+ remove_index :cms_files, [:site_id, :position]
15
+ remove_index :cms_files, [:site_id, :block_id]
16
+
17
+ remove_column :cms_snippets, :position
18
+ remove_column :cms_files, :position
19
+ remove_column :cms_files, :block_id
20
+ end
21
+ end
@@ -0,0 +1,25 @@
1
+ class UpgradeTo160 < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :cms_sites, :identifier, :string
4
+ add_index :cms_sites, :identifier
5
+
6
+ rename_column :cms_layouts, :slug, :identifier
7
+ rename_column :cms_blocks, :label, :identifier
8
+ rename_column :cms_snippets, :slug, :identifier
9
+
10
+ add_column :cms_categories, :site_id, :integer, :null => :false
11
+ add_index :cms_categories, [:site_id, :categorized_type, :label], :unique => true
12
+ end
13
+
14
+ def self.down
15
+ remove_index :cms_categories, [:site_id, :categorized_type, :label], :unique => true
16
+ remove_column :cms_categories, :site_id
17
+
18
+ rename_column :cms_snippets, :identifier, :slug
19
+ rename_column :cms_blocks, :identifier, :label
20
+ rename_column :cms_layouts, :identifier, :slug
21
+
22
+ remove_index :cms_sites, :identifier
23
+ remove_column :cms_sites, :identifier
24
+ end
25
+ end
data/doc/preview.png ADDED
Binary file
data/doc/sofa.png ADDED
Binary file
@@ -0,0 +1,8 @@
1
+ module ComfyPress::DummyAuth
2
+
3
+ # Will always let you in
4
+ def authenticate
5
+ true
6
+ end
7
+
8
+ end
@@ -0,0 +1,18 @@
1
+ module ComfyPress::HttpAuth
2
+ # Set username and password in config/initializers/comfypress.rb
3
+ # Like this:
4
+ # ComfyPress::HttpAuth.username = 'myname'
5
+ # ComfyPress::HttpAuth.password = 'mypassword'
6
+ mattr_accessor :username,
7
+ :password
8
+
9
+ # Simple http_auth. When implementing some other form of authentication
10
+ # this method should return +true+ if everything is great, or redirect user
11
+ # to some other page, thus denying access to cms admin section.
12
+ def authenticate
13
+ authenticate_or_request_with_http_basic do |username, password|
14
+ username == self.username && password == self.password
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1,99 @@
1
+ # encoding: utf-8
2
+
3
+ class ComfyPress::Configuration
4
+
5
+ # Don't like ComfyPress? Set it to whatever you like. :(
6
+ attr_accessor :cms_title
7
+
8
+ # Module that will handle authentication to access cms-admin area
9
+ attr_accessor :admin_auth
10
+
11
+ # Module that will handle authentication for public pages
12
+ attr_accessor :public_auth
13
+
14
+ # When arriving at /cms-admin you may chose to redirect to arbirtary path,
15
+ # for example '/cms-admin/users'
16
+ attr_accessor :admin_route_redirect
17
+
18
+ # Upload settings
19
+ attr_accessor :upload_file_options
20
+
21
+ # With each page load, files will be synched with the database. Database entries are
22
+ # destroyed if there's no corresponding file. Fixtures are disabled by default.
23
+ attr_accessor :enable_fixtures
24
+
25
+ # Path where fixtures can be located.
26
+ attr_accessor :fixtures_path
27
+
28
+ # Number of revisions kept. Default is 25. If you wish to disable: set this to 0.
29
+ attr_accessor :revisions_limit
30
+
31
+ # Locale definitions. If you want to define your own locale merge
32
+ # {:locale => 'Locale Title'} with this.
33
+ attr_accessor :locales
34
+
35
+ # Admin interface will respect the locale of the site being managed. However you can
36
+ # force it to English by setting this to `:en`
37
+ attr_accessor :admin_locale
38
+
39
+ # Database prefix. If you want to keep your comfortable mexican sofa tables
40
+ # in a location other than the default databases add a database_config.
41
+ # Setting this to `cms` will look for a cms_#{Rails.env} database definition
42
+ # in your database.yml file
43
+ attr_accessor :database_config
44
+
45
+ # A class that is included as a sweeper to admin base controller if it's set
46
+ attr_accessor :admin_cache_sweeper
47
+
48
+ # Not allowing irb code to be run inside page content. False by default.
49
+ attr_accessor :allow_irb
50
+
51
+ # Whitelist of all helper methods that can be used via {{cms:helper}} tag. By default
52
+ # all helpers are allowed except `eval`, `send`, `call` and few others. Empty array
53
+ # will prevent rendering of all helpers.
54
+ attr_accessor :allowed_helpers
55
+
56
+ # Whitelist of partials paths that can be used via {{cms:partial}} tag. All partials
57
+ # are accessible by default. Empty array will prevent rendering of all partials.
58
+ attr_accessor :allowed_partials
59
+
60
+ # Site aliases, if you want to have aliases for your site. Good for harmonizing
61
+ # production env with dev/testing envs.
62
+ # e.g. config.site_aliases = {'host.com' => 'host.inv', 'host_a.com' => ['host.lvh.me', 'host.dev']}
63
+ # Default is nil (not used)
64
+ attr_accessor :hostname_aliases
65
+
66
+ # Configuration defaults
67
+ def initialize
68
+ @cms_title = 'ComfyPress CMS Engine'
69
+ @admin_auth = 'ComfyPress::HttpAuth'
70
+ @public_auth = 'ComfyPress::DummyAuth'
71
+ @seed_data_path = nil
72
+ @admin_route_redirect = ''
73
+ @enable_sitemap = true
74
+ @upload_file_options = { }
75
+ @enable_fixtures = false
76
+ @fixtures_path = File.expand_path('db/cms_fixtures', Rails.root)
77
+ @revisions_limit = 25
78
+ @locales = {
79
+ 'en' => 'English',
80
+ 'fr' => 'Français',
81
+ 'es' => 'Español',
82
+ 'pt-BR' => 'Português Brasileiro',
83
+ 'zh-CN' => '简体中文',
84
+ 'ja' => '日本語',
85
+ 'sv' => 'Svenska',
86
+ 'ru' => 'Русский',
87
+ 'pl' => 'Polski',
88
+ 'de' => 'Deutsch'
89
+ }
90
+ @admin_locale = nil
91
+ @database_config = nil
92
+ @admin_cache_sweeper = nil
93
+ @allow_irb = false
94
+ @allowed_helpers = nil
95
+ @allowed_partials = nil
96
+ @hostname_aliases = nil
97
+ end
98
+
99
+ end
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'comfypress'
3
+ require 'rails'
4
+ require 'formatted_form'
5
+ require 'active_link_to'
6
+ require 'paperclip'
7
+ require 'redcarpet'
8
+ require 'jquery-rails'
9
+ require 'haml-rails'
10
+ require 'sass-rails'
11
+ require 'coffee-rails'
12
+
13
+ module ComfyPress
14
+ class Engine < ::Rails::Engine
15
+ # ...
16
+ end
17
+ end
18
+
@@ -0,0 +1,24 @@
1
+ module ComfyPress
2
+
3
+ class Error < StandardError
4
+ end
5
+
6
+ class MissingSite < ComfyPress::Error
7
+ def initialize(identifier)
8
+ super "Cannot find CMS Site with identifier: #{identifier}"
9
+ end
10
+ end
11
+
12
+ class MissingLayout < ComfyPress::Error
13
+ def initialize(identifier)
14
+ super "Cannot find CMS Layout with identifier: #{identifier}"
15
+ end
16
+ end
17
+
18
+ class MissingPage < ComfyPress::Error
19
+ def initialize(path)
20
+ super "Cannot find CMS Page at #{path}"
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,102 @@
1
+ module ComfyPress::ActsAsTree
2
+
3
+ def self.included(base)
4
+ base.extend(ClassMethods)
5
+ end
6
+
7
+ module ClassMethods
8
+ def cms_acts_as_tree(options = {})
9
+ configuration = {
10
+ :foreign_key => 'parent_id',
11
+ :order => nil,
12
+ :counter_cache => nil,
13
+ :dependent => :destroy,
14
+ :touch => false }
15
+ configuration.update(options) if options.is_a?(Hash)
16
+
17
+ belongs_to :parent,
18
+ :class_name => name,
19
+ :foreign_key => configuration[:foreign_key],
20
+ :counter_cache => configuration[:counter_cache],
21
+ :touch => configuration[:touch]
22
+
23
+ has_many :children,
24
+ :class_name => name,
25
+ :foreign_key => configuration[:foreign_key],
26
+ :order => configuration[:order],
27
+ :dependent => configuration[:dependent]
28
+
29
+ class_eval <<-EOV
30
+ include ComfyPress::ActsAsTree::InstanceMethods
31
+
32
+ scope :roots,
33
+ :conditions => "#{configuration[:foreign_key]} IS NULL",
34
+ :order => #{configuration[:order].nil? ? "nil" : %Q{"#{configuration[:order]}"}}
35
+
36
+ def self.root
37
+ roots.first
38
+ end
39
+
40
+ validates_each "#{configuration[:foreign_key]}" do |record, attr, value|
41
+ if value
42
+ if record.id == value
43
+ record.errors.add attr, "cannot be it's own id"
44
+ elsif record.descendants.map {|c| c.id}.include?(value)
45
+ record.errors.add attr, "cannot be a descendant's id"
46
+ end
47
+ end
48
+ end
49
+ EOV
50
+
51
+ end
52
+ end
53
+
54
+ module InstanceMethods
55
+ # Returns list of ancestors, starting from parent until root.
56
+ #
57
+ # subchild1.ancestors # => [child1, root]
58
+ def ancestors
59
+ node, nodes = self, []
60
+ nodes << node = node.parent while node.parent
61
+ nodes
62
+ end
63
+
64
+ # Returns all children and children of children
65
+ def descendants
66
+ nodes = []
67
+ self.children.each do |c|
68
+ nodes << c
69
+ nodes << c.descendants
70
+ end
71
+ nodes.flatten
72
+ end
73
+
74
+ # Returns the root node of the tree.
75
+ def root
76
+ node = self
77
+ node = node.parent while node.parent
78
+ node
79
+ end
80
+
81
+ # Checks if this node is a root
82
+ def root?
83
+ !self.parent_id
84
+ end
85
+
86
+ # Returns all siblings of the current node.
87
+ #
88
+ # subchild1.siblings # => [subchild2]
89
+ def siblings
90
+ self_and_siblings - [self]
91
+ end
92
+
93
+ # Returns all siblings and a reference to the current node.
94
+ #
95
+ # subchild1.self_and_siblings # => [subchild1, subchild2]
96
+ def self_and_siblings
97
+ parent ? parent.children : self.class.roots
98
+ end
99
+ end
100
+ end
101
+
102
+ ActiveRecord::Base.send :include, ComfyPress::ActsAsTree
@@ -0,0 +1,64 @@
1
+ module ComfyPress::HasRevisions
2
+
3
+ def self.included(base)
4
+ base.send :extend, ClassMethods
5
+ end
6
+
7
+ module ClassMethods
8
+
9
+ def cms_has_revisions_for(*fields)
10
+
11
+ include ComfyPress::HasRevisions::InstanceMethods
12
+
13
+ attr_accessor :revision_data
14
+
15
+ has_many :revisions,
16
+ :as => :record,
17
+ :dependent => :destroy
18
+
19
+ before_save :prepare_revision
20
+ after_save :create_revision
21
+
22
+ define_method(:revision_fields) do
23
+ fields.collect(&:to_s)
24
+ end
25
+ end
26
+ end
27
+
28
+ module InstanceMethods
29
+
30
+ # Preparing revision data. A bit of a special thing to grab page blocks
31
+ def prepare_revision
32
+ return if self.new_record?
33
+ if (self.respond_to?(:blocks_attributes_changed) && self.blocks_attributes_changed) ||
34
+ !(self.changed & revision_fields).empty?
35
+ self.revision_data = revision_fields.inject({}) do |c, field|
36
+ c[field] = self.send("#{field}_was")
37
+ c
38
+ end
39
+ end
40
+ end
41
+
42
+ # Revision is created only if relevant data changed
43
+ def create_revision
44
+ return unless self.revision_data
45
+
46
+ # creating revision
47
+ if ComfyPress.config.revisions_limit.to_i != 0
48
+ self.revisions.create!(:data => self.revision_data)
49
+ end
50
+
51
+ # blowing away old revisions
52
+ ids = [0] + self.revisions.limit(ComfyPress.config.revisions_limit.to_i).collect(&:id)
53
+ self.revisions.where('id NOT IN (?)', ids).destroy_all
54
+ end
55
+
56
+ # Assigning whatever is found in revision data and attemptint to save the object
57
+ def restore_from_revision(revision)
58
+ return unless revision.record == self
59
+ self.update_attributes!(revision.data)
60
+ end
61
+ end
62
+ end
63
+
64
+ ActiveRecord::Base.send :include, ComfyPress::HasRevisions