pages_core 3.4.2

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 (271) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +29 -0
  3. data/Rakefile +10 -0
  4. data/app/assets/images/pages/admin/description-bg.gif +0 -0
  5. data/app/assets/images/pages/admin/drag-handle.gif +0 -0
  6. data/app/assets/images/pages/admin/drag-icon.png +0 -0
  7. data/app/assets/images/pages/admin/flash-error-bg.gif +0 -0
  8. data/app/assets/images/pages/admin/formelement-bg.gif +0 -0
  9. data/app/assets/images/pages/admin/header-tab-current-bg.gif +0 -0
  10. data/app/assets/images/pages/admin/icon.png +0 -0
  11. data/app/assets/images/pages/admin/image-editor-bg.png +0 -0
  12. data/app/assets/images/pages/admin/list-table-pin-blue.gif +0 -0
  13. data/app/assets/images/pages/admin/list-table-pin-disabled.gif +0 -0
  14. data/app/assets/images/pages/admin/list-table-pin-green.gif +0 -0
  15. data/app/assets/images/pages/admin/list-table-pin-red.gif +0 -0
  16. data/app/assets/images/pages/admin/list-table-pin-yellow.gif +0 -0
  17. data/app/assets/images/pages/admin/list-table-td-bg.gif +0 -0
  18. data/app/assets/images/pages/admin/loading-modal.gif +0 -0
  19. data/app/assets/images/pages/admin/sidebar-bg.gif +0 -0
  20. data/app/assets/images/pages/admin/textarea_controls.gif +0 -0
  21. data/app/assets/images/pages/admin/warning-icon.gif +0 -0
  22. data/app/assets/images/pages/favicon.gif +0 -0
  23. data/app/assets/images/pages/feed-icon-14x14.png +0 -0
  24. data/app/assets/javascripts/pages/admin/controllers/base.js.coffee +4 -0
  25. data/app/assets/javascripts/pages/admin/controllers/pages_controller.js.coffee +139 -0
  26. data/app/assets/javascripts/pages/admin/controllers/users_controller.js.coffee +9 -0
  27. data/app/assets/javascripts/pages/admin/features/content_tabs.js.coffee +47 -0
  28. data/app/assets/javascripts/pages/admin/features/editable_image.js.coffee.erb +122 -0
  29. data/app/assets/javascripts/pages/admin/features/modal.js.coffee +66 -0
  30. data/app/assets/javascripts/pages/admin/features/page_images.js +329 -0
  31. data/app/assets/javascripts/pages/admin/features/rich_text.js.coffee +40 -0
  32. data/app/assets/javascripts/pages/admin/features/tag_editor.js +159 -0
  33. data/app/assets/javascripts/pages/admin/lib/ajax_extensions.js.coffee +17 -0
  34. data/app/assets/javascripts/pages/admin/lib/center_on_screen.js.coffee +21 -0
  35. data/app/assets/javascripts/pages/admin/lib/jrichtextarea.js +57 -0
  36. data/app/assets/javascripts/pages/admin.js.coffee +54 -0
  37. data/app/assets/javascripts/pages/login_form.js.coffee +17 -0
  38. data/app/assets/stylesheets/pages/admin/buttons.css.erb +5 -0
  39. data/app/assets/stylesheets/pages/admin/controllers/artists.css.erb +94 -0
  40. data/app/assets/stylesheets/pages/admin/controllers/files.css.erb +58 -0
  41. data/app/assets/stylesheets/pages/admin/controllers/pages.css.scss.erb +178 -0
  42. data/app/assets/stylesheets/pages/admin/controllers/users.css.erb +3 -0
  43. data/app/assets/stylesheets/pages/admin/editable_image.css.erb +19 -0
  44. data/app/assets/stylesheets/pages/admin/forms.css.scss.erb +73 -0
  45. data/app/assets/stylesheets/pages/admin/header.css.erb +129 -0
  46. data/app/assets/stylesheets/pages/admin/images.css.scss.erb +160 -0
  47. data/app/assets/stylesheets/pages/admin/links.css.erb +34 -0
  48. data/app/assets/stylesheets/pages/admin/list_table.css.erb +56 -0
  49. data/app/assets/stylesheets/pages/admin/login.css.scss.erb +32 -0
  50. data/app/assets/stylesheets/pages/admin/modal.css.erb +14 -0
  51. data/app/assets/stylesheets/pages/admin/pagination.css.scss +22 -0
  52. data/app/assets/stylesheets/pages/admin/print.css.erb +17 -0
  53. data/app/assets/stylesheets/pages/admin/sidebar.css.erb +39 -0
  54. data/app/assets/stylesheets/pages/admin/sortable_images.css.erb +18 -0
  55. data/app/assets/stylesheets/pages/admin/tag_editor.css.scss.erb +48 -0
  56. data/app/assets/stylesheets/pages/admin/textarea.css.erb +55 -0
  57. data/app/assets/stylesheets/pages/admin.css.erb +404 -0
  58. data/app/assets/stylesheets/pages/errors.css +126 -0
  59. data/app/controller_dummies/admin/admin_controller.rb +6 -0
  60. data/app/controller_dummies/application_controller.rb +6 -0
  61. data/app/controller_dummies/frontend_controller.rb +4 -0
  62. data/app/controller_dummies/images_controller.rb +4 -0
  63. data/app/controller_dummies/page_files_controller.rb +4 -0
  64. data/app/controller_dummies/pages_controller.rb +4 -0
  65. data/app/controller_dummies/sitemaps_controller.rb +4 -0
  66. data/app/controllers/admin/categories_controller.rb +57 -0
  67. data/app/controllers/admin/images_controller.rb +48 -0
  68. data/app/controllers/admin/invites_controller.rb +79 -0
  69. data/app/controllers/admin/page_comments_controller.rb +61 -0
  70. data/app/controllers/admin/page_files_controller.rb +81 -0
  71. data/app/controllers/admin/page_images_controller.rb +116 -0
  72. data/app/controllers/admin/pages_controller.rb +179 -0
  73. data/app/controllers/admin/password_resets_controller.rb +83 -0
  74. data/app/controllers/admin/users_controller.rb +102 -0
  75. data/app/controllers/concerns/pages_core/authentication.rb +48 -0
  76. data/app/controllers/concerns/pages_core/domain_based_cache.rb +28 -0
  77. data/app/controllers/concerns/pages_core/exception_handler.rb +114 -0
  78. data/app/controllers/concerns/pages_core/policies_helper.rb +40 -0
  79. data/app/controllers/concerns/pages_core/process_titler.rb +44 -0
  80. data/app/controllers/errors_controller.rb +45 -0
  81. data/app/controllers/pages_core/admin_controller.rb +109 -0
  82. data/app/controllers/pages_core/application_controller.rb +31 -0
  83. data/app/controllers/pages_core/frontend/page_files_controller.rb +42 -0
  84. data/app/controllers/pages_core/frontend/pages_controller.rb +308 -0
  85. data/app/controllers/pages_core/frontend_controller.rb +34 -0
  86. data/app/controllers/pages_core/images_controller.rb +15 -0
  87. data/app/controllers/pages_core/sitemaps_controller.rb +73 -0
  88. data/app/controllers/sessions_controller.rb +38 -0
  89. data/app/formatters/pages_core/html_formatter.rb +86 -0
  90. data/app/helpers/admin/admin_helper.rb +7 -0
  91. data/app/helpers/admin/menu_helper.rb +65 -0
  92. data/app/helpers/admin/pages_helper.rb +74 -0
  93. data/app/helpers/application_helper.rb +5 -0
  94. data/app/helpers/frontend_helper.rb +5 -0
  95. data/app/helpers/pages_core/admin/admin_helper.rb +108 -0
  96. data/app/helpers/pages_core/admin/labelled_field_helper.rb +73 -0
  97. data/app/helpers/pages_core/admin/tag_editor_helper.rb +46 -0
  98. data/app/helpers/pages_core/application_helper.rb +65 -0
  99. data/app/helpers/pages_core/form_builder.rb +187 -0
  100. data/app/helpers/pages_core/frontend_helper.rb +21 -0
  101. data/app/helpers/pages_core/head_tags_helper.rb +270 -0
  102. data/app/helpers/pages_core/images_helper.rb +36 -0
  103. data/app/helpers/pages_core/login_helper.rb +14 -0
  104. data/app/indices/page_file_index.rb +9 -0
  105. data/app/indices/page_index.rb +29 -0
  106. data/app/indices/user_index.rb +11 -0
  107. data/app/jobs/pages_core/autopublish_job.rb +11 -0
  108. data/app/jobs/pages_core/sweep_cache_job.rb +11 -0
  109. data/app/mailers/admin_mailer.rb +46 -0
  110. data/app/models/autopublisher.rb +33 -0
  111. data/app/models/category.rb +23 -0
  112. data/app/models/concerns/pages_core/has_roles.rb +25 -0
  113. data/app/models/concerns/pages_core/humanizable_param.rb +17 -0
  114. data/app/models/concerns/pages_core/page_tree.rb +85 -0
  115. data/app/models/concerns/pages_core/searchable_page.rb +33 -0
  116. data/app/models/concerns/pages_core/sweepable.rb +23 -0
  117. data/app/models/concerns/pages_core/taggable.rb +46 -0
  118. data/app/models/concerns/pages_core/templateable.rb +85 -0
  119. data/app/models/image.rb +23 -0
  120. data/app/models/invite.rb +33 -0
  121. data/app/models/invite_role.rb +11 -0
  122. data/app/models/localization.rb +27 -0
  123. data/app/models/page.rb +281 -0
  124. data/app/models/page_builder.rb +61 -0
  125. data/app/models/page_comment.rb +18 -0
  126. data/app/models/page_file.rb +74 -0
  127. data/app/models/page_image.rb +62 -0
  128. data/app/models/password_reset_token.rb +38 -0
  129. data/app/models/role.rb +51 -0
  130. data/app/models/tag.rb +64 -0
  131. data/app/models/tagging.rb +22 -0
  132. data/app/models/user.rb +131 -0
  133. data/app/policies/invite_policy.rb +29 -0
  134. data/app/policies/page_file_policy.rb +25 -0
  135. data/app/policies/page_image_policy.rb +25 -0
  136. data/app/policies/page_policy.rb +33 -0
  137. data/app/policies/policy.rb +64 -0
  138. data/app/policies/user_policy.rb +49 -0
  139. data/app/serializers/admin/image_serializer.rb +10 -0
  140. data/app/serializers/admin/page_image_serializer.rb +6 -0
  141. data/app/serializers/page_image_serializer.rb +38 -0
  142. data/app/serializers/page_serializer.rb +21 -0
  143. data/app/views/admin/invites/new.html.erb +16 -0
  144. data/app/views/admin/invites/show.html.erb +25 -0
  145. data/app/views/admin/pages/_edit_comments.html.erb +21 -0
  146. data/app/views/admin/pages/_edit_content.html.erb +10 -0
  147. data/app/views/admin/pages/_edit_images.html.erb +84 -0
  148. data/app/views/admin/pages/_edit_metadata.html.erb +24 -0
  149. data/app/views/admin/pages/_edit_options.html.erb +72 -0
  150. data/app/views/admin/pages/_pagelisting.html.erb +63 -0
  151. data/app/views/admin/pages/edit.html.erb +161 -0
  152. data/app/views/admin/pages/index.html.erb +67 -0
  153. data/app/views/admin/pages/new.html.erb +48 -0
  154. data/app/views/admin/pages/news.html.erb +69 -0
  155. data/app/views/admin/password_resets/show.html.erb +24 -0
  156. data/app/views/admin/users/_access_control.html.erb +14 -0
  157. data/app/views/admin/users/_list.html.erb +62 -0
  158. data/app/views/admin/users/_login_form.html.erb +47 -0
  159. data/app/views/admin/users/deactivated.html.erb +12 -0
  160. data/app/views/admin/users/edit.html.erb +54 -0
  161. data/app/views/admin/users/index.html.erb +27 -0
  162. data/app/views/admin/users/login.html.erb +15 -0
  163. data/app/views/admin/users/new.html.erb +23 -0
  164. data/app/views/admin/users/new_password.html.erb +19 -0
  165. data/app/views/admin/users/show.html.erb +64 -0
  166. data/app/views/admin_mailer/comment_notification.text.erb +7 -0
  167. data/app/views/admin_mailer/error_report.html.erb +70 -0
  168. data/app/views/admin_mailer/invite.text.erb +9 -0
  169. data/app/views/admin_mailer/password_reset.text.erb +13 -0
  170. data/app/views/errors/403.html.erb +6 -0
  171. data/app/views/errors/404.html.erb +11 -0
  172. data/app/views/errors/405.html.erb +4 -0
  173. data/app/views/errors/500.html.erb +19 -0
  174. data/app/views/errors/500_critical.html.erb +7 -0
  175. data/app/views/errors/_generic_help.html.erb +21 -0
  176. data/app/views/errors/report.html.erb +4 -0
  177. data/app/views/feeds/pages.rss.builder +39 -0
  178. data/app/views/layouts/admin/_analytics.html.erb +18 -0
  179. data/app/views/layouts/admin/_header.html.erb +37 -0
  180. data/app/views/layouts/admin.html.erb +79 -0
  181. data/app/views/layouts/errors.html.erb +23 -0
  182. data/app/views/sitemaps/show.xml.builder +9 -0
  183. data/config/locales/en.yml +6 -0
  184. data/config/removed_migrations.yml +60 -0
  185. data/config/routes.rb +127 -0
  186. data/db/migrate/20111219033112_create_pages_tables.rb +281 -0
  187. data/db/migrate/20120627033112_rename_textbits.rb +19 -0
  188. data/db/migrate/20121010055412_drop_removed_tables.rb +83 -0
  189. data/db/migrate/20130130053932_add_queue_to_delayed_jobs.rb +11 -0
  190. data/db/migrate/20130303053932_remove_filter_from_localizations.rb +11 -0
  191. data/db/migrate/20130303160632_remove_imagesets.rb +24 -0
  192. data/db/migrate/20130303161732_remove_sms_subscribers.rb +16 -0
  193. data/db/migrate/20130823133208_update_page_redirect_to.rb +25 -0
  194. data/db/migrate/20140203183900_create_roles.rb +63 -0
  195. data/db/migrate/20140414150500_change_locale_names.rb +13 -0
  196. data/db/migrate/20140515130100_remove_sphinx_deltas.rb +15 -0
  197. data/db/migrate/20140604142100_remove_openid_url.rb +9 -0
  198. data/db/migrate/20140920231700_convert_images_to_dis.rb +79 -0
  199. data/db/migrate/20140922124600_convert_page_files_to_dis.rb +50 -0
  200. data/db/migrate/20141004003100_create_password_reset_tokens.rb +10 -0
  201. data/db/migrate/20141006181300_remove_user_cruft.rb +11 -0
  202. data/db/migrate/20141007173000_create_invites.rb +16 -0
  203. data/db/migrate/20150204130800_update_delayed_job_table.rb +9 -0
  204. data/db/migrate/20150401131300_localize_images.rb +39 -0
  205. data/db/migrate/20150520174300_add_meta_image_to_page.rb +5 -0
  206. data/db/migrate/20150904164200_add_pinned_to_tags.rb +5 -0
  207. data/lib/pages_core/admin_menu_item.rb +22 -0
  208. data/lib/pages_core/archive_finder.rb +75 -0
  209. data/lib/pages_core/cache_sweeper.rb +112 -0
  210. data/lib/pages_core/configuration/base.rb +85 -0
  211. data/lib/pages_core/configuration/pages.rb +23 -0
  212. data/lib/pages_core/configuration.rb +9 -0
  213. data/lib/pages_core/engine.rb +27 -0
  214. data/lib/pages_core/extensions/hash_extensions.rb +23 -0
  215. data/lib/pages_core/extensions/string_extensions.rb +17 -0
  216. data/lib/pages_core/extensions.rb +4 -0
  217. data/lib/pages_core/localizable/active_record_extension.rb +41 -0
  218. data/lib/pages_core/localizable/class_methods.rb +51 -0
  219. data/lib/pages_core/localizable/configuration.rb +50 -0
  220. data/lib/pages_core/localizable/instance_methods.rb +130 -0
  221. data/lib/pages_core/localizable/localizer.rb +72 -0
  222. data/lib/pages_core/localizable/scope_extension.rb +22 -0
  223. data/lib/pages_core/localizable.rb +49 -0
  224. data/lib/pages_core/pages_plugin.rb +14 -0
  225. data/lib/pages_core/paginates.rb +102 -0
  226. data/lib/pages_core/plugin.rb +118 -0
  227. data/lib/pages_core/templates/block_configuration.rb +17 -0
  228. data/lib/pages_core/templates/configuration.rb +81 -0
  229. data/lib/pages_core/templates/configuration_handler.rb +62 -0
  230. data/lib/pages_core/templates/configuration_proxy.rb +28 -0
  231. data/lib/pages_core/templates/controller_actions.rb +32 -0
  232. data/lib/pages_core/templates/template_configuration.rb +198 -0
  233. data/lib/pages_core/templates.rb +53 -0
  234. data/lib/pages_core/version.rb +5 -0
  235. data/lib/pages_core.rb +89 -0
  236. data/lib/rails/generators/pages_core/frontend/frontend_generator.rb +68 -0
  237. data/lib/rails/generators/pages_core/frontend/templates/application.css.scss.erb +3 -0
  238. data/lib/rails/generators/pages_core/frontend/templates/application.js.erb +16 -0
  239. data/lib/rails/generators/pages_core/frontend/templates/base.css.scss.erb +3 -0
  240. data/lib/rails/generators/pages_core/frontend/templates/breakpoints.css.scss.erb +24 -0
  241. data/lib/rails/generators/pages_core/frontend/templates/hidpi.css.scss.erb +8 -0
  242. data/lib/rails/generators/pages_core/frontend/templates/layout.html.erb +15 -0
  243. data/lib/rails/generators/pages_core/frontend/templates/normalize.css.erb +425 -0
  244. data/lib/rails/generators/pages_core/install/install_generator.rb +135 -0
  245. data/lib/rails/generators/pages_core/install/templates/active_job_initializer.rb +1 -0
  246. data/lib/rails/generators/pages_core/install/templates/application_controller.rb +11 -0
  247. data/lib/rails/generators/pages_core/install/templates/application_helper.rb +5 -0
  248. data/lib/rails/generators/pages_core/install/templates/cache_sweeper_initializer.rb +11 -0
  249. data/lib/rails/generators/pages_core/install/templates/default_page_template.html.erb +5 -0
  250. data/lib/rails/generators/pages_core/install/templates/delayed_job +7 -0
  251. data/lib/rails/generators/pages_core/install/templates/delayed_job_initializer.rb +3 -0
  252. data/lib/rails/generators/pages_core/install/templates/frontend_controller.rb +6 -0
  253. data/lib/rails/generators/pages_core/install/templates/frontend_helper.rb +5 -0
  254. data/lib/rails/generators/pages_core/install/templates/gitignore.erb +25 -0
  255. data/lib/rails/generators/pages_core/install/templates/page_templates_initializer.rb +67 -0
  256. data/lib/rails/generators/pages_core/install/templates/pages_controller.rb +4 -0
  257. data/lib/rails/generators/pages_core/install/templates/pages_initializer.rb +45 -0
  258. data/lib/rails/generators/pages_core/install/templates/thinking_sphinx.yml +12 -0
  259. data/lib/rails/generators/pages_core/rspec/rspec_generator.rb +34 -0
  260. data/lib/rails/generators/pages_core/rspec/templates/factories.rb +9 -0
  261. data/lib/rails/generators/pages_core/rspec/templates/mailer_macros.rb +9 -0
  262. data/lib/rails/generators/pages_core/rspec/templates/spec_helper.rb +51 -0
  263. data/lib/tasks/db.rake +96 -0
  264. data/lib/tasks/pages/assets.rake +65 -0
  265. data/lib/tasks/pages/cache.rake +16 -0
  266. data/lib/tasks/pages/update.rake +19 -0
  267. data/lib/tasks/pages.rake +76 -0
  268. data/template.rb +19 -0
  269. data/vendor/assets/javascripts/jquery.dimscreen.js +77 -0
  270. data/vendor/assets/javascripts/jquery.fieldselection.js +59 -0
  271. metadata +690 -0
@@ -0,0 +1,135 @@
1
+ # encoding: utf-8
2
+
3
+ module PagesCore
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ desc "Creates the Pages configuration"
7
+ source_root File.expand_path("../templates", __FILE__)
8
+
9
+ def default_app_name
10
+ Rails.root.to_s.split("/").last
11
+ end
12
+
13
+ def read_configuration!
14
+ @app_name ||= ask_with_fallback("App name?", default_app_name)
15
+ @site_name ||= ask_with_fallback("Site name?", @app_name.humanize)
16
+ @domain_name ||= ask_with_fallback("Domain name?", "#{@app_name}.no")
17
+
18
+ @default_sender ||= ask_with_fallback(
19
+ "Default sender?",
20
+ "no-reply@#{@domain_name}"
21
+ )
22
+
23
+ @sphinx_port ||= ask_with_fallback("Sphinx port?", "3312")
24
+ end
25
+
26
+ def add_gem_source
27
+ add_source "http://gems.manualdesign.no/"
28
+ end
29
+
30
+ def create_active_job_initializer
31
+ template(
32
+ "active_job_initializer.rb",
33
+ File.join("config/initializers/active_job.rb")
34
+ )
35
+ end
36
+
37
+ def create_application_controller
38
+ template(
39
+ "application_controller.rb",
40
+ File.join("app/controllers/application_controller.rb")
41
+ )
42
+ end
43
+
44
+ def create_application_helper
45
+ template(
46
+ "application_helper.rb",
47
+ File.join("app/helpers/application_helper.rb")
48
+ )
49
+ end
50
+
51
+ def create_frontend_controller
52
+ template(
53
+ "frontend_controller.rb",
54
+ File.join("app/controllers/frontend_controller.rb")
55
+ )
56
+ end
57
+
58
+ def create_frontend_helper
59
+ template(
60
+ "frontend_helper.rb",
61
+ File.join("app/helpers/frontend_helper.rb")
62
+ )
63
+ end
64
+
65
+ def create_pages_controller
66
+ template(
67
+ "pages_controller.rb",
68
+ File.join("app/controllers/pages_controller.rb")
69
+ )
70
+ end
71
+
72
+ def create_default_template
73
+ copy_file(
74
+ "default_page_template.html.erb",
75
+ File.join("app/views/pages/templates/index.html.erb")
76
+ )
77
+ end
78
+
79
+ def create_delayed_job_script
80
+ template "delayed_job", File.join("script/delayed_job")
81
+ File.chmod(0755, Rails.root.join("script/delayed_job"))
82
+ end
83
+
84
+ def create_delayed_job_initializer
85
+ template(
86
+ "delayed_job_initializer.rb",
87
+ File.join("config/initializers/delayed_job.rb")
88
+ )
89
+ end
90
+
91
+ def create_initializer_file
92
+ read_configuration!
93
+ template(
94
+ "pages_initializer.rb",
95
+ File.join("config/initializers/pages.rb")
96
+ )
97
+ end
98
+
99
+ def create_cache_sweeper_initializer
100
+ read_configuration!
101
+ template(
102
+ "cache_sweeper_initializer.rb",
103
+ File.join("config/initializers/cache_sweeper.rb")
104
+ )
105
+ end
106
+
107
+ def create_template_initializer
108
+ read_configuration!
109
+ template(
110
+ "page_templates_initializer.rb",
111
+ File.join("config/initializers/page_templates.rb")
112
+ )
113
+ end
114
+
115
+ def create_sphinx_config
116
+ template "thinking_sphinx.yml", File.join("config/thinking_sphinx.yml")
117
+ end
118
+
119
+ def create_gitignore
120
+ template "gitignore.erb", File.join(".gitignore")
121
+ end
122
+
123
+ private
124
+
125
+ def ask_with_fallback(question, default)
126
+ result = ask(question + " [#{default}]")
127
+ if result.blank?
128
+ default
129
+ else
130
+ result
131
+ end
132
+ end
133
+ end
134
+ end
135
+ end
@@ -0,0 +1 @@
1
+ ActiveJob::Base.queue_adapter = :delayed_job
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ class ApplicationController < PagesCore::ApplicationController
4
+ # Put frontend specific code in frontend_controller.rb
5
+
6
+ helper :all # include all helpers, all the time
7
+
8
+ # Prevent CSRF attacks by raising an exception.
9
+ # For APIs, you may want to use :null_session instead.
10
+ protect_from_forgery with: :exception
11
+ end
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+
3
+ module ApplicationHelper
4
+ include PagesCore::ApplicationHelper
5
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ # Be sure to restart your web server when you modify this file.
4
+
5
+ PagesCore::CacheSweeper.config do |sweeper|
6
+ # Observed models
7
+ # sweeper.observe += [Artist, Song]
8
+
9
+ # Path patterns
10
+ # sweeper.patterns += [/^\/archive(.*)$/, /^\/tests(.*)$/]
11
+ end
@@ -0,0 +1,5 @@
1
+ <h1>
2
+ <%= @page.headline_or_name %>
3
+ </h1>
4
+
5
+ <%= @page.body.to_s %>
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(
4
+ File.join(File.dirname(__FILE__), "..", "config", "environment")
5
+ )
6
+ require "delayed/command"
7
+ Delayed::Command.new(ARGV).daemonize
@@ -0,0 +1,3 @@
1
+ # encoding: utf-8
2
+
3
+ Delayed::Worker.backend = :active_record
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+
3
+ # Abstract controller for all frontend controllers.
4
+ class FrontendController < PagesCore::FrontendController
5
+ layout "application"
6
+ end
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+
3
+ module FrontendHelper
4
+ include PagesCore::FrontendHelper
5
+ end
@@ -0,0 +1,25 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ /config/*.sphinx.conf
11
+
12
+ # Ignore the default SQLite database.
13
+ /db/*.sqlite3
14
+ /db/*.sqlite3-journal
15
+
16
+ /db/binary-objects
17
+ /db/dis
18
+ /db/sphinx
19
+
20
+ # Ignore all logfiles and tempfiles.
21
+ /log/*.log
22
+ /log/error_reports
23
+ /log/*.sphinx.pid
24
+ /tmp
25
+ /public/dynamic_images
@@ -0,0 +1,67 @@
1
+ # encoding: utf-8
2
+
3
+ # Be sure to restart your web server when you modify this file.
4
+
5
+ # Templates configuration
6
+ PagesCore::Templates.configure do |config|
7
+ # Default configuration for all templates
8
+ config.default do |default|
9
+ # The block definitions here will be available for all templates.
10
+ default.blocks do |block|
11
+ block.headline(
12
+ "Headline",
13
+ size: :field,
14
+ description: "The main statement, usually largest and boldest, " \
15
+ "describing the main story."
16
+ )
17
+ block.excerpt(
18
+ "Standfirst",
19
+ description: "An introductory paragraph before the start of the body."
20
+ )
21
+ block.body(
22
+ "Body",
23
+ size: :large
24
+ )
25
+ block.boxout(
26
+ "Boxout",
27
+ description: "Part of the page, usually background info or facts " \
28
+ "related to the article."
29
+ )
30
+ end
31
+
32
+ # Default template (default: :autodetect, root: 'index')
33
+ default.template :autodetect, root: "index"
34
+
35
+ # Enables image on page (default: :enabled, linkable: false)
36
+ default.image :enabled, linkable: false
37
+
38
+ # Enables file uploads (default: :disabled)
39
+ default.files :disabled
40
+
41
+ # Enables comments (default: :disabled)
42
+ default.comments :disabled
43
+
44
+ # New pages are open for comments by default (default: :enabled)
45
+ default.comments_allowed :enabled
46
+
47
+ # Pages can have tags (default: :disabled)
48
+ default.tags :disabled
49
+
50
+ # Only use the blocks enabled here by default
51
+ default.enabled_blocks [:headline, :excerpt, :body]
52
+
53
+ # Subpages will have this template. Will fall back to default.template
54
+ # unless specified. (default: nil)
55
+ # default.sub_template :news_page
56
+ end
57
+
58
+ # Sample template configuration:
59
+
60
+ # config.template(:news_page, :archive_page) do |t|
61
+ # t.blocks do |block|
62
+ # block.video_embed "Video embed", size: :field
63
+ # end
64
+ # t.enabled_blocks [:headline, :excerpt, :body, :boxout, :video_embed]
65
+ # t.sub_template :news_page
66
+ # end
67
+ end
@@ -0,0 +1,4 @@
1
+ # encoding: utf-8
2
+
3
+ class PagesController < PagesCore::Frontend::PagesController
4
+ end
@@ -0,0 +1,45 @@
1
+ # encoding: utf-8
2
+
3
+ # Be sure to restart your web server when you modify this file.
4
+
5
+ PagesCore.configure do |config|
6
+ # Site name and default mail sender
7
+ config.site_name "<%= @site_name %>"
8
+ config.default_sender "<%= @default_sender %>"
9
+
10
+ # Localizations (default: disabled)
11
+ # config.localizations :disabled
12
+
13
+ # Locales and names
14
+ # config.locales(nb: 'Norwegian', en: 'English')
15
+
16
+ # ReCAPTCHA (default: disabled)
17
+ # config.recaptcha :disabled
18
+
19
+ # Page cache (default: enabled)
20
+ # config.page_cache :enabled
21
+
22
+ # Domain based page cache (default: disabled)
23
+ # config.domain_based_cache :disabled
24
+
25
+ # Scoped path for pages (default: nil)
26
+ # config.pages_path_scope "/foo"
27
+
28
+ # Fulltext in RSS feeds (default: disabled)
29
+ # config.rss_fulltext :disabled
30
+
31
+ # New pages will be created by the user with this email address:
32
+ # config.default_author "email@example.com"
33
+
34
+ # Send notifications when new comments are posted
35
+ # config :comment_notifications, [:author, 'your@email.com']
36
+
37
+ # Automatically close comments after a certain amount of time has
38
+ # passed. (default: disabled)
39
+ # config.close_comments_after 60.days
40
+
41
+ # Comment honeypot.
42
+ # Add <%%= comment_honeypot_field %> to your form
43
+ # and .comment_email { display: none; } to your CSS.
44
+ # config.comment_honeypot :disabled
45
+ end
@@ -0,0 +1,12 @@
1
+ development:
2
+ mysql41: <%= @sphinx_port %>
3
+ enable_star: true
4
+ min_prefix_len: 3
5
+ charset_type: utf-8
6
+ dict: keywords
7
+ production:
8
+ mysql41: <%= @sphinx_port %>
9
+ enable_star: true
10
+ min_prefix_len: 3
11
+ charset_type: utf-8
12
+ dict: keywords
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+
3
+ module PagesCore
4
+ module Generators
5
+ class RspecGenerator < Rails::Generators::Base
6
+ desc "RSpec setup"
7
+ source_root File.expand_path("../templates", __FILE__)
8
+
9
+ def setup_gems
10
+ gem_group :development do
11
+ gem "spring-commands-rspec"
12
+ end
13
+ gem_group :test, :development do
14
+ gem "rspec-rails"
15
+ gem "shoulda-matchers", require: false
16
+ gem "json_spec"
17
+ gem "capybara"
18
+ gem "timecop"
19
+ gem "factory_girl_rails"
20
+ end
21
+ end
22
+
23
+ def setup_rspec
24
+ create_file File.join(".rspec"), "--colour"
25
+ create_file File.join("spec/controllers/.keep")
26
+ create_file File.join("spec/factories/.keep")
27
+ create_file File.join("spec/models/.keep")
28
+ template "spec_helper.rb", File.join("spec/spec_helper.rb")
29
+ template "factories.rb", File.join("spec/support/factories.rb")
30
+ template "mailer_macros.rb", File.join("spec/support/mailer_macros.rb")
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,9 @@
1
+ FactoryGirl.define do
2
+ sequence :email do |n|
3
+ "person#{n}@example.com"
4
+ end
5
+
6
+ sequence :sha1hash do |n|
7
+ Digest::SHA1.hexdigest("#{n}")
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module MailerMacros
2
+ def last_email
3
+ ActionMailer::Base.deliveries.last
4
+ end
5
+
6
+ def reset_email
7
+ ActionMailer::Base.deliveries = []
8
+ end
9
+ end
@@ -0,0 +1,51 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+
3
+ require "rubygems"
4
+ require File.expand_path("../../config/environment", __FILE__)
5
+ require "rspec/rails"
6
+ require "rspec/autorun"
7
+ require "thinking_sphinx/test"
8
+ require "shoulda-matchers"
9
+
10
+ # Requires supporting ruby files with custom matchers and macros, etc,
11
+ # in spec/support/ and its subdirectories.
12
+ Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| load f }
13
+
14
+ RSpec.configure do |config|
15
+ # == Mock Framework
16
+ #
17
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
18
+ #
19
+ # config.mock_with :mocha
20
+ # config.mock_with :flexmock
21
+ # config.mock_with :rr
22
+ config.mock_with :rspec
23
+
24
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
25
+ # config.fixture_path = "#{::Rails.root}/spec/fixtures"
26
+
27
+ # Use FactoryGirl shorthand
28
+ config.include FactoryGirl::Syntax::Methods
29
+
30
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
31
+ # examples within a transaction, remove the following line or assign false
32
+ # instead of true.
33
+ config.use_transactional_fixtures = true
34
+
35
+ # If true, the base class of anonymous controllers will be inferred
36
+ # automatically. This will be the default behavior in future versions of
37
+ # rspec-rails.
38
+ config.infer_base_class_for_anonymous_controllers = false
39
+
40
+ config.include JsonSpec::Helpers
41
+ config.include MailerMacros
42
+ config.before(:each) { reset_email }
43
+
44
+ config.before(:suite) do
45
+ # Ensure sphinx directories exist for the test environment
46
+ ThinkingSphinx::Test.init
47
+ # Configure and start Sphinx, and automatically
48
+ # stop Sphinx at the end of the test suite.
49
+ ThinkingSphinx::Test.start_with_autostop
50
+ end
51
+ end
data/lib/tasks/db.rake ADDED
@@ -0,0 +1,96 @@
1
+ # encoding: utf-8
2
+
3
+ require "digest/sha1"
4
+ require "tempfile"
5
+
6
+ namespace :db do
7
+ desc "Convert timestamps to UTC"
8
+ task convert_to_utc: :environment do
9
+ tables = ActiveRecord::Base.connection.execute("SHOW TABLES")
10
+ tables.each do |table_row|
11
+ table = table_row.first
12
+ columns = ActiveRecord::Base.connection.execute("DESC `#{table}`")
13
+ columns.each do |column_row|
14
+ column = column_row[0]
15
+ type = column_row[1]
16
+ next unless %w(datetime time timestamp).include?(type)
17
+ puts "Converting #{table}: #{column} (#{type})"
18
+ ActiveRecord::Base.connection.execute(
19
+ "UPDATE `#{table}` SET `#{column}` = " \
20
+ "DATE_SUB(`#{column}`, INTERVAL 1 HOUR)"
21
+ )
22
+ end
23
+ end
24
+ end
25
+
26
+ desc "Copy production database to current environment"
27
+ task copy_from_production: :environment do
28
+ db_config = YAML.load_file(Rails.root.join("config", "database.yml"))
29
+ temp_file = Tempfile.new(db_config[Rails.env]["database"])
30
+
31
+ export_opts = "--add-drop-table --single-transaction --allow-keywords " \
32
+ "--hex-blob --quick " \
33
+ "-u #{db_config['production']['username']} " \
34
+ "-p#{db_config['production']['password']} " \
35
+ "-h #{db_config['production']['host']} " \
36
+ "--max_allowed_packet=100M " \
37
+ "#{db_config['production']['database']}"
38
+
39
+ import_opts = if db_config[Rails.env]["password"]
40
+ "-u #{db_config[Rails.env]['username']} " \
41
+ "-p#{db_config[Rails.env]['password']} " \
42
+ "-h #{db_config[Rails.env]['host']} " \
43
+ "#{db_config[Rails.env]['database']}"
44
+ else
45
+ "-u #{db_config[Rails.env]['username']} " \
46
+ "-h #{db_config[Rails.env]['host']} " \
47
+ "#{db_config[Rails.env]['database']}"
48
+ end
49
+
50
+ puts "Dumping remote database... (this might take a while)"
51
+ `mysqldump #{export_opts} > #{temp_file.path}`
52
+
53
+ puts "Importing database dump"
54
+ `mysql #{import_opts} < #{temp_file.path}`
55
+
56
+ puts "Done!"
57
+ temp_file.close!
58
+ end
59
+
60
+ desc "Fixes double UTF-8 encoding"
61
+ task fix_double_encoding: :environment do
62
+ config = Rails.configuration.database_configuration[Rails.env]
63
+
64
+ temp_file = Tempfile.new(config["database"])
65
+
66
+ export_cmd = if config["password"]
67
+ "mysqldump -u #{config['username']} -p#{config['password']}"
68
+ else
69
+ "mysqldump -u #{config['username']}"
70
+ end
71
+
72
+ export_opts = "--opt --quote-names --skip-set-charset " \
73
+ "--default-character-set=latin1 " \
74
+ "-h #{config['host']} --max_allowed_packet=100M " \
75
+ "#{config['database']}"
76
+
77
+ `#{export_cmd} #{export_opts} > #{temp_file.path}`
78
+
79
+ puts "Dumping database..."
80
+
81
+ mysql_command = if config["password"]
82
+ "mysql -u #{config['username']} -p#{config['password']}"
83
+ else
84
+ "mysql -u #{config['username']}"
85
+ end
86
+
87
+ import_opts = "-h #{config['host']} --default-character-set=utf8 " \
88
+ "#{config['database']}"
89
+
90
+ puts "Importing database dump"
91
+ `#{mysql_command} #{import_opts} < #{temp_file.path}`
92
+
93
+ puts "Done!"
94
+ temp_file.close!
95
+ end
96
+ end
@@ -0,0 +1,65 @@
1
+ # encoding: utf-8
2
+
3
+ require "find"
4
+ require "open-uri"
5
+ require "fileutils"
6
+ require "pathname"
7
+
8
+ namespace :pages do
9
+ namespace :assets do
10
+ namespace :update do
11
+ desc "Updates jQuery"
12
+ task jquery: :environment do
13
+ puts "* Updating jQuery..."
14
+ output = open("http://code.jquery.com/jquery.min.js").read
15
+ File.open("app/assets/javascripts/jquery.js", "w") do |fh|
16
+ fh.write output
17
+ end
18
+ end
19
+
20
+ desc "Updates legacy assets"
21
+ task :legacy do
22
+ if File.exist?("public/plugin_assets")
23
+ puts "* Removing old plugin assets"
24
+ FileUtils.rm_rf "public/plugin_assets"
25
+ end
26
+ if File.exist?("public/javascripts")
27
+ puts "* Removing old javascripts"
28
+ FileUtils.rm_rf "public/javascripts"
29
+ end
30
+ if File.exist?("public/stylesheets")
31
+ puts "* Removing old stylesheets"
32
+ FileUtils.rm_rf "public/stylesheets"
33
+ end
34
+
35
+ Find.find("app/assets") do |path|
36
+ next unless path =~ /\.coffee$/ && !(path =~ /\.js\.coffee$/)
37
+ new_path = path.gsub(/\.coffee$/, ".js.coffee")
38
+ puts "#{path} => #{new_path}"
39
+ FileUtils.mv(path, new_path)
40
+ end
41
+
42
+ Find.find("app/assets") do |path|
43
+ next unless path =~ /\.scss$/ && !(path =~ /\.css\.scss$/)
44
+ new_path = path.gsub(/\.scss$/, ".css.scss")
45
+ puts "#{path} => #{new_path}"
46
+ FileUtils.mv(path, new_path)
47
+ end
48
+ end
49
+ end
50
+
51
+ desc "Update all assets"
52
+ task update: ["update:jquery"] do
53
+ end
54
+
55
+ desc "Update to SCSS"
56
+ task convert_to_scss: :environment do
57
+ assets_dir = Rails.root.join("app", "assets", "stylesheets")
58
+ Find.find(assets_dir) do |path|
59
+ next unless path =~ /\.css$/
60
+ scss_path = path.gsub(/\.css$/, ".css.scss")
61
+ `git mv #{path} #{scss_path}`
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ namespace :pages do
4
+ namespace :cache do
5
+ desc "Sweep the pages cache"
6
+ task sweep: :environment do
7
+ swept_files = PagesCore::CacheSweeper.sweep!
8
+ Rails.logger.info "Cache swept, #{swept_files.length} files deleted."
9
+ end
10
+ desc "Purge the entire pages cache"
11
+ task purge: :environment do
12
+ PagesCore::CacheSweeper.purge!
13
+ Rails.logger.info "Cache purged."
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+
3
+ require "find"
4
+ require "open-uri"
5
+
6
+ namespace :pages do
7
+ namespace :update do
8
+ desc "Update migrations"
9
+ task migrations: :environment do
10
+ removed_migrations = PagesCore::Plugin.remove_old_migrations!
11
+ if removed_migrations.any?
12
+ puts "\n#{removed_migrations.length} old migrations removed"
13
+ end
14
+ end
15
+ end
16
+
17
+ desc "Automated updates for newest version"
18
+ task update: ["update:migrations"]
19
+ end