-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Paginate Playlist History view; Install importmap and stimulus to con…
…trol the front end behavior; make the missing songs in the history link to archive.org
- Loading branch information
1 parent
b5f261b
commit aec54a5
Showing
26 changed files
with
265 additions
and
61 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
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,3 +1,5 @@ | ||
//= link_tree ../images | ||
//= link_directory ../javascripts .js | ||
//= link_directory ../stylesheets .css | ||
//= link_tree ../../javascript .js | ||
//= link_tree ../../../vendor/javascript .js |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
import "controllers" |
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,9 @@ | ||
import { Application } from "@hotwired/stimulus" | ||
|
||
const application = Application.start() | ||
|
||
// Configure Stimulus development experience | ||
application.debug = false | ||
window.Stimulus = application | ||
|
||
export { application } |
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,4 @@ | ||
// Import and register all your controllers from the importmap via controllers/**/*_controller | ||
import { application } from "./application" | ||
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading" | ||
eagerLoadControllersFrom("controllers", application) |
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,35 @@ | ||
import { Controller } from "@hotwired/stimulus"; | ||
|
||
export default class extends Controller { | ||
static targets = ["button", "timeline", "loading"]; | ||
|
||
initialize() { | ||
this.loading = false; | ||
} | ||
|
||
loadMore(event) { | ||
event.preventDefault(); | ||
|
||
if (this.loading) return; | ||
|
||
this.loading = true; | ||
this.loadingTarget.style.display = "block"; // Show loading indicator | ||
|
||
const url = this.buttonTarget.getAttribute("href"); | ||
|
||
if (url) { | ||
fetch(url, { headers: { "X-Requested-With": "XMLHttpRequest" } }) | ||
.then(response => response.text()) | ||
.then(html => { | ||
this.buttonTarget.remove(); // Remove the old "Load More" button from the page | ||
this.timelineTarget.insertAdjacentHTML("beforeend", html); // Append new items | ||
// this.updateButtonUrl(); | ||
}) | ||
.catch(error => console.error("Error loading more items:", error)) | ||
.finally(() => { | ||
this.loading = false; | ||
this.loadingTarget.style.display = "none"; // Hide loading indicator | ||
}); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<div class="card"> | ||
<div class="info"> | ||
<h3 class="title"><%= delta[:created_at].strftime("%b %d, %Y") %></h3> | ||
|
||
<% if delta[:added].present? %> | ||
<div> | ||
<h5>Added</h5> | ||
<ul> | ||
<% delta[:added].each do |song| %> | ||
<% if ["private video", "deleted video"].include?(song["title"].downcase) %> | ||
<li><a href="https://web.archive.org/web/*/<%= song["url"] %>" target="_blank" rel="noopener noreferrer">Song Removed - Click to look up an archive for the link.</a></li> | ||
<% else %> | ||
<li><a href="<%= song["url"] %>" target="_blank" rel="noopener noreferrer"><%= song["title"] %></a></li> | ||
<% end %> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<% if delta[:removed].present? %> | ||
<div> | ||
<h5>Removed</h5> | ||
<ul> | ||
<% delta[:removed].each do |song| %> | ||
<% if ["private video", "deleted video"].include?(song["title"].downcase) %> | ||
<li><a href="https://web.archive.org/web/*/<%= song["url"] %>" target="_blank" rel="noopener noreferrer">Song Removed - Click to look up an archive for the link.</a></li> | ||
<% else %> | ||
<li><a href="https://web.archive.org/web/*/<%= song["url"] %>" target="_blank" rel="noopener noreferrer"><%= song["title"] %></a></li> | ||
<% end %> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> |
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,3 @@ | ||
<%= render partial: 'delta_card', collection: @history[:changes], as: :delta %> | ||
|
||
<%= render partial: 'load_more_history_button', locals: {history: @history, params: params} %> |
8 changes: 8 additions & 0 deletions
8
app/views/playlist_history/_load_more_history_button.html.erb
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,8 @@ | ||
<%= | ||
link_to('Load More', | ||
load_more_history_path(playlist_id: params[:playlist_id], page: history[:changes].next_page), | ||
remote: true, | ||
id: 'load-more', | ||
class: 'btn btn-primary', | ||
data: { action: "click->load-more#loadMore", load_more_target: "button" }) if history[:changes].next_page | ||
%> |
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
49 changes: 49 additions & 0 deletions
49
app/views/playlist_history/renaming_show_to_test_slim_vs_erb_speeds.show.html.slim
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,49 @@ | ||
h1 History for #{@history[:name]} | ||
- start_time = Time.now | ||
- puts "Started building view at: #{start_time}" | ||
/ | ||
/ .timeline | ||
/ .outer | ||
/ - @history[:changes].each do |change| | ||
/ .card | ||
/ .info | ||
/ h3.title #{change[:start_date].strftime("%b %d, %Y")} - #{change[:end_date].strftime("%b %d, %Y")} | ||
/ | ||
/ - if change[:added].present? | ||
/ div | ||
/ h5 Added | ||
/ ul | ||
/ - change[:added].each do |song| | ||
/ li = song | ||
/ | ||
/ - if change[:removed].present? | ||
/ div | ||
/ h5 Removed | ||
/ ul | ||
/ - change[:removed].each do |song| | ||
/ li = song | ||
.timeline | ||
.outer | ||
- @history[:changes].each do |delta| | ||
.card | ||
.info | ||
h3.title #{delta.playlist_snapshot.created_at.strftime("%b %d, %Y")} | ||
|
||
- if delta.added.present? | ||
div | ||
h5 Added | ||
ul | ||
- delta.added.each do |song| | ||
li = song["title"] | ||
|
||
- if delta.removed.present? | ||
div | ||
h5 Removed | ||
ul | ||
- delta.removed.each do |song| | ||
li = song["title"] | ||
|
||
- finish_time = Time.now | ||
- puts "Finished building view at: #{finish_time}" | ||
- puts "Built view in: #{finish_time - start_time}s" |
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,10 @@ | ||
<h1>History for <%= @history[:name] %></h1> | ||
<div class="timeline" data-controller="load-more" data-load-more-target="timeline"> | ||
<div class="outer"> | ||
<%= render partial: "delta_card", collection: @history[:changes], as: :delta %> | ||
</div> | ||
|
||
<div id="loading" data-load-more-target="loading" style="display: none;">Loading more items...</div> | ||
|
||
<%= render partial: 'load_more_history_button', locals: {history: @history, params: params} %> | ||
</div> |
This file was deleted.
Oops, something went wrong.
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,4 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require_relative "../config/application" | ||
require "importmap/commands" |
Oops, something went wrong.