about summary refs log tree commit diff stats
path: root/app
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2025-11-21 21:01:50 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2025-11-21 21:01:50 -0500
commit4a9bf38ef61b39e482458ba56cd1e6fea379b4d7 (patch)
treeed778402e454cbbb3945f453f6d1682f4701924a /app
parentc260fbba4ed7cd0e7b80d5ae1316f597f9abb827 (diff)
downloadthoughts-4a9bf38ef61b39e482458ba56cd1e6fea379b4d7.tar.gz
thoughts-4a9bf38ef61b39e482458ba56cd1e6fea379b4d7.tar.bz2
thoughts-4a9bf38ef61b39e482458ba56cd1e6fea379b4d7.zip
Added "listening to" box in sidebar
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/main/layout.scss11
-rw-r--r--app/controllers/application_controller.rb10
-rw-r--r--app/models/scrobble.rb2
-rw-r--r--app/views/layouts/application.html.haml10
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 @@
1class ApplicationController < ActionController::Base 1class 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
9end 19end
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 @@
1class Scrobble < ApplicationRecord
2end
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