Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Clean up code.

Matthew Kennedy2b4636149b2d
diff --git a/backend/app/helpers/spree/admin/cms_helper.rb b/backend/app/helpers/spree/admin/cms_helper.rb
index 7dbe32a1f5..ad347c7860 100644
--- a/backend/app/helpers/spree/admin/cms_helper.rb
+++ b/backend/app/helpers/spree/admin/cms_helper.rb
@@ -1,19 +1,6 @@
module Spree
module Admin
module CmsHelper
- def build_page_section(section)
- fit = case section.fit
- when 'Screen'
- 'edge'
- else
- ''
- end
-
- render 'spree/admin/cms_pages/section_template',
- section: section,
- fit: fit
- end
-
def page_preview_link(page)
return unless frontend_available?
@@ -23,20 +10,17 @@ module Spree
spree.page_url(page.slug)
end
- button_link_to(
- Spree.t('admin.cms.preview_page'),
- url,
- class: 'btn-outline-secondary', icon: 'view.svg', id: 'admin_preview_product', target: :blank
- )
+ button_link_to(Spree.t('admin.cms.preview_page'), url,
+ class: 'btn-outline-secondary', icon: 'view.svg', id: 'admin_preview_product', target: :blank)
end
def preview_url(page)
return unless frontend_available?
if page.homepage?
- spree.root_path + page.locale
+ spree.root_path + page.locale + "?no_cache=#{rand(1...10000)}"
else
- spree.page_path(page.slug)
+ spree.page_path(page.slug) + "?no_cache=#{rand(1...10000)}"
end
end
end
diff --git a/backend/app/views/spree/admin/cms_pages/_section_template.html.erb b/backend/app/views/spree/admin/cms_pages/_section_template.html.erb
index 8054f61861..41e3da55ee 100644
--- a/backend/app/views/spree/admin/cms_pages/_section_template.html.erb
+++ b/backend/app/views/spree/admin/cms_pages/_section_template.html.erb
@@ -1,4 +1,4 @@
-<div class="<%= fit %> col-12 p-0 removable-dom-element" data-section-id="<%= section.id %>">
+<div class="col-12 p-0 removable-dom-element" data-section-id="<%= section.id %>">
<div class="row m-0 mb-1 pb-0 border border-secondary bg-white">
<div class="col move-handle d-flex pr-0 truncate">
<div class="py-3 align-items-center overflow-hidden w-100">
diff --git a/backend/app/views/spree/admin/cms_pages/edit.html.erb b/backend/app/views/spree/admin/cms_pages/edit.html.erb
index 813fc71e40..bfbdba6edc 100644
--- a/backend/app/views/spree/admin/cms_pages/edit.html.erb
+++ b/backend/app/views/spree/admin/cms_pages/edit.html.erb
@@ -43,7 +43,7 @@
<% if @cms_page.cms_sections.any? %>
<div id="cmsPagesectionsArea" class="card-body row m-0 p-1 no-gutters">
<% @cms_page.cms_sections.each do |section| %>
- <%= build_page_section(section) %>
+ <%= render 'spree/admin/cms_pages/section_template', section: section %>
<% end %>
</div>
diff --git a/core/app/models/spree/cms/sections/featured_article.rb b/core/app/models/spree/cms/sections/featured_article.rb
index c31af0e1e1..c1a18555bc 100644
--- a/core/app/models/spree/cms/sections/featured_article.rb
+++ b/core/app/models/spree/cms/sections/featured_article.rb
@@ -7,12 +7,8 @@ module Spree::Cms::Sections
LINKED_RESOURCE_TYPE = ['Spree::Taxon', 'Spree::Product', 'Spree::CmsPage']
- def gutters_sizes
- ['Use gutters', 'No Gutters']
- end
-
def gutters?
- gutters == 'Use gutters'
+ gutters == 'Gutters'
end
private
diff --git a/core/app/models/spree/cms/sections/full_screen_hero_image.rb b/core/app/models/spree/cms/sections/full_screen_hero_image.rb
index 10e14677f8..e64eeb9e2d 100644
--- a/core/app/models/spree/cms/sections/full_screen_hero_image.rb
+++ b/core/app/models/spree/cms/sections/full_screen_hero_image.rb
@@ -7,17 +7,14 @@ module Spree::Cms::Sections
LINKED_RESOURCE_TYPE = ['Spree::Taxon', 'Spree::Product']
- def gutters_sizes
- ['Use gutters', 'No Gutters']
- end
-
def gutters?
- gutters == 'Use gutters'
+ gutters == 'Gutters'
end
private
def default_values
+ self.gutters ||= 'No Gutters'
self.fit ||= 'Screen'
self.linked_resource_type ||= 'Spree::Taxon'
end
diff --git a/core/app/models/spree/cms/sections/side_by_side_promotion.rb b/core/app/models/spree/cms/sections/side_by_side_promotion.rb
index 8aa7038499..e6b5f27c6e 100644
--- a/core/app/models/spree/cms/sections/side_by_side_promotion.rb
+++ b/core/app/models/spree/cms/sections/side_by_side_promotion.rb
@@ -6,17 +6,14 @@ module Spree::Cms::Sections
:permalink_two, :title_two, :subtitle_two], coder: JSON
store :settings, accessors: [:gutters], coder: JSON
- def gutters_sizes
- ['Use gutters', 'No Gutters']
- end
-
def gutters?
- gutters == 'Use gutters'
+ gutters == 'Gutters'
end
private
def default_values
+ self.gutters ||= 'Gutters'
self.fit ||= 'Container'
end
end
diff --git a/core/app/models/spree/cms_section.rb b/core/app/models/spree/cms_section.rb
index 65a14403e1..d8e64aa267 100644
--- a/core/app/models/spree/cms_section.rb
+++ b/core/app/models/spree/cms_section.rb
@@ -7,7 +7,7 @@ module Spree
# Six images in one section should cover a large number of potential use cases.
# The standardization of putting them here means we can offer them up through
- # the API serializer vs hoping they get added per section basis and the naming
+ # the API serializer vs hoping they get added on a per-section basis and the naming
# matches those used in the API serializer attributes.
has_one_attached :image_one
has_one_attached :image_two
@@ -33,6 +33,10 @@ module Spree
['Container', 'Screen']
end
+ def gutters_sizes
+ ['Gutters', 'No Gutters']
+ end
+
def fullscreen?
fit == 'Screen'
end
diff --git a/frontend/app/assets/stylesheets/spree/frontend/helpers/spree/frontend_helper.scss b/frontend/app/assets/stylesheets/spree/frontend/helpers/spree/frontend_helper.scss
index 379ebc8290..27af9f4a3e 100644
--- a/frontend/app/assets/stylesheets/spree/frontend/helpers/spree/frontend_helper.scss
+++ b/frontend/app/assets/stylesheets/spree/frontend/helpers/spree/frontend_helper.scss
@@ -51,7 +51,8 @@
}
// Aspect Ratios
-[style*="--aspect-ratio"] > img {
+[style*="--aspect-ratio"] > img,
+[style*="--aspect-ratio"] > svg {
width: 100%;
height: 100%;
position: absolute;
diff --git a/frontend/app/views/spree/cms_pages/show.html.erb b/frontend/app/views/spree/cms_pages/show.html.erb
index 8d19495040..ce69b053db 100644
--- a/frontend/app/views/spree/cms_pages/show.html.erb
+++ b/frontend/app/views/spree/cms_pages/show.html.erb
@@ -8,28 +8,9 @@
</div>
</div>
<% else %>
- <div class="container">
- <div id="featurePageContent" class="row">
<% @cms_page.cms_sections.each do |section| %>
<%= build_section(section) %>
<% end %>
- </div>
- </div>
<% end %>
-<% else %>
- <div id="missingHomepage" class="container my-5">
- <div class="row my-5">
- <div class="col-12">
- <figure class="logo mx-auto missing-homepage-logo-container">
- <%= logo %>
- </figure>
- </div>
- <div class="col-12 mb-5 text-center">
- <h1 class="mb-3"><%= Spree.t('we_will_be_back') %></h1>
- <h4 class="text-dark"><%= Spree.t('we_are_busy_updating_page', store_name: current_store.name) %></h4>
- <h4 class="text-dark"><%= Spree.t('please_check_back_soon') %></h4>
- </div>
- </div>
- </div>
<% end %>
<%= render "spree/shared/cms/pages/edit_mode", edit_mode: @edit_mode %>
diff --git a/frontend/app/views/spree/shared/cms/sections/_side_by_side_promotion.html.erb b/frontend/app/views/spree/shared/cms/sections/_side_by_side_promotion.html.erb
index fbbb4a7989..69dba47a7d 100644
--- a/frontend/app/views/spree/shared/cms/sections/_side_by_side_promotion.html.erb
+++ b/frontend/app/views/spree/shared/cms/sections/_side_by_side_promotion.html.erb
@@ -15,88 +15,92 @@
<% end %>
<% end %>
-<div class="col-12 col-md-6 mb-3 mb-md-0 <%= section_one_padding %>">
- <%= link_to spree.nested_taxons_path(section.permalink_one),
- class: 'd-flex align-items-end justify-content-center bg-light text-center overflow-hidden homepage-bottom-box',
- style: '--aspect-ratio:54/35;' do %>
+<% if section.permalink_one.present? %>
+ <div class="col-12 col-md-6 mb-3 mb-md-0 <%= section_one_padding %>">
+ <%= link_to spree.nested_taxons_path(section.permalink_one),
+ class: 'd-flex align-items-end justify-content-center bg-light text-center overflow-hidden homepage-bottom-box',
+ style: '--aspect-ratio:54/35;' do %>
- <% if section.image_one.present? %>
- <!-- XS to MD -->
- <img class="d-md-none lazyload"
- data-src="<%= main_app.url_for(section.image_one.attachment.variant(resize: '387x250>')) %>"
- data-srcset="<%= main_app.url_for(section.image_one.attachment.variant(resize: '387x250>')) %>"
- alt="<%= section&.title_one %>">
+ <% if section.image_one.present? %>
+ <!-- XS to MD -->
+ <img class="d-md-none lazyload"
+ data-src="<%= main_app.url_for(section.image_one.attachment.variant(resize: '387x250>')) %>"
+ data-srcset="<%= main_app.url_for(section.image_one.attachment.variant(resize: '387x250>')) %>"
+ alt="<%= section&.title_one %>">
- <!-- MD to XL -->
- <img class="d-none d-md-block d-xl-none lazyload"
- data-src="<%= main_app.url_for(section.image_one.attachment.variant(resize: '734x476>')) %>"
- data-srcset="<%= main_app.url_for(section.image_one.attachment.variant(resize: '734x476>')) %>"
- alt="<%= section&.title_one %>">
+ <!-- MD to XL -->
+ <img class="d-none d-md-block d-xl-none lazyload"
+ data-src="<%= main_app.url_for(section.image_one.attachment.variant(resize: '734x476>')) %>"
+ data-srcset="<%= main_app.url_for(section.image_one.attachment.variant(resize: '734x476>')) %>"
+ alt="<%= section&.title_one %>">
- <!-- XL UP -->
- <img class="d-none d-xl-block lazyload"
- data-src="<%= main_app.url_for(section.image_one.attachment.variant(resize: '1468x952>')) %>"
- data-srcset="<%= main_app.url_for(section.image_one.attachment.variant(resize: '1468x952>')) %>"
- alt="<%= section&.title_one %>">
- <% else %>
- <%= icon( name: 'card-image',
- classes: 'text-black-50',
- width: 26,
- height: 26) %>
- <% end %>
+ <!-- XL UP -->
+ <img class="d-none d-xl-block lazyload"
+ data-src="<%= main_app.url_for(section.image_one.attachment.variant(resize: '1468x952>')) %>"
+ data-srcset="<%= main_app.url_for(section.image_one.attachment.variant(resize: '1468x952>')) %>"
+ alt="<%= section&.title_one %>">
+ <% else %>
+ <%= icon( name: 'card-image',
+ classes: 'text-black-50',
+ width: 26,
+ height: 26) %>
+ <% end %>
- <% if section.title_one.present? || section.subtitle_one.present? %>
- <div class="homepage-bottom-box-inner p-1 p-sm-2 p-md-4 homepage-hpb" role="img" aria-label="New Collection">
- <div class="homepage-bottom-box-inner-small-text">
- <%= section&.title_one %>
+ <% if section.title_one.present? || section.subtitle_one.present? %>
+ <div class="homepage-bottom-box-inner p-1 p-sm-2 p-md-4 homepage-hpb" role="img" aria-label="New Collection">
+ <div class="homepage-bottom-box-inner-small-text">
+ <%= section&.title_one %>
+ </div>
+ <div class="homepage-bottom-box-inner-big-text">
+ <%= section.subtitle_one %>
+ </div>
</div>
- <div class="homepage-bottom-box-inner-big-text">
- <%= section.subtitle_one %>
- </div>
- </div>
- <% end %>
- <% end %>
-</div>
+ <% end %>
+ <% end %>
+ </div>
+<% end %>
-<div class="col-12 col-md-6 <%= section_two_padding %>">
- <%= link_to spree.nested_taxons_path(section.permalink_two),
- class: 'd-flex align-items-end justify-content-center bg-light text-center overflow-hidden homepage-bottom-box',
- style: '--aspect-ratio:54/35;' do %>
+<% if section.permalink_two.present? %>
+ <div class="col-12 col-md-6 <%= section_two_padding %>">
+ <%= link_to spree.nested_taxons_path(section.permalink_two),
+ class: 'd-flex align-items-end justify-content-center bg-light text-center overflow-hidden homepage-bottom-box',
+ style: '--aspect-ratio:54/35;' do %>
- <% if section.image_two.present? %>
- <!-- XS to MD -->
- <img class="d-md-none lazyload"
- data-src="<%= main_app.url_for(section.image_two.attachment.variant(resize: '387x250>')) %>"
- data-srcset="<%= main_app.url_for(section.image_two.attachment.variant(resize: '387x250>')) %>"
- alt="<%= section&.title_two %>">
+ <% if section.image_two.present? %>
+ <!-- XS to MD -->
+ <img class="d-md-none lazyload"
+ data-src="<%= main_app.url_for(section.image_two.attachment.variant(resize: '387x250>')) %>"
+ data-srcset="<%= main_app.url_for(section.image_two.attachment.variant(resize: '387x250>')) %>"
+ alt="<%= section&.title_two %>">
- <!-- MD to XL -->
- <img class="d-none d-md-block d-xl-none lazyload"
- data-src="<%= main_app.url_for(section.image_two.attachment.variant(resize: '734x476>')) %>"
- data-srcset="<%= main_app.url_for(section.image_two.attachment.variant(resize: '734x476>')) %>"
- alt="<%= section&.title_two %>">
+ <!-- MD to XL -->
+ <img class="d-none d-md-block d-xl-none lazyload"
+ data-src="<%= main_app.url_for(section.image_two.attachment.variant(resize: '734x476>')) %>"
+ data-srcset="<%= main_app.url_for(section.image_two.attachment.variant(resize: '734x476>')) %>"
+ alt="<%= section&.title_two %>">
- <!-- XL UP -->
- <img class="d-none d-xl-block lazyload"
- data-src="<%= main_app.url_for(section.image_two.attachment.variant(resize: '1468x952>')) %>"
- data-srcset="<%= main_app.url_for(section.image_two.attachment.variant(resize: '1468x952>')) %>"
- alt="<%= section&.title_two %>">
- <% else %>
- <%= icon( name: 'card-image',
- classes: 'text-black-50',
- width: 26,
- height: 26) %>
- <% end %>
+ <!-- XL UP -->
+ <img class="d-none d-xl-block lazyload"
+ data-src="<%= main_app.url_for(section.image_two.attachment.variant(resize: '1468x952>')) %>"
+ data-srcset="<%= main_app.url_for(section.image_two.attachment.variant(resize: '1468x952>')) %>"
+ alt="<%= section&.title_two %>">
+ <% else %>
+ <%= icon( name: 'card-image',
+ classes: 'text-black-50',
+ width: 26,
+ height: 26) %>
+ <% end %>
- <% if section.title_two.present? || section.subtitle_two.present? %>
- <div class="homepage-bottom-box-inner p-1 p-sm-2 p-md-4 homepage-hpb" role="img" aria-label="New Collection">
- <div class="homepage-bottom-box-inner-small-text">
- <%= section&.title_two %>
+ <% if section.title_two.present? || section.subtitle_two.present? %>
+ <div class="homepage-bottom-box-inner p-1 p-sm-2 p-md-4 homepage-hpb" role="img" aria-label="New Collection">
+ <div class="homepage-bottom-box-inner-small-text">
+ <%= section&.title_two %>
+ </div>
+ <div class="homepage-bottom-box-inner-big-text">
+ <%= section.subtitle_two %>
+ </div>
</div>
- <div class="homepage-bottom-box-inner-big-text">
- <%= section.subtitle_two %>
- </div>
- </div>
- <% end %>
- <% end %>
-</div>
+ <% end %>
+ <% end %>
+ </div>
+<% end %>
diff --git a/frontend/app/views/spree/shared/cms/sections/_three_taxon_categories_block.html.erb b/frontend/app/views/spree/shared/cms/sections/_three_taxon_categories_block.html.erb
index 1b521fa38e..24a4da79e0 100644
--- a/frontend/app/views/spree/shared/cms/sections/_three_taxon_categories_block.html.erb
+++ b/frontend/app/views/spree/shared/cms/sections/_three_taxon_categories_block.html.erb
@@ -15,7 +15,7 @@
<div class="row" style="margin-bottom: 3.7%;">
<div class="col-12">
- <%= link_to spree.nested_taxons_path(section.permalink_one), class: 'homepage-taxon-box', style: '--aspect-ratio:18/13;' do %>
+ <%= link_to spree.nested_taxons_path(section.permalink_one), class: 'homepage-taxon-box bg-light', style: '--aspect-ratio:18/13;' do %>
<% if section.image_one.attached? && section.image_one.variable? %>
<!-- XS to MD -->
@@ -55,7 +55,7 @@
<div class="row">
<div class="col-12">
- <%= link_to spree.nested_taxons_path(section.permalink_three), class: 'homepage-taxon-box', style: '--aspect-ratio:18/13;' do %>
+ <%= link_to spree.nested_taxons_path(section.permalink_three), class: 'homepage-taxon-box bg-light', style: '--aspect-ratio:18/13;' do %>
<% if section.image_three.attached? && section.image_three.variable? %>
<!-- XS to MD -->
@@ -94,7 +94,7 @@
<!-- Right Block TALL -->
<div class="col-6 <%= section_two_padding %>">
<% if section.permalink_two.present? %>
- <%= link_to spree.nested_taxons_path(section.permalink_two), class: 'homepage-taxon-box', style: '--aspect-ratio:27/40;' do %>
+ <%= link_to spree.nested_taxons_path(section.permalink_two), class: 'homepage-taxon-box bg-light', style: '--aspect-ratio:27/40;' do %>
<% if section.image_two.attached? && section.image_two.variable? %>
<!-- XS to MD -->