From 7a8968d5beeb9dca2cca4e50a8e11d6b274deb50 Mon Sep 17 00:00:00 2001 From: Daniel Nitsikopoulos Date: Sun, 26 Feb 2023 10:11:45 +1100 Subject: [PATCH] Videos --- app/decorators/posts/decorator.rb | 14 +++++++++++++- app/templates/posts/show.html.slim | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/decorators/posts/decorator.rb b/app/decorators/posts/decorator.rb index b24f8f8..8124759 100644 --- a/app/decorators/posts/decorator.rb +++ b/app/decorators/posts/decorator.rb @@ -22,7 +22,19 @@ module Adamantium end def photos? - photos.count > 0 + __getobj__.photos.count { |p| !p["value"].end_with?("mp4") } > 0 + end + + def photos + __getobj__.photos.select { |p| !p["value"].end_with?("mp4") } + end + + def videos? + __getobj__.photos.count { |p| p["value"].end_with?("mp4") } > 0 + end + + def videos + __getobj__.photos.select { |p| p["value"].end_with?("mp4") } end def prefix_emoji diff --git a/app/templates/posts/show.html.slim b/app/templates/posts/show.html.slim index 585a34b..d15a0d3 100644 --- a/app/templates/posts/show.html.slim +++ b/app/templates/posts/show.html.slim @@ -5,6 +5,10 @@ article class="h-entry" = post.display_title article class="mb-12 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:text-gray-200 prose-a:text-blue-600 prose-a:no-underline hover:prose-a:underline prose-img:rounded" + - if post.videos? + - post.videos.each do |video| + video loop muted controls + source type="video/mp4" src=video["value"] - if post.photos? - post.photos.each do |photo| figure