FEATURE: use custom placeholder HTML for genric whitelisted oneboxes DEV: optimize usage of custom placeholder HTML

FEATURE: use custom placeholder HTML for genric whitelisted oneboxes DEV: optimize usage of custom placeholder HTML

diff --git a/lib/onebox/engine/audio_onebox.rb b/lib/onebox/engine/audio_onebox.rb
index 5c8e25e..75bfdd5 100644
--- a/lib/onebox/engine/audio_onebox.rb
+++ b/lib/onebox/engine/audio_onebox.rb
@@ -23,7 +23,7 @@ module Onebox
       end
 
       def placeholder_html
-        "<div class='onebox-placeholder-container'><span class='placeholder-icon audio'></span></div>"
+        ::Onebox::Helpers.audio_placeholder_html
       end
     end
   end
diff --git a/lib/onebox/engine/trello_onebox.rb b/lib/onebox/engine/trello_onebox.rb
index a13e7a6..0fc16ff 100644
--- a/lib/onebox/engine/trello_onebox.rb
+++ b/lib/onebox/engine/trello_onebox.rb
@@ -20,7 +20,7 @@ module Onebox
       end
 
       def placeholder_html
-        "<div class='onebox-placeholder-container'><span class='placeholder-icon generic'></span></div>"
+        ::Onebox::Helpers.generic_placeholder_html
       end
 
       private
diff --git a/lib/onebox/engine/typeform_onebox.rb b/lib/onebox/engine/typeform_onebox.rb
index 1f7aa95..d537fc6 100644
--- a/lib/onebox/engine/typeform_onebox.rb
+++ b/lib/onebox/engine/typeform_onebox.rb
@@ -22,7 +22,7 @@ module Onebox
       end
 
       def placeholder_html
-        "<div class='onebox-placeholder-container'><span class='placeholder-icon generic'></span></div>"
+        ::Onebox::Helpers.generic_placeholder_html
       end
 
       private
diff --git a/lib/onebox/engine/video_onebox.rb b/lib/onebox/engine/video_onebox.rb
index 9b894b5..c217f12 100644
--- a/lib/onebox/engine/video_onebox.rb
+++ b/lib/onebox/engine/video_onebox.rb
@@ -24,7 +24,7 @@ module Onebox
       end
 
       def placeholder_html
-        "<div class='onebox-placeholder-container'><span class='placeholder-icon video'></span></div>"
+        ::Onebox::Helpers.video_placeholder_html
       end
     end
   end
diff --git a/lib/onebox/engine/whitelisted_generic_onebox.rb b/lib/onebox/engine/whitelisted_generic_onebox.rb
index da56d90..fc7d2b7 100644
--- a/lib/onebox/engine/whitelisted_generic_onebox.rb
+++ b/lib/onebox/engine/whitelisted_generic_onebox.rb
@@ -190,8 +190,9 @@ module Onebox
 
       def placeholder_html
         return article_html if is_article?
-        return image_html   if has_image? && (is_video? || is_image?)
-        return article_html if has_text? && is_embedded?
+        return image_html if is_image?
+        return Onebox::Helpers.video_placeholder_html if is_video? || is_card?
+        return Onebox::Helpers.generic_placeholder_html if is_embedded?
         to_html
       end
 
diff --git a/lib/onebox/helpers.rb b/lib/onebox/helpers.rb
index 69d3c96..b5519de 100644
--- a/lib/onebox/helpers.rb
+++ b/lib/onebox/helpers.rb
@@ -236,5 +236,17 @@ module Onebox
       encoded += '#' + uri_query_encode(parts[:fragment]) unless parts[:fragment].nil?
       encoded
     end
+
+    def self.video_placeholder_html
+      "<div class='onebox-placeholder-container'><span class='placeholder-icon video'></span></div>"
+    end
+
+    def self.audio_placeholder_html
+      "<div class='onebox-placeholder-container'><span class='placeholder-icon audio'></span></div>"
+    end
+
+    def self.generic_placeholder_html
+      "<div class='onebox-placeholder-container'><span class='placeholder-icon generic'></span></div>"
+    end
   end
 end
diff --git a/lib/onebox/mixins/twitch_onebox.rb b/lib/onebox/mixins/twitch_onebox.rb
index df942e3..60e5d88 100644
--- a/lib/onebox/mixins/twitch_onebox.rb
+++ b/lib/onebox/mixins/twitch_onebox.rb
@@ -20,7 +20,7 @@ module Onebox
         end
 
         def placeholder_html
-          "<div class='onebox-placeholder-container'><span class='placeholder-icon video'></span></div>"
+          ::Onebox::Helpers.video_placeholder_html
         end
 
         def to_html

GitHub sha: b987f97e

1 Like