diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/assets/stylesheets/main/layout.scss | 11 | ||||
| -rw-r--r-- | app/controllers/application_controller.rb | 10 | ||||
| -rw-r--r-- | app/models/scrobble.rb | 2 | ||||
| -rw-r--r-- | app/views/layouts/application.html.haml | 10 |
4 files changed, 33 insertions, 0 deletions
| diff --git a/app/assets/stylesheets/main/layout.scss b/app/assets/stylesheets/main/layout.scss index ef31ada..d5fe7a7 100644 --- a/app/assets/stylesheets/main/layout.scss +++ b/app/assets/stylesheets/main/layout.scss | |||
| @@ -228,3 +228,14 @@ h2.centered { | |||
| 228 | text-decoration: none; | 228 | text-decoration: none; |
| 229 | } | 229 | } |
| 230 | } | 230 | } |
| 231 | |||
| 232 | #scrobble-box { | ||
| 233 | img { | ||
| 234 | margin: 0 auto; | ||
| 235 | display: block; | ||
| 236 | } | ||
| 237 | |||
| 238 | p { | ||
| 239 | text-align: center; | ||
| 240 | } | ||
| 241 | } | ||
| diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0174cae..ad46fb9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb | |||
| @@ -1,9 +1,19 @@ | |||
| 1 | class ApplicationController < ActionController::Base | 1 | class ApplicationController < ActionController::Base |
| 2 | protect_from_forgery with: :exception | 2 | protect_from_forgery with: :exception |
| 3 | before_action :choose_random_song | ||
| 3 | 4 | ||
| 4 | private | 5 | private |
| 5 | 6 | ||
| 6 | def after_sign_out_path_for(resource) | 7 | def after_sign_out_path_for(resource) |
| 7 | new_session_path(resource) | 8 | new_session_path(resource) |
| 8 | end | 9 | end |
| 10 | |||
| 11 | def choose_random_song | ||
| 12 | ids = Scrobble.ids | ||
| 13 | if ids.empty? | ||
| 14 | @random_song = nil | ||
| 15 | else | ||
| 16 | @random_song = Scrobble.find(ids.sample) | ||
| 17 | end | ||
| 18 | end | ||
| 9 | end | 19 | end |
| diff --git a/app/models/scrobble.rb b/app/models/scrobble.rb new file mode 100644 index 0000000..f527612 --- /dev/null +++ b/app/models/scrobble.rb | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | class Scrobble < ApplicationRecord | ||
| 2 | end | ||
| diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 1d0bea3..6bc7041 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml | |||
| @@ -73,6 +73,16 @@ | |||
| 73 | %li | 73 | %li |
| 74 | = image_tag "feed.png" | 74 | = image_tag "feed.png" |
| 75 | = link_to "Atom feed", blogs_url(format: :atom) | 75 | = link_to "Atom feed", blogs_url(format: :atom) |
| 76 | - unless @random_song.nil? | ||
| 77 | .sidebar-module#scrobble-box | ||
| 78 | .bubble.rounded | ||
| 79 | %h2 Listening to | ||
| 80 | = image_tag @random_song.image, width: "174px" | ||
| 81 | %p | ||
| 82 | %strong= @random_song.title | ||
| 83 | by | ||
| 84 | = @random_song.artist | ||
| 85 | %p= @random_song.album | ||
| 76 | .sidebar-module | 86 | .sidebar-module |
| 77 | .bubble.rounded | 87 | .bubble.rounded |
| 78 | %h2 Meta | 88 | %h2 Meta |
