cd2_catton_cms 1.1.10

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 (306) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +37 -0
  3. data/app/assets/config/c_manifest.js +2 -0
  4. data/app/assets/images/c/drag_handle.gif +0 -0
  5. data/app/assets/images/c/login_background.jpg +0 -0
  6. data/app/assets/images/c/main_application/hero.jpg +0 -0
  7. data/app/assets/images/c/main_application/search.png +0 -0
  8. data/app/assets/images/c/placeholder_product_image.png +0 -0
  9. data/app/assets/images/c/select_arrow_down_blk.png +0 -0
  10. data/app/assets/images/c/small_icon.png +0 -0
  11. data/app/assets/images/c/vendor/chosen-sprite.png +0 -0
  12. data/app/assets/javascripts/c/application.js +59 -0
  13. data/app/assets/javascripts/c/change_tag.js +49 -0
  14. data/app/assets/javascripts/c/chosen.js +2 -0
  15. data/app/assets/javascripts/c/confirm_delete.js +55 -0
  16. data/app/assets/javascripts/c/draggable_tree.js +223 -0
  17. data/app/assets/javascripts/c/dropzone_init.js +98 -0
  18. data/app/assets/javascripts/c/fake_table.js +87 -0
  19. data/app/assets/javascripts/c/master_form2/collection.js +180 -0
  20. data/app/assets/javascripts/c/master_form2/eu_cookie.js +1 -0
  21. data/app/assets/javascripts/c/master_form2/jrecord.js +116 -0
  22. data/app/assets/javascripts/c/master_form2/master_form.coffee +4 -0
  23. data/app/assets/javascripts/c/split_buttons.js.erb +15 -0
  24. data/app/assets/javascripts/c/things_to_be_done.js +138 -0
  25. data/app/assets/javascripts/c/unloadevent.js +35 -0
  26. data/app/assets/stylesheets/c/_core.sass +237 -0
  27. data/app/assets/stylesheets/c/_engine.sass +4 -0
  28. data/app/assets/stylesheets/c/_variables.sass +32 -0
  29. data/app/assets/stylesheets/c/_vendor.sass +6 -0
  30. data/app/assets/stylesheets/c/application/checkout/_cart.sass +85 -0
  31. data/app/assets/stylesheets/c/application/checkout/_checkout.sass +87 -0
  32. data/app/assets/stylesheets/c/application/elements/buttons.sass +34 -0
  33. data/app/assets/stylesheets/c/application/elements/forms.sass +135 -0
  34. data/app/assets/stylesheets/c/application/elements/shadows.sass +23 -0
  35. data/app/assets/stylesheets/c/application/partials/_breadcrumbs.sass +10 -0
  36. data/app/assets/stylesheets/c/application/partials/_categories_sidebars/_1.sass +53 -0
  37. data/app/assets/stylesheets/c/application/partials/_categories_sidebars/_2.sass +77 -0
  38. data/app/assets/stylesheets/c/application/partials/_footer.sass +43 -0
  39. data/app/assets/stylesheets/c/application/partials/_header.sass +317 -0
  40. data/app/assets/stylesheets/c/engine/_draggable_trees.sass +68 -0
  41. data/app/assets/stylesheets/c/engine/_form_pages.sass +153 -0
  42. data/app/assets/stylesheets/c/engine/_header_bar.sass +29 -0
  43. data/app/assets/stylesheets/c/engine/_index_header.sass +17 -0
  44. data/app/assets/stylesheets/c/engine/_layout.sass +15 -0
  45. data/app/assets/stylesheets/c/engine/_login.sass +38 -0
  46. data/app/assets/stylesheets/c/engine/_navbar.sass +19 -0
  47. data/app/assets/stylesheets/c/engine/_pagination.sass +16 -0
  48. data/app/assets/stylesheets/c/engine/_settings.sass +5 -0
  49. data/app/assets/stylesheets/c/engine/_sidebar.sass +20 -0
  50. data/app/assets/stylesheets/c/engine/_tables.sass +76 -0
  51. data/app/assets/stylesheets/c/engine/flash_messages.sass +2 -0
  52. data/app/assets/stylesheets/c/print_application.sass +167 -0
  53. data/app/assets/stylesheets/c/vendor/_flex_mixins.scss +394 -0
  54. data/app/assets/stylesheets/c/vendor/_normalize.sass +340 -0
  55. data/app/controllers/c/admin/blogs_controller.rb +57 -0
  56. data/app/controllers/c/admin/devise/passwords_controller.rb +5 -0
  57. data/app/controllers/c/admin/devise/sessions_controller.rb +5 -0
  58. data/app/controllers/c/admin/documents_controller.rb +50 -0
  59. data/app/controllers/c/admin/enquiries_controller.rb +22 -0
  60. data/app/controllers/c/admin/images_controller.rb +21 -0
  61. data/app/controllers/c/admin/locations_controller.rb +63 -0
  62. data/app/controllers/c/admin/menu_items_controller.rb +49 -0
  63. data/app/controllers/c/admin/pages_controller.rb +94 -0
  64. data/app/controllers/c/admin/projects_controller.rb +55 -0
  65. data/app/controllers/c/admin/redirects_controller.rb +55 -0
  66. data/app/controllers/c/admin/roles_controller.rb +49 -0
  67. data/app/controllers/c/admin/slides_controller.rb +50 -0
  68. data/app/controllers/c/admin/slideshows_controller.rb +34 -0
  69. data/app/controllers/c/admin/team_members_controller.rb +61 -0
  70. data/app/controllers/c/admin/testimonials_controller.rb +43 -0
  71. data/app/controllers/c/admin/users_controller.rb +51 -0
  72. data/app/controllers/c/admin_controller.rb +43 -0
  73. data/app/controllers/c/application_controller.rb +15 -0
  74. data/app/controllers/c/errors_controller.rb +12 -0
  75. data/app/controllers/c/front/devise/passwords_controller.rb +6 -0
  76. data/app/controllers/c/front/devise/registrations_controller.rb +32 -0
  77. data/app/controllers/c/front/devise/sessions_controller.rb +27 -0
  78. data/app/controllers/c/front/mailchimp_controller.rb +32 -0
  79. data/app/controllers/c/front_controller.rb +7 -0
  80. data/app/controllers/c/front_end/blogs_controller.rb +21 -0
  81. data/app/controllers/c/front_end/enquiries_controller.rb +32 -0
  82. data/app/controllers/c/front_end/pages_controller.rb +19 -0
  83. data/app/controllers/c/main_application_controller.rb +22 -0
  84. data/app/helpers/c/application_helper.rb +51 -0
  85. data/app/helpers/c/blogs_helper.rb +113 -0
  86. data/app/helpers/c/c_form_builder.rb +43 -0
  87. data/app/helpers/c/link_to_helper.rb +25 -0
  88. data/app/helpers/c/navigation_helper.rb +28 -0
  89. data/app/helpers/c/pages_helper.rb +27 -0
  90. data/app/helpers/c/storefront_helper.rb +63 -0
  91. data/app/mailers/c/application_mailer.rb +7 -0
  92. data/app/mailers/c/enquiries_mailer.rb +10 -0
  93. data/app/models/c/ability.rb +21 -0
  94. data/app/models/c/application_record.rb +6 -0
  95. data/app/models/c/author_record.rb +13 -0
  96. data/app/models/c/blog.rb +43 -0
  97. data/app/models/c/document.rb +17 -0
  98. data/app/models/c/enquiry.rb +95 -0
  99. data/app/models/c/image.rb +11 -0
  100. data/app/models/c/location.rb +18 -0
  101. data/app/models/c/menu_item.rb +35 -0
  102. data/app/models/c/non_delete.rb +10 -0
  103. data/app/models/c/page.rb +48 -0
  104. data/app/models/c/page_info.rb +16 -0
  105. data/app/models/c/permission.rb +9 -0
  106. data/app/models/c/permission_subject.rb +12 -0
  107. data/app/models/c/project.rb +20 -0
  108. data/app/models/c/redirect.rb +33 -0
  109. data/app/models/c/role.rb +18 -0
  110. data/app/models/c/slide.rb +16 -0
  111. data/app/models/c/slideshow.rb +23 -0
  112. data/app/models/c/team_member.rb +33 -0
  113. data/app/models/c/testimonial.rb +42 -0
  114. data/app/models/c/user.rb +42 -0
  115. data/app/models/c/user_role.rb +7 -0
  116. data/app/models/c/weight.rb +10 -0
  117. data/app/models/concerns/c/authorable.rb +18 -0
  118. data/app/models/concerns/c/documentable.rb +18 -0
  119. data/app/models/concerns/c/imageable.rb +49 -0
  120. data/app/models/concerns/c/non_deletable.rb +30 -0
  121. data/app/models/concerns/c/orderable.rb +30 -0
  122. data/app/models/concerns/c/previewable.rb +20 -0
  123. data/app/models/concerns/c/site_page.rb +89 -0
  124. data/app/uploaders/c/file_uploader.rb +9 -0
  125. data/app/uploaders/c/image_uploader.rb +39 -0
  126. data/app/views/c/admin/_background_jobs_dropdown.html.haml +18 -0
  127. data/app/views/c/admin/_bread_crumbs.html.haml +7 -0
  128. data/app/views/c/admin/_ebay_categories.html.haml +20 -0
  129. data/app/views/c/admin/_flash_messages.html.haml +5 -0
  130. data/app/views/c/admin/_header_bar.html.haml +18 -0
  131. data/app/views/c/admin/_index_table.html.haml +113 -0
  132. data/app/views/c/admin/_index_table_data.html.haml +17 -0
  133. data/app/views/c/admin/_navigation_bar.html.haml +1 -0
  134. data/app/views/c/admin/_preview_image.html.haml +2 -0
  135. data/app/views/c/admin/_preview_upload.html.haml +18 -0
  136. data/app/views/c/admin/_seo.html.haml +11 -0
  137. data/app/views/c/admin/_side_menu.html.haml +26 -0
  138. data/app/views/c/admin/_uploaded_images_new.html.haml +13 -0
  139. data/app/views/c/admin/blogs/_form.html.haml +58 -0
  140. data/app/views/c/admin/blogs/index.html.haml +9 -0
  141. data/app/views/c/admin/confirm_destroy.html.haml +6 -0
  142. data/app/views/c/admin/confirm_mass_destroy.html.haml +10 -0
  143. data/app/views/c/admin/documents/_form.html.haml +8 -0
  144. data/app/views/c/admin/documents/index.html.haml +9 -0
  145. data/app/views/c/admin/edit.html.haml +15 -0
  146. data/app/views/c/admin/enquiries/index.html.haml +14 -0
  147. data/app/views/c/admin/locations/_form.html.haml +58 -0
  148. data/app/views/c/admin/locations/index.html.haml +9 -0
  149. data/app/views/c/admin/menu_items/_form.html.haml +44 -0
  150. data/app/views/c/admin/menu_items/_menu_item_list_item.html.haml +10 -0
  151. data/app/views/c/admin/menu_items/index.html.haml +10 -0
  152. data/app/views/c/admin/new.html.haml +8 -0
  153. data/app/views/c/admin/pages/_form.html.haml +93 -0
  154. data/app/views/c/admin/pages/_page_list_item.html.haml +10 -0
  155. data/app/views/c/admin/pages/dashboard.html.erb +0 -0
  156. data/app/views/c/admin/pages/index.html.haml +11 -0
  157. data/app/views/c/admin/projects/_form.html.haml +46 -0
  158. data/app/views/c/admin/projects/index.html.haml +9 -0
  159. data/app/views/c/admin/quick_edit.js.erb +6 -0
  160. data/app/views/c/admin/redirects/_form.html.haml +14 -0
  161. data/app/views/c/admin/redirects/index.html.haml +9 -0
  162. data/app/views/c/admin/reload_images.js.erb +2 -0
  163. data/app/views/c/admin/roles/_form.html.haml +42 -0
  164. data/app/views/c/admin/roles/index.html.haml +17 -0
  165. data/app/views/c/admin/set_preview_image.js.erb +1 -0
  166. data/app/views/c/admin/show.html.haml +1 -0
  167. data/app/views/c/admin/slides/_form.html.haml +19 -0
  168. data/app/views/c/admin/slideshows/_form.html.haml +25 -0
  169. data/app/views/c/admin/slideshows/index.html.haml +8 -0
  170. data/app/views/c/admin/team_members/_form.html.haml +20 -0
  171. data/app/views/c/admin/team_members/index.html.haml +10 -0
  172. data/app/views/c/admin/testimonials/_form.html.haml +13 -0
  173. data/app/views/c/admin/testimonials/index.html.haml +8 -0
  174. data/app/views/c/admin/users/_form.html.haml +17 -0
  175. data/app/views/c/admin/users/index.html.haml +12 -0
  176. data/app/views/c/enquiries_mailer/new_enquiry.html.haml +14 -0
  177. data/app/views/c/enquiries_mailer/new_enquiry.text.haml +9 -0
  178. data/app/views/c/errors/404.html.haml +5 -0
  179. data/app/views/c/errors/500.html.haml +5 -0
  180. data/app/views/c/front/application/_category_item.html.haml +2 -0
  181. data/app/views/c/front/application/_menu_item.html.haml +4 -0
  182. data/app/views/c/front/application/_sales_highlight.html.haml +1 -0
  183. data/app/views/c/front/application/_slide.html.haml +6 -0
  184. data/app/views/c/front/blogs/_archive_filter_month.html.haml +2 -0
  185. data/app/views/c/front/blogs/_archive_filter_year.html.haml +1 -0
  186. data/app/views/c/front/blogs/_menu_item.html.haml +2 -0
  187. data/app/views/c/front_end/enquiries/new.html.haml +23 -0
  188. data/app/views/c/front_end/enquiries/thanks.html.haml +5 -0
  189. data/app/views/c/front_end/pages/_sales_highlight.html.haml +7 -0
  190. data/app/views/c/front_end/pages/about.html.haml +8 -0
  191. data/app/views/c/front_end/pages/home.html.haml +19 -0
  192. data/app/views/c/front_end/pages/search.html.haml +16 -0
  193. data/app/views/c/front_end/pages/show.html.haml +7 -0
  194. data/app/views/c/front_end/pages/sitemap.xml.builder +25 -0
  195. data/app/views/c/mailchimp/_signup_newsletter.html.haml +4 -0
  196. data/app/views/c/main_application/_application_bar.html.haml +22 -0
  197. data/app/views/c/main_application/_breadcrumbs.html.haml +7 -0
  198. data/app/views/c/main_application/_contact_info.html.haml +5 -0
  199. data/app/views/c/main_application/_footer.html.haml +49 -0
  200. data/app/views/c/main_application/_front_head_tags.html.haml +3 -0
  201. data/app/views/c/main_application/_header.html.haml +55 -0
  202. data/app/views/c/main_application/_site_search.html.haml +3 -0
  203. data/app/views/c/main_application/_yield.html.haml +5 -0
  204. data/app/views/devise/confirmations/new.html.erb +16 -0
  205. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  206. data/app/views/devise/mailer/password_change.html.erb +3 -0
  207. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  208. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  209. data/app/views/devise/passwords/edit.html.haml +26 -0
  210. data/app/views/devise/passwords/new.html.haml +14 -0
  211. data/app/views/devise/registrations/edit.html.haml +40 -0
  212. data/app/views/devise/registrations/new.html.haml +24 -0
  213. data/app/views/devise/sessions/new.html.haml +20 -0
  214. data/app/views/devise/shared/_links.html.erb +25 -0
  215. data/app/views/devise/unlocks/new.html.erb +16 -0
  216. data/app/views/layouts/c/application.html.haml +18 -0
  217. data/app/views/layouts/c/cms_login_layout.html.haml +18 -0
  218. data/app/views/layouts/c/mailer.html.erb +245 -0
  219. data/app/views/layouts/c/mailer.text.erb +3 -0
  220. data/app/views/layouts/c/main_application.html.haml +13 -0
  221. data/config/environment.rb +0 -0
  222. data/config/initializers/carrierwave.rb +18 -0
  223. data/config/initializers/devise.rb +283 -0
  224. data/config/initializers/rack_profiler.rb +8 -0
  225. data/config/locales/devise.en.yml +62 -0
  226. data/config/locales/en.yml +17 -0
  227. data/config/routes.rb +150 -0
  228. data/db/migrate/20160819000000_migrate_schema.rb +273 -0
  229. data/db/seed_data/countries.txt +227 -0
  230. data/lib/c/engine.rb +38 -0
  231. data/lib/c/version.rb +4 -0
  232. data/lib/cd2_catton_cms.rb +51 -0
  233. data/lib/tasks/c_tasks.rake +28 -0
  234. data/spec/dummy/Gemfile +4 -0
  235. data/spec/dummy/Gemfile.lock +20 -0
  236. data/spec/dummy/Rakefile +6 -0
  237. data/spec/dummy/app/assets/config/manifest.js +5 -0
  238. data/spec/dummy/app/assets/images/placeholder.png +0 -0
  239. data/spec/dummy/app/assets/javascripts/application.js +26 -0
  240. data/spec/dummy/app/assets/javascripts/cable.js +13 -0
  241. data/spec/dummy/app/assets/javascripts/pages.coffee +3 -0
  242. data/spec/dummy/app/assets/stylesheets/application.sass +13 -0
  243. data/spec/dummy/app/assets/stylesheets/c/application.sass +2 -0
  244. data/spec/dummy/app/controllers/application_controller.rb +10 -0
  245. data/spec/dummy/app/controllers/blogs_controller.rb +11 -0
  246. data/spec/dummy/app/controllers/pages_controller.rb +13 -0
  247. data/spec/dummy/app/models/application_record.rb +4 -0
  248. data/spec/dummy/app/models/page.rb +3 -0
  249. data/spec/dummy/bin/bundle +4 -0
  250. data/spec/dummy/bin/rails +5 -0
  251. data/spec/dummy/bin/rake +5 -0
  252. data/spec/dummy/bin/setup +35 -0
  253. data/spec/dummy/bin/update +30 -0
  254. data/spec/dummy/config/application.rb +17 -0
  255. data/spec/dummy/config/boot.rb +6 -0
  256. data/spec/dummy/config/cable.yml +9 -0
  257. data/spec/dummy/config/database.travis.yml +3 -0
  258. data/spec/dummy/config/database.yml +85 -0
  259. data/spec/dummy/config/environment.rb +6 -0
  260. data/spec/dummy/config/environments/development.rb +61 -0
  261. data/spec/dummy/config/environments/production.rb +87 -0
  262. data/spec/dummy/config/environments/test.rb +43 -0
  263. data/spec/dummy/config/initializers/application_controller_renderer.rb +7 -0
  264. data/spec/dummy/config/initializers/assets.rb +21 -0
  265. data/spec/dummy/config/initializers/backtrace_silencers.rb +8 -0
  266. data/spec/dummy/config/initializers/carrierwave.rb +15 -0
  267. data/spec/dummy/config/initializers/commercity.rb +4 -0
  268. data/spec/dummy/config/initializers/cookies_serializer.rb +6 -0
  269. data/spec/dummy/config/initializers/filter_parameter_logging.rb +5 -0
  270. data/spec/dummy/config/initializers/inflections.rb +17 -0
  271. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  272. data/spec/dummy/config/initializers/new_framework_defaults.rb +25 -0
  273. data/spec/dummy/config/initializers/session_store.rb +4 -0
  274. data/spec/dummy/config/initializers/wrap_parameters.rb +15 -0
  275. data/spec/dummy/config/locales/en.yml +23 -0
  276. data/spec/dummy/config/puma.rb +48 -0
  277. data/spec/dummy/config/routes.rb +4 -0
  278. data/spec/dummy/config/secrets.yml +22 -0
  279. data/spec/dummy/config/sidekiq.yml +6 -0
  280. data/spec/dummy/config/spring.rb +7 -0
  281. data/spec/dummy/config.ru +5 -0
  282. data/spec/dummy/db/schema.rb +1110 -0
  283. data/spec/dummy/lib/tasks/reprocess_images.rake +12 -0
  284. data/spec/dummy/lib/tasks/reset_all.rake +44 -0
  285. data/spec/dummy/lib/tasks/seeds/seed_blogs.rake +8 -0
  286. data/spec/dummy/lib/tasks/seeds/seed_pages.rake +24 -0
  287. data/spec/dummy/public/404.html +67 -0
  288. data/spec/dummy/public/422.html +67 -0
  289. data/spec/dummy/public/500.html +66 -0
  290. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  291. data/spec/dummy/public/apple-touch-icon.png +0 -0
  292. data/spec/dummy/public/favicon.ico +0 -0
  293. data/spec/dummy/seed/highlight1.png +0 -0
  294. data/spec/dummy/seed/highlight2.png +0 -0
  295. data/spec/dummy/seed/images/1/main.jpg +0 -0
  296. data/spec/dummy/seed/images/1/thumb.JPG +0 -0
  297. data/spec/dummy/seed/images/1/thumb2.jpg +0 -0
  298. data/spec/dummy/seed/images/2/main.jpeg +0 -0
  299. data/spec/dummy/seed/images/2/thumb.JPG +0 -0
  300. data/spec/dummy/seed/images/2/thumb2.JPG +0 -0
  301. data/spec/dummy/spec/models/redirect_spec.rb +57 -0
  302. data/spec/dummy/spec/support/factory_girl.rb +8 -0
  303. data/spec/dummy/spec/support/seed/images/product_image.png +0 -0
  304. data/spec/rails_helper.rb +49 -0
  305. data/spec/spec_helper.rb +52 -0
  306. metadata +734 -0
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+ module C
3
+ class Page < ApplicationRecord
4
+ include SitePage
5
+ include Imageable
6
+ include Authorable
7
+ include Orderable
8
+ include Previewable
9
+ include Documentable
10
+
11
+ acts_as_tree order: 'weight'
12
+
13
+ validates :name, presence: true
14
+
15
+ has_many :menu_items
16
+
17
+ has_many :product_points, dependent: :destroy, class_name: 'ProductPoint'
18
+
19
+ accepts_nested_attributes_for :product_points, allow_destroy: true
20
+
21
+ before_save do
22
+ self.layout = 'show' if layout.blank?
23
+ end
24
+
25
+ def build_product_points
26
+ case product_points.count
27
+ when 3
28
+ return
29
+ when 2
30
+ 1.times { product_points.build }
31
+ when 1
32
+ 2.times { product_points.build }
33
+ when 0
34
+ 3.times { product_points.build }
35
+ else
36
+ return
37
+ end
38
+ end
39
+
40
+ INDEX_TABLE = {
41
+ "Name": { link: { name: { call: 'name' }, options: '[:edit, object]' }, sort: 'name' },
42
+ "Author": { call: 'author', sort: 'author' },
43
+ "Published": { call: 'published', sort: 'published' },
44
+ "Created": { call: 'created_at', sort: 'published' },
45
+ "Edit": { link: { name: { text: 'edit' }, options: '[:edit, object]' } }
46
+ }.freeze
47
+ end
48
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+ module C
3
+ class PageInfo < ApplicationRecord
4
+ belongs_to :page, polymorphic: true
5
+
6
+ def fallback_title
7
+ if (name = page.try(:name))
8
+ "#{name} | #{C.store_name}"
9
+ else
10
+ C.store_name
11
+ end
12
+ rescue
13
+ ''
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+ module C
3
+ class Permission < ApplicationRecord
4
+ belongs_to :role
5
+ belongs_to :permission_subject
6
+
7
+ delegate :name, :body, :subject, :subject_id, to: :permission_subject
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ module C
3
+ class PermissionSubject < ApplicationRecord
4
+ validates :name, presence: true
5
+
6
+ def subject
7
+ subject_type.constantize
8
+ rescue NameError
9
+ subject_type
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ module C
3
+ class Project < ApplicationRecord
4
+ include SitePage
5
+ include Imageable
6
+ include Orderable
7
+ include Previewable
8
+ include Authorable
9
+
10
+ validates :name, presence: true
11
+
12
+ INDEX_TABLE = {
13
+ 'Name': { link: { name: { call: 'name' }, options: '[:edit, object]' }, sort: 'name' },
14
+ 'Author': { call: 'author', sort: 'author' },
15
+ 'Published': { call: 'published', sort: 'published' },
16
+ 'Created': { call: 'created_at', sort: 'published' },
17
+ 'Edit': { link: { name: { text: 'edit' }, options: '[:edit, object]' } }
18
+ }.freeze
19
+ end
20
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+ module C
3
+ class Redirect < ApplicationRecord
4
+ scope :ordered, -> { order created_at: :desc }
5
+
6
+ validates :old_url, presence: true
7
+ validates :new_url, presence: true
8
+
9
+ def increment
10
+ self.used_counter = used_counter + 1
11
+ self.last_used = Time.zone.now
12
+ save!
13
+ end
14
+
15
+ def self.bulk_action(action)
16
+ case action
17
+ when 'delete'
18
+ destroy_all
19
+ 'Deleted Redirects'
20
+ else
21
+ 'No action selected'
22
+ end
23
+ end
24
+
25
+ INDEX_TABLE = {
26
+ 'Old URL': { call: 'old_url', sort: 'old_url' },
27
+ 'New URL': { call: 'new_url', sort: 'new_url' },
28
+ 'Used': { call: 'used_counter', sort: 'used_counter' },
29
+ 'Last Used': { call: 'last_used', sort: 'last_used' },
30
+ 'Edit': { link: { name: { text: 'edit' }, options: '[:edit, object]' } }
31
+ }.freeze
32
+ end
33
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+ module C
3
+ class Role < ApplicationRecord
4
+ has_many :permissions
5
+ accepts_nested_attributes_for :permissions
6
+
7
+ has_many :user_roles
8
+ has_many :users, through: :user_roles
9
+
10
+ validates :name, presence: true
11
+
12
+ def build_or_find_permissions
13
+ PermissionSubject.find_each do |subject|
14
+ permissions.collect(&:permission_subject_id).include?(subject.id) || permissions.build(permission_subject: subject)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+ module C
3
+ class Slide < ApplicationRecord
4
+ include Orderable
5
+
6
+ belongs_to :slideshow
7
+
8
+ mount_uploader :image, ImageUploader
9
+
10
+ INDEX_TABLE = {
11
+ 'Slide': { image: 'image.preview' },
12
+ 'Name': { link: { name: { call: 'name' }, options: '[:edit, object.slideshow, object]' } },
13
+ 'Edit': { link: { name: { text: 'Edit' }, options: '[:edit, object.slideshow, object]' } }
14
+ }.freeze
15
+ end
16
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ module C
3
+ class Slideshow < ApplicationRecord
4
+ scope :ordered, -> { order created_at: :asc }
5
+
6
+ has_many :slides, dependent: :delete_all
7
+
8
+ before_validation on: :create do
9
+ self.machine_name = name
10
+ end
11
+
12
+ # Force non blank parametized machine name
13
+ def machine_name=(val)
14
+ super val.to_s.parameterize
15
+ end
16
+
17
+ INDEX_TABLE = {
18
+ 'Name': { link: { name: { call: 'name' }, options: '[:edit, object]' } },
19
+ 'Description': { call: 'body&.html_safe' },
20
+ 'Slides': { link: { name: { call: 'slides.count' }, options: '[:edit, object]' } }
21
+ }.freeze
22
+ end
23
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+ module C
3
+ class TeamMember < ApplicationRecord
4
+ include Orderable
5
+
6
+ validates :name, presence: true
7
+
8
+ mount_uploader :image, ImageUploader
9
+
10
+ def name_and_role
11
+ "#{name} - #{role}"
12
+ end
13
+
14
+ INDEX_TABLE = {
15
+ 'Image': {
16
+ image: 'image.preview'
17
+ },
18
+ '': {},
19
+ 'Name': {
20
+ link: {
21
+ name: { call: 'name_and_role' },
22
+ options: '[:edit, object]'
23
+ }
24
+ },
25
+ 'Edit': {
26
+ link: {
27
+ name: { text: 'Edit' },
28
+ options: '[:edit, object]'
29
+ }
30
+ }
31
+ }.freeze
32
+ end
33
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+ module C
3
+ class Testimonial < ApplicationRecord
4
+ include Orderable
5
+ include Imageable
6
+
7
+ validates :quote, :author, presence: true
8
+ belongs_to :project, optional: true
9
+
10
+ def quote_teaser
11
+ if quote.length > 150
12
+ quote.truncate(150)
13
+ else
14
+ quote
15
+ end
16
+ end
17
+
18
+ INDEX_TABLE = {
19
+ "Quote": {
20
+ call: 'quote'
21
+ },
22
+ "Author": {
23
+ call: 'author'
24
+ },
25
+ "Created": {
26
+ call: 'created_at'
27
+ },
28
+ "Delete": {
29
+ link: {
30
+ name: {
31
+ text: 'Delete'
32
+ },
33
+ options: '[object]',
34
+ method: :delete,
35
+ data: {
36
+ confirm: 'Are you sure?'
37
+ }
38
+ }
39
+ }
40
+ }.freeze
41
+ end
42
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+ module C
3
+ class User < ApplicationRecord
4
+ # Include default devise modules. Others available are:
5
+ # :confirmable, :lockable, :timeoutable and :omniauthable, :registerable
6
+ devise :database_authenticatable, :recoverable,
7
+ :rememberable, :trackable, :validatable
8
+
9
+ scope :ordered, -> { order name: :asc }
10
+
11
+ has_many :user_roles
12
+ has_many :roles, through: :user_roles
13
+ has_many :permissions, -> { distinct }, through: :roles
14
+
15
+ validates :name, presence: true
16
+
17
+ INDEX_TABLE = {
18
+ 'Name': {
19
+ link: {
20
+ name: {
21
+ call: 'name'
22
+ },
23
+ options: '[:edit, object]'
24
+ },
25
+ sort: 'name'
26
+ },
27
+ 'Email': {
28
+ call: 'email', sort: 'email'
29
+ },
30
+ 'Last Sign In': {
31
+ call: 'last_sign_in_at'
32
+ },
33
+ 'Edit': {
34
+ link: {
35
+ name: {
36
+ text: 'edit'
37
+ }, options: '[:edit, object]'
38
+ }
39
+ }
40
+ }.freeze
41
+ end
42
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+ module C
3
+ class UserRole < ApplicationRecord
4
+ belongs_to :user
5
+ belongs_to :role
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ module C
3
+ class Weight < ApplicationRecord
4
+ belongs_to :orderable, polymorphic: true
5
+
6
+ def value
7
+ super || 0
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+ module C
3
+ module Authorable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ has_one :author_record, as: :authored, autosave: true, dependent: :destroy
8
+ delegate :user, to: :author_record
9
+ delegate :author, to: :author_record, allow_nil: true
10
+
11
+ after_save :assign_author
12
+
13
+ def assign_author
14
+ create_author_record(user_id: $user_id)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+ module C
3
+ module Documentable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ has_many :documents, as: :documentable, autosave: true, dependent: :destroy
8
+
9
+ accepts_nested_attributes_for :documents, allow_destroy: true
10
+
11
+ def new_documents=(val)
12
+ Array(val).each do |document|
13
+ documents.build(document: document)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+ module C
3
+ module Imageable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ has_many :images, as: :imageable, autosave: true, dependent: :destroy
8
+ has_one :feature_image, -> { where(featured_image: true) }, as: :imageable, class_name: 'C::Image'
9
+ has_one :preview_image, -> { where(preview_image: true) }, as: :imageable, class_name: 'C::Image'
10
+
11
+ accepts_nested_attributes_for :images, allow_destroy: true
12
+
13
+ def new_images=(val)
14
+ Array(val).each do |image|
15
+ images.build(image: image)
16
+ end
17
+ end
18
+
19
+ def feature_image(fallback=nil)
20
+ super&.image || images.first&.image || fallback || ''
21
+ end
22
+
23
+ def feature_image?
24
+ images.where(featured_image: true).exists?
25
+ end
26
+
27
+ def preview_image(fallback=nil)
28
+ super&.image || images.first&.image || fallback || ''
29
+ end
30
+
31
+ def teaser_image(fallback=nil)
32
+ preview_image fallback
33
+ end
34
+
35
+ def preview_image?
36
+ images.where(preview_image: true).exists?
37
+ end
38
+
39
+ def teaser_image?
40
+ preview_image?
41
+ end
42
+ end
43
+
44
+ class_methods do
45
+ def asd; end
46
+ IMAGEABLE_ATTRIBUTES = [images_attributes: [:_destroy, :id, :alt, :caption, :image, :image_cache, :feature_image, :preview_image, :weight, :featured_image]].freeze
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ module C
3
+ module NonDeletable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ has_one :non_delete, as: :non_deletable, dependent: :destroy
8
+
9
+ before_create do
10
+ create_non_delete!
11
+ end
12
+
13
+ def destroy
14
+ create_non_delete! unless non_delete
15
+ non_delete.update(deleted: true)
16
+ end
17
+
18
+ def deleted?
19
+ create_non_delete! unless non_delete
20
+ non_delete.deleted
21
+ end
22
+ end
23
+
24
+ def self.included(klass)
25
+ klass.instance_eval do
26
+ default_scope { includes(:non_delete).where(c_non_deletes: { deleted: false }) }
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ module C
3
+ module Orderable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ has_one :_weight, dependent: :destroy, class_name: 'C::Weight', as: :orderable
8
+ accepts_nested_attributes_for :_weight
9
+
10
+ scope :ordered, -> { includes(:_weight).order('c_weights.value asc') }
11
+
12
+ def _weight
13
+ super || build__weight
14
+ end
15
+
16
+ def weight
17
+ _weight.value
18
+ end
19
+
20
+ def weight=(val)
21
+ _weight.value = val
22
+ end
23
+
24
+ def self.update_order(ordered_ids)
25
+ order = ordered_ids.each_with_index.map { |_, i| { weight: i + 1 } }
26
+ update(ordered_ids, order)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ module C
3
+ module Previewable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ def preview_body
8
+ if !self.class.column_names.include?('preview_body') || super.blank?
9
+ if body.present?
10
+ ActionController::Base.helpers.strip_tags(body.gsub(%r{<h(\d)>.*?<\/h(\1)>}, '')).truncate(150, strip_tags: true)
11
+ else
12
+ ''
13
+ end
14
+ else
15
+ super
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+ module C
3
+ module SitePage
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ scope :published, -> { includes(:page_info).where("c_page_infos.published": true) }
8
+
9
+ has_one :page_info, as: :page, dependent: :destroy
10
+ accepts_nested_attributes_for :page_info
11
+
12
+ has_one :menu_item, autosave: true
13
+ accepts_nested_attributes_for :menu_item
14
+
15
+ delegate :title=, to: :page_info
16
+ delegate :meta_description=, to: :page_info
17
+ delegate :published=, to: :page_info
18
+ delegate :protected=, to: :page_info
19
+ delegate :home_page=, to: :page_info
20
+
21
+ delegate :protected, to: :page_info
22
+ delegate :published, to: :page_info
23
+ delegate :home_page, to: :page_info
24
+ delegate :home_page?, to: :page_info
25
+ delegate :title, to: :page_info
26
+ delegate :meta_description, to: :page_info
27
+ delegate :author, to: :page_info
28
+
29
+ validates :url_alias, presence: true
30
+
31
+ before_validation do
32
+ if url_alias.blank?
33
+
34
+ ident = if new_record?
35
+ self.class.count + 1
36
+ else
37
+ id
38
+ end
39
+
40
+ url_pattern = if name.blank?
41
+ ident
42
+ else
43
+ name.parameterize
44
+ end
45
+
46
+ if self.class.find_by(url_alias: url_pattern)
47
+ url_pattern = "#{url_pattern}-#{ident}"
48
+ end
49
+ self.url_alias = url_pattern
50
+ end
51
+ end
52
+
53
+ before_create do
54
+ create_page_info unless page_info
55
+ end
56
+
57
+ def to_param
58
+ url_alias
59
+ end
60
+
61
+ def page_info
62
+ super || build_page_info(page: self)
63
+ end
64
+
65
+ def assign_author(user)
66
+ page_info.author_id = user.id
67
+ page_info.save
68
+ end
69
+ end
70
+
71
+ class_methods do
72
+ def get_from_url(url=nil)
73
+ # TODO: url alias can be nil w/o being homepage
74
+ # cond = url ? {url_alias: url} : {home_page: true}
75
+ if url
76
+ all.find_by(url_alias: url)
77
+ else
78
+ all.includes(:page_info).find_by(c_page_infos: { home_page: true })
79
+ end
80
+ end
81
+
82
+ def root_page
83
+ PageInfo.find_by(page_type: page_type, root: true).page
84
+ end
85
+
86
+ PAGE_INFO_ATTRIBUTES = [page_info_attributes: [:id, :title, :meta_description]].freeze
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+ # frozen_string_literal: true
3
+ module C
4
+ class FileUploader < CarrierWave::Uploader::Base
5
+ def store_dir
6
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+ # frozen_string_literal: true
3
+ module C
4
+ class ImageUploader < CarrierWave::Uploader::Base
5
+ include CarrierWave::MiniMagick
6
+
7
+ def store_dir
8
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
9
+ end
10
+
11
+ version :thumbnail do
12
+ process resize_and_pad: [150, 150]
13
+ end
14
+
15
+ version :preview do
16
+ process resize_to_fit: [100, 100]
17
+ end
18
+
19
+ version :cropped_square do
20
+ process resize_to_fill: [300, 300]
21
+ end
22
+
23
+ version :square do
24
+ process resize_to_fit: [300, 300]
25
+ end
26
+
27
+ version :big_sq do
28
+ process resize_and_pad: [600, 400]
29
+ end
30
+
31
+ version :large do
32
+ process resize_to_fill: [1000, 600]
33
+ end
34
+
35
+ version :cropped_rect do
36
+ process :resize_to_fill => [250, 100]
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,18 @@
1
+ - unless @background_jobs.blank?
2
+ #background_jobs
3
+ .label
4
+ = fa_icon("caret-down")
5
+ = pluralize(@background_jobs_count, "Running Job")
6
+ .background_jobs_container
7
+ %ul
8
+ - @background_jobs.each do |product|
9
+ %li
10
+ - max_length = 20
11
+ %p
12
+ Processing Amazon data for
13
+ %span.product_name
14
+ = "#{product.name[0..max_length]}#{"..." if product.name.length > max_length}"
15
+ - difference = @background_jobs_count - @background_jobs.count
16
+ - if difference > 0
17
+ %li
18
+ %p And #{difference} more
@@ -0,0 +1,7 @@
1
+ .bread_crumbs
2
+ %span You are here:
3
+ - nav.each_with_index do |crumb, i|
4
+ - next if i == 0
5
+ = link_to crumb[:title], crumb[:url]
6
+ = fa_icon 'chevron-right'
7
+ = link_to yield(:title), request.path, class: 'no_link'