cmsimple 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. data/.gitignore +31 -0
  2. data/.rspec +1 -0
  3. data/.travis.yml +16 -0
  4. data/Gemfile +20 -0
  5. data/Gemfile.ci +5 -0
  6. data/LICENSE +19 -0
  7. data/README.md +118 -0
  8. data/Rakefile +47 -0
  9. data/app/assets/javascripts/cmsimple.js +61 -0
  10. data/app/assets/javascripts/cmsimple/controllers/editor.coffee +102 -0
  11. data/app/assets/javascripts/cmsimple/lib/namespaces.coffee +3 -0
  12. data/app/assets/javascripts/cmsimple/lib/support.coffee +4 -0
  13. data/app/assets/javascripts/cmsimple/mercury/config.js +462 -0
  14. data/app/assets/javascripts/cmsimple/mercury/handlers.coffee +9 -0
  15. data/app/assets/javascripts/cmsimple/models/image.coffee +49 -0
  16. data/app/assets/javascripts/cmsimple/models/page.coffee +106 -0
  17. data/app/assets/javascripts/cmsimple/models/path.coffee +31 -0
  18. data/app/assets/javascripts/cmsimple/models/version.coffee +29 -0
  19. data/app/assets/javascripts/cmsimple/panels/images/index.coffee +2 -0
  20. data/app/assets/javascripts/cmsimple/panels/images/list.coffee +48 -0
  21. data/app/assets/javascripts/cmsimple/panels/images/panel.coffee +69 -0
  22. data/app/assets/javascripts/cmsimple/panels/images/selection.coffee +52 -0
  23. data/app/assets/javascripts/cmsimple/panels/page_metadata.coffee +42 -0
  24. data/app/assets/javascripts/cmsimple/panels/publish.coffee +32 -0
  25. data/app/assets/javascripts/cmsimple/panels/redirects/form.coffee +51 -0
  26. data/app/assets/javascripts/cmsimple/panels/redirects/index.coffee +2 -0
  27. data/app/assets/javascripts/cmsimple/panels/redirects/list.coffee +34 -0
  28. data/app/assets/javascripts/cmsimple/panels/redirects/panel.coffee +39 -0
  29. data/app/assets/javascripts/cmsimple/panels/sitemap/index.coffee +2 -0
  30. data/app/assets/javascripts/cmsimple/panels/sitemap/panel.coffee +40 -0
  31. data/app/assets/javascripts/cmsimple/panels/sitemap/sortable.coffee +55 -0
  32. data/app/assets/javascripts/cmsimple/panels/sitemap/tree.coffee +61 -0
  33. data/app/assets/javascripts/cmsimple/panels/versions/index.coffee +2 -0
  34. data/app/assets/javascripts/cmsimple/panels/versions/list.coffee +51 -0
  35. data/app/assets/javascripts/cmsimple/panels/versions/panel.coffee +53 -0
  36. data/app/assets/javascripts/cmsimple/views/image_library/_item.jst.hamlc +24 -0
  37. data/app/assets/javascripts/cmsimple/views/image_library/list.jst.hamlc +8 -0
  38. data/app/assets/javascripts/cmsimple/views/redirects/_path.jst.hamlc +6 -0
  39. data/app/assets/javascripts/cmsimple/views/redirects/list.jst.hamlc +19 -0
  40. data/app/assets/javascripts/cmsimple/views/sitemap/_page.jst.hamlc +9 -0
  41. data/app/assets/javascripts/cmsimple/views/sitemap/tree.jst.hamlc +5 -0
  42. data/app/assets/javascripts/cmsimple/views/versions/_item.jst.hamlc +6 -0
  43. data/app/assets/javascripts/cmsimple/views/versions/list.jst.hamlc +4 -0
  44. data/app/assets/stylesheets/cmsimple.css +15 -0
  45. data/app/assets/stylesheets/cmsimple/forms.css +10 -0
  46. data/app/assets/stylesheets/cmsimple/panels.css +399 -0
  47. data/app/assets/stylesheets/cmsimple/toolbar-images.css +27 -0
  48. data/app/assets/stylesheets/mercury_overrides.css +2 -0
  49. data/app/controllers/cmsimple/front_controller.rb +38 -0
  50. data/app/controllers/cmsimple/images_controller.rb +28 -0
  51. data/app/controllers/cmsimple/mercury_controller.rb +7 -0
  52. data/app/controllers/cmsimple/pages_controller.rb +89 -0
  53. data/app/controllers/cmsimple/paths_controller.rb +23 -0
  54. data/app/controllers/cmsimple/snippets_controller.rb +23 -0
  55. data/app/controllers/cmsimple/versions_controller.rb +17 -0
  56. data/app/helpers/cmsimple/regions_helper.rb +38 -0
  57. data/app/models/cmsimple/image.rb +19 -0
  58. data/app/models/cmsimple/page.rb +203 -0
  59. data/app/models/cmsimple/path.rb +63 -0
  60. data/app/models/cmsimple/region.rb +43 -0
  61. data/app/models/cmsimple/snippet.rb +64 -0
  62. data/app/models/cmsimple/version.rb +18 -0
  63. data/app/uploaders/image_attachment_uploader.rb +53 -0
  64. data/app/views/cmsimple/images/_form.html.haml +13 -0
  65. data/app/views/cmsimple/images/new.html.haml +5 -0
  66. data/app/views/cmsimple/pages/_form.html.haml +49 -0
  67. data/app/views/cmsimple/pages/_form_extras.html.haml +2 -0
  68. data/app/views/cmsimple/pages/edit.html.haml +3 -0
  69. data/app/views/cmsimple/pages/new.html.haml +3 -0
  70. data/app/views/cmsimple/pages/publish.html.haml +12 -0
  71. data/app/views/cmsimple/snippets/index.html.haml +5 -0
  72. data/app/views/cmsimple/templates/default.html.haml +4 -0
  73. data/app/views/layouts/editor.html.haml +12 -0
  74. data/app/views/layouts/panel.html.haml +9 -0
  75. data/cmsimple.gemspec +44 -0
  76. data/config.ru +4 -0
  77. data/config/application.rb +1 -0
  78. data/config/cucumber.yml +8 -0
  79. data/config/environment.rb +2 -0
  80. data/config/routes.rb +34 -0
  81. data/db/migrate/20120201221410_create_cmsimple_pages.rb +10 -0
  82. data/db/migrate/20120222185901_add_title_parent_id_and_position_to_pages.rb +10 -0
  83. data/db/migrate/20120229185214_add_slug_to_pages.rb +7 -0
  84. data/db/migrate/20120323200439_add_is_root_to_page.rb +5 -0
  85. data/db/migrate/20120328174339_add_meta_info_to_cmsimple_pages.rb +9 -0
  86. data/db/migrate/20120329172857_create_cmsimple_path.rb +11 -0
  87. data/db/migrate/20120407024752_create_cmsimple_images.rb +13 -0
  88. data/db/migrate/20120410041105_add_timestamps_to_cmsimple_pages.rb +7 -0
  89. data/db/migrate/20120425211937_add_published_at_to_cmsimple_pages.rb +6 -0
  90. data/db/migrate/20120430175047_create_cmsimple_versions.rb +13 -0
  91. data/db/migrate/20120831233927_rename_path_to_current_uri_on_paths.rb +5 -0
  92. data/features/create.feature +18 -0
  93. data/features/delete.feature +12 -0
  94. data/features/edit.feature +54 -0
  95. data/features/publishing.feature +31 -0
  96. data/features/redirects.feature +27 -0
  97. data/features/step_definitions/mercury_steps.rb +440 -0
  98. data/features/step_definitions/page_steps.rb +269 -0
  99. data/features/step_definitions/web_steps.rb +254 -0
  100. data/features/support/env.rb +77 -0
  101. data/features/support/mercury_content.rb +25 -0
  102. data/features/support/mercury_selectors.rb +148 -0
  103. data/features/support/paths.rb +16 -0
  104. data/features/support/selectors.rb +26 -0
  105. data/features/support/utils.rb +18 -0
  106. data/features/versioning.feature +27 -0
  107. data/features/visit.feature +7 -0
  108. data/lib/cmsimple.rb +22 -0
  109. data/lib/cmsimple/configuration.rb +65 -0
  110. data/lib/cmsimple/exts/to_bool.rb +25 -0
  111. data/lib/cmsimple/page_responder.rb +46 -0
  112. data/lib/cmsimple/rails.rb +5 -0
  113. data/lib/cmsimple/regions_proxy.rb +32 -0
  114. data/lib/cmsimple/template_resolver.rb +14 -0
  115. data/lib/cmsimple/template_responder.rb +12 -0
  116. data/lib/cmsimple/version.rb +3 -0
  117. data/lib/generators/cmsimple/install/install_generator.rb +46 -0
  118. data/lib/generators/cmsimple/install/templates/default.html.erb +10 -0
  119. data/lib/generators/cmsimple/install/templates/default.html.haml +6 -0
  120. data/lib/generators/cmsimple/install/templates/initializer.rb +22 -0
  121. data/lib/generators/cmsimple/snippet/snippet_generator.rb +56 -0
  122. data/lib/generators/cmsimple/snippet/templates/cell.rb +18 -0
  123. data/lib/generators/cmsimple/snippet/templates/display.html.erb +14 -0
  124. data/lib/generators/cmsimple/snippet/templates/display.html.haml +11 -0
  125. data/lib/generators/cmsimple/snippet/templates/options.html.erb +18 -0
  126. data/lib/generators/cmsimple/snippet/templates/options.html.haml +12 -0
  127. data/script/app +2 -0
  128. data/script/migrate +2 -0
  129. data/script/rails +8 -0
  130. data/spec/fixtures/rails.png +0 -0
  131. data/spec/helpers/regions_helper_spec.rb +62 -0
  132. data/spec/javascripts/controllers/editor_spec.coffee +57 -0
  133. data/spec/javascripts/models/image_geometry_spec.coffee +64 -0
  134. data/spec/javascripts/models/image_spec.coffee +4 -0
  135. data/spec/javascripts/models/page_spec.coffee +121 -0
  136. data/spec/javascripts/models/path_spec.coffee +39 -0
  137. data/spec/javascripts/models/version_spec.coffee +31 -0
  138. data/spec/javascripts/panels/images/selection_spec.coffee +104 -0
  139. data/spec/javascripts/panels/sitemap/panel_spec.coffee +10 -0
  140. data/spec/javascripts/panels/sitemap/sortable_spec.coffee +63 -0
  141. data/spec/javascripts/panels/sitemap/tree_spec.coffee +62 -0
  142. data/spec/javascripts/spec_helper.coffee +25 -0
  143. data/spec/javascripts/support/stubs.coffee +16 -0
  144. data/spec/lib/page_responder_spec.rb +58 -0
  145. data/spec/lib/regions_proxy_spec.rb +47 -0
  146. data/spec/models/image_spec.rb +46 -0
  147. data/spec/models/page_spec.rb +237 -0
  148. data/spec/models/path_spec.rb +71 -0
  149. data/spec/models/region_spec.rb +14 -0
  150. data/spec/models/snippet_spec.rb +57 -0
  151. data/spec/models/version_spec.rb +7 -0
  152. data/spec/rails_app/.gitignore +33 -0
  153. data/spec/rails_app/Rakefile +7 -0
  154. data/spec/rails_app/app/assets/images/rails.png +0 -0
  155. data/spec/rails_app/app/assets/javascripts/application.js +9 -0
  156. data/spec/rails_app/app/assets/stylesheets/application.css +7 -0
  157. data/spec/rails_app/app/cells/example/display.html.haml +2 -0
  158. data/spec/rails_app/app/cells/example/options.html.haml +15 -0
  159. data/spec/rails_app/app/cells/example_cell.rb +19 -0
  160. data/spec/rails_app/app/cells/image_example/display.html.haml +4 -0
  161. data/spec/rails_app/app/cells/image_example/options.html.haml +15 -0
  162. data/spec/rails_app/app/cells/image_example_cell.rb +18 -0
  163. data/spec/rails_app/app/controllers/application_controller.rb +3 -0
  164. data/spec/rails_app/app/helpers/application_helper.rb +2 -0
  165. data/spec/rails_app/app/mailers/.gitkeep +0 -0
  166. data/spec/rails_app/app/models/.gitkeep +0 -0
  167. data/spec/rails_app/app/views/cmsimple/_snippet_list.html.haml +8 -0
  168. data/spec/rails_app/app/views/cmsimple/templates/default.html.haml +19 -0
  169. data/spec/rails_app/app/views/cmsimple/templates/test.html.haml +2 -0
  170. data/spec/rails_app/app/views/layouts/application.html.haml +13 -0
  171. data/spec/rails_app/config.ru +4 -0
  172. data/spec/rails_app/config/application.rb +65 -0
  173. data/spec/rails_app/config/boot.rb +9 -0
  174. data/spec/rails_app/config/database.example.yml +22 -0
  175. data/spec/rails_app/config/database.travis.yml +8 -0
  176. data/spec/rails_app/config/environment.rb +5 -0
  177. data/spec/rails_app/config/environments/development.rb +30 -0
  178. data/spec/rails_app/config/environments/test.rb +39 -0
  179. data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  180. data/spec/rails_app/config/initializers/cells.rb +1 -0
  181. data/spec/rails_app/config/initializers/cmsimple.rb +3 -0
  182. data/spec/rails_app/config/initializers/inflections.rb +10 -0
  183. data/spec/rails_app/config/initializers/mime_types.rb +5 -0
  184. data/spec/rails_app/config/initializers/secret_token.rb +7 -0
  185. data/spec/rails_app/config/initializers/session_store.rb +8 -0
  186. data/spec/rails_app/config/initializers/teabag.rb +58 -0
  187. data/spec/rails_app/config/initializers/wrap_parameters.rb +14 -0
  188. data/spec/rails_app/config/locales/en.yml +5 -0
  189. data/spec/rails_app/config/routes.rb +61 -0
  190. data/spec/rails_app/db/seeds.rb +11 -0
  191. data/spec/rails_app/lib/assets/.gitkeep +0 -0
  192. data/spec/rails_app/lib/tasks/.gitkeep +0 -0
  193. data/spec/rails_app/public/404.html +26 -0
  194. data/spec/rails_app/public/422.html +26 -0
  195. data/spec/rails_app/public/500.html +26 -0
  196. data/spec/rails_app/public/robots.txt +5 -0
  197. data/spec/rails_app/script/rails +6 -0
  198. data/spec/rails_app/vendor/assets/stylesheets/.gitkeep +0 -0
  199. data/spec/rails_app/vendor/plugins/.gitkeep +0 -0
  200. data/spec/spec_helper.rb +31 -0
  201. data/spec/support/active_model_lint_example.rb +14 -0
  202. data/spec/teabag_env.rb +28 -0
  203. data/vendor/assets/images/sitemap/has-changes.png +0 -0
  204. data/vendor/assets/images/sitemap/published.png +0 -0
  205. data/vendor/assets/images/sitemap/unpublished.png +0 -0
  206. data/vendor/assets/images/toolbar/metadata.png +0 -0
  207. data/vendor/assets/images/toolbar/publish.png +0 -0
  208. data/vendor/assets/images/toolbar/redirect.png +0 -0
  209. data/vendor/assets/images/toolbar/sitemap.png +0 -0
  210. data/vendor/assets/images/toolbar/snippets.png +0 -0
  211. data/vendor/assets/images/toolbar/unpublished.png +0 -0
  212. data/vendor/assets/images/tree-line-horizontal-last.png +0 -0
  213. data/vendor/assets/images/tree-line-horizontal.png +0 -0
  214. data/vendor/assets/images/tree-line-vertical.png +0 -0
  215. data/vendor/assets/javascripts/jquery-serializeObject.js +107 -0
  216. data/vendor/assets/javascripts/jquery.to-json.js +74 -0
  217. data/vendor/assets/javascripts/jquery.ui.nestedSortable-1.3.4.js +391 -0
  218. data/vendor/assets/javascripts/moment-1.6.2.js +918 -0
  219. data/vendor/assets/javascripts/underscore-1.3.1.js +31 -0
  220. data/vendor/assets/stylesheets/jasmine-modified.css +216 -0
  221. metadata +686 -0
@@ -0,0 +1,77 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+ ENV['RAILS_ENV'] = 'test'
7
+
8
+ require 'cucumber/rails'
9
+ require 'capybara/rails'
10
+
11
+ Capybara.register_driver :selenium do |app|
12
+ Capybara::Selenium::Driver.new(app, :resynchronize => true)
13
+ end
14
+
15
+ # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
16
+ # order to ease the transition to Capybara we set the default here. If you'd
17
+ # prefer to use XPath just remove this line and adjust any selectors in your
18
+ # steps to use the XPath syntax.
19
+ Capybara.default_selector = :css
20
+ Capybara.ignore_hidden_elements = true
21
+
22
+ Capybara.default_wait_time = ENV['CI_WAIT_TIME'].try(:to_i) || 4
23
+
24
+ # By default, any exception happening in your Rails application will bubble up
25
+ # to Cucumber so that your scenario will fail. This is a different from how
26
+ # your application behaves in the production environment, where an error page will
27
+ # be rendered instead.
28
+ #
29
+ # Sometimes we want to override this default behaviour and allow Rails to rescue
30
+ # exceptions and display an error page (just like when the app is running in production).
31
+ # Typical scenarios where you want to do this is when you test your error pages.
32
+ # There are two ways to allow Rails to rescue exceptions:
33
+ #
34
+ # 1) Tag your scenario (or feature) with @allow-rescue
35
+ #
36
+ # 2) Set the value below to true. Beware that doing this globally is not
37
+ # recommended as it will mask a lot of errors for you!
38
+ #
39
+ ActionController::Base.allow_rescue = true
40
+
41
+ # Remove/comment out the lines below if your app doesn't have a database.
42
+ # For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
43
+ begin
44
+ DatabaseCleaner.strategy = :transaction
45
+ rescue NameError
46
+ raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
47
+ end
48
+
49
+ # You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
50
+ # See the DatabaseCleaner documentation for details. Example:
51
+ #
52
+ # Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
53
+ # DatabaseCleaner.strategy = :truncation, {:except => %w[widgets]}
54
+ # end
55
+ #
56
+ # Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
57
+ # DatabaseCleaner.strategy = :transaction
58
+ # end
59
+ #
60
+
61
+ # Possible values are :truncation and :transaction
62
+ # The :transaction strategy is faster, but might give you threading problems.
63
+ # See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
64
+ Cucumber::Rails::Database.javascript_strategy = :truncation
65
+
66
+ Before('@allow_hidden_elements') do
67
+ Capybara.ignore_hidden_elements = false
68
+ end
69
+
70
+ After('@allow_hidden_elements') do
71
+ Capybara.ignore_hidden_elements = true
72
+ end
73
+
74
+ # Always run maximized so the toolbar is showing
75
+ Before('@javascript') do
76
+ page.driver.browser.manage.window.maximize
77
+ end
@@ -0,0 +1,25 @@
1
+ module MercuryContentsHelpers
2
+ def contents_for(name)
3
+ case name
4
+ when 'simple content' then "this is <span>simple</span> <b>content</b>"
5
+ when 'justifiable content' then "<div>first line</div><br/>this is <span>justifiable</span> <b>content</b>"
6
+ when 'wrapped content' then "<span>this <a href='http://google.com'>is</a> <i>wrapped</i> <b>content</b></span>"
7
+ when 'an image' then "this is <img src='/assets/mercury/temp-logo.png'> <b>content</b>"
8
+ when 'a table' then "this is a <table><tr><td><span>1</span></td><td><span>2</span></td></tr><tr><td><span>3</span></td><td><span>4</span></td></tr></table> <b>content</b>"
9
+ when 'the snippet', 'that snippet' then "<div class='mercury-snippet' data-snippet='#{@snippet_id || 'snippet_42'}'>#{@snippet_id || 'snippet_42'}</div> <b>content</b>"
10
+
11
+ else name
12
+ end
13
+ end
14
+
15
+ def parse_snippet_options_from(options_string)
16
+ json = []
17
+ options_string.scan(/(?:,\s)?([^:]*): ("[^"]*")/).each do |pair|
18
+ json << %Q{'options[#{pair[0]}]': #{pair[1]}}
19
+ end
20
+
21
+ "{#{json.join(', ')}}"
22
+ end
23
+ end
24
+
25
+ World(MercuryContentsHelpers)
@@ -0,0 +1,148 @@
1
+ module MercurySelectorsHelpers
2
+
3
+ def mercury_selector_for(locator)
4
+ case locator
5
+
6
+ # toolbar selectors
7
+ when 'the toolbar' then '.mercury-toolbar-container'
8
+
9
+ when /^the "(.*?)" button$/
10
+ ".mercury-primary-toolbar .mercury-#{mercury_button_mapping_for($1)}-button, .mercury-primary-expander .mercury-expander-button[data-button='#{mercury_button_mapping_for($1)}']"
11
+
12
+ when /^the (.*?) editor (button|dropdown|palette)$/
13
+ ".mercury-editable-toolbar .mercury-#{mercury_button_mapping_for($1)}-button"
14
+
15
+ when /^the (.*?) toolbar button$/
16
+ ".mercury-snippet-toolbar .mercury-#{mercury_button_mapping_for($1)}-button"
17
+
18
+ when /^the (.*?) select$/
19
+ ".mercury-#{mercury_button_mapping_for($1)}-select"
20
+
21
+ when /^the (.*?) palette$/
22
+ ".mercury-#{mercury_button_mapping_for($1)}-palette"
23
+
24
+ # palette / select dropdown
25
+ when 'the color red' then '.mercury-palette .picker:nth-child(22n)'
26
+
27
+ when 'the red style' then '.mercury-select-options .red'
28
+ when 'the heading 2 block' then '.mercury-select-options h2'
29
+
30
+ # statusbar selectors
31
+ when 'the statusbar' then '.mercury-statusbar'
32
+ when 'the about the editor link' then 'a.mercury-statusbar-about'
33
+
34
+ # panel selectors
35
+ when 'the panel', /^the (.*?) panel$/ then '.mercury-panel'
36
+
37
+ # modal window selectors
38
+ when 'the modal', 'the modal window', /^the (.*?) modal$/ then '.mercury-modal'
39
+ when 'the modal overlay' then '.mercury-modal-overlay'
40
+ when 'the modal title' then '.mercury-modal h1.mercury-modal-title'
41
+ when 'the modal close button' then '.mercury-modal h1.mercury-modal-title a'
42
+
43
+ when 'the sweet snowman' then '.mercury-modal .character:nth-child(247n)'
44
+
45
+ when 'the first cell in the first row' then '.mercury-modal tr:nth-child(1n) td:nth-child(1n)'
46
+ when 'the third cell in the first row' then '.mercury-modal tr:nth-child(1n) td:nth-child(3n)'
47
+ when 'the forth cell in the first row' then '.mercury-modal tr:nth-child(1n) td:nth-child(4n)'
48
+ when 'the second cell in the second row' then '.mercury-modal tr:nth-child(2n) td:nth-child(2n)'
49
+ when 'the forth cell in the second row' then '.mercury-modal tr:nth-child(2n) td:nth-child(4n)'
50
+
51
+ when 'a selected cell' then '.mercury-modal td.selected'
52
+
53
+ # lightview selectors
54
+ when 'the lightview', 'the lightview window', /^the (.*?) lightview$/ then '.mercury-lightview'
55
+ when 'the lightview overlay' then '.mercury-lightview-overlay'
56
+ when 'the lightview title' then '.mercury-lightview h1.mercury-lightview-title'
57
+ when 'the lightview close button' then '.mercury-lightview h1.mercury-lightview-title a'
58
+
59
+ # snippet selectors
60
+ when 'the snippet toolbar' then '.mercury-snippet-toolbar'
61
+ when 'the snippet', 'that snippet' then "div[data-snippet=#{@snippet_id || 'snippet_0'}]"
62
+
63
+ # other selectors
64
+ when 'the first image' then 'img:nth-child(1n)'
65
+
66
+ end
67
+ end
68
+
69
+ def mercury_button_mapping_for(locator)
70
+ case locator.downcase
71
+
72
+ # primary toolbar
73
+ when 'save' then 'save'
74
+ when 'preview' then 'preview'
75
+ when 'undo' then 'undo'
76
+ when 'redo' then 'redo'
77
+ when 'link', 'insert link' then 'insertLink'
78
+ when 'media', 'insert media' then 'insertMedia'
79
+ when 'table', 'insert table' then 'insertTable'
80
+ when 'character', 'insert character' then 'insertCharacter'
81
+ when 'snippet', 'insert snippet' then 'snippetPanel'
82
+ when 'history', 'view history' then 'historyPanel'
83
+ when 'notes', 'view notes' then 'notesPanel'
84
+
85
+ # editor toolbar
86
+ when 'predefined styles' then 'style'
87
+ when 'block format' then 'formatblock'
88
+ when 'backcolor', 'background color' then 'backColor'
89
+ when 'forecolor', 'foreground color' then 'foreColor'
90
+ when 'italicize' then 'italic'
91
+ when 'overline' then 'overline'
92
+ when 'strike through' then 'strikethrough'
93
+ when 'underline' then 'underline'
94
+ when 'subscript' then 'subscript'
95
+ when 'superscript' then 'superscript'
96
+ when 'justify left', 'left justify' then 'justifyLeft'
97
+ when 'justify center', 'center justify' then 'justifyCenter'
98
+ when 'justify right', 'right justify' then 'justifyRight'
99
+ when 'justify full', 'full justification' then 'justifyFull'
100
+ when 'unordered list', 'insert unordered list' then 'insertUnorderedList'
101
+ when 'ordered list', 'insert ordered list' then 'insertOrderedList'
102
+ when 'hr', 'insert hr', 'horizontal rule', 'insert horizontal rule' then 'horizontalRule'
103
+ when 'clean formatting', 'remove formatting' then 'removeFormatting'
104
+ when 'html editor' then 'htmlEditor'
105
+
106
+ # table context buttons
107
+ when 'add row before', 'insert row before' then 'insertRowBefore'
108
+ when 'add row after', 'insert row after' then 'insertRowAfter'
109
+ when 'delete row' then 'deleteRow'
110
+ when 'add column before', 'insert column before' then 'insertColumnBefore'
111
+ when 'add column after', 'insert column after' then 'insertColumnAfter'
112
+ when 'delete column' then 'deleteColumn'
113
+ when 'increase colspan' then 'increaseColspan'
114
+ when 'decrease colspan' then 'decreaseColspan'
115
+ when 'increase rowspan' then 'increaseRowspan'
116
+ when 'decrease rowspan' then 'decreaseRowspan'
117
+
118
+ # snippet toolbar
119
+ when 'edit snippet settings', 'edit snippet' then 'editSnippet'
120
+ when 'remove snippet' then 'removeSnippet'
121
+
122
+ else locator
123
+ end
124
+ end
125
+
126
+ def region_selector_for(locator)
127
+ case locator.downcase
128
+
129
+ when 'the first editable region', 'the editable region' then '#editable1'
130
+ when 'the first markupable region', 'the markupable region', 'the markdown region' then '#markupable1'
131
+ when 'the first snippetable region', 'the first snippet region', 'the snippetable region', 'the snippet region' then '#snippetable1'
132
+
133
+ else locator
134
+ end
135
+ end
136
+
137
+ def snippet_name_for(locator)
138
+ case locator.downcase
139
+
140
+ when 'the example snippet' then 'example'
141
+
142
+ else locator
143
+ end
144
+ end
145
+
146
+ end
147
+
148
+ World(MercurySelectorsHelpers)
@@ -0,0 +1,16 @@
1
+
2
+ module NavigationHelpers
3
+ # Maps a name to a path. Used by the
4
+ #
5
+ # When /^I go to (.+)$/ do |page_name|
6
+ #
7
+ # step definition in web_steps.rb
8
+ PATHS = {
9
+ "the home page" => '/'
10
+ }
11
+ def path_to(page_name)
12
+ PATHS[page_name] || page_name.gsub('"', '')
13
+ end
14
+ end
15
+
16
+ World(NavigationHelpers)
@@ -0,0 +1,26 @@
1
+
2
+ module HtmlSelectorsHelpers
3
+ # Maps a name to a selector. Used primarily by the
4
+ #
5
+ # When /^(.+) within (.+)$/ do |step, scope|
6
+ #
7
+ # step definitions in web_steps.rb
8
+ #
9
+ def selector_for(locator)
10
+
11
+ # add in for mercury support
12
+ result = mercury_selector_for(locator)
13
+ return result if result.present?
14
+
15
+ case locator
16
+ when /the page/
17
+ "html > body"
18
+ when /"(.+)"/
19
+ $1
20
+ else
21
+ raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
22
+ "Now, go and add a mapping in #{__FILE__}"
23
+ end
24
+ end
25
+ end
26
+ World(HtmlSelectorsHelpers)
@@ -0,0 +1,18 @@
1
+ module StepUtils
2
+ def wait_for_client_page_refresh
3
+ page.driver.execute_script("window.__page_refreshed = false; CMSimple.Page.one('refresh', function(){ window.__page_refreshed = true; });")
4
+ yield
5
+ wait_until(10) do
6
+ page.evaluate_script('window.__page_refreshed') == true
7
+ # not sure why this makes the tests pass
8
+ sleep(1)
9
+ end
10
+ end
11
+
12
+ def allow_hidden_elements
13
+ Capybara.ignore_hidden_elements = false
14
+ yield
15
+ Capybara.ignore_hidden_elements = true
16
+ end
17
+ end
18
+ World(StepUtils)
@@ -0,0 +1,27 @@
1
+ @javascript
2
+ Feature: As a user I should be able to view different versions of pages on the site
3
+
4
+ Background:
5
+ Given a page exists at a custom path with custom content
6
+ And I visit that page's edit path
7
+
8
+ Scenario: As a user I should be able to see the versions
9
+ that have been created when I publish a page
10
+ Given I open the sitemap
11
+ And I add a new page
12
+ When I publish the current page
13
+ And I open the page's history
14
+ Then I there should be one version in the history panel
15
+
16
+ Scenario: As a user I should be able to view the page
17
+ at a particular version that has been published
18
+ Given I open the sitemap
19
+ And I add a new page
20
+ And I publish the current page
21
+ When I publish a new version of the current page
22
+ And I open the page's history
23
+ And I view the old version
24
+ Then I should see the old version
25
+ # When I view the new version
26
+ # Then I should see the new version
27
+
@@ -0,0 +1,7 @@
1
+ Feature: As a user I should be able to visit pages on the site
2
+
3
+ Scenario: As a user I should be able to view a page with custom content at a specified path
4
+ Given a page exists at a custom path with custom content
5
+ When I visit that page's path
6
+ Then I should see that page's content in it's template
7
+
@@ -0,0 +1,22 @@
1
+ require 'cmsimple/version'
2
+ require 'rails'
3
+ require 'mercury-rails'
4
+ require 'cells'
5
+ require 'carrierwave'
6
+ require 'dimensions'
7
+
8
+ # dependencies we want to reduce the
9
+ # need of after codebase stabilizes
10
+ require 'spine-rails'
11
+ require 'haml-rails'
12
+ require 'haml_coffee_assets'
13
+ require 'cmsimple/configuration'
14
+
15
+ require 'cmsimple/rails'
16
+ require 'cmsimple/template_resolver'
17
+ require 'cmsimple/template_responder'
18
+ require 'cmsimple/page_responder'
19
+ require 'cmsimple/regions_proxy'
20
+
21
+ require 'cmsimple/exts/to_bool'
22
+
@@ -0,0 +1,65 @@
1
+ module Cmsimple
2
+ class Configuration
3
+ def initialize
4
+ # the parent controller for the front controller
5
+ self.parent_front_controller = 'ApplicationController'
6
+ # the parent controller for all CRUD controllers
7
+ self.parent_controller = 'ApplicationController'
8
+ # where the templates are located in the project
9
+ self.template_path = 'cmsimple/templates'
10
+ # set a template strategy (i.e. if you wanted to build a db backed template system)
11
+ self.template_strategy = :basic
12
+ # the path carrierwave will use to store image assets
13
+ self.asset_path = 'uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}'
14
+ # the library to use for processing images in carrierwave (rmagick or mini_magick)
15
+ self.image_processor = :mini_magick
16
+ # stylesheets to be included in the editor layout page
17
+ self.editor_stylesheets = ['cmsimple']
18
+ # javascripts to be included in the editor layout page
19
+ self.editor_javascripts = ['cmsimple']
20
+ # set this to change layouts or pass other params into rendering a template
21
+ self.template_render_options = {}
22
+ end
23
+
24
+ attr_accessor :parent_controller,
25
+ :parent_front_controller,
26
+ :template_path,
27
+ :asset_path,
28
+ :image_processor,
29
+ :editor_stylesheets,
30
+ :editor_javascripts,
31
+ :template_render_options
32
+
33
+ attr_writer :template_strategy
34
+
35
+ def template_strategy
36
+ case @template_strategy
37
+ when :basic
38
+ Cmsimple::TemplateResponder
39
+ else
40
+ @template_strategy.constantize
41
+ end
42
+ end
43
+
44
+ def image_processor_mixin
45
+ case @image_processor
46
+ when :rmagick
47
+ CarrierWave::RMagick
48
+ else
49
+ CarrierWave::MiniMagick
50
+ end
51
+ end
52
+
53
+ end
54
+
55
+ class << self
56
+ attr_accessor :configuration
57
+
58
+ # Configure CMSimple
59
+ #
60
+ def configure
61
+ self.configuration ||= Configuration.new
62
+ yield self.configuration
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,25 @@
1
+ class String
2
+ def to_bool
3
+ return true if self == true || self =~ (/(true|t|yes|y|1)$/i)
4
+ return false if self == false || self.blank? || self =~ (/(false|f|no|n|0)$/i)
5
+ raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
6
+ end
7
+ end
8
+
9
+ class TrueClass
10
+ def to_bool
11
+ self
12
+ end
13
+ end
14
+
15
+ class FalseClass
16
+ def to_bool
17
+ self
18
+ end
19
+ end
20
+
21
+ class NilClass
22
+ def to_bool
23
+ false
24
+ end
25
+ end