From c6bb414b57a2ae8c6927826b143027f5c43dada9 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 10 Jan 2025 18:22:23 -0500 Subject: Made uploading videos work --- app/assets/stylesheets/main/entries.scss | 4 ++++ app/models/blog.rb | 2 +- app/views/admin/blogs/_form.html.haml | 10 +++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/assets/stylesheets/main/entries.scss b/app/assets/stylesheets/main/entries.scss index 37b0a49..609a5f7 100644 --- a/app/assets/stylesheets/main/entries.scss +++ b/app/assets/stylesheets/main/entries.scss @@ -194,6 +194,10 @@ box-sizing: border-box; } + video { + max-width: 100%; + } + figure { background-color: #eee; border: 1px solid #bbb; diff --git a/app/models/blog.rb b/app/models/blog.rb index db05432..37b60dd 100644 --- a/app/models/blog.rb +++ b/app/models/blog.rb @@ -15,7 +15,7 @@ class Blog < ApplicationRecord validates :body, presence: true, if: :published validates :slug, presence: true, format: /\A[-a-z0-9]+\z/, if: :published validates :user, presence: true - validates :images, content_type: ['image/png', 'image/jpeg'] + validates :images, content_type: ['image/png', 'image/jpeg', 'video/mp4'] before_validation :set_draft_title before_save :set_published_at diff --git a/app/views/admin/blogs/_form.html.haml b/app/views/admin/blogs/_form.html.haml index f64ebe5..323d499 100644 --- a/app/views/admin/blogs/_form.html.haml +++ b/app/views/admin/blogs/_form.html.haml @@ -42,9 +42,13 @@ .details-module.image-uploads %h4 Images - f.object.images.each do |image| - = image_tag image.variant(:thumb) - = f.hidden_field :images, multiple: true, value: image.signed_id - %pre= rails_blob_url(image) + - if image.representable? + = image_tag image.variant(:thumb) + - else + = image.filename.to_s + - unless image.new_record? + = f.hidden_field :images, multiple: true, value: image.signed_id + %pre= rails_blob_url(image) %hr = f.file_field :images, multiple: true .details-module= f.submit -- cgit 1.4.1