douban.fm 0.2.8 → 0.3.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/douban.fm +5 -0
- data/index.html +165 -0
- data/lib/douban.fm/version.rb +1 -1
- metadata +7 -6
data/bin/douban.fm
CHANGED
@@ -181,6 +181,8 @@ class DoubanFMCLI
|
|
181
181
|
|
182
182
|
def do_GET request, response
|
183
183
|
path = request.path[1..-1].split('/')
|
184
|
+
puts "======" + path[0].to_s
|
185
|
+
puts "lkj" if path[0].nil?
|
184
186
|
case path[0]
|
185
187
|
when 'channels'
|
186
188
|
@@douban_fm.fetch_channels
|
@@ -197,6 +199,9 @@ class DoubanFMCLI
|
|
197
199
|
end
|
198
200
|
when 'now'
|
199
201
|
response.body = JSON.generate({'channel' => @@douban_fm.current_channel})
|
202
|
+
when 'index', nil
|
203
|
+
html_path = File.expand_path('../../index.html', __FILE__)
|
204
|
+
response.body = File.readlines(html_path).join('')
|
200
205
|
else
|
201
206
|
raise WEBrick::HTTPStatus::NotFound
|
202
207
|
end
|
data/index.html
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>douban.fm channels</title>
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7
|
+
<meta name="description" content="douban.fm channels">
|
8
|
+
<meta name="author" content="@honnix,@jihao">
|
9
|
+
|
10
|
+
<!-- CSS -->
|
11
|
+
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet">
|
12
|
+
<style type="text/css">
|
13
|
+
|
14
|
+
/* Sticky footer styles
|
15
|
+
-------------------------------------------------- */
|
16
|
+
|
17
|
+
html,
|
18
|
+
body {
|
19
|
+
height: 100%;
|
20
|
+
/* The html and body elements cannot have any padding or margin. */
|
21
|
+
font-family: "Microsoft YaHei" ! important;
|
22
|
+
text-align: center;
|
23
|
+
}
|
24
|
+
|
25
|
+
/* Wrapper for page content to push down footer */
|
26
|
+
#wrap {
|
27
|
+
min-height: 100%;
|
28
|
+
height: auto !important;
|
29
|
+
height: 100%;
|
30
|
+
/* Negative indent footer by it's height */
|
31
|
+
margin: 0 auto -60px;
|
32
|
+
}
|
33
|
+
|
34
|
+
/* Set the fixed height of the footer here */
|
35
|
+
#push,
|
36
|
+
#footer {
|
37
|
+
height: 60px;
|
38
|
+
}
|
39
|
+
#footer {
|
40
|
+
background-color: #f5f5f5;
|
41
|
+
}
|
42
|
+
|
43
|
+
/* Lastly, apply responsive CSS fixes as necessary */
|
44
|
+
@media (max-width: 767px) {
|
45
|
+
#footer {
|
46
|
+
margin-left: -20px;
|
47
|
+
margin-right: -20px;
|
48
|
+
padding-left: 20px;
|
49
|
+
padding-right: 20px;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
/* Custom page CSS
|
54
|
+
-------------------------------------------------- */
|
55
|
+
/* Not required for template or sticky footer method. */
|
56
|
+
|
57
|
+
.container {
|
58
|
+
width: auto;
|
59
|
+
max-width: 680px;
|
60
|
+
}
|
61
|
+
.container .credit {
|
62
|
+
margin: 20px 0;
|
63
|
+
}
|
64
|
+
.music {
|
65
|
+
display: inline-block;
|
66
|
+
padding: 2px 2px;
|
67
|
+
}
|
68
|
+
</style>
|
69
|
+
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap-responsive.css" rel="stylesheet">
|
70
|
+
|
71
|
+
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
|
72
|
+
<!--[if lt IE 9]>
|
73
|
+
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
74
|
+
<![endif]-->
|
75
|
+
|
76
|
+
<!-- Fav and touch icons, you might need specify the following images -->
|
77
|
+
<!--
|
78
|
+
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png">
|
79
|
+
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png">
|
80
|
+
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png">
|
81
|
+
<link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png">
|
82
|
+
<link rel="shortcut icon" href="../assets/ico/favicon.png">
|
83
|
+
-->
|
84
|
+
</head>
|
85
|
+
|
86
|
+
<body>
|
87
|
+
|
88
|
+
|
89
|
+
<!-- Part 1: Wrap all page content here -->
|
90
|
+
<div id="wrap">
|
91
|
+
|
92
|
+
<!-- Begin page content -->
|
93
|
+
<div class="container">
|
94
|
+
<div class="page-header">
|
95
|
+
<h1>douban.fm channels</h1>
|
96
|
+
</div>
|
97
|
+
<div class="body">
|
98
|
+
<a id="now" class="btn btn-large btn-success" data-loading-text="loading ..." data-complete-text="" href=""><i class="icon-play"></i><i class="icon-music"></i> </a>
|
99
|
+
<hr>
|
100
|
+
<div class="channels">
|
101
|
+
|
102
|
+
</div>
|
103
|
+
</div>
|
104
|
+
</div>
|
105
|
+
|
106
|
+
<div id="push"></div>
|
107
|
+
</div>
|
108
|
+
|
109
|
+
<div id="footer">
|
110
|
+
<div class="container">
|
111
|
+
<p class="muted credit">Present by <a href="http://honnix.com">honnix</a>.</p>
|
112
|
+
</div>
|
113
|
+
</div>
|
114
|
+
|
115
|
+
<!-- Le javascript
|
116
|
+
================================================== -->
|
117
|
+
<!-- Placed at the end of the document so the pages load faster -->
|
118
|
+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
|
119
|
+
<script src="http://twitter.github.com/bootstrap/assets/js/bootstrap-button.js"></script>
|
120
|
+
<script type="text/javascript">
|
121
|
+
$(function(){
|
122
|
+
$('a#now').button('loading');
|
123
|
+
// load current play channel
|
124
|
+
$.getJSON("/now", function(data) {
|
125
|
+
var now_id = data['channel'];
|
126
|
+
var now_name;
|
127
|
+
if (now_id === -1)
|
128
|
+
now_name = "乱放"
|
129
|
+
|
130
|
+
// load all the channels
|
131
|
+
$.getJSON('/channels', function(data) {
|
132
|
+
var items = [];
|
133
|
+
data = data['channels']
|
134
|
+
|
135
|
+
$.each(data, function(index, val) {
|
136
|
+
if(val['channel_id'] == now_id)
|
137
|
+
now_name = val['name'];
|
138
|
+
|
139
|
+
items.push('<div class="music"><a class="btn channel" href="#" id="channel_'+val['channel_id']+'"><i class="icon-music"></i> '+val['name']+'</a></div>');
|
140
|
+
});
|
141
|
+
items.push('<div class="music"><a class="btn channel" href="#" id="channel_-1"><i class="icon-music"></i>乱放</a></div>');
|
142
|
+
|
143
|
+
$('div.channels').html(items.join(''));
|
144
|
+
$('a#now').button('reset');
|
145
|
+
$('a#now').html($('a#now').html()+now_name);
|
146
|
+
}); // end of getJSON
|
147
|
+
|
148
|
+
});
|
149
|
+
|
150
|
+
// bind click event to channel buttons
|
151
|
+
$('body').on('click','a.btn.channel',function(event){
|
152
|
+
$('a#now').button('loading');
|
153
|
+
event.preventDefault();
|
154
|
+
var channel = $(this).attr('id').substr(8);
|
155
|
+
// switch channel
|
156
|
+
$.get("/channel/"+channel, function(data) {
|
157
|
+
window.location.href = window.location.href;
|
158
|
+
});
|
159
|
+
});
|
160
|
+
|
161
|
+
}); // end of document.ready
|
162
|
+
|
163
|
+
</script>
|
164
|
+
</body>
|
165
|
+
</html>
|
data/lib/douban.fm/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: douban.fm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruby-mpd
|
16
|
-
requirement: &
|
16
|
+
requirement: &70287836247780 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - =
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.1.5
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70287836247780
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: highline
|
27
|
-
requirement: &
|
27
|
+
requirement: &70287836247140 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - =
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 1.6.15
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70287836247140
|
36
36
|
description: douban.fm
|
37
37
|
email:
|
38
38
|
- hxliang1982@gmail.com
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- Rakefile
|
49
49
|
- bin/douban.fm
|
50
50
|
- douban.fm.gemspec
|
51
|
+
- index.html
|
51
52
|
- lib/douban.fm.rb
|
52
53
|
- lib/douban.fm/douban_fm.rb
|
53
54
|
- lib/douban.fm/logger.rb
|