Skip to content

Commit

Permalink
skip bullet for search results page
Browse files Browse the repository at this point in the history
  • Loading branch information
BlazingRockStorm committed Nov 4, 2023
1 parent 89bfac9 commit 61fd3c7
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 16 deletions.
10 changes: 10 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ def not_found
render404
end

private

def skip_bullet
previous_value = Bullet.enable?
Bullet.enable = false
yield
ensure
Bullet.enable = previous_value
end

def render404
render file: Rails.public_path.join('404.html').to_s, status: :not_found
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

class HomeController < ApplicationController
around_action :skip_bullet, only: :search_results, if: -> { defined?(Bullet) }
PAGE_LIMIT = 10

def index
Expand Down
50 changes: 34 additions & 16 deletions app/views/home/search_results.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,53 @@
.container-fluid
.row.mt-2.lyrics-site-content
main.col-md-9.col-lg-10
p
h2
| Searched results for
strong = params[:search]
- if params[:target] == 'Song'
- @results.each do |song|
p
strong = link_to song.name, song_path(song)
p = artists_list song.artists
p
strong Views:
= song.views_count
.card.mb-2
.card-title
h3 = song.name
.card-body
p
= artists_list song.artists
p
= song.genre.name
p
= song.album.name if song.album
p
= song.tempo.to_s + ' BPM'
p
= link_to 'View lyrics', song_path(song)

- if params[:target] == 'Artist'
- @results.each do |artist|
p
strong = link_to artist.name, artist_path(artist)
p
strong Biography:
= artist.biography
.card.mb-2
.card-body
p
strong = link_to artist.name, artist_path(artist)
p
strong Biography:
= artist.biography

- if params[:target] == 'Genre'
- @results.each do |genre|
p
strong = link_to genre.name, genre_path(genre)
.card.mb-2
.card-body
p
= link_to genre.name, genre_path(genre)

- if params[:target] == 'Album'
- @results.each do |album|
p
strong = link_to album.name, album_path(album)
.card.mb-2
.card-body
p
= link_to album.name, album_path(album)
p
= album.artist.name
p
= album.release_year

= paginate @results, theme: 'bootstrap-5'

Expand Down

0 comments on commit 61fd3c7

Please sign in to comment.