diff --git a/app/services/content_scrubber.rb b/app/services/content_scrubber.rb index f517dbda89..7305aecf7e 100644 --- a/app/services/content_scrubber.rb +++ b/app/services/content_scrubber.rb @@ -10,6 +10,14 @@ class ContentScrubber < Rails::Html::PermitScrubber self.attributes = ALLOWED_ATTRIBUTES end + def scrub(node) + if node.name == 'p' && (node.children.empty? || node.text.blank?) + node.remove + else + super + end + end + def skip_node?(node) node.text? end diff --git a/app/views/shop/products/_summary.html.haml b/app/views/shop/products/_summary.html.haml index c99eabaa4e..76c9da9a93 100644 --- a/app/views/shop/products/_summary.html.haml +++ b/app/views/shop/products/_summary.html.haml @@ -9,7 +9,7 @@ %h3 %a{"ng-click" => "triggerProductModal()", href: 'javascript:void(0)'} %span{"ng-bind" => "::product.name"} - %p.product-description{ng: {"bind-html": "::product.description_html", click: "triggerProductModal()", show: "product.description_html.length"}} + .product-description{ng: {"bind-html": "::product.description_html", click: "triggerProductModal()", show: "product.description_html.length"}} .product-producer = t :products_from %span diff --git a/app/webpacker/css/darkswarm/_shop-product-rows.scss b/app/webpacker/css/darkswarm/_shop-product-rows.scss index 3f91e04165..401db4f8a0 100644 --- a/app/webpacker/css/darkswarm/_shop-product-rows.scss +++ b/app/webpacker/css/darkswarm/_shop-product-rows.scss @@ -149,6 +149,15 @@ text-overflow: ellipsis; margin-bottom: 0.75rem; cursor: pointer; + // Force product description to be on one line + // and truncate with ellipsis + display: -webkit-box; + -webkit-line-clamp: 1; + -webkit-box-orient: vertical; + overflow: hidden; + // line-clamp is not supported in Safari + line-height: 1rem; + height: 1.75rem; } .product-properties { diff --git a/spec/services/content_sanitizer_spec.rb b/spec/services/content_sanitizer_spec.rb index 8e2117c1e8..6961d8e574 100644 --- a/spec/services/content_sanitizer_spec.rb +++ b/spec/services/content_sanitizer_spec.rb @@ -53,5 +53,9 @@ describe ContentSanitizer do it "echos nil if given nil" do expect(service.sanitize_content(nil)).to be(nil) end + + it "removes empty

tags and keeps non-empty ones" do + expect(service.sanitize_content("

hello

world!

")).to eq("

hello

world!

") + end end end