pwb 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +40 -25
- data/app/assets/fonts/fonts/FontAwesome.otf +0 -0
- data/app/assets/fonts/fonts/fontawesome-webfont.eot +0 -0
- data/app/assets/fonts/fonts/fontawesome-webfont.svg +2668 -637
- data/app/assets/fonts/fonts/fontawesome-webfont.ttf +0 -0
- data/app/assets/fonts/fonts/fontawesome-webfont.woff +0 -0
- data/app/assets/fonts/fonts/fontawesome-webfont.woff2 +0 -0
- data/app/assets/javascripts/pwb/shared/page-content.js +24 -0
- data/app/assets/javascripts/pwb/shared/squares-container.js +58 -0
- data/app/assets/javascripts/pwb/shared/vue-main.js +1 -1
- data/app/assets/javascripts/pwb/shared/vue-squares.js.erb +74 -0
- data/app/assets/javascripts/pwb/squares/tabable-section.js +47 -0
- data/app/assets/javascripts/pwb/themes/squares.js.erb +45 -0
- data/app/assets/javascripts/pwb/themes/vic.js.erb +152 -0
- data/app/assets/javascripts/pwb_admin_panel/application_legacy_1.js +5 -0
- data/app/assets/stylesheets/pwb/themes/berlin.scss +4 -0
- data/app/assets/stylesheets/pwb/themes/berlin/main.scss +1 -1
- data/app/assets/stylesheets/pwb/themes/default.scss +1 -0
- data/app/assets/stylesheets/pwb/themes/default/carousel.scss +2 -1
- data/app/assets/stylesheets/pwb/themes/default/landing_content_areas.scss +13 -13
- data/app/assets/stylesheets/pwb/themes/default/shame.scss +0 -16
- data/app/assets/stylesheets/pwb/themes/matt.scss +18 -0
- data/app/assets/stylesheets/pwb/themes/shared/liquid_templates.scss +37 -0
- data/app/assets/stylesheets/pwb/themes/shared/shame.scss +7 -0
- data/app/assets/stylesheets/pwb/themes/squares.scss +22 -0
- data/app/assets/stylesheets/pwb/themes/squares/vue-material-docs.scss +200 -0
- data/app/assets/stylesheets/pwb/themes/squares/vue-material-vars.scss +141 -0
- data/app/assets/stylesheets/pwb/themes/vic.scss +104 -0
- data/app/assets/stylesheets/pwb/themes/vic/general.scss +15 -0
- data/app/assets/stylesheets/pwb/themes/vic/landing.scss +189 -0
- data/app/assets/stylesheets/pwb/themes/vic/slider.scss +127 -0
- data/app/assets/stylesheets/pwb_admin_panel/application_legacy_1.scss +6 -0
- data/app/controllers/pwb/admin_panel_controller.rb +7 -1
- data/app/controllers/pwb/api/v1/clients_controller.rb +35 -0
- data/app/controllers/pwb/api/v1/contacts_controller.rb +41 -0
- data/app/controllers/pwb/api/v1/links_controller.rb +47 -0
- data/app/controllers/pwb/api/v1/page_controller.rb +117 -0
- data/app/controllers/pwb/api/v1/page_fragments_controller.rb +74 -0
- data/app/controllers/pwb/api/v1/properties_controller.rb +30 -9
- data/app/controllers/pwb/api/v1/sections_controller.rb +27 -26
- data/app/controllers/pwb/api/v1/website_controller.rb +11 -11
- data/app/controllers/pwb/application_controller.rb +22 -11
- data/app/controllers/pwb/{sections_controller.rb → contact_us_controller.rb} +24 -45
- data/app/controllers/pwb/css_controller.rb +5 -2
- data/app/controllers/pwb/pages_controller.rb +36 -0
- data/app/controllers/pwb/search_controller.rb +33 -11
- data/app/controllers/pwb/squares_controller.rb +48 -0
- data/app/controllers/pwb/welcome_controller.rb +30 -5
- data/app/helpers/pwb/application_helper.rb +50 -49
- data/app/helpers/pwb/css_helper.rb +14 -0
- data/app/helpers/pwb/navigation_helper.rb +82 -0
- data/app/models/pwb/contact.rb +25 -0
- data/app/models/pwb/content.rb +26 -8
- data/app/models/pwb/content_photo.rb +18 -0
- data/app/models/pwb/link.rb +41 -0
- data/app/models/pwb/message.rb +1 -1
- data/app/models/pwb/page.rb +227 -0
- data/app/models/pwb/page_content.rb +33 -0
- data/app/models/pwb/page_part.rb +17 -0
- data/app/models/pwb/preset_style.rb +37 -0
- data/app/models/pwb/prop.rb +4 -0
- data/app/models/pwb/website.rb +64 -9
- data/app/resources/pwb/api/v1/{section_resource.rb → client_resource.rb} +3 -4
- data/app/resources/pwb/api/v1/property_resource.rb +23 -4
- data/app/resources/pwb/api/v1/web_content_resource.rb +1 -1
- data/app/resources/pwb/api_public/v1/prop_resource.rb +9 -2
- data/{db/cms_fixtures/cms/layouts/about-us/content.html → app/themes/airbnb/views/layouts/pwb/_generic_modal.html.erb} +0 -0
- data/{db/cms_fixtures/cms/layouts/about-us/javascript.js → app/themes/airbnb/views/layouts/pwb/_login_modal.html.erb} +0 -0
- data/app/themes/airbnb/views/layouts/pwb/application.html.erb +82 -0
- data/app/themes/airbnb/views/pwb/_footer.html.erb +25 -0
- data/app/themes/airbnb/views/pwb/props/_images_section_carousel.html.erb +43 -0
- data/app/themes/airbnb/views/pwb/props/show.html.erb +69 -0
- data/app/themes/airbnb/views/pwb/search/_search_form_for_rent.html.erb +183 -0
- data/app/themes/airbnb/views/pwb/search/_search_results.html.erb +34 -0
- data/app/themes/airbnb/views/pwb/search/buy.html.erb +65 -0
- data/app/themes/airbnb/views/pwb/search/rent.html.erb +87 -0
- data/app/themes/airbnb/views/pwb/sections/_contact_us_form.html.erb +49 -0
- data/app/themes/airbnb/views/pwb/sections/contact_us.html.erb +56 -0
- data/app/themes/airbnb/views/pwb/welcome/_content_area_cols.html.erb +12 -0
- data/app/themes/airbnb/views/pwb/welcome/_single_property_row.html.erb +51 -0
- data/app/themes/airbnb/views/pwb/welcome/index.html.erb +66 -0
- data/app/themes/berlin/views/pwb/_footer.html.erb +15 -20
- data/app/themes/berlin/views/pwb/_header.html.erb +7 -9
- data/app/themes/berlin/views/pwb/pages/show.html.erb +50 -0
- data/app/themes/berlin/views/pwb/search/buy.html.erb +1 -1
- data/app/themes/berlin/views/pwb/search/rent.html.erb +1 -2
- data/app/themes/berlin/views/pwb/sections/contact_us.html.erb +1 -1
- data/app/themes/berlin/views/pwb/welcome/index.html.erb +51 -7
- data/app/themes/config.json +14 -0
- data/app/themes/default/views/pwb/{sections/cms.html.erb → pages/show.html.erb} +9 -8
- data/app/themes/default/views/pwb/search/buy.html.erb +1 -1
- data/app/themes/default/views/pwb/search/rent.html.erb +1 -1
- data/app/themes/default/views/pwb/sections/about_us.html.erb +8 -7
- data/app/themes/default/views/pwb/sections/contact_us.html.erb +40 -30
- data/app/themes/default/views/pwb/sections/static.html.erb +3 -20
- data/app/themes/default/views/pwb/welcome/_single_property_row.html.erb +1 -1
- data/app/themes/default/views/pwb/welcome/index.html.erb +7 -38
- data/app/themes/matt/views/layouts/pwb/application.html.erb +45 -0
- data/app/themes/matt/views/pwb/_footer.html.erb +60 -0
- data/app/themes/matt/views/pwb/_header.html.erb +105 -0
- data/app/themes/matt/views/pwb/search/buy.html.erb +65 -0
- data/app/themes/matt/views/pwb/welcome/index.html.erb +132 -0
- data/app/themes/vic/views/layouts/pwb/application.html.erb +94 -0
- data/app/themes/vic/views/pwb/_header.html.erb +100 -0
- data/app/themes/vic/views/pwb/props/_images_section_carousel.html.erb +43 -0
- data/app/themes/vic/views/pwb/props/show.html.erb +69 -0
- data/app/themes/vic/views/pwb/search/buy.html.erb +65 -0
- data/app/themes/vic/views/pwb/search/rent.html.erb +65 -0
- data/app/themes/vic/views/pwb/sections/_contact_us_form.html.erb +49 -0
- data/app/themes/vic/views/pwb/sections/contact_us.html.erb +56 -0
- data/app/themes/vic/views/pwb/welcome/_content_area_cols.html.erb +12 -0
- data/app/themes/vic/views/pwb/welcome/_single_property_row.html.erb +51 -0
- data/app/themes/vic/views/pwb/welcome/index.html.erb +27 -0
- data/app/views/devise/shared/_links.html.erb +1 -1
- data/app/views/layouts/pwb/admin_panel_error.html.erb +19 -0
- data/app/views/layouts/pwb/admin_panel_legacy_1.html.erb +21 -0
- data/app/views/layouts/pwb/squares.html.erb +72 -0
- data/app/views/pwb/_footer.html.erb +2 -6
- data/app/views/pwb/_header.html.erb +23 -25
- data/app/views/pwb/admin_panel/show_legacy_1.html.erb +3 -0
- data/app/views/pwb/custom_css/_berlin.css.erb +0 -67
- data/app/views/pwb/custom_css/_default.css.erb +0 -22
- data/app/views/pwb/custom_css/_shared.css.erb +4 -3
- data/app/views/pwb/custom_css/_vic.css.erb +10 -0
- data/app/views/pwb/props/_images_section_carousel.html.erb +1 -1
- data/app/views/pwb/search/_search_result_item.html.erb +1 -1
- data/app/views/pwb/squares/show_client.html.erb +26 -0
- data/app/views/pwb/squares/show_prop.html.erb +26 -0
- data/app/views/pwb/squares/vue.html.erb +1 -0
- data/config/client_setups/default.json +28 -27
- data/config/initializers/i18n_globalise.rb +4 -0
- data/config/locales/admin.en.yml +38 -7
- data/config/locales/admin.es.yml +60 -6
- data/config/locales/admin.pt.yml +474 -0
- data/config/locales/admin.ru.yml +49 -6
- data/config/locales/devise.it.yml +137 -0
- data/config/locales/en.yml +7 -7
- data/config/locales/it.yml +160 -0
- data/config/locales/pt.yml +2 -0
- data/config/locales/rails.it.yml +213 -0
- data/config/locales/tr.yml +36 -36
- data/config/locales/vi.yml +5 -5
- data/config/preset_styles/green_amber.json +23 -0
- data/config/preset_styles/purple_teal.json +23 -0
- data/config/preset_styles/red_light.json +18 -0
- data/config/routes.rb +35 -23
- data/db/example_images/carousel_villa_with_pool.jpg +0 -0
- data/db/example_images/flat_luxury_dining_area.jpg +0 -0
- data/db/example_images/flat_luxury_living_area.jpg +0 -0
- data/db/migrate/20161120103546_create_pwb_props.rb +3 -3
- data/db/migrate/20161122174847_create_pwb_sections.rb +9 -8
- data/db/migrate/20161128221919_create_pwb_clients.rb +1 -0
- data/db/migrate/20170315195413_add_extra_cols_to_pwb_sections.rb +7 -6
- data/db/migrate/20170716075456_create_pwb_pages.rb +23 -0
- data/db/migrate/20170716110121_translate_pages.rb +17 -0
- data/db/migrate/20170720183443_create_pwb_links.rb +29 -0
- data/db/migrate/20170720201601_translate_links.rb +13 -0
- data/db/migrate/20170915094326_create_pwb_page_contents.rb +17 -0
- data/db/migrate/20170917215533_add_page_part_key_to_pwb_contents.rb +7 -0
- data/db/migrate/20170919134945_add_block_key_to_pwb_content_photos.rb +5 -0
- data/db/migrate/20170923195321_create_pwb_contacts.rb +33 -0
- data/db/migrate/20171011212930_create_pwb_page_parts.rb +30 -0
- data/db/seeds/translations_es.rb +1 -87
- data/db/seeds/translations_it.rb +92 -0
- data/db/yml_seeds/agency_address.yml +8 -8
- data/db/yml_seeds/contacts.yml +13 -0
- data/db/yml_seeds/content_translations/en.yml +73 -0
- data/db/yml_seeds/content_translations/es.yml +74 -0
- data/db/yml_seeds/content_translations/it.yml +73 -0
- data/db/yml_seeds/content_translations/pt.yml +73 -0
- data/db/yml_seeds/{content/footer.yml → footer.yml} +0 -0
- data/db/yml_seeds/links.yml +389 -0
- data/db/yml_seeds/page_parts/ABOUT_PAGE_PARTS.md +5 -0
- data/db/yml_seeds/page_parts/about-us__content_html.yml +24 -0
- data/db/yml_seeds/page_parts/about-us__our_agency.yml +51 -0
- data/db/yml_seeds/page_parts/contact-us__content_html.yml +24 -0
- data/db/yml_seeds/page_parts/contact-us__form_and_map.yml +17 -0
- data/db/yml_seeds/page_parts/home__about_us_services.yml +85 -0
- data/db/yml_seeds/page_parts/home__content_html.yml +24 -0
- data/db/yml_seeds/page_parts/home__landing_hero.yml +51 -0
- data/db/yml_seeds/page_parts/legal__content_html.yml +24 -0
- data/db/yml_seeds/page_parts/privacy__content_html.yml +24 -0
- data/db/yml_seeds/page_parts/sell__content_html.yml +24 -0
- data/db/yml_seeds/pages/about.yml +11 -0
- data/db/yml_seeds/pages/buy.yml +23 -0
- data/db/yml_seeds/pages/contact.yml +12 -0
- data/db/yml_seeds/pages/home.yml +15 -0
- data/db/yml_seeds/pages/legal_notice.yml +11 -0
- data/db/yml_seeds/pages/privacy_policy.yml +11 -0
- data/db/yml_seeds/pages/rent.yml +15 -0
- data/db/yml_seeds/pages/sell.yml +13 -0
- data/db/yml_seeds/prop/flat_for_rent.yml +11 -11
- data/db/yml_seeds/prop/flat_for_rent_2.yml +57 -0
- data/db/yml_seeds/prop/flat_for_sale.yml +11 -12
- data/db/yml_seeds/prop/flat_for_sale_2.yml +56 -0
- data/db/yml_seeds/prop/villa_for_rent.yml +14 -14
- data/db/yml_seeds/prop/villa_for_sale.yml +15 -15
- data/db/yml_seeds/prop_spain/flat_for_rent.yml +58 -0
- data/db/yml_seeds/prop_spain/flat_for_sale.yml +58 -0
- data/db/yml_seeds/prop_spain/villa_for_rent.yml +58 -0
- data/db/yml_seeds/prop_spain/villa_for_sale.yml +59 -0
- data/db/yml_seeds/sections.yml +119 -119
- data/db/yml_seeds/{content → to_delete}/about_us.yml +0 -0
- data/db/yml_seeds/{content → to_delete}/carousel.yml +0 -0
- data/db/yml_seeds/{content → to_delete}/content_columns.yml +0 -0
- data/db/yml_seeds/to_delete/footer.yml +15 -0
- data/db/yml_seeds/{content → to_delete}/sell.yml +0 -0
- data/db/yml_seeds/{content → to_delete}/static.yml +0 -0
- data/db/yml_seeds/website.yml +2 -1
- data/lib/pwb/engine.rb +16 -2
- data/lib/pwb/pages_seeder.rb +190 -0
- data/lib/pwb/seeder.rb +56 -14
- data/lib/pwb/version.rb +1 -1
- data/lib/tasks/pwb_tasks.rake +19 -2
- data/spec/controllers/pwb/api/v1/propeties_controller_spec.rb +2 -2
- data/spec/controllers/pwb/welcome_controller_spec.rb +18 -5
- data/spec/dummy/config/initializers/assets.rb +9 -0
- data/spec/dummy/config/routes.rb +2 -0
- data/spec/dummy/config/secrets.yml +3 -0
- data/spec/dummy/db/migrate/20171201161323_create_property_web_scraper_import_hosts.property_web_scraper.rb +22 -0
- data/spec/dummy/db/migrate/20171201161324_create_property_web_scraper_listings.property_web_scraper.rb +84 -0
- data/spec/dummy/db/schema.rb +475 -398
- data/spec/factories/pwb_contacts.rb +5 -0
- data/spec/factories/pwb_contents.rb +3 -0
- data/spec/factories/pwb_links.rb +5 -0
- data/spec/factories/pwb_page_contents.rb +5 -0
- data/spec/factories/pwb_page_parts.rb +8 -0
- data/spec/factories/pwb_pages.rb +29 -0
- data/spec/factories/pwb_prop_photos.rb +11 -2
- data/spec/fixtures/mls/properties_interealty.json +1 -496
- data/spec/fixtures/params/bulk_create.json +3 -3
- data/spec/libraries/pwb/pages_seeder_spec.rb +56 -0
- data/spec/libraries/pwb/seeder_spec.rb +14 -10
- data/spec/models/pwb/contact_spec.rb +7 -0
- data/spec/models/pwb/link_spec.rb +7 -0
- data/spec/models/pwb/page_content_spec.rb +7 -0
- data/spec/models/pwb/page_part_spec.rb +7 -0
- data/spec/models/pwb/page_spec.rb +28 -0
- data/spec/models/pwb/website_spec.rb +10 -0
- data/spec/rails_helper.rb +1 -1
- data/spec/requests/pwb/themes_spec.rb +15 -10
- data/spec/views/pwb/application_layout.html.erb_spec.rb +28 -21
- data/spec/views/pwb/contact_us.html.erb_spec.rb +11 -0
- data/spec/views/pwb/welcome.html.erb_spec.rb +13 -9
- metadata +230 -244
- data/app/controllers/pwb/api/v1/cms_pages_controller.rb +0 -102
- data/app/controllers/pwb/comfy_controller.rb +0 -106
- data/app/models/pwb/cms_page_container.rb +0 -9
- data/app/models/pwb/section.rb +0 -35
- data/app/models/pwb/welcome.rb +0 -4
- data/app/resources/pwb/api/v1/cms_block_resource.rb +0 -11
- data/app/resources/pwb/api/v1/cms_page_resource.rb +0 -27
- data/app/themes/berlin/views/pwb/sections/about_us.html.erb +0 -59
- data/app/themes/berlin/views/pwb/sections/cms.html.erb +0 -34
- data/app/themes/berlin/views/pwb/sections/static.html.erb +0 -58
- data/app/views/pwb/search/_search_result_item_to_del.html.erb +0 -56
- data/config/cms_page_containers/about-us.json +0 -18
- data/config/cms_page_containers/about.json +0 -107
- data/config/cms_page_containers/landing.json +0 -19
- data/config/cms_page_containers/legal.json +0 -17
- data/config/cms_page_containers/sell.json +0 -96
- data/config/initializers/comfortable_mexican_sofa.rb +0 -142
- data/config/initializers/i18n.rb +0 -1
- data/db/cms_fixtures/cms/categories/pages.yml +0 -3
- data/db/cms_fixtures/cms/files/_rerenting-landing_framed.png.yml +0 -6
- data/db/cms_fixtures/cms/files/rerenting-landing_framed.png +0 -0
- data/db/cms_fixtures/cms/layouts/about-us/attributes.yml +0 -4
- data/db/cms_fixtures/cms/layouts/about-us/people/attributes.yml +0 -4
- data/db/cms_fixtures/cms/layouts/about-us/people/content.html +0 -55
- data/db/cms_fixtures/cms/layouts/about-us/services/attributes.yml +0 -4
- data/db/cms_fixtures/cms/layouts/about-us/services/content.html +0 -32
- data/db/cms_fixtures/cms/layouts/about-us/services/javascript.js +0 -0
- data/db/cms_fixtures/cms/layouts/about-us/services/stylesheet.css +0 -0
- data/db/cms_fixtures/cms/layouts/about-us/stylesheet.css +0 -0
- data/db/cms_fixtures/cms/layouts/default-layout/attributes.yml +0 -4
- data/db/cms_fixtures/cms/layouts/default-layout/content.html +0 -51
- data/db/cms_fixtures/cms/layouts/default-layout/javascript.js +0 -0
- data/db/cms_fixtures/cms/layouts/default-layout/stylesheet.css +0 -0
- data/db/cms_fixtures/cms/pages/index/about-us/attributes.yml +0 -8
- data/db/cms_fixtures/cms/pages/index/about-us/people/attributes.yml +0 -8
- data/db/cms_fixtures/cms/pages/index/about-us/people/de/attributes.yml +0 -8
- data/db/cms_fixtures/cms/pages/index/about-us/people/de/person_details_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/de/person_details_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/de/person_details_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/de/person_details_d.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/de/person_img_url_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/de/person_img_url_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/de/person_img_url_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/de/person_img_url_d.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/de/person_name_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/de/person_name_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/de/person_name_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/de/person_name_d.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/de/person_title_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/de/person_title_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/de/person_title_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/de/person_title_d.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/en/attributes.yml +0 -8
- data/db/cms_fixtures/cms/pages/index/about-us/people/en/person_details_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/en/person_details_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/en/person_details_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/en/person_details_d.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/en/person_img_url_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/en/person_img_url_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/en/person_img_url_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/en/person_img_url_d.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/en/person_name_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/en/person_name_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/en/person_name_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/en/person_name_d.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/en/person_title_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/en/person_title_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/en/person_title_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/en/person_title_d.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/es/attributes.yml +0 -8
- data/db/cms_fixtures/cms/pages/index/about-us/people/es/person_details_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/es/person_details_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/es/person_details_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/es/person_details_d.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/es/person_img_url_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/es/person_img_url_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/es/person_img_url_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/es/person_img_url_d.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/es/person_name_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/es/person_name_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/es/person_name_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/es/person_name_d.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/es/person_title_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/es/person_title_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/es/person_title_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/es/person_title_d.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/pt/attributes.yml +0 -8
- data/db/cms_fixtures/cms/pages/index/about-us/people/pt/person_details_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/pt/person_details_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/pt/person_details_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/pt/person_details_d.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/pt/person_name_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/pt/person_name_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/pt/person_name_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/pt/person_name_d.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/pt/person_title_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/pt/person_title_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/pt/person_title_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/pt/person_title_d.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/ru/attributes.yml +0 -8
- data/db/cms_fixtures/cms/pages/index/about-us/people/ru/person_details_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/ru/person_details_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/ru/person_details_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/ru/person_details_d.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/ru/person_img_url_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/ru/person_img_url_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/ru/person_img_url_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/ru/person_img_url_d.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/ru/person_name_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/ru/person_name_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/ru/person_name_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/ru/person_name_d.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/ru/person_title_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/ru/person_title_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/ru/person_title_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/people/ru/person_title_d.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/services/attributes.yml +0 -8
- data/db/cms_fixtures/cms/pages/index/about-us/services/content_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/services/content_b.html +0 -0
- data/db/cms_fixtures/cms/pages/index/about-us/services/content_c.html +0 -0
- data/db/cms_fixtures/cms/pages/index/about-us/services/de/attributes.yml +0 -8
- data/db/cms_fixtures/cms/pages/index/about-us/services/de/content_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/services/de/content_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/services/de/content_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/services/de/title_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/services/de/title_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/services/de/title_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/services/en/attributes.yml +0 -8
- data/db/cms_fixtures/cms/pages/index/about-us/services/en/content_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/services/en/content_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/services/en/content_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/services/en/title_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/services/en/title_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/services/en/title_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/services/es/attributes.yml +0 -8
- data/db/cms_fixtures/cms/pages/index/about-us/services/es/content_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/services/es/content_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/services/es/content_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/services/es/title_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/services/es/title_b.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/services/es/title_c.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/services/title_a.html +0 -1
- data/db/cms_fixtures/cms/pages/index/about-us/services/title_b.html +0 -0
- data/db/cms_fixtures/cms/pages/index/about-us/services/title_c.html +0 -0
- data/db/cms_fixtures/cms/pages/index/attributes.yml +0 -8
- data/db/cms_fixtures/cms/pages/index/content.html +0 -1
- data/db/cms_fixtures/cms/pages/index/title.html +0 -0
- data/db/cms_fixtures/cms/snippets/snippet1/attributes.yml +0 -3
- data/db/cms_fixtures/cms/snippets/snippet1/content.html +0 -1
- data/db/cms_fixtures/sample-site/categories/files.yml +0 -1
- data/db/cms_fixtures/sample-site/categories/pages.yml +0 -1
- data/db/cms_fixtures/sample-site/categories/snippets.yml +0 -1
- data/db/cms_fixtures/sample-site/files/_sample.jpg.yml +0 -5
- data/db/cms_fixtures/sample-site/files/sample.jpg +0 -0
- data/db/cms_fixtures/sample-site/layouts/default/attributes.yml +0 -1
- data/db/cms_fixtures/sample-site/layouts/default/content.html +0 -5
- data/db/cms_fixtures/sample-site/layouts/default/javascript.js +0 -1
- data/db/cms_fixtures/sample-site/layouts/default/nested/attributes.yml +0 -2
- data/db/cms_fixtures/sample-site/layouts/default/nested/content.haml +0 -3
- data/db/cms_fixtures/sample-site/layouts/default/nested/javascript.js +0 -1
- data/db/cms_fixtures/sample-site/layouts/default/nested/stylesheet.css +0 -1
- data/db/cms_fixtures/sample-site/layouts/default/stylesheet.css +0 -1
- data/db/cms_fixtures/sample-site/pages/index/attributes.yml +0 -6
- data/db/cms_fixtures/sample-site/pages/index/child/attributes.yml +0 -3
- data/db/cms_fixtures/sample-site/pages/index/child/left.haml +0 -1
- data/db/cms_fixtures/sample-site/pages/index/child/right.html +0 -1
- data/db/cms_fixtures/sample-site/pages/index/child/thumbnail.png +0 -0
- data/db/cms_fixtures/sample-site/pages/index/content.html +0 -2
- data/db/cms_fixtures/sample-site/snippets/default/attributes.yml +0 -4
- data/db/cms_fixtures/sample-site/snippets/default/content.html +0 -1
- data/db/migrate/20170315212222_translate_sections.rb +0 -15
- data/db/migrate/20170513221300_create_cms.rb +0 -133
- data/lib/pwb/cms_data_loader.rb +0 -38
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/log/test.log +0 -0
- data/spec/dummy/public/uploads/pwb/content_photo/image/1/carousel_windows.jpg +0 -0
- data/spec/dummy/public/uploads/pwb/content_photo/image/2/carousel_deck_chair.jpg +0 -0
- data/spec/dummy/public/uploads/pwb/content_photo/image/3/carousel_grass.jpg +0 -0
- data/spec/dummy/public/uploads/pwb/content_photo/image/4/carousel_grass.jpg +0 -0
- data/spec/dummy/public/uploads/pwb/prop_photo/image/1/flat_balcony.jpg +0 -0
- data/spec/dummy/public/uploads/pwb/prop_photo/image/1/gdaje3atcct1gx2ngv9u.jpg +0 -0
- data/spec/dummy/public/uploads/pwb/prop_photo/image/1/new_villa.jpg +0 -0
- data/spec/dummy/public/uploads/pwb/prop_photo/image/2/flat_balcony.jpg +0 -0
- data/spec/dummy/public/uploads/pwb/prop_photo/image/2/kitchen_modern.jpg +0 -0
- data/spec/dummy/public/uploads/pwb/prop_photo/image/2/rxo23syongfydjpoizrd.jpg +0 -0
- data/spec/dummy/public/uploads/pwb/prop_photo/image/3/mansion_front.jpg +0 -0
- data/spec/dummy/public/uploads/pwb/prop_photo/image/3/vzlptgtccsk2d2ewp4id.jpg +0 -0
- data/spec/dummy/public/uploads/pwb/prop_photo/image/4/mansion_bedroom.jpg +0 -0
- data/spec/dummy/public/uploads/pwb/prop_photo/image/4/xwayprwnmmmhrzrgwvch.jpg +0 -0
- data/spec/dummy/public/uploads/pwb/prop_photo/image/5/flat_window.jpg +0 -0
- data/spec/dummy/public/uploads/pwb/prop_photo/image/5/ilxn2u37bak0v60u6f8q.jpg +0 -0
- data/spec/dummy/public/uploads/pwb/prop_photo/image/6/kitchen_classic.jpg +0 -0
- data/spec/dummy/public/uploads/pwb/prop_photo/image/7/flat_balcony.jpg +0 -0
- data/spec/dummy/public/uploads/pwb/prop_photo/image/8/lounge_cosy.jpg +0 -0
- data/spec/factories/pwb_sections.rb +0 -4
- data/spec/models/pwb/section_spec.rb +0 -11
@@ -1,7 +1,21 @@
|
|
1
1
|
module Pwb
|
2
2
|
module CssHelper
|
3
|
+
def element_classes(*identifiers)
|
4
|
+
classes = ""
|
5
|
+
identifiers.each do |identifier|
|
6
|
+
classes += @current_website.get_element_class(identifier) + " "
|
7
|
+
end
|
8
|
+
classes
|
9
|
+
end
|
3
10
|
|
4
11
|
def custom_styles(theme_name)
|
12
|
+
@bg_style_vars = ["primary-color-light", "primary-color-dark",
|
13
|
+
"primary-color",
|
14
|
+
"accent-color", "divider-color",
|
15
|
+
"primary-background-dark"]
|
16
|
+
@text_color_style_vars = ["primary-color-text",
|
17
|
+
"primary-text-color","secondary-text-color",
|
18
|
+
]
|
5
19
|
render :partial => "pwb/custom_css/#{theme_name}", :locals => {}, formats: :css
|
6
20
|
end
|
7
21
|
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module Pwb
|
2
|
+
module NavigationHelper
|
3
|
+
|
4
|
+
def render_top_navigation_links
|
5
|
+
html = ""
|
6
|
+
@tn_links ||= Pwb::Link.ordered_visible_top_nav
|
7
|
+
@tn_links.each do |page|
|
8
|
+
unless page.slug == "top_nav_admin"
|
9
|
+
html += (top_nav_link_for page) || ""
|
10
|
+
end
|
11
|
+
end
|
12
|
+
html.html_safe
|
13
|
+
end
|
14
|
+
|
15
|
+
def render_footer_links
|
16
|
+
html = ""
|
17
|
+
@ftr_links ||= Pwb::Link.ordered_visible_footer
|
18
|
+
@ftr_links.each do |page|
|
19
|
+
html += (footer_link_for page) || ""
|
20
|
+
end
|
21
|
+
html.html_safe
|
22
|
+
end
|
23
|
+
|
24
|
+
def footer_link_for(page)
|
25
|
+
html = ""
|
26
|
+
begin
|
27
|
+
if page[:link_path].present?
|
28
|
+
# link_path should be valid - below checks that
|
29
|
+
target_path = self.pwb.send(page[:link_path], [page[:link_path_params]], {locale: locale})
|
30
|
+
# below works in most routes but had to change to above to support devise routes
|
31
|
+
# target_path = send(page[:link_path], {locale: locale})
|
32
|
+
# else
|
33
|
+
# target_path = self.pwb.send("show_page_path", page[:slug], {locale: locale})
|
34
|
+
elsif page[:link_url].present?
|
35
|
+
target_path = page[:link_url]
|
36
|
+
end
|
37
|
+
rescue NoMethodError
|
38
|
+
# target_path = '/'
|
39
|
+
# rescue Exception => e
|
40
|
+
end
|
41
|
+
if target_path
|
42
|
+
html = <<-HTML
|
43
|
+
#{ link_to page.link_title, target_path}.
|
44
|
+
HTML
|
45
|
+
end
|
46
|
+
html
|
47
|
+
end
|
48
|
+
|
49
|
+
def top_nav_link_for(page)
|
50
|
+
html = ""
|
51
|
+
begin
|
52
|
+
if page[:link_path].present?
|
53
|
+
# link_path should be valid - below checks that
|
54
|
+
target_path = self.pwb.send(page[:link_path], [page[:link_path_params]], {locale: locale})
|
55
|
+
# below works in most routes but had to change to above to support devise routes
|
56
|
+
# target_path = send(page[:link_path], {locale: locale})
|
57
|
+
# else
|
58
|
+
# target_path = self.pwb.send("show_page_path", page[:slug], {locale: locale})
|
59
|
+
elsif page[:link_url].present?
|
60
|
+
target_path = page[:link_url]
|
61
|
+
end
|
62
|
+
rescue NoMethodError
|
63
|
+
# target_path = '/'
|
64
|
+
# rescue Exception => e
|
65
|
+
end
|
66
|
+
if target_path
|
67
|
+
style_class = 'selected active' if current_page?( target_path )
|
68
|
+
if current_page?("/") && (page[:link_path] == "home_path")
|
69
|
+
# so correct tab is higlighted when at root path
|
70
|
+
style_class = 'selected active'
|
71
|
+
end
|
72
|
+
html = <<-HTML
|
73
|
+
<li class="#{style_class}">
|
74
|
+
#{link_to page.link_title, target_path, target: page[:href_target]}
|
75
|
+
</li>
|
76
|
+
HTML
|
77
|
+
end
|
78
|
+
html
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Pwb
|
2
|
+
class Contact < ApplicationRecord
|
3
|
+
has_many :messages
|
4
|
+
belongs_to :primary_address, optional: true, class_name: "Address", foreign_key: 'primary_address_id'
|
5
|
+
belongs_to :secondary_address, optional: true, class_name: "Address", foreign_key: 'secondary_address_id'
|
6
|
+
belongs_to :user, optional: true
|
7
|
+
|
8
|
+
# enum title: [ :mr, :mrs ]
|
9
|
+
# above method of declaring less flexible than below:
|
10
|
+
enum title: { mr: 0, mrs: 1 }
|
11
|
+
|
12
|
+
def street_number
|
13
|
+
primary_address.present? ? primary_address.street_number : nil
|
14
|
+
end
|
15
|
+
def street_address
|
16
|
+
primary_address.present? ? primary_address.street_address : nil
|
17
|
+
end
|
18
|
+
def city
|
19
|
+
primary_address.present? ? primary_address.city : nil
|
20
|
+
end
|
21
|
+
def postal_code
|
22
|
+
primary_address.present? ? primary_address.postal_code : nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/app/models/pwb/content.rb
CHANGED
@@ -1,23 +1,41 @@
|
|
1
1
|
module Pwb
|
2
2
|
class Content < ApplicationRecord
|
3
3
|
has_many :content_photos, dependent: :destroy
|
4
|
-
belongs_to :section, optional: true, foreign_key: "section_key", primary_key: "link_path"
|
4
|
+
# belongs_to :section, optional: true, foreign_key: "section_key", primary_key: "link_path"
|
5
|
+
has_many :page_contents
|
6
|
+
has_many :pages, :through => :page_contents
|
7
|
+
# , :uniq => true
|
5
8
|
|
6
9
|
translates :raw, fallbacks_for_empty_translations: true
|
7
10
|
globalize_accessors locales: I18n.available_locales
|
8
11
|
# globalize_accessors locales: [:en, :ca, :es, :fr, :ar, :de, :ru, :pt]
|
9
12
|
|
13
|
+
attribute :raw
|
14
|
+
|
15
|
+
def as_json(options = nil)
|
16
|
+
super({only: [
|
17
|
+
"key","page_part_key", "visible_on_page"
|
18
|
+
],
|
19
|
+
methods: admin_attribute_names
|
20
|
+
}.merge(options || {}))
|
21
|
+
end
|
22
|
+
|
23
|
+
def admin_attribute_names
|
24
|
+
self.globalize_attribute_names.push :content_photos
|
25
|
+
end
|
26
|
+
|
27
|
+
|
10
28
|
def default_photo
|
11
29
|
content_photos.first
|
12
30
|
end
|
13
31
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
32
|
+
def default_photo_url
|
33
|
+
if content_photos.first
|
34
|
+
content_photos.first.image_url
|
35
|
+
else
|
36
|
+
'https://placeholdit.imgix.net/~text?txtsize=38&txt=&w=550&h=300&txttrack=0'
|
37
|
+
end
|
38
|
+
end
|
21
39
|
|
22
40
|
class << self
|
23
41
|
def import(file)
|
@@ -2,10 +2,28 @@ module Pwb
|
|
2
2
|
class ContentPhoto < ApplicationRecord
|
3
3
|
mount_uploader :image, ContentPhotoUploader
|
4
4
|
belongs_to :content, optional: true
|
5
|
+
# I use block_key col to indicate if there is a fragment block associated
|
6
|
+
# with this photo
|
5
7
|
|
6
8
|
# validates_processing_of :image
|
7
9
|
# validate :image_size_validation
|
8
10
|
|
11
|
+
def optimized_image_url
|
12
|
+
unless self.image.url.present?
|
13
|
+
# if this method is called too soon after an image is
|
14
|
+
# uploaded, might need to reload the record to
|
15
|
+
# have the url available
|
16
|
+
self.reload
|
17
|
+
end
|
18
|
+
if Rails.application.config.use_cloudinary
|
19
|
+
options = {height: 800, crop: "scale", quality: "auto"}
|
20
|
+
image_url = Cloudinary::Utils.cloudinary_url self.image, options
|
21
|
+
else
|
22
|
+
image_url = self.image.url
|
23
|
+
end
|
24
|
+
image_url
|
25
|
+
end
|
26
|
+
|
9
27
|
# private
|
10
28
|
# def image_size_validation
|
11
29
|
# errors[:image] << "should be less than 500KB" if image.size > 0.5.megabytes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Pwb
|
2
|
+
# added July 2017
|
3
|
+
class Link < ApplicationRecord
|
4
|
+
translates :link_title, fallbacks_for_empty_translations: true
|
5
|
+
# globalize_accessors locales: [:en, :ca, :es, :fr, :ar, :de, :ru, :pt]
|
6
|
+
globalize_accessors locales: I18n.available_locales
|
7
|
+
|
8
|
+
belongs_to :page, optional: true, foreign_key: "page_slug", primary_key: "slug"
|
9
|
+
|
10
|
+
# below needed to avoid "... is not an attribute known to Active Record" warnings
|
11
|
+
attribute :link_title
|
12
|
+
|
13
|
+
|
14
|
+
# enum placement: [ :top_nav, :footer ]
|
15
|
+
# above method of declaring less flexible than below:
|
16
|
+
enum placement: { top_nav: 0, footer: 1, social_media: 2, admin: 3}
|
17
|
+
|
18
|
+
scope :ordered_visible_admin, -> () { where(visible: true, placement: :admin).order('sort_order asc') }
|
19
|
+
scope :ordered_visible_top_nav, -> () { where(visible: true, placement: :top_nav).order('sort_order asc') }
|
20
|
+
scope :ordered_visible_footer, -> () { where(visible: true, placement: :footer).order('sort_order asc') }
|
21
|
+
scope :ordered_top_nav, -> () { where(placement: :top_nav).order('sort_order asc') }
|
22
|
+
scope :ordered_footer, -> () { where(placement: :footer).order('sort_order asc') }
|
23
|
+
|
24
|
+
|
25
|
+
def as_json(options = nil)
|
26
|
+
super({only: [
|
27
|
+
"sort_order", "placement",
|
28
|
+
"href_class", "is_deletable",
|
29
|
+
"slug", "link_path","visible",
|
30
|
+
"link_title", "page_slug"
|
31
|
+
],
|
32
|
+
methods: admin_attribute_names}.merge(options || {}))
|
33
|
+
end
|
34
|
+
|
35
|
+
def admin_attribute_names
|
36
|
+
self.globalize_attribute_names
|
37
|
+
# self.globalize_attribute_names.push :content_photos
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
data/app/models/pwb/message.rb
CHANGED
@@ -0,0 +1,227 @@
|
|
1
|
+
module Pwb
|
2
|
+
# added July 2017
|
3
|
+
# has details json col where page_fragment info is stored
|
4
|
+
class Page < ApplicationRecord
|
5
|
+
extend ActiveHash::Associations::ActiveRecordExtensions
|
6
|
+
# belongs_to_active_hash :page_setup, optional: true, foreign_key: "setup_id", class_name: "Pwb::PageSetup", shortcuts: [:friendly_name], primary_key: "id"
|
7
|
+
|
8
|
+
has_many :links, foreign_key: "page_slug", primary_key: "slug"
|
9
|
+
has_one :main_link, -> { where(placement: :top_nav) }, foreign_key: "page_slug", primary_key: "slug", class_name: "Pwb::Link"
|
10
|
+
# , :conditions => ['placement = ?', :admin]
|
11
|
+
|
12
|
+
has_many :page_parts, foreign_key: "page_slug", primary_key: "slug"
|
13
|
+
|
14
|
+
has_many :page_contents
|
15
|
+
has_many :contents, :through => :page_contents
|
16
|
+
# https://stackoverflow.com/questions/5856838/scope-with-join-on-has-many-through-association
|
17
|
+
has_many :ordered_visible_page_contents, -> { ordered_visible }, :class_name => 'PageContent'
|
18
|
+
# below would get me the correct items but the order gets lost:
|
19
|
+
# has_many :ordered_visible_contents, :source => :content, :through => :ordered_visible_page_contents
|
20
|
+
# note, even where ordered_visible_contents exist,
|
21
|
+
# @page.ordered_visible_contents.first will return nill
|
22
|
+
# @page.ordered_visible_contents.all.first will return content
|
23
|
+
|
24
|
+
translates :raw_html, fallbacks_for_empty_translations: true
|
25
|
+
translates :page_title, fallbacks_for_empty_translations: true
|
26
|
+
translates :link_title, fallbacks_for_empty_translations: true
|
27
|
+
# globalize_accessors locales: [:en, :ca, :es, :fr, :ar, :de, :ru, :pt]
|
28
|
+
globalize_accessors locales: I18n.available_locales
|
29
|
+
|
30
|
+
# Pwb::Page.has_attribute?("raw_html")
|
31
|
+
# below needed so above returns true
|
32
|
+
attribute :link_title
|
33
|
+
attribute :page_title
|
34
|
+
attribute :raw_html
|
35
|
+
# without above, Rails 5.1 will give deprecation warnings in my specs
|
36
|
+
|
37
|
+
# scope :visible_in_admin, -> () { where visible: true }
|
38
|
+
|
39
|
+
# def get_fragment_html label, locale
|
40
|
+
# content_key = slug + "_" + label
|
41
|
+
# content = self.contents.find_by_key content_key
|
42
|
+
# if content.present?
|
43
|
+
# content.raw
|
44
|
+
# else
|
45
|
+
# nil
|
46
|
+
# end
|
47
|
+
# end
|
48
|
+
|
49
|
+
# used by page_controller to create a photo (from upload) that can
|
50
|
+
# later be used in fragment html
|
51
|
+
def create_fragment_photo page_part_key, block_label, photo_file
|
52
|
+
# content_key = self.slug + "_" + page_part_key
|
53
|
+
# get content model associated with page and fragment
|
54
|
+
page_fragment_content = contents.find_or_create_by(page_part_key: page_part_key)
|
55
|
+
|
56
|
+
if ENV["RAILS_ENV"] == "test"
|
57
|
+
# don't create photos for tests
|
58
|
+
return nil
|
59
|
+
end
|
60
|
+
begin
|
61
|
+
photo = page_fragment_content.content_photos.create(block_key: block_label)
|
62
|
+
photo.image = photo_file
|
63
|
+
# photo.image = Pwb::Engine.root.join(photo_file).open
|
64
|
+
photo.save!
|
65
|
+
rescue Exception => e
|
66
|
+
# log exception to console
|
67
|
+
print e
|
68
|
+
# if photo
|
69
|
+
# photo.destroy!
|
70
|
+
# end
|
71
|
+
end
|
72
|
+
return photo
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
# when seeding I only need to ensure that a photo exists for the fragment
|
77
|
+
# so will return existing photo if it can be found
|
78
|
+
def seed_fragment_photo page_part_key, block_label, photo_file
|
79
|
+
# content_key = self.slug + "_" + page_part_key
|
80
|
+
# get in content model associated with page and fragment
|
81
|
+
page_fragment_content = contents.find_or_create_by(page_part_key: page_part_key)
|
82
|
+
photo = page_fragment_content.content_photos.find_by_block_key(block_label)
|
83
|
+
|
84
|
+
if photo.present?
|
85
|
+
return photo
|
86
|
+
else
|
87
|
+
photo = page_fragment_content.content_photos.create(block_key: block_label)
|
88
|
+
end
|
89
|
+
|
90
|
+
if ENV["RAILS_ENV"] == "test"
|
91
|
+
# don't create photos for tests
|
92
|
+
return nil
|
93
|
+
end
|
94
|
+
begin
|
95
|
+
# if photo_file.is_a?(String)
|
96
|
+
# photo.image = photo_file
|
97
|
+
photo.image = Pwb::Engine.root.join(photo_file).open
|
98
|
+
photo.save!
|
99
|
+
print "#{self.slug}--#{page_part_key} image created: #{photo.optimized_image_url}\n"
|
100
|
+
# reload the record to ensure that url is available
|
101
|
+
photo.reload
|
102
|
+
print "#{self.slug}--#{page_part_key} image created: #{photo.optimized_image_url}(after reload..)"
|
103
|
+
rescue Exception => e
|
104
|
+
# log exception to console
|
105
|
+
print e
|
106
|
+
end
|
107
|
+
return photo
|
108
|
+
end
|
109
|
+
|
110
|
+
def set_fragment_sort_order page_part_key, sort_order
|
111
|
+
page_fragment_content = contents.find_by_page_part_key page_part_key
|
112
|
+
# using join model for sorting and visibility as it
|
113
|
+
# will allow use of same content by different pages
|
114
|
+
# with different settings for sorting and visibility
|
115
|
+
page_content_join_model = page_fragment_content.page_contents.find_by_page_id self.id
|
116
|
+
page_content_join_model.sort_order = sort_order
|
117
|
+
page_content_join_model.save!
|
118
|
+
end
|
119
|
+
|
120
|
+
def set_fragment_visibility page_part_key, visible_on_page
|
121
|
+
page_fragment_content = contents.find_by_page_part_key page_part_key
|
122
|
+
page_content_join_model = page_fragment_content.page_contents.find_by_page_id self.id
|
123
|
+
page_content_join_model.visible_on_page = visible_on_page
|
124
|
+
page_content_join_model.save!
|
125
|
+
end
|
126
|
+
|
127
|
+
# currently only used in
|
128
|
+
# /pwb/spec/controllers/pwb/welcome_controller_spec.rb
|
129
|
+
def set_fragment_html page_part_key, locale, new_fragment_html
|
130
|
+
# content_key = slug + "_" + page_part_key
|
131
|
+
# save in content model associated with page
|
132
|
+
page_fragment_content = contents.find_or_create_by(page_part_key: page_part_key)
|
133
|
+
content_html_col = "raw_" + locale + "="
|
134
|
+
# above is the col used by globalize gem to store localized data
|
135
|
+
# page_fragment_content[content_html_col] = fragment_html
|
136
|
+
page_fragment_content.send content_html_col, new_fragment_html
|
137
|
+
page_fragment_content.save!
|
138
|
+
|
139
|
+
return page_fragment_content
|
140
|
+
end
|
141
|
+
|
142
|
+
# def parse_page_part page_part_key, content_for_pf_locale
|
143
|
+
|
144
|
+
# page_part = self.page_parts.find_by_page_part_key page_part_key
|
145
|
+
|
146
|
+
# if page_part.present?
|
147
|
+
# l_template = Liquid::Template.parse(page_part.template)
|
148
|
+
# fragment_html = l_template.render('page_part' => content_for_pf_locale["blocks"] )
|
149
|
+
# p "#{page_part_key} content for #{self.slug} page parsed."
|
150
|
+
|
151
|
+
# else
|
152
|
+
# fragment_html = ""
|
153
|
+
# end
|
154
|
+
|
155
|
+
# # fragment_html = l_template.render('page_part' => content_for_pf_locale["blocks"] )
|
156
|
+
# # ac = ActionController::Base.new()
|
157
|
+
# # # render html for fragment with associated partial
|
158
|
+
# # fragment_html = ac.render_to_string :partial => "pwb/fragments/#{page_part_key}", :locals => { page_part: content_for_pf_locale["blocks"]}
|
159
|
+
# return fragment_html
|
160
|
+
# end
|
161
|
+
|
162
|
+
# Will retrieve saved page_part blocks and use that along with template
|
163
|
+
# to rebuild page_content html
|
164
|
+
def rebuild_page_content page_part_key, locale
|
165
|
+
page_part = self.page_parts.find_by_page_part_key page_part_key
|
166
|
+
|
167
|
+
if page_part.present?
|
168
|
+
l_template = Liquid::Template.parse(page_part.template)
|
169
|
+
new_fragment_html = l_template.render('page_part' => page_part.block_contents[locale]["blocks"] )
|
170
|
+
# p "#{page_part_key} content for #{self.slug} page parsed."
|
171
|
+
# save in content model associated with page
|
172
|
+
page_fragment_content = contents.find_or_create_by(page_part_key: page_part_key)
|
173
|
+
content_html_col = "raw_" + locale + "="
|
174
|
+
# above is the col used by globalize gem to store localized data
|
175
|
+
# page_fragment_content[content_html_col] = new_fragment_html
|
176
|
+
page_fragment_content.send content_html_col, new_fragment_html
|
177
|
+
page_fragment_content.save!
|
178
|
+
|
179
|
+
else
|
180
|
+
new_fragment_html = ""
|
181
|
+
end
|
182
|
+
|
183
|
+
return new_fragment_html
|
184
|
+
end
|
185
|
+
|
186
|
+
def set_page_part_block_contents page_part_key, locale, fragment_details
|
187
|
+
page_part = self.page_parts.find_by_page_part_key page_part_key
|
188
|
+
if page_part.present?
|
189
|
+
page_part.block_contents[locale] = fragment_details
|
190
|
+
page_part.save!
|
191
|
+
# fragment_details passed in might be a params object
|
192
|
+
# - retrieving what has just been saved will return it as JSON
|
193
|
+
fragment_details = page_part.block_contents[locale]
|
194
|
+
end
|
195
|
+
return fragment_details
|
196
|
+
end
|
197
|
+
|
198
|
+
|
199
|
+
# def as_json(options = nil)
|
200
|
+
# super({only: ["sort_order_top_nav", "show_in_top_nav"],
|
201
|
+
# methods: ["link_title_en","link_title_es"
|
202
|
+
# ]}.merge(options || {}))
|
203
|
+
# end
|
204
|
+
# above can be called on a result set from a query like so:
|
205
|
+
# Page.all.as_json
|
206
|
+
# Below can only be called on a single record like so:
|
207
|
+
# Page.first.as_json
|
208
|
+
def as_json_for_admin(options = nil)
|
209
|
+
as_json({only: [
|
210
|
+
"sort_order_top_nav", "show_in_top_nav",
|
211
|
+
"sort_order_footer", "show_in_footer",
|
212
|
+
"slug", "link_path","visible"
|
213
|
+
],
|
214
|
+
methods: admin_attribute_names}.merge(options || {}))
|
215
|
+
end
|
216
|
+
|
217
|
+
def admin_attribute_names
|
218
|
+
|
219
|
+
self.globalize_attribute_names.push :page_contents, :page_parts
|
220
|
+
# return "link_title_en","link_title_es", "link_title_de",
|
221
|
+
end
|
222
|
+
|
223
|
+
# def page_fragment_blocks
|
224
|
+
# return details["fragments"]
|
225
|
+
# end
|
226
|
+
end
|
227
|
+
end
|