the_little_streamer 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/the_little_streamer +33 -12
- metadata +3 -3
data/bin/the_little_streamer
CHANGED
@@ -51,9 +51,10 @@ def css
|
|
51
51
|
end
|
52
52
|
|
53
53
|
#Create a link
|
54
|
-
def link root, path, text = path
|
54
|
+
def link root, path, text = path, params = {}
|
55
55
|
full_path = root.split('/').map! {|r| CGI.escape r }.join('/') << "/" << CGI.escape(path)
|
56
|
-
|
56
|
+
params = params.map { |k, v| "#{k}=#{v}" }.join "&"
|
57
|
+
"<a href=\"#{full_path}?#{params}\">#{text}</a>"
|
57
58
|
end
|
58
59
|
|
59
60
|
#Audio tag
|
@@ -114,12 +115,23 @@ def prev_and_next
|
|
114
115
|
end
|
115
116
|
|
116
117
|
#HTML for playing all songs by artist
|
117
|
-
def play_artist artist
|
118
|
+
def play_artist artist, order = "normal"
|
118
119
|
songs = []
|
119
120
|
|
120
|
-
|
121
|
-
|
122
|
-
|
121
|
+
case order
|
122
|
+
when "random"
|
123
|
+
Music[artist].each_value do |album|
|
124
|
+
album.each_value do |song|
|
125
|
+
songs << song
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
songs.shuffle!
|
130
|
+
else
|
131
|
+
Music[artist].each_value do |album|
|
132
|
+
album.values.sort_by { |s| s.track }.each do |song|
|
133
|
+
songs << song
|
134
|
+
end
|
123
135
|
end
|
124
136
|
end
|
125
137
|
|
@@ -132,8 +144,14 @@ def play_artist artist
|
|
132
144
|
end
|
133
145
|
|
134
146
|
#HTML for playing all songs on an album
|
135
|
-
def play_album artist, album
|
136
|
-
|
147
|
+
def play_album artist, album, order = "normal"
|
148
|
+
|
149
|
+
case order
|
150
|
+
when "random"
|
151
|
+
songs = Music[artist][album].values.shuffle!
|
152
|
+
else
|
153
|
+
songs = Music[artist][album].values.sort_by { |s| s.track }
|
154
|
+
end
|
137
155
|
|
138
156
|
html <<-HTML
|
139
157
|
#{song_info songs.first}<br/>
|
@@ -199,7 +217,9 @@ get '/artist/:artist/?' do |artist|
|
|
199
217
|
unless Music[artist].empty?
|
200
218
|
path = "/artist/#{artist}/album/"
|
201
219
|
html Music[artist].keys.sort.map { |a| link path, a }.join("<br/>") << "<br/><br/>" <<
|
202
|
-
link("/artist/#{artist}/", "play", "Play All")
|
220
|
+
link("/artist/#{artist}/", "play", "Play All") << " - " <<
|
221
|
+
link("/artist/#{artist}/", "play", "Randomly", :order => :random)
|
222
|
+
|
203
223
|
else
|
204
224
|
html "Could not find <b>#{artist}</b>."
|
205
225
|
end
|
@@ -208,7 +228,7 @@ end
|
|
208
228
|
#Play songs by given artist
|
209
229
|
get '/artist/:artist/play/?' do |artist|
|
210
230
|
unless Music[artist].empty?
|
211
|
-
play_artist artist
|
231
|
+
play_artist artist, params["order"]
|
212
232
|
else
|
213
233
|
html "Could not find <b>#{artist}</b>."
|
214
234
|
end
|
@@ -219,7 +239,8 @@ get '/artist/:artist/album/:album/?' do |artist, album|
|
|
219
239
|
unless Music[artist][album].empty?
|
220
240
|
path = "/artist/#{artist}/album/#{album}/song/"
|
221
241
|
html Music[artist][album].values.sort_by { |s| s.track || 0}.map { |s| link path, s.title }.join("<br/>") << "<br/><br/>" <<
|
222
|
-
link("/artist/#{artist}/album/#{album}/", "play", "Play All")
|
242
|
+
link("/artist/#{artist}/album/#{album}/", "play", "Play All") << " - " <<
|
243
|
+
link("/artist/#{artist}/album/#{album}/", "play", "Randomly", :order => :random)
|
223
244
|
else
|
224
245
|
html "Could not find <b>#{album}</b> for <b>#{artist}</b>."
|
225
246
|
end
|
@@ -228,7 +249,7 @@ end
|
|
228
249
|
#Play all songs from a given album
|
229
250
|
get '/artist/:artist/album/:album/play/?' do |artist, album|
|
230
251
|
if Music[artist][album]
|
231
|
-
play_album artist, album
|
252
|
+
play_album artist, album, params["order"]
|
232
253
|
else
|
233
254
|
html "Could not find <b>#{album}</b> by <b>#{artist}</b>."
|
234
255
|
end
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.2
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Collins
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-25 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|