-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from bkeepers/browse
Browse
- Loading branch information
Showing
119 changed files
with
11,702 additions
and
243 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# https://www.theaudiodb.com/api_guide.php | ||
THEAUDIODB_API_KEY=2 |
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 |
---|---|---|
|
@@ -44,3 +44,5 @@ node_modules | |
*.local | ||
.DS_Store | ||
|
||
.env | ||
app/frontend/components.d.ts |
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,3 @@ | ||
web: puma -C config/puma.rb | ||
release: rails db:migrate | ||
worker: bundle exec good_job start |
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,2 +1,3 @@ | ||
web: bin/rails s | ||
vite: bin/vite dev | ||
worker: bundle exec good_job start |
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,17 @@ | ||
class Api::AlbumsController < ApiController | ||
before_action :set_artist, only: :index | ||
|
||
def index | ||
@albums = @artist.albums.order_by_popular.limit(10) | ||
end | ||
|
||
def show | ||
@album = Album.find(params[:id]) | ||
end | ||
|
||
private | ||
|
||
def set_artist | ||
@artist = Artist.find(params[:artist_id]) | ||
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,16 @@ | ||
class Api::ArtistsController < ApiController | ||
before_action :set_artist, only: %i[show] | ||
|
||
def index | ||
@artists = params[:letter] ? Artist.starts_with(:name, params[:letter]) : Artist.all | ||
end | ||
|
||
def show | ||
end | ||
|
||
private | ||
|
||
def set_artist | ||
@artist = Artist.find(params[:id]) | ||
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 @@ | ||
class Api::AutocompleteController < ApiController | ||
def index | ||
case params[:type] | ||
when "title" | ||
@results = Track.includes(:album, :artist).starts_with(:title, params[:query]).limit(10) | ||
when "artist" | ||
@results = Artist.starts_with(:name, params[:query]).limit(10) | ||
else | ||
render json: "Unknown type: #{params[:type].inspect}", status: :unprocessable_entity | ||
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,9 @@ | ||
class Api::GenresController < ApiController | ||
def index | ||
@genres = Genre.order_by_popular.all | ||
end | ||
|
||
def show | ||
@genre = Genre.find(params[:id]) | ||
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,8 @@ | ||
class Api::SearchController < ApiController | ||
def index | ||
@results = PgSearch.multisearch(params[:q]).limit(10).with_pg_search_rank | ||
unless params[:type].blank? | ||
@results = @results.where(searchable_type: params[:type].split(",").map { |type| type.singularize.titleize }) | ||
end | ||
end | ||
end |
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,54 @@ | ||
class Api::SongsheetsController < ApiController | ||
before_action :set_songsheet, only: %i[show update destroy] | ||
|
||
# GET /songsheets.json | ||
def index | ||
@songsheets = if params[:letter] | ||
current_scope.starts_with(:title, params[:letter]) | ||
else | ||
current_scope.recent | ||
end | ||
end | ||
|
||
# GET /songsheets/1.json | ||
def show | ||
end | ||
|
||
# POST /songsheets.json | ||
def create | ||
@songsheet = Songsheet.new(songsheet_params) | ||
|
||
if @songsheet.save | ||
render :show, status: :created, location: [:api, @songsheet] | ||
else | ||
render json: @songsheet.errors, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
# PATCH/PUT /songsheets/1.json | ||
def update | ||
if @songsheet.update(songsheet_params) | ||
render :show, status: :ok, location: [:api, @songsheet] | ||
else | ||
render json: @songsheet.errors, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
# DELETE /songsheets/1.json | ||
def destroy | ||
@songsheet.destroy | ||
head :no_content, location: api_songsheets_url | ||
end | ||
|
||
private | ||
|
||
# Use callbacks to share common setup or constraints between actions. | ||
def set_songsheet | ||
@songsheet = Songsheet.find(params[:id]) | ||
end | ||
|
||
# Only allow a list of trusted parameters through. | ||
def songsheet_params | ||
params.require(:songsheet).permit(:source, metadata: {}) | ||
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,5 @@ | ||
class Api::TracksController < ApiController | ||
def index | ||
@tracks = current_scope.order_by_popular.limit(12) | ||
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,24 @@ | ||
class ApiController < ActionController::API | ||
private | ||
|
||
# Return the current scope based on current controller and route | ||
# | ||
# For example, in the `Api::SongsheetsController`, a request to | ||
# `GET /api/artists/:artist_id/songsheets` will return | ||
# `Artist.find(params[:artist_id]).songsheets`. | ||
# | ||
def current_scope | ||
@current_scope ||= %w[track album artist].detect do |name| | ||
id = params["#{name}_id"] | ||
break name.classify.constantize.find(id).send(default_scope_name) if id | ||
end || default_scope | ||
end | ||
|
||
def default_scope_name | ||
controller_name | ||
end | ||
|
||
def default_scope | ||
controller_name.singularize.classify.constantize | ||
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,17 @@ | ||
module AlphaPaginate | ||
extend ActiveSupport::Concern | ||
|
||
LETTERS = ["#"] + ("A".."Z").to_a | ||
|
||
included do | ||
scope :starts_with, ->(key, letter) { | ||
result = if letter == "#" | ||
where(arel_table[key].matches_regexp("^[0-9]")) | ||
else | ||
where(arel_table[key].matches(letter + "%")) | ||
end | ||
|
||
result.order(key) | ||
} | ||
end | ||
end |
Oops, something went wrong.