cd2_catton_cms 1.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +37 -0
- data/app/assets/config/c_manifest.js +2 -0
- data/app/assets/images/c/drag_handle.gif +0 -0
- data/app/assets/images/c/login_background.jpg +0 -0
- data/app/assets/images/c/main_application/hero.jpg +0 -0
- data/app/assets/images/c/main_application/search.png +0 -0
- data/app/assets/images/c/placeholder_product_image.png +0 -0
- data/app/assets/images/c/select_arrow_down_blk.png +0 -0
- data/app/assets/images/c/small_icon.png +0 -0
- data/app/assets/images/c/vendor/chosen-sprite.png +0 -0
- data/app/assets/javascripts/c/application.js +59 -0
- data/app/assets/javascripts/c/change_tag.js +49 -0
- data/app/assets/javascripts/c/chosen.js +2 -0
- data/app/assets/javascripts/c/confirm_delete.js +55 -0
- data/app/assets/javascripts/c/draggable_tree.js +223 -0
- data/app/assets/javascripts/c/dropzone_init.js +98 -0
- data/app/assets/javascripts/c/fake_table.js +87 -0
- data/app/assets/javascripts/c/master_form2/collection.js +180 -0
- data/app/assets/javascripts/c/master_form2/eu_cookie.js +1 -0
- data/app/assets/javascripts/c/master_form2/jrecord.js +116 -0
- data/app/assets/javascripts/c/master_form2/master_form.coffee +4 -0
- data/app/assets/javascripts/c/split_buttons.js.erb +15 -0
- data/app/assets/javascripts/c/things_to_be_done.js +138 -0
- data/app/assets/javascripts/c/unloadevent.js +35 -0
- data/app/assets/stylesheets/c/_core.sass +237 -0
- data/app/assets/stylesheets/c/_engine.sass +4 -0
- data/app/assets/stylesheets/c/_variables.sass +32 -0
- data/app/assets/stylesheets/c/_vendor.sass +6 -0
- data/app/assets/stylesheets/c/application/checkout/_cart.sass +85 -0
- data/app/assets/stylesheets/c/application/checkout/_checkout.sass +87 -0
- data/app/assets/stylesheets/c/application/elements/buttons.sass +34 -0
- data/app/assets/stylesheets/c/application/elements/forms.sass +135 -0
- data/app/assets/stylesheets/c/application/elements/shadows.sass +23 -0
- data/app/assets/stylesheets/c/application/partials/_breadcrumbs.sass +10 -0
- data/app/assets/stylesheets/c/application/partials/_categories_sidebars/_1.sass +53 -0
- data/app/assets/stylesheets/c/application/partials/_categories_sidebars/_2.sass +77 -0
- data/app/assets/stylesheets/c/application/partials/_footer.sass +43 -0
- data/app/assets/stylesheets/c/application/partials/_header.sass +317 -0
- data/app/assets/stylesheets/c/engine/_draggable_trees.sass +68 -0
- data/app/assets/stylesheets/c/engine/_form_pages.sass +153 -0
- data/app/assets/stylesheets/c/engine/_header_bar.sass +29 -0
- data/app/assets/stylesheets/c/engine/_index_header.sass +17 -0
- data/app/assets/stylesheets/c/engine/_layout.sass +15 -0
- data/app/assets/stylesheets/c/engine/_login.sass +38 -0
- data/app/assets/stylesheets/c/engine/_navbar.sass +19 -0
- data/app/assets/stylesheets/c/engine/_pagination.sass +16 -0
- data/app/assets/stylesheets/c/engine/_settings.sass +5 -0
- data/app/assets/stylesheets/c/engine/_sidebar.sass +20 -0
- data/app/assets/stylesheets/c/engine/_tables.sass +76 -0
- data/app/assets/stylesheets/c/engine/flash_messages.sass +2 -0
- data/app/assets/stylesheets/c/print_application.sass +167 -0
- data/app/assets/stylesheets/c/vendor/_flex_mixins.scss +394 -0
- data/app/assets/stylesheets/c/vendor/_normalize.sass +340 -0
- data/app/controllers/c/admin/blogs_controller.rb +57 -0
- data/app/controllers/c/admin/devise/passwords_controller.rb +5 -0
- data/app/controllers/c/admin/devise/sessions_controller.rb +5 -0
- data/app/controllers/c/admin/documents_controller.rb +50 -0
- data/app/controllers/c/admin/enquiries_controller.rb +22 -0
- data/app/controllers/c/admin/images_controller.rb +21 -0
- data/app/controllers/c/admin/locations_controller.rb +63 -0
- data/app/controllers/c/admin/menu_items_controller.rb +49 -0
- data/app/controllers/c/admin/pages_controller.rb +94 -0
- data/app/controllers/c/admin/projects_controller.rb +55 -0
- data/app/controllers/c/admin/redirects_controller.rb +55 -0
- data/app/controllers/c/admin/roles_controller.rb +49 -0
- data/app/controllers/c/admin/slides_controller.rb +50 -0
- data/app/controllers/c/admin/slideshows_controller.rb +34 -0
- data/app/controllers/c/admin/team_members_controller.rb +61 -0
- data/app/controllers/c/admin/testimonials_controller.rb +43 -0
- data/app/controllers/c/admin/users_controller.rb +51 -0
- data/app/controllers/c/admin_controller.rb +43 -0
- data/app/controllers/c/application_controller.rb +15 -0
- data/app/controllers/c/errors_controller.rb +12 -0
- data/app/controllers/c/front/devise/passwords_controller.rb +6 -0
- data/app/controllers/c/front/devise/registrations_controller.rb +32 -0
- data/app/controllers/c/front/devise/sessions_controller.rb +27 -0
- data/app/controllers/c/front/mailchimp_controller.rb +32 -0
- data/app/controllers/c/front_controller.rb +7 -0
- data/app/controllers/c/front_end/blogs_controller.rb +21 -0
- data/app/controllers/c/front_end/enquiries_controller.rb +32 -0
- data/app/controllers/c/front_end/pages_controller.rb +19 -0
- data/app/controllers/c/main_application_controller.rb +22 -0
- data/app/helpers/c/application_helper.rb +51 -0
- data/app/helpers/c/blogs_helper.rb +113 -0
- data/app/helpers/c/c_form_builder.rb +43 -0
- data/app/helpers/c/link_to_helper.rb +25 -0
- data/app/helpers/c/navigation_helper.rb +28 -0
- data/app/helpers/c/pages_helper.rb +27 -0
- data/app/helpers/c/storefront_helper.rb +63 -0
- data/app/mailers/c/application_mailer.rb +7 -0
- data/app/mailers/c/enquiries_mailer.rb +10 -0
- data/app/models/c/ability.rb +21 -0
- data/app/models/c/application_record.rb +6 -0
- data/app/models/c/author_record.rb +13 -0
- data/app/models/c/blog.rb +43 -0
- data/app/models/c/document.rb +17 -0
- data/app/models/c/enquiry.rb +95 -0
- data/app/models/c/image.rb +11 -0
- data/app/models/c/location.rb +18 -0
- data/app/models/c/menu_item.rb +35 -0
- data/app/models/c/non_delete.rb +10 -0
- data/app/models/c/page.rb +48 -0
- data/app/models/c/page_info.rb +16 -0
- data/app/models/c/permission.rb +9 -0
- data/app/models/c/permission_subject.rb +12 -0
- data/app/models/c/project.rb +20 -0
- data/app/models/c/redirect.rb +33 -0
- data/app/models/c/role.rb +18 -0
- data/app/models/c/slide.rb +16 -0
- data/app/models/c/slideshow.rb +23 -0
- data/app/models/c/team_member.rb +33 -0
- data/app/models/c/testimonial.rb +42 -0
- data/app/models/c/user.rb +42 -0
- data/app/models/c/user_role.rb +7 -0
- data/app/models/c/weight.rb +10 -0
- data/app/models/concerns/c/authorable.rb +18 -0
- data/app/models/concerns/c/documentable.rb +18 -0
- data/app/models/concerns/c/imageable.rb +49 -0
- data/app/models/concerns/c/non_deletable.rb +30 -0
- data/app/models/concerns/c/orderable.rb +30 -0
- data/app/models/concerns/c/previewable.rb +20 -0
- data/app/models/concerns/c/site_page.rb +89 -0
- data/app/uploaders/c/file_uploader.rb +9 -0
- data/app/uploaders/c/image_uploader.rb +39 -0
- data/app/views/c/admin/_background_jobs_dropdown.html.haml +18 -0
- data/app/views/c/admin/_bread_crumbs.html.haml +7 -0
- data/app/views/c/admin/_ebay_categories.html.haml +20 -0
- data/app/views/c/admin/_flash_messages.html.haml +5 -0
- data/app/views/c/admin/_header_bar.html.haml +18 -0
- data/app/views/c/admin/_index_table.html.haml +113 -0
- data/app/views/c/admin/_index_table_data.html.haml +17 -0
- data/app/views/c/admin/_navigation_bar.html.haml +1 -0
- data/app/views/c/admin/_preview_image.html.haml +2 -0
- data/app/views/c/admin/_preview_upload.html.haml +18 -0
- data/app/views/c/admin/_seo.html.haml +11 -0
- data/app/views/c/admin/_side_menu.html.haml +26 -0
- data/app/views/c/admin/_uploaded_images_new.html.haml +13 -0
- data/app/views/c/admin/blogs/_form.html.haml +58 -0
- data/app/views/c/admin/blogs/index.html.haml +9 -0
- data/app/views/c/admin/confirm_destroy.html.haml +6 -0
- data/app/views/c/admin/confirm_mass_destroy.html.haml +10 -0
- data/app/views/c/admin/documents/_form.html.haml +8 -0
- data/app/views/c/admin/documents/index.html.haml +9 -0
- data/app/views/c/admin/edit.html.haml +15 -0
- data/app/views/c/admin/enquiries/index.html.haml +14 -0
- data/app/views/c/admin/locations/_form.html.haml +58 -0
- data/app/views/c/admin/locations/index.html.haml +9 -0
- data/app/views/c/admin/menu_items/_form.html.haml +44 -0
- data/app/views/c/admin/menu_items/_menu_item_list_item.html.haml +10 -0
- data/app/views/c/admin/menu_items/index.html.haml +10 -0
- data/app/views/c/admin/new.html.haml +8 -0
- data/app/views/c/admin/pages/_form.html.haml +93 -0
- data/app/views/c/admin/pages/_page_list_item.html.haml +10 -0
- data/app/views/c/admin/pages/dashboard.html.erb +0 -0
- data/app/views/c/admin/pages/index.html.haml +11 -0
- data/app/views/c/admin/projects/_form.html.haml +46 -0
- data/app/views/c/admin/projects/index.html.haml +9 -0
- data/app/views/c/admin/quick_edit.js.erb +6 -0
- data/app/views/c/admin/redirects/_form.html.haml +14 -0
- data/app/views/c/admin/redirects/index.html.haml +9 -0
- data/app/views/c/admin/reload_images.js.erb +2 -0
- data/app/views/c/admin/roles/_form.html.haml +42 -0
- data/app/views/c/admin/roles/index.html.haml +17 -0
- data/app/views/c/admin/set_preview_image.js.erb +1 -0
- data/app/views/c/admin/show.html.haml +1 -0
- data/app/views/c/admin/slides/_form.html.haml +19 -0
- data/app/views/c/admin/slideshows/_form.html.haml +25 -0
- data/app/views/c/admin/slideshows/index.html.haml +8 -0
- data/app/views/c/admin/team_members/_form.html.haml +20 -0
- data/app/views/c/admin/team_members/index.html.haml +10 -0
- data/app/views/c/admin/testimonials/_form.html.haml +13 -0
- data/app/views/c/admin/testimonials/index.html.haml +8 -0
- data/app/views/c/admin/users/_form.html.haml +17 -0
- data/app/views/c/admin/users/index.html.haml +12 -0
- data/app/views/c/enquiries_mailer/new_enquiry.html.haml +14 -0
- data/app/views/c/enquiries_mailer/new_enquiry.text.haml +9 -0
- data/app/views/c/errors/404.html.haml +5 -0
- data/app/views/c/errors/500.html.haml +5 -0
- data/app/views/c/front/application/_category_item.html.haml +2 -0
- data/app/views/c/front/application/_menu_item.html.haml +4 -0
- data/app/views/c/front/application/_sales_highlight.html.haml +1 -0
- data/app/views/c/front/application/_slide.html.haml +6 -0
- data/app/views/c/front/blogs/_archive_filter_month.html.haml +2 -0
- data/app/views/c/front/blogs/_archive_filter_year.html.haml +1 -0
- data/app/views/c/front/blogs/_menu_item.html.haml +2 -0
- data/app/views/c/front_end/enquiries/new.html.haml +23 -0
- data/app/views/c/front_end/enquiries/thanks.html.haml +5 -0
- data/app/views/c/front_end/pages/_sales_highlight.html.haml +7 -0
- data/app/views/c/front_end/pages/about.html.haml +8 -0
- data/app/views/c/front_end/pages/home.html.haml +19 -0
- data/app/views/c/front_end/pages/search.html.haml +16 -0
- data/app/views/c/front_end/pages/show.html.haml +7 -0
- data/app/views/c/front_end/pages/sitemap.xml.builder +25 -0
- data/app/views/c/mailchimp/_signup_newsletter.html.haml +4 -0
- data/app/views/c/main_application/_application_bar.html.haml +22 -0
- data/app/views/c/main_application/_breadcrumbs.html.haml +7 -0
- data/app/views/c/main_application/_contact_info.html.haml +5 -0
- data/app/views/c/main_application/_footer.html.haml +49 -0
- data/app/views/c/main_application/_front_head_tags.html.haml +3 -0
- data/app/views/c/main_application/_header.html.haml +55 -0
- data/app/views/c/main_application/_site_search.html.haml +3 -0
- data/app/views/c/main_application/_yield.html.haml +5 -0
- data/app/views/devise/confirmations/new.html.erb +16 -0
- data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/devise/mailer/password_change.html.erb +3 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/devise/passwords/edit.html.haml +26 -0
- data/app/views/devise/passwords/new.html.haml +14 -0
- data/app/views/devise/registrations/edit.html.haml +40 -0
- data/app/views/devise/registrations/new.html.haml +24 -0
- data/app/views/devise/sessions/new.html.haml +20 -0
- data/app/views/devise/shared/_links.html.erb +25 -0
- data/app/views/devise/unlocks/new.html.erb +16 -0
- data/app/views/layouts/c/application.html.haml +18 -0
- data/app/views/layouts/c/cms_login_layout.html.haml +18 -0
- data/app/views/layouts/c/mailer.html.erb +245 -0
- data/app/views/layouts/c/mailer.text.erb +3 -0
- data/app/views/layouts/c/main_application.html.haml +13 -0
- data/config/environment.rb +0 -0
- data/config/initializers/carrierwave.rb +18 -0
- data/config/initializers/devise.rb +283 -0
- data/config/initializers/rack_profiler.rb +8 -0
- data/config/locales/devise.en.yml +62 -0
- data/config/locales/en.yml +17 -0
- data/config/routes.rb +150 -0
- data/db/migrate/20160819000000_migrate_schema.rb +273 -0
- data/db/seed_data/countries.txt +227 -0
- data/lib/c/engine.rb +38 -0
- data/lib/c/version.rb +4 -0
- data/lib/cd2_catton_cms.rb +51 -0
- data/lib/tasks/c_tasks.rake +28 -0
- data/spec/dummy/Gemfile +4 -0
- data/spec/dummy/Gemfile.lock +20 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +5 -0
- data/spec/dummy/app/assets/images/placeholder.png +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +26 -0
- data/spec/dummy/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy/app/assets/javascripts/pages.coffee +3 -0
- data/spec/dummy/app/assets/stylesheets/application.sass +13 -0
- data/spec/dummy/app/assets/stylesheets/c/application.sass +2 -0
- data/spec/dummy/app/controllers/application_controller.rb +10 -0
- data/spec/dummy/app/controllers/blogs_controller.rb +11 -0
- data/spec/dummy/app/controllers/pages_controller.rb +13 -0
- data/spec/dummy/app/models/application_record.rb +4 -0
- data/spec/dummy/app/models/page.rb +3 -0
- data/spec/dummy/bin/bundle +4 -0
- data/spec/dummy/bin/rails +5 -0
- data/spec/dummy/bin/rake +5 -0
- data/spec/dummy/bin/setup +35 -0
- data/spec/dummy/bin/update +30 -0
- data/spec/dummy/config/application.rb +17 -0
- data/spec/dummy/config/boot.rb +6 -0
- data/spec/dummy/config/cable.yml +9 -0
- data/spec/dummy/config/database.travis.yml +3 -0
- data/spec/dummy/config/database.yml +85 -0
- data/spec/dummy/config/environment.rb +6 -0
- data/spec/dummy/config/environments/development.rb +61 -0
- data/spec/dummy/config/environments/production.rb +87 -0
- data/spec/dummy/config/environments/test.rb +43 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +7 -0
- data/spec/dummy/config/initializers/assets.rb +21 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +8 -0
- data/spec/dummy/config/initializers/carrierwave.rb +15 -0
- data/spec/dummy/config/initializers/commercity.rb +4 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +6 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +5 -0
- data/spec/dummy/config/initializers/inflections.rb +17 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/new_framework_defaults.rb +25 -0
- data/spec/dummy/config/initializers/session_store.rb +4 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +15 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/puma.rb +48 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config/sidekiq.yml +6 -0
- data/spec/dummy/config/spring.rb +7 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/db/schema.rb +1110 -0
- data/spec/dummy/lib/tasks/reprocess_images.rake +12 -0
- data/spec/dummy/lib/tasks/reset_all.rake +44 -0
- data/spec/dummy/lib/tasks/seeds/seed_blogs.rake +8 -0
- data/spec/dummy/lib/tasks/seeds/seed_pages.rake +24 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/seed/highlight1.png +0 -0
- data/spec/dummy/seed/highlight2.png +0 -0
- data/spec/dummy/seed/images/1/main.jpg +0 -0
- data/spec/dummy/seed/images/1/thumb.JPG +0 -0
- data/spec/dummy/seed/images/1/thumb2.jpg +0 -0
- data/spec/dummy/seed/images/2/main.jpeg +0 -0
- data/spec/dummy/seed/images/2/thumb.JPG +0 -0
- data/spec/dummy/seed/images/2/thumb2.JPG +0 -0
- data/spec/dummy/spec/models/redirect_spec.rb +57 -0
- data/spec/dummy/spec/support/factory_girl.rb +8 -0
- data/spec/dummy/spec/support/seed/images/product_image.png +0 -0
- data/spec/rails_helper.rb +49 -0
- data/spec/spec_helper.rb +52 -0
- metadata +734 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module C
|
3
|
+
module ApplicationHelper
|
4
|
+
include FontAwesome::Rails::IconHelper
|
5
|
+
ActionView::Base.default_form_builder = CFormBuilder
|
6
|
+
|
7
|
+
def store_page_title(title)
|
8
|
+
title ? "#{title} | #{C.store_name}" : C.store_name
|
9
|
+
end
|
10
|
+
|
11
|
+
def path_exists?(path)
|
12
|
+
begin
|
13
|
+
C::Engine.routes.recognize_path(path)
|
14
|
+
rescue
|
15
|
+
return false
|
16
|
+
end
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
20
|
+
def content_can_tag(tag, action, subject, content, opts={}, &block)
|
21
|
+
return unless can? action, subject
|
22
|
+
if block
|
23
|
+
opts = content || {}
|
24
|
+
content = capture(&block)
|
25
|
+
end
|
26
|
+
content_tag tag, content, opts
|
27
|
+
end
|
28
|
+
|
29
|
+
def index_table(collection, index_data, opts={})
|
30
|
+
content_tag :div, class: 'data_table' do
|
31
|
+
render 'index_table', collection: collection, index_data: index_data, sortable: opts[:sortable], bulk_actions: opts[:bulk_actions]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def tinymce_standard
|
36
|
+
tinymce(height: 200,
|
37
|
+
menubar: false,
|
38
|
+
plugins: ['autolink lists link image media charmap anchor',
|
39
|
+
'insertdatetime media table contextmenu paste code textcolor colorpicker'],
|
40
|
+
toolbar: 'undo redo styleselect bold italic alignleft aligncenter alignright alignjustify bullist numlist link media uploadimage forecolor')
|
41
|
+
end
|
42
|
+
|
43
|
+
def tinymce_light
|
44
|
+
tinymce(height: 200,
|
45
|
+
menubar: false,
|
46
|
+
plugins: ['lists'],
|
47
|
+
toolbar: 'undo redo | bold italic | bullist')
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# TODO: This file has a few rubocop issues but isnt being used - need to clear it up
|
3
|
+
# rubocop:disable all
|
4
|
+
|
5
|
+
module C
|
6
|
+
module BlogsHelper
|
7
|
+
|
8
|
+
def test_method
|
9
|
+
true
|
10
|
+
end
|
11
|
+
|
12
|
+
# Call in the controller to allow usage of blog_archive_menu and blog_archive_month_submenu
|
13
|
+
# Returns the collection of blogs filtered by the params
|
14
|
+
# Optionally accepts a limit for the size of the returned collection
|
15
|
+
def archive_blogs limit = nil
|
16
|
+
@blog_archive_filter_years, @blog_archive_filter_months = [[], []]
|
17
|
+
|
18
|
+
year = params[:year] || Time.now.year
|
19
|
+
if params[:month].to_i > 0 && params[:month].to_i < 13
|
20
|
+
month = params[:month]
|
21
|
+
else
|
22
|
+
month = Time.now.month
|
23
|
+
params[:month] = nil
|
24
|
+
end
|
25
|
+
|
26
|
+
if C::Blog.any?
|
27
|
+
age_limit = C::Blog.order(:created_at).limit(1).first&.created_at.beginning_of_year
|
28
|
+
num_years = Time.now.year - age_limit.year
|
29
|
+
@blog_archive_filter_years = (age_limit.year..(age_limit.year + num_years)).to_a.reverse
|
30
|
+
@blog_archive_filter_years.select! { |y| C::Blog.created_in_year(year: y).any? }
|
31
|
+
if age_limit.year.to_s == params[:year].to_s
|
32
|
+
@blog_archive_filter_months = (1..age_limit.month).to_a
|
33
|
+
else
|
34
|
+
@blog_archive_filter_months = (1..12).to_a
|
35
|
+
end
|
36
|
+
@blog_archive_filter_months.select! { |m| C::Blog.created_in_month(year: year, month: m).any? }
|
37
|
+
if params[:month]
|
38
|
+
return C::Blog.created_in_month(month: month, year: year, limit: limit).ordered
|
39
|
+
else
|
40
|
+
return C::Blog.created_in_year(year: year, limit: limit).ordered
|
41
|
+
end
|
42
|
+
end
|
43
|
+
return nil
|
44
|
+
end
|
45
|
+
|
46
|
+
# Returns html for a ul of links, which set params[:year]
|
47
|
+
# Only months from @blog_archive_filter_years are listed
|
48
|
+
# Also accepts an options hash
|
49
|
+
# The :permitted option expects an array of keys which are permitted to be included in the generated links
|
50
|
+
# The :submenu option expects a boolean, which can be used to disable rendering the month submenu
|
51
|
+
def blog_archive_menu options = {}
|
52
|
+
permitted = options[:permitted] || []
|
53
|
+
submenu = options[:submenu]
|
54
|
+
submenu = true if submenu.nil?
|
55
|
+
|
56
|
+
content_tag :ul do
|
57
|
+
result = ""
|
58
|
+
|
59
|
+
@blog_archive_filter_years.each do |filter_year|
|
60
|
+
if params[:year].to_s == filter_year.to_s
|
61
|
+
if submenu
|
62
|
+
if params[:month]
|
63
|
+
result += content_tag :li, (
|
64
|
+
(render partial: 'c/front/blogs/archive_filter_year', locals: {permitted: permitted, archive_filter_year: filter_year}) +
|
65
|
+
blog_archive_month_submenu(permitted: permitted)
|
66
|
+
)
|
67
|
+
else
|
68
|
+
result += content_tag :li, (
|
69
|
+
raw filter_year.to_s + blog_archive_month_submenu(permitted: permitted)
|
70
|
+
)
|
71
|
+
end
|
72
|
+
else
|
73
|
+
result += content_tag :li, filter_year.to_s
|
74
|
+
end
|
75
|
+
else
|
76
|
+
result += content_tag :li, (render partial: 'c/front/blogs/archive_filter_year', locals: {permitted: permitted, archive_filter_year: filter_year})
|
77
|
+
end
|
78
|
+
end
|
79
|
+
raw result
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# Returns html for a ul of links, which set params[:month]
|
84
|
+
# Only months from @blog_archive_filter_months are listed
|
85
|
+
# Accepts an options hash
|
86
|
+
# The :permitted option expects an array of keys which are permitted to be included in the generated links
|
87
|
+
def blog_archive_month_submenu options = {}
|
88
|
+
permitted = options[:permitted] || []
|
89
|
+
content_tag :ul do
|
90
|
+
# render partial: 'c/front/blogs/archive_filter_month', collection: @blog_archive_filter_months, locals: {permitted: permitted}
|
91
|
+
result = ""
|
92
|
+
@blog_archive_filter_months.each do |filter_month|
|
93
|
+
if params[:month].to_s == filter_month.to_s
|
94
|
+
result += content_tag :li, (Date::MONTHNAMES[filter_month])
|
95
|
+
else
|
96
|
+
result += render partial: 'c/front/blogs/archive_filter_month', locals: {permitted: permitted, archive_filter_month: filter_month}
|
97
|
+
end
|
98
|
+
end
|
99
|
+
raw result
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# Given a hash, permits only :month and :year
|
104
|
+
# Accepts an options hash
|
105
|
+
# The :permitted option expects an array of other keys to permit
|
106
|
+
def safe_params unsafe = {}, options = {}
|
107
|
+
permitted = options[:permitted] || []
|
108
|
+
permitted.push :month, :year
|
109
|
+
params.merge(unsafe).merge(only_path: true, script_name: nil).permit(permitted)
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module C
|
3
|
+
class CFormBuilder < ActionView::Helpers::FormBuilder
|
4
|
+
def error_messages
|
5
|
+
return unless object.respond_to?(:errors) && object.errors.any?
|
6
|
+
|
7
|
+
header = @template.content_tag(:h4, 'Errors prevented the form from saving', class: 'title-error')
|
8
|
+
errors_array = object.errors.full_messages.map { |message| @template.content_tag(:li, message) }
|
9
|
+
errors_list = @template.safe_join([header, @template.safe_join(errors_array)])
|
10
|
+
|
11
|
+
@template.content_tag(:ul, @template.raw(errors_list), class: 'form_errors')
|
12
|
+
end
|
13
|
+
|
14
|
+
def price_field(method, _options={})
|
15
|
+
@template.field_set_tag '', class: 'price_field' do
|
16
|
+
@template.content_tag(:span, method.to_s.titleize.to_s, class: 'fieldset-title') +
|
17
|
+
fields_for(method) do |builder|
|
18
|
+
@template.content_tag(:div, class: 'gs') do
|
19
|
+
@template.content_tag(:div, class: 'field field--inner-label g-1') { builder.label(:without_tax) + builder.number_field(:without_tax, step: 0.01, min: 0) } +
|
20
|
+
@template.content_tag(:div, class: 'field field--inner-label g-1 g-gutter--narrow') { builder.label(:with_tax) + builder.number_field(:with_tax, step: 0.01, min: 0) } +
|
21
|
+
@template.content_tag(:div, class: 'field field--inner-label g-1 g-gutter--narrow') { builder.label(:tax_rate) + builder.number_field(:tax_rate, step: 0.01, min: 0) }
|
22
|
+
end +
|
23
|
+
builder.label(:override) { builder.check_box(:override) + @template.content_tag(:span, 'Override tax rate', class: 'checkbox-span-label') }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def image_field(method, options = {})
|
29
|
+
@template.field_set_tag '', class: 'image_field' do
|
30
|
+
@template.content_tag(:span, method.to_s.titleize, class: 'fieldset-title') +
|
31
|
+
hidden_field("#{method}_cache") +
|
32
|
+
(@template.image_tag(@object.send(method)) || '') +
|
33
|
+
file_field(method, options)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def tiny_mce_text_area(method, tinymce_config='standard')
|
38
|
+
text_area(method, class: 'tinymce') +
|
39
|
+
@template.send("tinymce_#{tinymce_config}")
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module C
|
3
|
+
module LinkToHelper
|
4
|
+
def link_to_delete(text, resource, opts={})
|
5
|
+
nested = [opts.delete(:nested) { [] }].flatten
|
6
|
+
|
7
|
+
opts[:data] ||= {}
|
8
|
+
|
9
|
+
url = opts.delete(:url) { nil }
|
10
|
+
redirection = opts.delete(:redirection) { nil }
|
11
|
+
opts[:data].merge!(delete_link: url || url_for([*nested, resource]),
|
12
|
+
after_delete_redirection: redirection)
|
13
|
+
link_to text, [:confirm_destroy, *nested, resource], opts
|
14
|
+
end
|
15
|
+
|
16
|
+
def link_to_add_fields(name, f, assoc, opts={})
|
17
|
+
new_object = f.object.send(assoc).build
|
18
|
+
id = new_object.object_id
|
19
|
+
fields = f.fields_for(assoc, new_object, child_index: id) do |builder|
|
20
|
+
render assoc.to_s.singularize + '_fields', f: builder
|
21
|
+
end
|
22
|
+
link_to name, '#', data: { fields: fields.gsub('\n', ''), fields_id: id }.merge(opts)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module C
|
3
|
+
module NavigationHelper
|
4
|
+
def ensure_navigation
|
5
|
+
@navigation ||= [{ title: 'Home', url: '/' }]
|
6
|
+
end
|
7
|
+
|
8
|
+
def navigation_add(title, url)
|
9
|
+
ensure_navigation << { title: title, url: url }
|
10
|
+
end
|
11
|
+
|
12
|
+
def render_navigation(partial = nil)
|
13
|
+
render partial: partial || 'c/admin/bread_crumbs', locals: { nav: ensure_navigation }
|
14
|
+
rescue
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def parent_navigation_add(nav)
|
19
|
+
@tree_navigation ||= []
|
20
|
+
@tree_navigation << { title: nav.name, url: nav }
|
21
|
+
if nav.parent
|
22
|
+
parent_navigation_add nav.parent
|
23
|
+
else
|
24
|
+
@tree_navigation.reverse.map { |node| ensure_navigation << node }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module C
|
3
|
+
module PagesHelper
|
4
|
+
def get_page(model, url=params[:id])
|
5
|
+
@page = if !url.present? || (url =~ /[^0-9]/)
|
6
|
+
model.get_from_url(url)
|
7
|
+
else
|
8
|
+
# This is accommodating a use-case that *will* result in problems, given enough products
|
9
|
+
model.find_by(id: url) || model.get_from_url(url)
|
10
|
+
end
|
11
|
+
begin
|
12
|
+
@page_info = @page.page_info
|
13
|
+
rescue NoMethodError
|
14
|
+
raise ActiveRecord::RecordNotFound
|
15
|
+
end
|
16
|
+
if @page.respond_to?('layout') && !@page.layout.blank? && @page.layout != 'show'
|
17
|
+
@render = @page.layout
|
18
|
+
else
|
19
|
+
@page
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def force_clean_url(object)
|
24
|
+
redirect_to [:front_end, object] if object.url_alias && params[:id] != object.url_alias
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module C
|
3
|
+
module StorefrontHelper
|
4
|
+
def menu(menu_item_name, depth=1)
|
5
|
+
return unless (menu_item = C::MenuItem.find_by(machine_name: menu_item_name))
|
6
|
+
return unless menu_item.children.any?
|
7
|
+
content_tag :ul do
|
8
|
+
render partial: 'c/front/application/menu_item', collection: menu_item.children.includes(:page), cached: true, locals: { depth: depth }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def menu_items_for(menu_item_name, depth=1)
|
13
|
+
return unless (menu_item = C::MenuItem.find_by(machine_name: menu_item_name))
|
14
|
+
return unless menu_item.children.any?
|
15
|
+
render partial: 'c/front/application/menu_item', collection: menu_item.children.includes(:page), cached: true, locals: { depth: depth }
|
16
|
+
end
|
17
|
+
|
18
|
+
def category_root_menu
|
19
|
+
content_tag :ul do
|
20
|
+
render partial: 'c/front/application/category_item', collection: C::Category.find_all_by_generation(0)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def meta_tags
|
25
|
+
safe_join([page_title, meta_description]) if @page_info
|
26
|
+
end
|
27
|
+
|
28
|
+
def page_title
|
29
|
+
if @page_info.title.blank?
|
30
|
+
if @page_info.fallback_title.blank?
|
31
|
+
content_tag(:title, C.store_name)
|
32
|
+
else
|
33
|
+
content_tag(:title, @page_info.fallback_title)
|
34
|
+
end
|
35
|
+
else
|
36
|
+
content_tag(:title, @page_info.title)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def meta_description
|
41
|
+
return unless @page_info&.meta_description&.present?
|
42
|
+
tag :meta, name: :description, content: @page_info.meta_description
|
43
|
+
end
|
44
|
+
|
45
|
+
def slideshow(slideshow_name, klass=nil)
|
46
|
+
return 'No slideshow found' unless (slide_show = C::Slideshow.find_by(machine_name: slideshow_name))
|
47
|
+
content_tag :div, class: :slideshow do
|
48
|
+
content_tag :ul do
|
49
|
+
render partial: 'c/front/application/slide', collection: slide_show.slides.ordered, cached: true, locals: { klass: klass }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def sales_highlights(page)
|
55
|
+
case page
|
56
|
+
when :home
|
57
|
+
render partial: 'c/front/application/sales_highlight', collection: C::SalesHighlight.first(4), cached: true
|
58
|
+
when :store
|
59
|
+
render partial: 'c/front/application/sales_highlight', collection: C::SalesHighlight.first(3), cached: true
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module C
|
3
|
+
class Ability
|
4
|
+
include CanCan::Ability
|
5
|
+
|
6
|
+
def initialize(user)
|
7
|
+
user ||= C::User.new
|
8
|
+
can :manage, :all if user
|
9
|
+
|
10
|
+
user.permissions.each do |permission|
|
11
|
+
opts = {}
|
12
|
+
opts[:id] = permission.subject_id if permission.subject_id
|
13
|
+
|
14
|
+
can [:read], permission.subject, opts if permission.read?
|
15
|
+
can [:new, :create], permission.subject, opts if permission.new?
|
16
|
+
can [:edit, :update], permission.subject, opts if permission.edit?
|
17
|
+
can [:destroy, :confirm_destroy], permission.subject, opts if permission.remove?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module C
|
3
|
+
class Blog < ApplicationRecord
|
4
|
+
include SitePage
|
5
|
+
include Imageable
|
6
|
+
include Previewable
|
7
|
+
include Authorable
|
8
|
+
|
9
|
+
scope :ordered, -> { order created_at: :desc }
|
10
|
+
|
11
|
+
validates :name, presence: true
|
12
|
+
|
13
|
+
def self.created_in_date_range(start_date, end_date, options = {})
|
14
|
+
limit = options.delete(:limit)
|
15
|
+
Blog.where(created_at: start_date...end_date).limit(limit)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.created_in_month(options = {})
|
19
|
+
year = options[:year] || Time.now.year
|
20
|
+
month = options[:month] || Time.now.month
|
21
|
+
limit = options[:limit]
|
22
|
+
date_start = Time.new(year, month, 1, 0, 0, 0)
|
23
|
+
date_end = date_start.advance(months: 1)
|
24
|
+
created_in_date_range(date_start, date_end, limit: limit)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.created_in_year(options = {})
|
28
|
+
year = options[:year] || Time.now.year
|
29
|
+
limit = options[:limit]
|
30
|
+
date_start = Time.new(year, 1, 1, 0, 0, 0)
|
31
|
+
date_end = date_start.advance(years: 1)
|
32
|
+
created_in_date_range(date_start, date_end, limit: limit)
|
33
|
+
end
|
34
|
+
|
35
|
+
INDEX_TABLE = {
|
36
|
+
"Name": { link: { name: { call: 'name' }, options: '[:edit, object]' }, sort: 'name' },
|
37
|
+
"Author": { call: 'author', sort: 'author' },
|
38
|
+
"Published": { call: 'published', sort: 'published' },
|
39
|
+
"Created": { call: 'created_at', sort: 'published' },
|
40
|
+
"Edit": { link: { name: { text: 'edit' }, options: '[:edit, object]' } }
|
41
|
+
}.freeze
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module C
|
3
|
+
class Document < ApplicationRecord
|
4
|
+
mount_uploader :document, C::FileUploader
|
5
|
+
validates :document, presence: true
|
6
|
+
belongs_to :documentable, polymorphic: true
|
7
|
+
|
8
|
+
INDEX_TABLE = {
|
9
|
+
"Name": { call: 'name' },
|
10
|
+
"File": { call: 'document.url' },
|
11
|
+
"Created": { call: 'created_at' },
|
12
|
+
"Delete": { link: { name: { text: 'Delete' }, options: '[object]', method: :delete, data: { confirm: 'Are you sure?' } } }
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
# TODO: Add edit to this, name should link to edit page
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module C
|
3
|
+
class Enquiry < ApplicationRecord
|
4
|
+
enum job_type: [
|
5
|
+
'Supply Only',
|
6
|
+
'Supply and Fit',
|
7
|
+
]
|
8
|
+
|
9
|
+
enum response_type: [
|
10
|
+
'Callback',
|
11
|
+
'Quote'
|
12
|
+
]
|
13
|
+
|
14
|
+
enum timber_type: [
|
15
|
+
'Hardwood',
|
16
|
+
'European Oak',
|
17
|
+
'Accoya',
|
18
|
+
'Other',
|
19
|
+
]
|
20
|
+
|
21
|
+
enum frame: [
|
22
|
+
'Braemar',
|
23
|
+
'Buttermilk',
|
24
|
+
'Dove Grey',
|
25
|
+
'Forest Green',
|
26
|
+
'Garsenia',
|
27
|
+
'Oxford Blue',
|
28
|
+
'Poppy Red',
|
29
|
+
'RAL7034',
|
30
|
+
'Techno White',
|
31
|
+
'Dark Oak',
|
32
|
+
'Mahogany',
|
33
|
+
'Rosewood',
|
34
|
+
'Sikkins Teak',
|
35
|
+
'African Walnut',
|
36
|
+
'Antique Pine',
|
37
|
+
'Ebony',
|
38
|
+
'Jacobean Walnut',
|
39
|
+
'Red Wood',
|
40
|
+
'Saddolins Teak'
|
41
|
+
]
|
42
|
+
|
43
|
+
enum handle: [
|
44
|
+
'Chrome',
|
45
|
+
'Black',
|
46
|
+
'Gold',
|
47
|
+
'Satin',
|
48
|
+
'White',
|
49
|
+
'Monkey Tail'
|
50
|
+
]
|
51
|
+
|
52
|
+
mount_uploader :file, C::FileUploader
|
53
|
+
|
54
|
+
validates :phone, presence: true
|
55
|
+
validates :response_type, presence: true
|
56
|
+
|
57
|
+
validates :name, presence: true
|
58
|
+
|
59
|
+
scope :ordered, -> { order created_at: :desc }
|
60
|
+
|
61
|
+
def get_jobs_selected
|
62
|
+
this = []
|
63
|
+
this << 'Windows' if job_windows
|
64
|
+
this << 'Doors' if job_doors
|
65
|
+
this << 'Bi-Fold Doors' if job_bi
|
66
|
+
this << 'Conservatory' if job_conservatory
|
67
|
+
this << 'Lantern Tops' if job_lantern
|
68
|
+
this << 'Garden Rooms' if job_garden
|
69
|
+
this << 'Orangery' if job_orangery
|
70
|
+
this << "Other: #{job_string}" if job_other
|
71
|
+
return this.join(', ')
|
72
|
+
end
|
73
|
+
|
74
|
+
def get_timber_selected
|
75
|
+
if timber_type == 'Other'
|
76
|
+
return 'Other: ' + timber_string
|
77
|
+
else
|
78
|
+
return timber_type
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
|
83
|
+
validates :email,
|
84
|
+
presence: true,
|
85
|
+
length: { maximum: 255 },
|
86
|
+
format: { with: VALID_EMAIL_REGEX }
|
87
|
+
|
88
|
+
INDEX_TABLE = {
|
89
|
+
"Name": { call: 'name', sort: 'name' },
|
90
|
+
"Email": { call: 'email', sort: 'email' },
|
91
|
+
"Message": { call: 'body' },
|
92
|
+
"Date": { call: 'created_at', sort: 'created_at' }
|
93
|
+
}.freeze
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module C
|
3
|
+
class Location < ApplicationRecord
|
4
|
+
include SitePage
|
5
|
+
include Imageable
|
6
|
+
include Previewable
|
7
|
+
include Orderable
|
8
|
+
|
9
|
+
validates :name, presence: true
|
10
|
+
|
11
|
+
INDEX_TABLE = {
|
12
|
+
"Name": { link: { name: { call: 'name' }, options: '[:edit, object]' }, sort: 'name' },
|
13
|
+
"Published": { call: 'published', sort: 'published' },
|
14
|
+
"Created": { call: 'created_at', sort: 'published' },
|
15
|
+
"Edit": { link: { name: { text: 'edit' }, options: '[:edit, object]' } }
|
16
|
+
}.freeze
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module C
|
3
|
+
class MenuItem < ApplicationRecord
|
4
|
+
has_closure_tree order: 'weight'
|
5
|
+
|
6
|
+
validates :machine_name, presence: true
|
7
|
+
validates :name, presence: true
|
8
|
+
|
9
|
+
belongs_to :page
|
10
|
+
|
11
|
+
before_validation on: :create do
|
12
|
+
self.machine_name = name
|
13
|
+
end
|
14
|
+
|
15
|
+
belongs_to :page
|
16
|
+
|
17
|
+
def self.depth_select_options(item)
|
18
|
+
opts = []
|
19
|
+
save_pair = proc do |level, i|
|
20
|
+
level.each do |key, value|
|
21
|
+
next if key.id == item.id
|
22
|
+
opts.append(["#{'-' * i}#{key.name}", key.id])
|
23
|
+
save_pair.call(value, i + 1) if value.class <= Hash
|
24
|
+
end
|
25
|
+
end
|
26
|
+
save_pair.call(hash_tree, 0)
|
27
|
+
opts
|
28
|
+
end
|
29
|
+
|
30
|
+
# Force non blank parametized machine name
|
31
|
+
def machine_name=(val)
|
32
|
+
super val.to_s.parameterize
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|