Skip to content

Commit

Permalink
WIP: Embedded player for social media
Browse files Browse the repository at this point in the history
  • Loading branch information
floehopper committed Aug 9, 2024
1 parent 74f7bc9 commit 464a090
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/controllers/tracks_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions app/policies/track_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ def move_lower?
def reorder?
record.unpublished? && move_lower? && move_higher?
end

def player?
true
end
end
42 changes: 42 additions & 0 deletions app/views/tracks/player.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= 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? %>
</head>

<style>
.player {
width: 100vw;
height: 100vh;
background-image: url('<%= cdn_url(@album.cover.representation(resize_to_limit: [750, 750])) %>');
background-size: cover;
background-position: 50% 50%;
}

.footer {
position: absolute;
right: 0;
bottom: 3%;
left: 3%;
}
</style>

<body>
<div class="player">
<div class="footer">
<span class="text-white bg-slate-600 px-2 py-1">
<%= text_link_to @album.title, artist_album_url(@album.artist, @album) %> by <%= @album.artist.name %>
</span>
<span></span>
</div>
</div>
</body>
</html>
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
member do
post 'move_higher'
post 'move_lower'
get 'player'
end
end

Expand Down

0 comments on commit 464a090

Please sign in to comment.