the_little_streamer 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/the_little_streamer/html.rb +208 -0
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51105a77ed843dde2841f3dcdf07fec04e2b16c6
|
4
|
+
data.tar.gz: 4897f52dd669382e145ad146e718ad9fe4b8b05e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0183101cbdcf9f3efa30dcdbed1cd8fd3f49ef8b38090341c351bda1e6d554c0021e76083178dba4a8469e5b7f6b3b23fd6a369c9e8cde8abbdcf4a19f2827e2
|
7
|
+
data.tar.gz: 6083e64a11d887896d174475aee1a6da6aa91936edd5305533cc91f2aafea7d278d5e15f8b60873f37b3ef8b565ca7a271b0c7efed140ceab3b314ffc6bea458
|
@@ -0,0 +1,208 @@
|
|
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.text;
|
23
|
+
var title = document.getElementById('title').textContent;
|
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"> </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 " + document.getElementById('artist').firstChild.text;
|
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> <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
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_little_streamer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Collins
|
@@ -14,28 +14,28 @@ dependencies:
|
|
14
14
|
name: sinatra
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: taglib-ruby
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0.6'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.6'
|
41
41
|
description: Point the Little Streamer to your music directory and it will serve up
|
@@ -46,16 +46,16 @@ executables:
|
|
46
46
|
extensions: []
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
|
-
- bin/the_little_streamer
|
50
49
|
- README.md
|
50
|
+
- bin/the_little_streamer
|
51
51
|
- lib/the_little_streamer.rb
|
52
52
|
- lib/the_little_streamer/finder.rb
|
53
|
-
- lib/the_little_streamer/
|
53
|
+
- lib/the_little_streamer/html.rb
|
54
54
|
- lib/the_little_streamer/music.rb
|
55
|
+
- lib/the_little_streamer/player.rb
|
55
56
|
- lib/the_little_streamer/song.rb
|
56
57
|
homepage: http://github.com/presidentbeef/the_little_streamer
|
57
|
-
licenses:
|
58
|
-
- MIT
|
58
|
+
licenses: []
|
59
59
|
metadata: {}
|
60
60
|
post_install_message:
|
61
61
|
rdoc_options: []
|
@@ -63,17 +63,17 @@ require_paths:
|
|
63
63
|
- lib
|
64
64
|
required_ruby_version: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
|
-
- -
|
71
|
+
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
version: '0'
|
74
74
|
requirements: []
|
75
75
|
rubyforge_project:
|
76
|
-
rubygems_version: 2.
|
76
|
+
rubygems_version: 2.2.2
|
77
77
|
signing_key:
|
78
78
|
specification_version: 4
|
79
79
|
summary: Simple Sinatra application for streaming music.
|