From 464a09064360fabc304eeafcad8a42851c610ec5 Mon Sep 17 00:00:00 2001 From: James Mead Date: Fri, 9 Aug 2024 15:18:04 +0100 Subject: [PATCH] WIP: Embedded player for social media --- app/controllers/tracks_controller.rb | 8 +++++- app/policies/track_policy.rb | 4 +++ app/views/tracks/player.html.erb | 42 ++++++++++++++++++++++++++++ config/routes.rb | 1 + 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 app/views/tracks/player.html.erb diff --git a/app/controllers/tracks_controller.rb b/app/controllers/tracks_controller.rb index 18512879..b43332b1 100644 --- a/app/controllers/tracks_controller.rb +++ b/app/controllers/tracks_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class TracksController < ApplicationController - before_action :set_track, only: %i[move_higher move_lower] + before_action :set_track, only: %i[move_higher move_lower player] def move_higher authorize @track @@ -19,6 +19,12 @@ def move_lower redirect_to artist_album_path(@track.artist, @track.album) end + def player + authorize @track + @album = @track.album + render layout: false + end + private def set_track diff --git a/app/policies/track_policy.rb b/app/policies/track_policy.rb index 0d6b6593..820e90de 100644 --- a/app/policies/track_policy.rb +++ b/app/policies/track_policy.rb @@ -12,4 +12,8 @@ def move_lower? def reorder? record.unpublished? && move_lower? && move_higher? end + + def player? + true + end end diff --git a/app/views/tracks/player.html.erb b/app/views/tracks/player.html.erb new file mode 100644 index 00000000..f5b28b17 --- /dev/null +++ b/app/views/tracks/player.html.erb @@ -0,0 +1,42 @@ + + + + + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + <%= display_meta_tags site: "jam.coop" %> + <%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %> + + <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> + <%= javascript_importmap_tags %> + <%= hotwire_livereload_tags if Rails.env.development? %> + + + + + +
+ +
+ + diff --git a/config/routes.rb b/config/routes.rb index 1cb37ef3..2ebe61a9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -55,6 +55,7 @@ member do post 'move_higher' post 'move_lower' + get 'player' end end