the_little_streamer 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba04105936f88f2cea71bf565934e892590cbf6f
4
- data.tar.gz: 7da1b197bfc2e8ddac3bf5f3cee5faad14a09b8a
3
+ metadata.gz: b03679acd1ab6444fbfc9cfc7a12bf121bfba39e
4
+ data.tar.gz: ce0b49c91defdfeb426e71a5f74908239b009edd
5
5
  SHA512:
6
- metadata.gz: b8ba19974db05fc9e901b76a06945e6f01eac9954bff693baf50060a80593375b8456084967e585cee38c21e8defb4a93d522702f9bced89847ba7f9a87f359f
7
- data.tar.gz: e249d40b2a7ab750448890d33c3226e5c16d038c574a9abb59f9aa8d973f6552e4b5d780212d3e1c4546a3af47123b54d3be0d20dc9d02219c6f83a28b629e64
6
+ metadata.gz: da677439965af7e19dce818aaf4154eaa14572e195164bf88a748a612c9d176e37000e34627ff95bb7acb44c06d15326f1dc2a20cb4e080eca4c45b203a955dd
7
+ data.tar.gz: 2af892f229291e69ef1f6d872836e2e1f0cdda49ea2265c04e3826c02524df2378081f83ddde69cc969b67620f8959b7bf7ca1cc83ea743988166e1eebec6de1
@@ -1,4 +1,6 @@
1
1
  class TLS::Music
2
+ attr_reader :songs
3
+
2
4
  def initialize finder
3
5
  #Hash three levels deep for artist, album, and song
4
6
  @music = Hash.new do |h,k|
@@ -29,10 +31,6 @@ class TLS::Music
29
31
  end
30
32
  end
31
33
 
32
- def all_songs
33
- @songs
34
- end
35
-
36
34
  def has? artist, album = nil, title = nil
37
35
  not self[artist, album, title].empty?
38
36
  end
@@ -8,9 +8,9 @@ class TLS::Player
8
8
  def play_all limit = 100, order = "normal"
9
9
  case order
10
10
  when "random"
11
- songs = @music.all_songs.shuffle
11
+ songs = @music.songs.shuffle
12
12
  else
13
- songs = @music.all_songs
13
+ songs = @music.songs
14
14
  end
15
15
 
16
16
  player_html songs[0..limit.to_i]
@@ -82,7 +82,6 @@ class TLS::Player
82
82
  #{link("/", "all", "10", :limit => 10, :order => :random)}
83
83
  #{link("/", "all", "50", :limit => 50, :order => :random) }
84
84
  #{link("/", "all", "100", :limit => 100, :order => :random) })
85
- #{search_box}
86
85
  <br/><hr/>
87
86
  #{@music.artist_names.map { |a| link path, a }.join "<br/>"}
88
87
  <br/><br/>
@@ -93,13 +92,16 @@ class TLS::Player
93
92
  if @music.has? artist
94
93
  path = "/artist/#{artist}/album/"
95
94
 
96
- page <<-HTML
95
+ puts "making page"
96
+ x = page <<-HTML
97
97
  #{title(artist)}
98
98
  #{@music.album_names_by(artist).map { |a| link path, a }.join("<br/>")}
99
99
  <br/><br/>
100
100
  #{link("/artist/#{artist}/", "play", "Play All")} -
101
101
  #{link("/artist/#{artist}/", "play", "Randomly", :order => :random)}
102
102
  HTML
103
+ puts "down"
104
+ x
103
105
  else
104
106
  artist_not_found artist
105
107
  end
@@ -120,8 +122,4 @@ class TLS::Player
120
122
  album_not_found artist, album
121
123
  end
122
124
  end
123
-
124
- def list_search search
125
- songs = @music.find search
126
- end
127
125
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: the_little_streamer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Collins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-17 00:00:00.000000000 Z
11
+ date: 2014-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -50,13 +50,12 @@ files:
50
50
  - README.md
51
51
  - lib/the_little_streamer.rb
52
52
  - lib/the_little_streamer/finder.rb
53
- - lib/the_little_streamer/html.rb
54
- - lib/the_little_streamer/searcher.rb
55
53
  - lib/the_little_streamer/player.rb
56
54
  - lib/the_little_streamer/music.rb
57
55
  - lib/the_little_streamer/song.rb
58
56
  homepage: http://github.com/presidentbeef/the_little_streamer
59
- licenses: []
57
+ licenses:
58
+ - MIT
60
59
  metadata: {}
61
60
  post_install_message:
62
61
  rdoc_options: []
@@ -74,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
73
  version: '0'
75
74
  requirements: []
76
75
  rubyforge_project:
77
- rubygems_version: 2.0.7
76
+ rubygems_version: 2.1.11
78
77
  signing_key:
79
78
  specification_version: 4
80
79
  summary: Simple Sinatra application for streaming music.
@@ -1,219 +0,0 @@
1
- module TLS::HTML
2
- #Wrap up in HTML
3
- def page body = nil
4
- if block_given?
5
- body = yield
6
- end
7
-
8
- <<-HTML
9
- <html>
10
- <head>
11
- <style type="text/css">
12
- #{css}
13
- </style>
14
- <title>The Little Streamer</title>
15
- </head>
16
- <body>
17
- #{body}
18
- </body>
19
- <script>
20
- if(document.getElementById('artist')) {
21
- window.onload = function() {
22
- var artist = document.getElementById('artist').firstChild.innerText;
23
- var title = document.getElementById('title').innerHTML;
24
- document.title = title + " by " + artist;
25
- }
26
- }
27
- </script>
28
- </html>
29
- HTML
30
- end
31
-
32
- def css
33
- @css ||= <<-CSS
34
- body {
35
- font-family: Helvetica,Verdana,Arial,sans-serif;
36
- font-size: 13pt;
37
- }
38
-
39
- span#title {
40
- font-size: 14pt;
41
- font-weight: bold;
42
- }
43
-
44
- span#artist {
45
- font-size: 14pt;
46
- font-weight: bold;
47
- }
48
-
49
- span#artist a {
50
- text-decoration: none;
51
- color: black;
52
- }
53
-
54
- span#artist a:hover {
55
- text-decoration: underline;
56
- }
57
-
58
- span#album {
59
- font-style: italic;
60
- }
61
-
62
- span#album a {
63
- text-decoration: none;
64
- color: black;
65
- }
66
-
67
- span#album a:hover {
68
- text-decoration: underline;
69
- }
70
-
71
- div#playlist {
72
- float: left;
73
- margin-top: 15px;
74
- height: 80%;
75
- overflow: auto;
76
- text-align: left;
77
- }
78
-
79
- div#playerbox {
80
- float: left;
81
- text-align: center;
82
- }
83
- CSS
84
-
85
- @css
86
- end
87
-
88
- #Create a link
89
- def link root, path, text = path, params = {}
90
- full_path = root.split('/').map! {|r| URI.escape r }.join('/') << "/" << URI.escape(path)
91
- params = params.map { |k, v| "#{k}=#{v}" }.join "&"
92
- "<a href=\"#{full_path}?#{params}\">#{text}</a>"
93
- end
94
-
95
- #Some navigation
96
- def title artist, album = nil
97
- if album
98
- "<h3>#{link "/", "", "Music"} : #{link "/artist/", artist, artist} : #{album}</h3>"
99
- else
100
- "<h3>#{link "/", "", "Music"} : #{artist}</h3>"
101
- end
102
- end
103
-
104
- #Audio tag
105
- def audio path
106
- <<-HTML
107
- <audio id='player' onEnded='javascript:play_next()' src=#{("/" << URI.escape(path)).inspect} autobuffer controls autoplay >
108
- You need the power of HTML5!
109
- </audio>
110
- <script type="text/javascript">
111
- document.getElementById('player').volume = 0.3;
112
- </script>
113
- HTML
114
- end
115
-
116
- #HTML for displaying playlist
117
- def playlist_html songs
118
- list = []
119
-
120
- songs.each_with_index do |song, i|
121
- list << "<li><a href=\"javascript:play_index(#{i})\">#{song.artist} - #{song.title}</a></li>"
122
- end
123
-
124
- <<-HTML
125
- <div style="clear:both">&nbsp;</div>
126
- <div id="playlist">
127
- <ol>
128
- #{list.join}
129
- </ol>
130
- </div>
131
- HTML
132
- end
133
-
134
- #Javascript for playlist
135
- def playlist_js songs
136
- <<-JAVASCRIPT
137
- <script type="text/javascript">
138
- var player = document.getElementById('player');
139
- var artist = document.getElementById('artist');
140
- var album = document.getElementById('album');
141
- var title = document.getElementById('title');
142
- var playlist = [#{songs.map { |s| song_to_js s }.join "," }]
143
- var current_song = 0;
144
-
145
- play_next = function(reverse) {
146
- if(reverse && current_song > 0)
147
- current_song--;
148
- else if(!reverse && current_song < playlist.length)
149
- current_song++;
150
- else
151
- return;
152
-
153
- play_current();
154
- }
155
-
156
- play_current = function() {
157
- var song = playlist[current_song];
158
- player.src = song.path;
159
- artist.innerHTML = song.artist
160
- album.innerHTML = song.album
161
- title.innerHTML = song.title
162
- document.title = song.title + " by " + artist.firstChild.innerText;
163
- player.play();
164
- }
165
-
166
- play_index = function(index) {
167
- current_song = index;
168
- play_current();
169
- }
170
- </script>
171
- JAVASCRIPT
172
- end
173
-
174
- #Javascript for a song
175
- def song_to_js song
176
- <<-JAVASCRIPT
177
- { artist: #{link("/artist", song.artist, song.artist).inspect},
178
- album: #{link("/artist/#{song.artist}/album/", song.album, song.album).inspect},
179
- title: #{song.title.inspect},
180
- path: #{(CGI.escapeHTML "/" << CGI.escape(song.path)).inspect} }
181
- JAVASCRIPT
182
- end
183
-
184
- #HTML for song information header
185
- def song_info song
186
- "<span id='title'>#{song.title}</span> by <span id='artist'>#{link "/artist/", song.artist}</span><br/><span id='album'>#{link "/artist/#{song.artist}/album", song.album}</span>"
187
- end
188
-
189
- #Back/forward links
190
- def prev_and_next
191
- @prev_and_next ||= "<a href='javascript:play_next(true)'>Prev</a>&nbsp;&nbsp;&nbsp;<a href='javascript:play_next()'>Next</a>"
192
- @prev_and_next
193
- end
194
-
195
- #Output HTML for player
196
- def player_html songs
197
- page <<-HTML
198
- <div id="playerbox">
199
- #{song_info songs.first}<br/>
200
- #{audio songs.first.path}<br/>
201
- #{prev_and_next if songs.length > 1}
202
- #{playlist_js songs}
203
- #{playlist_html songs if songs.length > 1}
204
- <div style="clear:both">#{link "/", "", "Back to All Music"}</div>
205
- </div>
206
- HTML
207
- end
208
-
209
- def search_box
210
- <<-HTML
211
- <div id="searchbox">
212
- <form action="/search">
213
- <label for="search">Search:</label>
214
- <input type="text" />
215
- </form>
216
- </div>
217
- HTML
218
- end
219
- end
@@ -1,21 +0,0 @@
1
- module TLS
2
- class Searcher
3
- def initialize music
4
- @music = music
5
- end
6
-
7
- def find_all search
8
- search = normalize search
9
-
10
- @music.all_songs.select do |song|
11
- song.title.downcase.include? search or
12
- song.album.downcase.include? search or
13
- song.artist.downcase.include? search
14
- end
15
- end
16
-
17
- def normalize search
18
- search.strip.gsub(/\s{2,}/, ' ').downcase
19
- end
20
- end
21
- end