-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clipboard sharer, like & repost button
- Loading branch information
Showing
23 changed files
with
299 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
class LikesController < ApplicationController | ||
def create | ||
@track = Track.friendly.find(params[:track_id]) | ||
@button_class = current_user.toggle_like!(@track) ? "button-active" : "button" | ||
@resource = find_resource | ||
@button_class = current_user.toggle_like!(@resource) ? "button-active" : "button" | ||
end | ||
|
||
def find_resource | ||
if params[:track_id] | ||
@resource = Track.friendly.find(params[:track_id]) | ||
elsif params[:playlist_id] | ||
@resource = Playlist.friendly.find(params[:playlist_id]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class SharerController < ApplicationController | ||
|
||
before_action :authenticate_user!, except: [:index, :show ] | ||
|
||
def new | ||
@resource, @resource_path = find_resource | ||
|
||
@button_class = "button" | ||
end | ||
|
||
def find_resource | ||
if params[:track_id] | ||
resource = Track.friendly.find(params[:track_id]) | ||
[ resource, track_embed_url(resource)] | ||
elsif params[:playlist_id] | ||
resource = Playlist.friendly.find(params[:playlist_id]) | ||
[ resource, playlist_embed_url(resource)] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module SharerHelper | ||
end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
<%= turbo_frame_tag "repost-frame-item-#{track.id}", "data-turbo": true do %> | ||
<%= button_to track_reposts_path(track), | ||
<% resource = local_assigns[:track] || local_assigns[:playlist] %> | ||
<% path = resource.is_a?(Track) ? track_reposts_path(resource) : playlist_reposts_path(resource) %> | ||
<%= turbo_frame_tag "repost-frame-item-#{resource.id}", "data-turbo": true do %> | ||
<%= button_to path, | ||
class: local_assigns[:button_class], | ||
"data-method": "post", | ||
"data-confirm": "Are you sure?" do %> | ||
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" viewBox="0 0 20 20" fill="currentColor"> | ||
<path fill-rule="evenodd" d="M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z" clip-rule="evenodd"></path> | ||
</svg> | ||
<span class="hidden sm:block">Repostar</span> | ||
<span class="hidden sm:block"><%= t("repost") %></span> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<% path = resource.is_a?(Track) ? new_track_sharer_path(resource) : new_playlist_sharer_path(resource) %> | ||
<%= turbo_frame_tag "share-frame-item-#{resource.id}", "data-turbo": true do %> | ||
<%= link_to path, | ||
"data-turbo-frame": "modal", | ||
class: local_assigns[:button_class] || "button" do %> | ||
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" viewBox="0 0 20 20" fill="currentColor"> | ||
<path d="M15 8a3 3 0 10-2.977-2.63l-4.94 2.47a3 3 0 100 4.319l4.94 2.47a3 3 0 10.895-1.789l-4.94-2.47a3.027 3.027 0 000-.74l4.94-2.47C13.456 7.68 14.19 8 15 8z"></path> | ||
</svg> | ||
<span class="hidden sm:block"><%= t("share") %></span> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
<%= turbo_frame_tag "modal" do %> | ||
<%= render "shared/modal" do %> | ||
|
||
<div class="space-y-8 divide-y divide-gray-200 dark:divide-gray-800 sm:space-y-5"> | ||
<div class="mx-2 py-6"> | ||
<div class="relative"> | ||
<nav class="flex space-x-4 mt-2" aria-label="Tabs" data-controller="tabs"> | ||
<a | ||
href="#" | ||
data-tab="#share-tab" | ||
data-action="click->tabs#changeTab" | ||
class="tab-link bg-brand-100 text-brand-700 px-3 py-2 font-medium text-sm rounded-md" | ||
> | ||
<%= t("sharer.share") %> | ||
</a> | ||
<a | ||
href="#" | ||
data-tab="#embed-tab" | ||
data-action="click->tabs#changeTab" | ||
class="tab-link text-brand-500 hover:text-brand-700 px-3 py-2 font-medium text-sm rounded-md" | ||
> | ||
<%= t("sharer.embed") %> | ||
</a> | ||
<a | ||
href="#" | ||
data-tab="#message-tab" | ||
data-action="click->tabs#changeTab" | ||
class="hidden tab-link text-brand-500 hover:text-brand-700 px-3 py-2 font-medium text-sm rounded-md" | ||
> | ||
<%= t("sharer.message") %> | ||
</a> | ||
</nav> | ||
|
||
<section id="share-tab" class="tab-pane block py-4"> | ||
<h2 class="mx-0 mt-0 mb-4 font-sans text-base font-bold leading-none"> | ||
<%= t("sharer.private_share") %> | ||
</h2> | ||
<div class="mb-4 text-zinc-800 dark:text-gray-100"> | ||
<div class="flex items-center space-x-3"> | ||
<input | ||
type="text" | ||
value="<%= track_url(@resource, format: :private, utm_source: 'clipboard', utm_campaign: 'social_sharing', utm_medium: 'text') %>" | ||
class="shadow-sm focus:ring-brand-500 focus:border-brand-500 block w-full sm:text-sm border-gray-300 rounded-md dark:bg-gray-900 dark:text-gray-100" | ||
readonly="readonly" | ||
/> | ||
<label class="flex items-center space-x-2"> | ||
<input | ||
type="checkbox" | ||
id="" | ||
name="share_from" | ||
class="focus:ring-brand-500 h-4 w-4 text-brand-600 border-gray-300 rounded" | ||
/> | ||
<span class=""><%= t("sharer.at") %></span> | ||
</label> | ||
<input | ||
type="text" | ||
value="0:00" | ||
class="w-1/4 shadow-sm focus:ring-brand-500 focus:border-brand-500 block w-full sm:text-sm border-gray-300 rounded-md dark:bg-gray-900 dark:text-gray-100" | ||
/> | ||
</div> | ||
</div> | ||
<div class="text-sm text-gray-700 dark:text-gray-300 py-2"> | ||
<%= t("sharer.private_share_instructions") %> | ||
</div> | ||
<div class="hidden mb-4 text-brand-600 dark:text-brand-400"> | ||
<%= t("sharer.reset_link_warning") %> | ||
</div> | ||
<div class="hidden visible py-1 px-0 mb-4 font-sans text-xs text-red-700 opacity-100"> | ||
<%= t("sharer.link_reset_error") %> | ||
</div> | ||
<div class="text-zinc-800"> | ||
<button | ||
type="button" | ||
class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-brand-600 hover:bg-brand-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-brand-500" | ||
> | ||
<%= t("sharer.reset_secret_link") %> | ||
</button> | ||
<div class="hidden"> | ||
<button | ||
type="button" | ||
class="inline-block relative py-px pr-3 pl-2 m-0 h-6 font-sans text-sm font-thin leading-5 text-center text-white whitespace-nowrap bg-brand-600 rounded-sm border border-brand-600 border-solid cursor-pointer select-none box-border focus:border-brand-600 focus:bg-brand-600 focus:text-white hover:border-brand-600 hover:bg-brand-600 hover:text-white" | ||
> | ||
<%= t("sharer.reset") %> | ||
</button> | ||
<button | ||
type="button" | ||
class="inline-block relative py-1 pr-3 pl-2 m-0 h-6 font-sans text-sm font-thin leading-5 text-center whitespace-nowrap bg-none rounded-sm border-0 border-solid cursor-pointer select-none box-border border-neutral-200 focus:border-0 focus:border-stone-300 focus:bg-none focus:py-1 focus:text-zinc-800 hover:border-0 hover:border-stone-300 hover:bg-none hover:py-1 hover:text-zinc-800" | ||
> | ||
<%= t("sharer.cancel") %> | ||
</button> | ||
</div> | ||
</div> | ||
<div class="hidden text-zinc-800"> | ||
<%= t("sharer.secret_link_reset_success") %> | ||
</div> | ||
</section> | ||
|
||
<section id="embed-tab" class="tab-pane hidden py-4"> | ||
<h2 class="mx-0 mt-0 mb-4 font-sans text-base font-bold leading-none"> | ||
<%= t("sharer.embed") %> | ||
</h2> | ||
<div> | ||
<div | ||
data-controller="clipboard" | ||
data-clipboard-success-content="Copied!" | ||
class="mt-1 flex rounded-md shadow-sm" | ||
> | ||
<input | ||
type="text" | ||
value="<%= @resource.iframe_code_string(@resource_path) %>" | ||
data-clipboard-target="source" | ||
readonly="" | ||
class="py-2 border-0 focus:ring-brand-500 focus:border-brand-500 flex-1 block w-full rounded-none rounded-l-md sm:text-sm border-gray-300 rounded-md dark:bg-gray-900 dark:text-gray-100" | ||
/> | ||
<span | ||
data-clipboard-target="trigger" | ||
data-action="clipboard#copy" | ||
class="cursor-pointer inline-flex items-center px-4 py-2 border border-l-0 border-gray-300 bg-gray-50 text-gray-500 text-sm rounded-md hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-brand-500" | ||
> | ||
<%= t("sharer.copy") %> | ||
</span> | ||
</div> | ||
</div> | ||
</section> | ||
|
||
<section id="message-tab" class="tab-pane hidden py-4"> | ||
<h2 class="mx-0 mt-0 mb-4 font-sans text-base font-bold leading-none"> | ||
<%= t("sharer.message") %> | ||
</h2> | ||
<div class="text-zinc-800"> | ||
<%= t("sharer.message_placeholder") %> | ||
</div> | ||
</section> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<% end %> | ||
<% end %> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.