landable 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (310) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/CHANGELOG.md +5 -0
  4. data/Gemfile +15 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.md +56 -0
  7. data/Rakefile +22 -0
  8. data/app/controllers/concerns/landable/variables_concern.rb +38 -0
  9. data/app/controllers/landable/api/access_tokens_controller.rb +48 -0
  10. data/app/controllers/landable/api/assets_controller.rb +55 -0
  11. data/app/controllers/landable/api/categories_controller.rb +13 -0
  12. data/app/controllers/landable/api/directories_controller.rb +19 -0
  13. data/app/controllers/landable/api/page_revisions_controller.rb +38 -0
  14. data/app/controllers/landable/api/pages_controller.rb +96 -0
  15. data/app/controllers/landable/api/templates_controller.rb +33 -0
  16. data/app/controllers/landable/api/themes_controller.rb +57 -0
  17. data/app/controllers/landable/api_controller.rb +75 -0
  18. data/app/controllers/landable/application_controller.rb +4 -0
  19. data/app/controllers/landable/public/pages_controller.rb +25 -0
  20. data/app/controllers/landable/public/preview/page_revisions_controller.rb +16 -0
  21. data/app/controllers/landable/public/preview/pages_controller.rb +16 -0
  22. data/app/controllers/landable/public/sitemap_controller.rb +18 -0
  23. data/app/decorators/landable/null_page_decorator.rb +26 -0
  24. data/app/decorators/landable/page_decorator.rb +40 -0
  25. data/app/helpers/landable/application_helper.rb +13 -0
  26. data/app/helpers/landable/pages_helper.rb +20 -0
  27. data/app/models/concerns/landable/has_assets.rb +74 -0
  28. data/app/models/concerns/landable/table_name.rb +12 -0
  29. data/app/models/concerns/landable/traffic/table_name.rb +14 -0
  30. data/app/models/landable/access_token.rb +20 -0
  31. data/app/models/landable/asset.rb +63 -0
  32. data/app/models/landable/asset_search_engine.rb +20 -0
  33. data/app/models/landable/author.rb +12 -0
  34. data/app/models/landable/category.rb +27 -0
  35. data/app/models/landable/directory.rb +23 -0
  36. data/app/models/landable/page.rb +259 -0
  37. data/app/models/landable/page_revision.rb +74 -0
  38. data/app/models/landable/page_search_engine.rb +20 -0
  39. data/app/models/landable/search_engine.rb +39 -0
  40. data/app/models/landable/template.rb +24 -0
  41. data/app/models/landable/theme.rb +20 -0
  42. data/app/models/landable/traffic/access.rb +11 -0
  43. data/app/models/landable/traffic/ad_group.rb +11 -0
  44. data/app/models/landable/traffic/ad_type.rb +11 -0
  45. data/app/models/landable/traffic/attribution.rb +38 -0
  46. data/app/models/landable/traffic/bid_match_type.rb +11 -0
  47. data/app/models/landable/traffic/browser.rb +11 -0
  48. data/app/models/landable/traffic/campaign.rb +11 -0
  49. data/app/models/landable/traffic/city.rb +11 -0
  50. data/app/models/landable/traffic/content.rb +11 -0
  51. data/app/models/landable/traffic/cookie.rb +16 -0
  52. data/app/models/landable/traffic/country.rb +11 -0
  53. data/app/models/landable/traffic/creative.rb +11 -0
  54. data/app/models/landable/traffic/device.rb +11 -0
  55. data/app/models/landable/traffic/device_type.rb +11 -0
  56. data/app/models/landable/traffic/domain.rb +12 -0
  57. data/app/models/landable/traffic/event.rb +12 -0
  58. data/app/models/landable/traffic/event_type.rb +11 -0
  59. data/app/models/landable/traffic/experiment.rb +11 -0
  60. data/app/models/landable/traffic/http_method.rb +11 -0
  61. data/app/models/landable/traffic/ip_address.rb +11 -0
  62. data/app/models/landable/traffic/ip_lookup.rb +12 -0
  63. data/app/models/landable/traffic/keyword.rb +11 -0
  64. data/app/models/landable/traffic/location.rb +11 -0
  65. data/app/models/landable/traffic/match_type.rb +11 -0
  66. data/app/models/landable/traffic/medium.rb +11 -0
  67. data/app/models/landable/traffic/mime_type.rb +11 -0
  68. data/app/models/landable/traffic/network.rb +11 -0
  69. data/app/models/landable/traffic/owner.rb +10 -0
  70. data/app/models/landable/traffic/ownership.rb +10 -0
  71. data/app/models/landable/traffic/page_view.rb +24 -0
  72. data/app/models/landable/traffic/path.rb +13 -0
  73. data/app/models/landable/traffic/placement.rb +11 -0
  74. data/app/models/landable/traffic/platform.rb +11 -0
  75. data/app/models/landable/traffic/position.rb +11 -0
  76. data/app/models/landable/traffic/query_string.rb +12 -0
  77. data/app/models/landable/traffic/referer.rb +11 -0
  78. data/app/models/landable/traffic/region.rb +11 -0
  79. data/app/models/landable/traffic/search_term.rb +11 -0
  80. data/app/models/landable/traffic/source.rb +11 -0
  81. data/app/models/landable/traffic/target.rb +11 -0
  82. data/app/models/landable/traffic/user_agent.rb +28 -0
  83. data/app/models/landable/traffic/user_agent_type.rb +11 -0
  84. data/app/models/landable/traffic/visit.rb +15 -0
  85. data/app/models/landable/traffic/visitor.rb +13 -0
  86. data/app/responders/landable/api_responder.rb +76 -0
  87. data/app/responders/landable/page_render_responder.rb +15 -0
  88. data/app/serializers/landable/access_token_serializer.rb +6 -0
  89. data/app/serializers/landable/asset_serializer.rb +14 -0
  90. data/app/serializers/landable/author_serializer.rb +5 -0
  91. data/app/serializers/landable/category_serializer.rb +5 -0
  92. data/app/serializers/landable/directory_serializer.rb +8 -0
  93. data/app/serializers/landable/page_revision_serializer.rb +15 -0
  94. data/app/serializers/landable/page_serializer.rb +31 -0
  95. data/app/serializers/landable/template_serializer.rb +5 -0
  96. data/app/serializers/landable/theme_serializer.rb +7 -0
  97. data/app/services/landable/authentication_service.rb +44 -0
  98. data/app/services/landable/registration_service.rb +13 -0
  99. data/app/services/landable/render_service.rb +86 -0
  100. data/app/services/landable/tidy_service.rb +155 -0
  101. data/app/uploaders/landable/asset_uploader.rb +9 -0
  102. data/app/validators/path_validator.rb +12 -0
  103. data/app/validators/url_validator.rb +13 -0
  104. data/app/views/templates/preview.liquid +122 -0
  105. data/bin/rails +8 -0
  106. data/bin/redb +7 -0
  107. data/config.ru +7 -0
  108. data/config/cucumber.yml +5 -0
  109. data/config/routes.rb +62 -0
  110. data/db/migrate/20130510221424_create_landable_schema.rb +338 -0
  111. data/db/migrate/20130909182713_landable_pages__add_updated_by.rb +11 -0
  112. data/db/migrate/20130909182715_landable_page_revisions__break_out_snapshot.rb +72 -0
  113. data/db/migrate/20130909191153_landable_pages__add_lock_version.rb +5 -0
  114. data/db/migrate/20131002220041_file_based_themes.rb +12 -0
  115. data/db/migrate/20131008164204_create_head_tag_on_page.rb +19 -0
  116. data/db/migrate/20131008193544_drop_status_codes_model.rb +44 -0
  117. data/db/migrate/20131028145652_add_traffic_schema.rb +276 -0
  118. data/db/migrate/20131101213623_add_dnt_column_to_visits.rb +7 -0
  119. data/db/migrate/20131104224120_add_meta_on_events.rb +7 -0
  120. data/db/migrate/20131106185946_add_index_on_page_revisions_path.rb +6 -0
  121. data/db/migrate/20131106193021_page_revisisons__path_status_code_index.rb +9 -0
  122. data/db/migrate/20131108212501_traffic_owner_ids_are_serials.rb +20 -0
  123. data/db/migrate/20131121150902_add_attribution_id_to_unique_index.rb +10 -0
  124. data/db/migrate/20131216214027_drop_browser_screenshot_tables.rb +6 -0
  125. data/db/migrate/20140128170659_file_backed_templates.rb +8 -0
  126. data/db/migrate/20140205193757_fix_status_codes.rb +24 -0
  127. data/db/migrate/20140206211322_add_response_time_to_traffic_page_views.rb +7 -0
  128. data/db/migrate/20140220170324_add_slug_to_categories.rb +14 -0
  129. data/db/migrate/20140220174630_add_abstract_and_hero_asset_to_pages_and_page_revisions.rb +8 -0
  130. data/db/migrate/20140224205516_rename_traffic_schema.rb +40 -0
  131. data/db/pgtap/pgtap.sql +9034 -0
  132. data/db/test/landable.access_tokens.sql +13 -0
  133. data/db/test/landable.assets.sql +16 -0
  134. data/db/test/landable.authors.sql +22 -0
  135. data/db/test/landable.categories.sql +9 -0
  136. data/db/test/landable.page_revisions.sql +41 -0
  137. data/db/test/landable.pages.sql +19 -0
  138. data/db/test/landable.templates.sql +15 -0
  139. data/db/test/landable.themes.sql +25 -0
  140. data/doc/schema/access_token.json +22 -0
  141. data/doc/schema/asset.json +65 -0
  142. data/doc/schema/author.json +30 -0
  143. data/doc/schema/directory.json +24 -0
  144. data/doc/schema/page.json +95 -0
  145. data/doc/schema/page_revision.json +70 -0
  146. data/doc/schema/theme.json +37 -0
  147. data/doc/schema/uuid.json +6 -0
  148. data/features/api/access_tokens.feature +84 -0
  149. data/features/api/assets.feature +46 -0
  150. data/features/api/cors.feature +25 -0
  151. data/features/api/pages.feature +42 -0
  152. data/features/api/preview.feature +16 -0
  153. data/features/api/templates.feature +33 -0
  154. data/features/api/themes.feature +33 -0
  155. data/features/liquid/body.feature +35 -0
  156. data/features/liquid/drops/categories.feature +54 -0
  157. data/features/liquid/tags.feature +168 -0
  158. data/features/public/content_types.feature +17 -0
  159. data/features/public/publishing.feature +45 -0
  160. data/features/public/status_codes.feature +25 -0
  161. data/features/public/views.feature +17 -0
  162. data/features/step_definitions/asset_steps.rb +60 -0
  163. data/features/step_definitions/core_api_steps.rb +139 -0
  164. data/features/step_definitions/debug_steps.rb +3 -0
  165. data/features/step_definitions/factory_steps.rb +124 -0
  166. data/features/step_definitions/html_steps.rb +9 -0
  167. data/features/step_definitions/liquid_steps.rb +79 -0
  168. data/features/step_definitions/revision_steps.rb +5 -0
  169. data/features/step_definitions/theme_steps.rb +43 -0
  170. data/features/support/env.rb +66 -0
  171. data/features/support/usefulness.rb +13 -0
  172. data/landable.gemspec +54 -0
  173. data/lib/generators/landable/collection/collection_generator.rb +0 -0
  174. data/lib/generators/landable/collection/templates/stylesheets/landable/%file_name%.less +0 -0
  175. data/lib/generators/landable/collection/templates/stylesheets/landable/%file_name%/mixins.less +0 -0
  176. data/lib/generators/landable/collection/templates/stylesheets/landable/%file_name%/variables.less +0 -0
  177. data/lib/generators/landable/component/component_generator.rb +0 -0
  178. data/lib/generators/landable/component/templates/javascripts/landable/%file_name%.less +0 -0
  179. data/lib/generators/landable/component/templates/stylesheets/landable/%file_name%.less +0 -0
  180. data/lib/generators/landable/install_generator.rb +19 -0
  181. data/lib/generators/landable/landable_generator.rb +22 -0
  182. data/lib/generators/templates/landable.rb +34 -0
  183. data/lib/landable.rb +30 -0
  184. data/lib/landable/configuration.rb +115 -0
  185. data/lib/landable/core_ext/ipaddr.rb +18 -0
  186. data/lib/landable/engine.rb +69 -0
  187. data/lib/landable/error.rb +16 -0
  188. data/lib/landable/inflections.rb +4 -0
  189. data/lib/landable/layout.rb +60 -0
  190. data/lib/landable/liquid.rb +27 -0
  191. data/lib/landable/liquid/asset_tags.rb +76 -0
  192. data/lib/landable/liquid/drops.rb +46 -0
  193. data/lib/landable/liquid/filters.rb +11 -0
  194. data/lib/landable/liquid/tags.rb +91 -0
  195. data/lib/landable/migration.rb +40 -0
  196. data/lib/landable/mime_types.rb +15 -0
  197. data/lib/landable/partial.rb +46 -0
  198. data/lib/landable/seeds.rb +36 -0
  199. data/lib/landable/traffic.rb +34 -0
  200. data/lib/landable/traffic/crawl_tracker.rb +9 -0
  201. data/lib/landable/traffic/noop_tracker.rb +8 -0
  202. data/lib/landable/traffic/ping_tracker.rb +9 -0
  203. data/lib/landable/traffic/scan_tracker.rb +9 -0
  204. data/lib/landable/traffic/scrape_tracker.rb +9 -0
  205. data/lib/landable/traffic/tracker.rb +283 -0
  206. data/lib/landable/traffic/user_tracker.rb +65 -0
  207. data/lib/landable/version.rb +10 -0
  208. data/lib/tasks/landable/cucumber.rake +67 -0
  209. data/lib/tasks/landable/data.rake +166 -0
  210. data/lib/tasks/landable/pgtap.rake +26 -0
  211. data/lib/tasks/landable/rdoc.rake +11 -0
  212. data/lib/tasks/landable/seed.rake +16 -0
  213. data/lib/tasks/landable/spec.rake +15 -0
  214. data/script/cucumber +10 -0
  215. data/spec/concerns/landable/has_assets_spec.rb +75 -0
  216. data/spec/concerns/landable/table_name_spec.rb +15 -0
  217. data/spec/concerns/landable/traffic/table_name_spec.rb +16 -0
  218. data/spec/controllers/concerns/landable/variables_concern_spec.rb +66 -0
  219. data/spec/controllers/landable/api/assets_controller_spec.rb +24 -0
  220. data/spec/controllers/landable/api/categories_controller_spec.rb +45 -0
  221. data/spec/controllers/landable/api/directories_controller_spec.rb +56 -0
  222. data/spec/controllers/landable/api/page_revisions_controller_spec.rb +29 -0
  223. data/spec/controllers/landable/api/pages_controller_spec.rb +271 -0
  224. data/spec/controllers/landable/api_controller_spec.rb +189 -0
  225. data/spec/controllers/public/preview/page_revisions_controller_spec.rb +41 -0
  226. data/spec/controllers/public/preview/pages_controller_spec.rb +36 -0
  227. data/spec/controllers/public/sitemap_controller_spec.rb +25 -0
  228. data/spec/decorators/page_decorator_spec.rb +90 -0
  229. data/spec/dummy/README.rdoc +28 -0
  230. data/spec/dummy/Rakefile +6 -0
  231. data/spec/dummy/app/assets/images/foo.jpg +0 -0
  232. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  233. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  234. data/spec/dummy/app/controllers/application_controller.rb +10 -0
  235. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  236. data/spec/dummy/app/controllers/priority_controller.rb +7 -0
  237. data/spec/dummy/app/helpers/application_helper.rb +5 -0
  238. data/spec/dummy/app/mailers/.keep +0 -0
  239. data/spec/dummy/app/models/.keep +0 -0
  240. data/spec/dummy/app/models/concerns/.keep +0 -0
  241. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  242. data/spec/dummy/app/views/layouts/priority.html.erb +18 -0
  243. data/spec/dummy/app/views/partials/_foobazz.html +1 -0
  244. data/spec/dummy/app/views/priority/show.html.erb +11 -0
  245. data/spec/dummy/bin/bundle +3 -0
  246. data/spec/dummy/bin/rails +4 -0
  247. data/spec/dummy/bin/rake +4 -0
  248. data/spec/dummy/config.ru +4 -0
  249. data/spec/dummy/config/application.rb +21 -0
  250. data/spec/dummy/config/boot.rb +5 -0
  251. data/spec/dummy/config/database.yml +60 -0
  252. data/spec/dummy/config/environment.rb +5 -0
  253. data/spec/dummy/config/environments/development.rb +29 -0
  254. data/spec/dummy/config/environments/production.rb +80 -0
  255. data/spec/dummy/config/environments/test.rb +42 -0
  256. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  257. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  258. data/spec/dummy/config/initializers/inflections.rb +16 -0
  259. data/spec/dummy/config/initializers/landable.rb +22 -0
  260. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  261. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  262. data/spec/dummy/config/initializers/session_store.rb +3 -0
  263. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  264. data/spec/dummy/config/locales/en.yml +23 -0
  265. data/spec/dummy/config/routes.rb +4 -0
  266. data/spec/dummy/db/structure.sql +3736 -0
  267. data/spec/dummy/lib/assets/.keep +0 -0
  268. data/spec/dummy/log/.keep +0 -0
  269. data/spec/dummy/public/404.html +58 -0
  270. data/spec/dummy/public/422.html +58 -0
  271. data/spec/dummy/public/500.html +57 -0
  272. data/spec/dummy/public/favicon.ico +0 -0
  273. data/spec/factories/asset.rb +29 -0
  274. data/spec/factories/authors.rb +12 -0
  275. data/spec/factories/category.rb +6 -0
  276. data/spec/factories/page_revision.rb +6 -0
  277. data/spec/factories/pages.rb +33 -0
  278. data/spec/factories/template.rb +13 -0
  279. data/spec/factories/theme.rb +14 -0
  280. data/spec/fixtures/assets/cthulhu.jpg +0 -0
  281. data/spec/fixtures/assets/panda.png +0 -0
  282. data/spec/fixtures/assets/sloth.png +0 -0
  283. data/spec/fixtures/assets/small.pdf +0 -0
  284. data/spec/helpers/pages_helper_spec.rb +35 -0
  285. data/spec/lib/landable/configuration_spec.rb +20 -0
  286. data/spec/lib/landable/layout_spec.rb +25 -0
  287. data/spec/lib/landable/liquid_spec.rb +24 -0
  288. data/spec/lib/landable/migration_spec.rb +51 -0
  289. data/spec/lib/landable/partial_spec.rb +84 -0
  290. data/spec/lib/landable/tracking_spec.rb +62 -0
  291. data/spec/lib/landable/traffic_spec.rb +45 -0
  292. data/spec/models/landable/access_token_spec.rb +13 -0
  293. data/spec/models/landable/asset_spec.rb +48 -0
  294. data/spec/models/landable/directory_spec.rb +36 -0
  295. data/spec/models/landable/page/errors_spec.rb +30 -0
  296. data/spec/models/landable/page_revision_spec.rb +75 -0
  297. data/spec/models/landable/page_spec.rb +377 -0
  298. data/spec/models/landable/template_spec.rb +47 -0
  299. data/spec/models/landable/theme_spec.rb +8 -0
  300. data/spec/responders/page_render_responder_spec.rb +43 -0
  301. data/spec/routing/public_page_route_spec.rb +36 -0
  302. data/spec/services/landable/authentication_service_spec.rb +61 -0
  303. data/spec/services/landable/render_service_spec.rb +103 -0
  304. data/spec/services/landable/tidy_service_spec.rb +157 -0
  305. data/spec/spec_helper.rb +38 -0
  306. data/spec/support/behaviors.rb +107 -0
  307. data/spec/support/carrier_wave.rb +17 -0
  308. data/spec/support/categories.yml +2 -0
  309. data/spec/support/helpers.rb +22 -0
  310. metadata +795 -0
@@ -0,0 +1,79 @@
1
+ Given 'the asset URI prefix is "$uri"' do |uri|
2
+ # Kinda bogus, but makes explicit tests significantly easier
3
+ Landable::Asset.stub!(:url_generator) do
4
+ proc { |asset|
5
+ uri = "#{uri}/" unless uri.ends_with?('/')
6
+ "#{uri}#{asset.data}"
7
+ }
8
+ end
9
+ end
10
+
11
+ Given /^a page under test$/ do
12
+ @page = Landable::Page.new(title: "Page Under Test")
13
+ end
14
+
15
+ Given "the page's body is \"$body\"" do |body|
16
+ @page.body = body
17
+ end
18
+
19
+ Given "the page's body is:" do |body|
20
+ @page.body = body
21
+ end
22
+
23
+ Given "the page's meta tags are:" do |table|
24
+ @page.meta_tags = {}
25
+ table.hashes.each do |tag|
26
+ @page.meta_tags[tag['name']] = tag['content']
27
+ end
28
+ end
29
+
30
+ Given "the page's head tag is \"$tag\"" do |tag|
31
+ @page.head_content = tag
32
+ end
33
+
34
+ Given "the page uses a theme with the body:" do |body|
35
+ @page.theme ||= Landable::Theme.new
36
+ @theme ||= @page.theme
37
+ @page.theme.body = body
38
+ end
39
+
40
+ Given "these assets:" do |table|
41
+ table.hashes.each do |attrs|
42
+ create :asset, attrs
43
+ end
44
+ end
45
+
46
+ Given 'a theme with the body:' do |body|
47
+ @theme = Landable::Theme.new body: body
48
+ end
49
+
50
+ Given 'a theme with the body "$body"' do |body|
51
+ @theme = Landable::Theme.new body: body
52
+ end
53
+
54
+ Given 'the template "$template_slug" with body "$template_body"' do |template_slug, template_body|
55
+ Landable::Template.create! name: template_slug, slug: template_slug, body: template_body, description: template_slug
56
+ end
57
+
58
+ Given 'the template "$template_slug" with the body:' do |template_slug, template_body|
59
+ Landable::Template.create! name: template_slug, slug: template_slug, body: template_body, description: template_slug
60
+ end
61
+
62
+ Given 'the template is a filed backed partial' do
63
+ # Parial Defined in spec/dummy/app/views/partials/_foobazz, and configured in spec/dummy/app/config/initializers/landable
64
+ Landable::Template.create_from_partials!
65
+ @responder = Landable::PageRenderResponder
66
+ @responder.stub(:controller).and_return(ActionController::Base.new)
67
+ end
68
+
69
+ When 'this page is rendered:' do |body|
70
+ @page = Landable::Page.new body: body
71
+ @page.theme = @theme
72
+ @rendered_content = Landable::RenderService.call(@page)
73
+ end
74
+
75
+ Then 'the rendered content should be:' do |body|
76
+ @responder ||= nil
77
+ @rendered_content ||= Landable::RenderService.call(@page, responder: @responder)
78
+ @rendered_content.strip.should == body.strip
79
+ end
@@ -0,0 +1,5 @@
1
+ Then 'the JSON at "$path" should be a page revision\'s ID' do |path|
2
+ id = at_json path
3
+ id.should_not be_nil
4
+ @revision = Landable::PageRevision.find(id)
5
+ end
@@ -0,0 +1,43 @@
1
+ def make_request(id = page.id)
2
+ get :show, id: id
3
+ end
4
+
5
+ Given 'a published page "$path" with a theme containing "$body"' do |path, body|
6
+ @theme = create :theme, body: body
7
+ @page = create :page, path: path, theme: @theme
8
+ @page.publish! author: create(:author)
9
+ end
10
+
11
+ When 'I choose another theme containing "$body"' do |body|
12
+ @new_theme = create :theme, body: body
13
+ @page.theme = @new_theme
14
+ end
15
+
16
+ When 'I change the theme to contain "$body"' do |body|
17
+ @page.theme.body = body
18
+ @page.save
19
+ end
20
+
21
+ And "I GET '/pubbed'" do
22
+ make_request
23
+ end
24
+
25
+ Then 'I should see "$body"' do |body|
26
+ @page.reload
27
+ last_response.body.should include(@page.theme.body)
28
+ end
29
+
30
+ When "I publish the page with another theme" do
31
+ @page.theme = @new_theme
32
+ @page.save
33
+ @page.publish! author: create(:author)
34
+ end
35
+
36
+ When /^I publish the page$/ do
37
+ @page.publish! author: create(:author)
38
+ end
39
+
40
+ When 'I revert to the previous revision' do
41
+ revision = @page.revisions.order('created_at asc').first
42
+ @page.revert_to! revision
43
+ end
@@ -0,0 +1,66 @@
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
+
7
+ ENV["RAILS_ENV"] ||= "test"
8
+ require 'simplecov'
9
+ SimpleCov.start 'rails'
10
+
11
+ require File.expand_path("../../../spec/dummy/config/environment.rb", __FILE__)
12
+ ENV["RAILS_ROOT"] ||= File.dirname(__FILE__) + "../../../spec/dummy"
13
+
14
+ require 'cucumber/rails'
15
+ require 'cucumber/rspec/doubles'
16
+
17
+ # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
18
+ # order to ease the transition to Capybara we set the default here. If you'd
19
+ # prefer to use XPath just remove this line and adjust any selectors in your
20
+ # steps to use the XPath syntax.
21
+ Capybara.default_selector = :css
22
+
23
+ # By default, any exception happening in your Rails application will bubble up
24
+ # to Cucumber so that your scenario will fail. This is a different from how
25
+ # your application behaves in the production environment, where an error page will
26
+ # be rendered instead.
27
+ #
28
+ # Sometimes we want to override this default behaviour and allow Rails to rescue
29
+ # exceptions and display an error page (just like when the app is running in production).
30
+ # Typical scenarios where you want to do this is when you test your error pages.
31
+ # There are two ways to allow Rails to rescue exceptions:
32
+ #
33
+ # 1) Tag your scenario (or feature) with @allow-rescue
34
+ #
35
+ # 2) Set the value below to true. Beware that doing this globally is not
36
+ # recommended as it will mask a lot of errors for you!
37
+ #
38
+ ActionController::Base.allow_rescue = false
39
+
40
+ # Remove/comment out the lines below if your app doesn't have a database.
41
+ # For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
42
+ begin
43
+ DatabaseCleaner.strategy = :transaction
44
+ rescue NameError
45
+ raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
46
+ end
47
+
48
+ # You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
49
+ # See the DatabaseCleaner documentation for details. Example:
50
+ #
51
+ # Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
52
+ # # { :except => [:widgets] } may not do what you expect here
53
+ # # as tCucumber::Rails::Database.javascript_strategy overrides
54
+ # # this setting.
55
+ # DatabaseCleaner.strategy = :truncation
56
+ # end
57
+ #
58
+ # Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
59
+ # DatabaseCleaner.strategy = :transaction
60
+ # end
61
+ #
62
+
63
+ # Possible values are :truncation and :transaction
64
+ # The :transaction strategy is faster, but might give you threading problems.
65
+ # See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
66
+ Cucumber::Rails::Database.javascript_strategy = :truncation
@@ -0,0 +1,13 @@
1
+ require 'factory_girl_rails'
2
+ require 'pry'
3
+
4
+ load Landable::Engine.root.join('spec/support/helpers.rb').to_s
5
+ load Landable::Engine.root.join('spec/support/carrier_wave.rb').to_s
6
+
7
+ World(FactoryGirl::Syntax::Methods)
8
+ World(Landable::Spec::CoreHelpers)
9
+ World(Landable::Spec::HttpHelpers)
10
+
11
+ Landable.configure do |c|
12
+ c.authenticators = Landable::AuthenticationService::EchoAuthenticator
13
+ end
data/landable.gemspec ADDED
@@ -0,0 +1,54 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $:.unshift(lib) unless $:.include?(lib)
5
+
6
+ # Maintain your gem's version:
7
+ require "landable/version"
8
+
9
+ # Describe your gem and declare its dependencies:
10
+ Gem::Specification.new do |gem|
11
+ gem.name = "landable"
12
+ gem.version = Landable::VERSION::STRING
13
+
14
+ gem.authors = ["Team Trogdor"]
15
+ gem.email = ["trogdor@enova.com"]
16
+
17
+ gem.homepage = "https://github.com/enova/landable"
18
+
19
+ gem.license = "MIT-LICENSE"
20
+
21
+ gem.summary = "Mountable CMS engine for Rails"
22
+ gem.description = "Landing page storage, rendering, tracking, and management API"
23
+
24
+ gem.files = `git ls-files`.split($/)
25
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
26
+ gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
27
+
28
+ gem.require_paths = ["lib"]
29
+
30
+ gem.add_dependency "rails", "~> 4.0.0"
31
+ gem.add_dependency "rack-cors", ">= 0.2.7"
32
+ gem.add_dependency "active_model_serializers", "~> 0.8"
33
+ gem.add_dependency "carrierwave"
34
+ gem.add_dependency "liquid"
35
+ gem.add_dependency "fog"
36
+ gem.add_dependency "rest-client"
37
+ gem.add_dependency "builder"
38
+ gem.add_dependency "lookup_by", "~> 0.4.0"
39
+
40
+ gem.add_development_dependency "pg"
41
+ gem.add_development_dependency "rspec-rails", '~> 2.13.0'
42
+ gem.add_development_dependency "shoulda-matchers", '~> 2.2.0'
43
+ gem.add_development_dependency "factory_girl_rails", '~> 4.2.0'
44
+ gem.add_development_dependency "json-schema", '= 2.1.3'
45
+ gem.add_development_dependency "rack-schema"
46
+ gem.add_development_dependency "cucumber", '= 1.3.2'
47
+ gem.add_development_dependency "cucumber-rails"
48
+ gem.add_development_dependency "database_cleaner"
49
+ gem.add_development_dependency "simplecov"
50
+ gem.add_development_dependency "valid_attribute"
51
+ gem.add_development_dependency "pry"
52
+ gem.add_development_dependency "faker"
53
+ gem.add_development_dependency "bundler_geminabox"
54
+ end
@@ -0,0 +1,19 @@
1
+ require 'rails/generators'
2
+
3
+ module Landable
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ source_root File.expand_path('../../templates', __FILE__)
7
+
8
+ desc 'Creates the Landable initializer and installs the engine route'
9
+
10
+ def copy_initializer
11
+ template 'landable.rb', 'config/initializers/landable.rb'
12
+ end
13
+
14
+ def add_landable_route
15
+ route 'mount Landable::Engine => \'/\' # move this to the end of your routes block'
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,22 @@
1
+ require 'landable'
2
+ require 'rails/generators'
3
+
4
+ module Landable
5
+ module Generators
6
+ class Base < ::Rails::Generators::NamedBase
7
+ class << self
8
+ def namespace
9
+ "landable:#{generator_name}"
10
+ end
11
+
12
+ def source_root
13
+ @source_root ||= File.expand_path(File.join(File.dirname(__FILE__), "landable", generator_name, "templates"))
14
+ end
15
+
16
+ def target_root
17
+ File.expand_path(Rails.root.join("app", "assets"))
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,34 @@
1
+ require 'landable'
2
+
3
+ Landable.configure do |config|
4
+ # Specify the hostname(s) of your Publicist instance
5
+ config.cors.origins = %w(publicist.dev http://publicist.10.224.109.244.xip.io/)
6
+
7
+ # Simple singleton user authenticator
8
+ # config.authenticator = Landable::AuthenticationService::EchoAuthenticator.new('trogdor', 'trogdor')
9
+
10
+ # Set up a custom database schema prefix (default: nil)
11
+ # config.database_schema_prefix = Rails.application.class.parent_name.downcase
12
+
13
+ # Add landable-ldap to your application's Gemfile to authenticate by LDAP:
14
+ # config.authenticator = Landable::LDAP::Authenticator.new(
15
+ # host: 'ldap.acme.corp',
16
+ # port: 389,
17
+ # ssl: 'start_tls',
18
+ # base: 'ou=user,dc=acme,dc=corp',
19
+ # )
20
+
21
+ # Categories to create (can also be given as a hash to provide descriptions,
22
+ # e.g. {'SEO' => 'Search engine optimization', 'PPC' => 'Pay-per-click'})
23
+ config.categories = %w(Affiliates PPC SEO Social Email Traditional)
24
+
25
+ # Uncomment to enable tracking of all requests.
26
+ # Set to :html to track only HTML requests.
27
+ # config.traffic_enabled = true
28
+ end
29
+
30
+ # Configure asset uploads. Assets will be uploaded to public/uploads by default.
31
+ # More configuration options: https://github.com/carrierwaveuploader/carrierwave
32
+ CarrierWave.configure do |config|
33
+ # config.asset_host = 'http://cdn.myapp.com'
34
+ end
data/lib/landable.rb ADDED
@@ -0,0 +1,30 @@
1
+ require 'landable/version'
2
+ require "landable/engine"
3
+ require 'landable/liquid'
4
+ require "landable/error"
5
+ require 'landable/mime_types'
6
+ require "landable/inflections"
7
+ require "landable/traffic"
8
+ require "landable/migration"
9
+
10
+ require "landable/core_ext/ipaddr"
11
+
12
+ require "lookup_by"
13
+
14
+ module Landable
15
+ # This absurd configuration loading code is not intended to live long.
16
+
17
+ autoload :Configuration, 'landable/configuration'
18
+ autoload :Layout, 'landable/layout'
19
+ autoload :Partial, 'landable/partial'
20
+ autoload :Seeds, 'landable/seeds'
21
+
22
+ def self.configuration
23
+ @configuration ||= Configuration.new
24
+ end
25
+
26
+ def self.configure
27
+ yield configuration if block_given?
28
+ configuration
29
+ end
30
+ end
@@ -0,0 +1,115 @@
1
+ module Landable
2
+ class Configuration
3
+ attr_writer :api_namespace, :public_namespace, :categories, :traffic_enabled
4
+ attr_writer :sitemap_exclude_categories, :sitemap_protocol, :sitemap_host
5
+ attr_writer :sitemap_additional_paths, :reserved_paths, :partials_to_templates, :database_schema_prefix
6
+
7
+ def authenticators
8
+ @authenticators || raise("No Landable authenticator configured.")
9
+ end
10
+
11
+ def authenticators=(authenticators)
12
+ @authenticators = Array(authenticators)
13
+ end
14
+
15
+ alias :authenticator= :authenticators=
16
+
17
+ def api_namespace
18
+ @api_namespace ||= '/api/landable'
19
+ end
20
+
21
+ def public_namespace
22
+ raise NotImplementedError
23
+ @public_namespace ||= '/'
24
+ end
25
+
26
+ def database_schema_prefix
27
+ @database_schema_prefix ||= ''
28
+ end
29
+
30
+ def database_schema_prefix=(val)
31
+ @database_schema_prefix = "#{val}_" if val.present?
32
+ end
33
+
34
+ def categories
35
+ # default categories
36
+ @categories ||= {
37
+ 'Affiliates' => '',
38
+ 'PPC' => 'Pay-per-click',
39
+ 'SEO' => 'Search engine optimization',
40
+ 'Social' => '',
41
+ 'Email' => '',
42
+ 'Traditional' => '',
43
+ }
44
+ end
45
+
46
+ def partials_to_templates
47
+ @partials_to_templates ||= []
48
+ end
49
+
50
+ def reserved_paths
51
+ @reserved_paths ||= []
52
+ end
53
+
54
+ def sitemap_exclude_categories
55
+ @sitemap_exclude_categories ||= []
56
+ end
57
+
58
+ def sitemap_additional_paths
59
+ @sitemap_additional_paths ||= []
60
+ end
61
+
62
+ def sitemap_protocol
63
+ @sitemap_protocol ||= "http"
64
+ end
65
+
66
+ def sitemap_host
67
+ @sitemap_host
68
+ end
69
+
70
+ def traffic_enabled
71
+ @traffic_enabled ||= false
72
+ end
73
+
74
+ def traffic_enabled=(val)
75
+ raise ArgumentError.new("Landable::Configuration#traffic_enabled accepts false, true, :all or :html") unless [true, false, :all, :html].include? val
76
+ @traffic_enabled = val
77
+ end
78
+
79
+ def cors
80
+ @cors ||= CORS.new
81
+ end
82
+
83
+ def cors=(bool)
84
+ raise ArgumentError.new("Landable::Configuration#cors should be assigned 'false' to disable CORS support") if bool != false
85
+ cors.origins = []
86
+ end
87
+
88
+ class CORS
89
+ def enabled?
90
+ origins.any?
91
+ end
92
+
93
+ def origins
94
+ @origins ||= []
95
+ end
96
+
97
+ def origins=(origins)
98
+ @origins = Array(origins)
99
+ end
100
+ end
101
+
102
+ def screenshots
103
+ @screenshots ||= Screenshots.new
104
+ end
105
+
106
+ class Screenshots
107
+ attr_accessor :autorun
108
+ attr_accessor :browserstack_username, :browserstack_password
109
+
110
+ def initialize
111
+ @autorun = true
112
+ end
113
+ end
114
+ end
115
+ end