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,3 @@
1
+ module ComfyPress
2
+ VERSION = "0.1.3"
3
+ end
@@ -0,0 +1,32 @@
1
+ module ComfyPress::ViewHooks
2
+
3
+ # Array of declared hooks
4
+ def self.hooks
5
+ @@hooks ||= { }
6
+ end
7
+
8
+ # Renders hook content
9
+ def self.render(name, template, options = {})
10
+ out = ''
11
+ (self.hooks[name.to_sym] || []).each do |path|
12
+ out += template.render({:partial => path.first}.merge(options))
13
+ end
14
+ return out.html_safe
15
+ end
16
+
17
+ # Will declare a partial that will be rendered for this hook
18
+ # Example:
19
+ # ComfyPress::ViewHooks.add(:navigation, 'shared/navigation')
20
+ def self.add(name, partial_path, position = 0)
21
+ self.hooks[name.to_sym] ||= []
22
+ self.hooks[name.to_sym] << [partial_path, position]
23
+ self.hooks[name.to_sym].sort_by! { |hook| hook.last }
24
+ end
25
+
26
+
27
+ # Removing previously declared hook
28
+ def self.remove(name)
29
+ self.hooks.delete(name)
30
+ end
31
+
32
+ end
@@ -0,0 +1,52 @@
1
+ module ComfyPress::ViewMethods
2
+
3
+ # Wrapper around ComfyPress::FormBuilder
4
+ def comfy_form_for(record, options = {}, &proc)
5
+ options[:builder] = ComfyPress::FormBuilder
6
+ options[:type] ||= :horizontal
7
+ formatted_form_for(record, options, &proc)
8
+ end
9
+
10
+ # Injects some content somewhere inside cms admin area
11
+ def cms_hook(name, options = {})
12
+ ComfyPress::ViewHooks.render(name, self, options)
13
+ end
14
+
15
+ # Content of a snippet. Example:
16
+ # cms_snippet_content(:my_snippet)
17
+ def cms_snippet_content(identifier, cms_site = nil)
18
+ unless cms_site
19
+ host, path = request.host.downcase, request.fullpath if respond_to?(:request) && request
20
+ cms_site ||= (@cms_site || Cms::Site.find_site(host, path))
21
+ end
22
+ return '' unless cms_site
23
+ case identifier
24
+ when Cms::Snippet
25
+ snippet = identifier
26
+ else
27
+ return '' unless snippet = cms_site.snippets.find_by_identifier(identifier)
28
+ end
29
+ render :inline => ComfyPress::Tag.process_content(cms_site.pages.build, snippet.content)
30
+ end
31
+
32
+ # Content of a page block. This is how you get content from page:field
33
+ # Example:
34
+ # cms_page_content(:left_column, CmsPage.first)
35
+ # cms_page_content(:left_column) # if @cms_page is present
36
+ def cms_page_content(identifier, page = nil)
37
+ return '' unless page ||= @cms_page
38
+ return '' unless block = page.blocks.find_by_identifier(identifier)
39
+ # If block is a page_file(s) we will return objects instead of attempting
40
+ # to render them out
41
+ case block.tag
42
+ when ComfyPress::Tag::PageFile
43
+ block.files.first
44
+ when ComfyPress::Tag::PageFiles
45
+ block.files
46
+ else
47
+ render :inline => ComfyPress::Tag.process_content(page, block.content)
48
+ end
49
+ end
50
+ end
51
+
52
+ ActionView::Base.send :include, ComfyPress::ViewMethods
data/lib/comfypress.rb ADDED
@@ -0,0 +1,66 @@
1
+ # Loading engine only if this is not a standalone installation
2
+ unless defined? ComfyPress::Application
3
+ require File.expand_path('comfypress/engine', File.dirname(__FILE__))
4
+ end
5
+
6
+ [ 'comfypress/version',
7
+ 'comfypress/error',
8
+ 'comfypress/configuration',
9
+ 'comfypress/routing',
10
+ 'comfypress/authentication/http_auth',
11
+ 'comfypress/authentication/dummy_auth',
12
+ 'comfypress/render_methods',
13
+ 'comfypress/view_hooks',
14
+ 'comfypress/view_methods',
15
+ 'comfypress/form_builder',
16
+ 'comfypress/tag',
17
+ 'comfypress/sitemap',
18
+ 'comfypress/fixtures',
19
+ 'comfypress/extensions/rails',
20
+ 'comfypress/extensions/acts_as_tree',
21
+ 'comfypress/extensions/has_revisions',
22
+ 'comfypress/extensions/is_mirrored',
23
+ 'comfypress/extensions/is_categorized'
24
+ ].each do |path|
25
+ require File.expand_path(path, File.dirname(__FILE__))
26
+ end
27
+
28
+ Dir.glob(File.expand_path('comfypress/tags/*.rb', File.dirname(__FILE__))).each do |path|
29
+ require path
30
+ end
31
+
32
+ module ComfyPress
33
+ class << self
34
+
35
+ # Modify CMS configuration
36
+ # Example:
37
+ # ComfyPress.configure do |config|
38
+ # config.cms_title = 'ComfyPress'
39
+ # end
40
+ def configure
41
+ yield configuration
42
+ end
43
+
44
+ # Accessor for ComfyPress::Configuration
45
+ def configuration
46
+ @configuration ||= Configuration.new
47
+ end
48
+ alias :config :configuration
49
+
50
+ # Establishing database connection if custom one is defined
51
+ def establish_connection(klass)
52
+ if ComfyPress.config.database_config && !Rails.env.test?
53
+ klass.establish_connection "#{ComfyPress.config.database_config}_#{Rails.env}"
54
+ end
55
+ end
56
+
57
+ def logger=(new_logger)
58
+ @logger = new_logger
59
+ end
60
+
61
+ def logger
62
+ @logger ||= Rails.logger
63
+ end
64
+
65
+ end
66
+ end
@@ -0,0 +1,10 @@
1
+ --------------
2
+ !!COMFYPRESS!!
3
+ --------------
4
+
5
+ Hey! Everything is almost done. Please don't forget to
6
+
7
+ * run migrations -> `rake db:migrate`
8
+
9
+ After that go to http://your-awesome-app/cms-admin to start populating content.
10
+ Default username and password are: username // password
@@ -0,0 +1,57 @@
1
+ module Comfy
2
+ module Generators
3
+ class CmsGenerator < Rails::Generators::Base
4
+
5
+ require 'rails/generators/active_record'
6
+ include Rails::Generators::Migration
7
+ include Thor::Actions
8
+
9
+ source_root File.expand_path('../../../../..', __FILE__)
10
+
11
+ def generate_migration
12
+ destination = File.expand_path('db/migrate/01_create_cms.rb', self.destination_root)
13
+ migration_dir = File.dirname(destination)
14
+ destination = self.class.migration_exists?(migration_dir, 'create_cms')
15
+
16
+ if destination
17
+ puts "\e[0m\e[31mFound existing cms_create.rb migration. Remove it if you want to regenerate.\e[0m"
18
+ else
19
+ migration_template 'db/migrate/01_create_cms.rb', 'db/migrate/create_cms.rb'
20
+ end
21
+ end
22
+
23
+ def generate_initialization
24
+ copy_file 'config/initializers/comfypress.rb',
25
+ 'config/initializers/comfypress.rb'
26
+ end
27
+
28
+ def generate_routing
29
+ route "
30
+ ComfyPress::Routing.admin(:path => '/cms-admin')
31
+
32
+ # Make sure this routeset is defined last
33
+ ComfyPress::Routing.content(:path => '/', :sitemap => false)"
34
+ end
35
+
36
+ def generate_cms_seeds
37
+ directory 'db/cms_fixtures', 'db/cms_fixtures'
38
+ end
39
+
40
+ def generate_assets
41
+ directory 'app/assets/javascripts/comfypress/admin',
42
+ 'app/assets/javascripts/comfypress/admin'
43
+ directory 'app/assets/stylesheets/comfypress/admin',
44
+ 'app/assets/stylesheets/comfypress/admin'
45
+ end
46
+
47
+ def show_readme
48
+ readme 'lib/generators/comfy/cms/README'
49
+ end
50
+
51
+ def self.next_migration_number(dirname)
52
+ ActiveRecord::Generators::Base.next_migration_number(dirname)
53
+ end
54
+
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,45 @@
1
+ # Small hack to auto-run migrations during testing
2
+ namespace :db do
3
+ task :abort_if_pending_migrations => [:migrate]
4
+ end
5
+
6
+ namespace :comfypress do
7
+ namespace :fixtures do
8
+
9
+ desc 'Import Fixture data into database (options: FROM=folder_name TO=site_identifier)'
10
+
11
+ task :import => :environment do
12
+ to = ENV['TO'] || ENV['FROM']
13
+ from = ENV['FROM']
14
+ force_reload = ENV['FORCE'].try(:downcase) != 'false'
15
+
16
+ puts "Importing CMS Fixtures from Folder [#{from}] to Site [#{to}] ..."
17
+
18
+ # changing so that logger is going straight to screen
19
+ logger_org = ComfyPress.logger
20
+ ComfyPress.logger = Logger.new(STDOUT)
21
+
22
+ ComfyPress::Fixtures.import_all(to, from, force_reload)
23
+
24
+ ComfyPress.logger = logger_org
25
+ end
26
+
27
+ desc 'Export database data into Fixtures (options: FROM=site_identifier.com TO=folder_name)'
28
+ task :export => :environment do
29
+ to = ENV['TO'] || ENV['FROM']
30
+ from = ENV['FROM']
31
+
32
+ puts "Exporting CMS data from Site [#{from}] to Folder [#{to}] ..."
33
+
34
+ # changing so that logger is going straight to screen
35
+ logger_org = ComfyPress.logger
36
+ ComfyPress.logger = Logger.new(STDOUT)
37
+
38
+ ComfyPress::Fixtures.export_all(from, to)
39
+
40
+ ComfyPress.logger = logger_org
41
+
42
+ puts 'Done!'
43
+ end
44
+ end
45
+ end
data/script/rails ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,12 @@
1
+ default_field_text:
2
+ page: default
3
+ identifier: default_field_text
4
+ content: default_field_text_content
5
+
6
+ default_page_text:
7
+ page: default
8
+ identifier: default_page_text
9
+ content: |-
10
+ default_page_text_content_a
11
+ {{cms:snippet:default}}
12
+ default_page_text_content_b
@@ -0,0 +1,4 @@
1
+ default:
2
+ site: default
3
+ label: Default
4
+ categorized_type: Cms::File
@@ -0,0 +1,3 @@
1
+ default:
2
+ category: default
3
+ categorized: default (Cms::File)
@@ -0,0 +1,9 @@
1
+ default:
2
+ site: default
3
+ block:
4
+ label: Sample
5
+ file_file_name: sample.jpg
6
+ file_content_type: image/jpeg
7
+ file_file_size: 20099
8
+ description: Description
9
+ position: 0
@@ -0,0 +1,40 @@
1
+ default:
2
+ site: default
3
+ label: Default Layout
4
+ identifier: default
5
+ parent:
6
+ content: |-
7
+ {{cms:field:default_field_text:text}}
8
+ layout_content_a
9
+ {{cms:page:default_page_text:text}}
10
+ layout_content_b
11
+ {{cms:snippet:default}}
12
+ layout_content_c
13
+ css: default_css
14
+ js: default_js
15
+ position: 0
16
+
17
+ nested:
18
+ site: default
19
+ label: Nested Layout
20
+ identifier: nested
21
+ parent:
22
+ content: |-
23
+ {{cms:page:header}}
24
+ {{cms:page:content}}
25
+ css: nested_css
26
+ js: nested_js
27
+ position: 0
28
+
29
+ child:
30
+ site: default
31
+ label: Child Layout
32
+ identifier: child
33
+ parent: nested
34
+ content: |-
35
+ {{cms:page:left_column}}
36
+ {{cms:page:right_column}}
37
+ css: child_css
38
+ js: child_js
39
+ position: 0
40
+
@@ -0,0 +1,15 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ one:
4
+ menu_id: 1
5
+ label: MyString
6
+ page_id: 1
7
+ link: MyString
8
+ type:
9
+
10
+ two:
11
+ menu_id: 1
12
+ label: MyString
13
+ page_id: 1
14
+ link: MyString
15
+ type:
@@ -0,0 +1,9 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ one:
4
+ site_id: 1
5
+ label: MyString
6
+
7
+ two:
8
+ site_id: 1
9
+ label: MyString
@@ -0,0 +1,39 @@
1
+ default:
2
+ site: default
3
+ parent:
4
+ target_page:
5
+ layout: default
6
+ label: Default Page
7
+ slug:
8
+ full_path: '/'
9
+ children_count: 1
10
+ position: 0
11
+ is_published: true
12
+ content: |-
13
+
14
+ layout_content_a
15
+ default_page_text_content_a
16
+ default_snippet_content
17
+ default_page_text_content_b
18
+ layout_content_b
19
+ default_snippet_content
20
+ layout_content_c
21
+
22
+ child:
23
+ site: default
24
+ parent: default
25
+ target_page:
26
+ layout: default
27
+ label: Child Page
28
+ slug: 'child-page'
29
+ full_path: '/child-page'
30
+ children_count: 0
31
+ position: 0
32
+ is_published: true
33
+ content: |-
34
+
35
+ layout_content_a
36
+
37
+ layout_content_b
38
+ default_snippet_content
39
+ layout_content_c
@@ -0,0 +1,21 @@
1
+ layout:
2
+ record: default (Cms::Layout)
3
+ data: <%= {
4
+ 'content' => 'revision {{cms:page:default_page_text}}',
5
+ 'css' => 'revision css',
6
+ 'js' => 'revision js' }.to_yaml.inspect %>
7
+
8
+ page:
9
+ record: default (Cms::Page)
10
+ data: <%= {
11
+ 'blocks_attributes' => [
12
+ { 'identifier' => 'default_page_text',
13
+ 'content' => 'revision page content' },
14
+ { 'identifier' => 'default_field_text',
15
+ 'content' => 'revision field content'}
16
+ ]}.to_yaml.inspect %>
17
+
18
+ snippet:
19
+ record: default (Cms::Snippet)
20
+ data: <%= {
21
+ 'content' => 'revision content' }.to_yaml.inspect %>
@@ -0,0 +1,6 @@
1
+ default:
2
+ label: Default Site
3
+ identifier: default-site
4
+ hostname: test.host
5
+ path:
6
+ is_mirrored: false
@@ -0,0 +1,6 @@
1
+ default:
2
+ site: default
3
+ label: Default Snippet
4
+ identifier: default
5
+ content: default_snippet_content
6
+ position: 0
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1 @@
1
+ hook_content
@@ -0,0 +1 @@
1
+ <hook_content_2>
@@ -0,0 +1 @@
1
+ TestPartial <%= @test_value %>
@@ -0,0 +1 @@
1
+ Can render CMS layout and specify action
@@ -0,0 +1 @@
1
+ TestTemplate <%= @test_value %>
@@ -0,0 +1,18 @@
1
+ require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
+
3
+ class CmsAdmin::BaseControllerTest < ActionController::TestCase
4
+
5
+ def test_get_jump
6
+ get :jump
7
+ assert_response :redirect
8
+ assert_redirected_to cms_admin_site_pages_path(cms_sites(:default))
9
+ end
10
+
11
+ def test_get_jump_with_redirect_setting
12
+ ComfyPress.config.admin_route_redirect = '/cms-admin/sites'
13
+ get :jump
14
+ assert_response :redirect
15
+ assert_redirected_to '/cms-admin/sites'
16
+ end
17
+
18
+ end
@@ -0,0 +1,70 @@
1
+ require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
+
3
+ class CmsAdmin::CategoriesControllerTest < ActionController::TestCase
4
+
5
+ def test_get_edit
6
+ xhr :get, :edit, :site_id => cms_sites(:default), :id => cms_categories(:default)
7
+ assert_response :success
8
+ assert_template :edit
9
+ assert assigns(:category)
10
+ end
11
+
12
+ def test_get_edit_failure
13
+ xhr :get, :edit, :site_id => cms_sites(:default), :id => 'invalid'
14
+ assert_response :success
15
+ assert response.body.blank?
16
+ end
17
+
18
+ def test_creation
19
+ assert_difference 'Cms::Category.count' do
20
+ xhr :post, :create, :site_id => cms_sites(:default), :category => {
21
+ :label => 'Test Label',
22
+ :categorized_type => 'Cms::Snippet'
23
+ }
24
+ assert_response :success
25
+ assert_template :create
26
+ assert assigns(:category)
27
+ end
28
+ end
29
+
30
+ def test_creation_failure
31
+ assert_no_difference 'Cms::Category.count' do
32
+ xhr :post, :create, :site_id => cms_sites(:default), :category => { }
33
+ assert_response :success
34
+ assert response.body.blank?
35
+ end
36
+ end
37
+
38
+ def test_update
39
+ category = cms_categories(:default)
40
+ xhr :put, :update, :site_id => cms_sites(:default), :id => category, :category => {
41
+ :label => 'Updated Label'
42
+ }
43
+ assert_response :success
44
+ assert_template :update
45
+ assert assigns(:category)
46
+ category.reload
47
+ assert_equal 'Updated Label', category.label
48
+ end
49
+
50
+ def test_update_failure
51
+ category = cms_categories(:default)
52
+ xhr :put, :update, :site_id => cms_sites(:default), :id => category, :category => {
53
+ :label => ''
54
+ }
55
+ assert_response :success
56
+ assert response.body.blank?
57
+ category.reload
58
+ assert_not_equal '', category.label
59
+ end
60
+
61
+ def test_destroy
62
+ assert_difference 'Cms::Category.count', -1 do
63
+ xhr :delete, :destroy, :site_id => cms_sites(:default), :id => cms_categories(:default)
64
+ assert assigns(:category)
65
+ assert_response :success
66
+ assert_template :destroy
67
+ end
68
+ end
69
+
70
+ end