junkie 0.0.8 → 0.0.9
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/junkie.gemspec +13 -10
- data/lib/junkie/config.rb +4 -1
- data/lib/junkie/reactor.rb +6 -5
- data/lib/junkie/version.rb +1 -1
- data/lib/junkie/webinterface/interface.rb +70 -0
- data/lib/junkie/webinterface/views/index.erb +72 -0
- metadata +52 -2
data/junkie.gemspec
CHANGED
@@ -18,14 +18,17 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
20
|
gem.required_ruby_version = '>= 1.9.0'
|
21
|
-
gem.add_runtime_dependency(
|
22
|
-
gem.add_runtime_dependency(
|
23
|
-
gem.add_runtime_dependency(
|
24
|
-
gem.add_runtime_dependency(
|
25
|
-
gem.add_runtime_dependency(
|
26
|
-
gem.add_runtime_dependency(
|
27
|
-
gem.add_runtime_dependency(
|
28
|
-
gem.add_runtime_dependency(
|
29
|
-
gem.add_runtime_dependency(
|
30
|
-
gem.add_runtime_dependency(
|
21
|
+
gem.add_runtime_dependency('eventmachine', [">= 1.0"])
|
22
|
+
gem.add_runtime_dependency('em-http-request', [">= 1.0"])
|
23
|
+
gem.add_runtime_dependency('yajl-ruby', ["~> 1.1.0"])
|
24
|
+
gem.add_runtime_dependency('nokogiri', [">= 1.5"])
|
25
|
+
gem.add_runtime_dependency('hashconfig', [">= 0.0.2"])
|
26
|
+
gem.add_runtime_dependency('serienrenamer', [">= 0.0.1"])
|
27
|
+
gem.add_runtime_dependency('sjunkieex', [">= 0.0.1"])
|
28
|
+
gem.add_runtime_dependency('sindex', [">= 0.0.1"])
|
29
|
+
gem.add_runtime_dependency('logging', ["~> 1.8.0"])
|
30
|
+
gem.add_runtime_dependency('twitter', ["~> 4.4.0"])
|
31
|
+
gem.add_runtime_dependency('thin')
|
32
|
+
gem.add_runtime_dependency('sinatra')
|
33
|
+
gem.add_runtime_dependency('sinatra-websocket')
|
31
34
|
end
|
data/lib/junkie/config.rb
CHANGED
@@ -49,7 +49,10 @@ module Junkie
|
|
49
49
|
default_config.merge_with_serialized(Junkie::CONFIG_FILE)
|
50
50
|
end
|
51
51
|
|
52
|
-
|
52
|
+
class_name = source.class.to_s
|
53
|
+
(class_name = source.to_s) if source.is_a? Class
|
54
|
+
|
55
|
+
return @comlete_config[class_name]
|
53
56
|
end
|
54
57
|
|
55
58
|
|
data/lib/junkie/reactor.rb
CHANGED
@@ -8,6 +8,7 @@ require 'junkie'
|
|
8
8
|
require 'junkie/pyload/api'
|
9
9
|
require 'junkie/pyload/observer'
|
10
10
|
require 'junkie/errors'
|
11
|
+
require 'junkie/webinterface/interface'
|
11
12
|
|
12
13
|
module Junkie
|
13
14
|
|
@@ -27,12 +28,10 @@ module Junkie
|
|
27
28
|
|
28
29
|
log.info("Starting Junkie #{Junkie::VERSION}")
|
29
30
|
|
30
|
-
episode_channel = EM::Channel.new
|
31
|
-
notification_channel = EM::Channel.new
|
32
|
-
|
33
31
|
@channels = {
|
34
|
-
episodes:
|
35
|
-
notifications:
|
32
|
+
episodes: EM::Channel.new,
|
33
|
+
notifications: EM::Channel.new,
|
34
|
+
info: EM::Channel.new,
|
36
35
|
}
|
37
36
|
|
38
37
|
@pyload_observer = Junkie::Pyload::Observer.new(@channels)
|
@@ -96,6 +95,8 @@ module Junkie
|
|
96
95
|
end
|
97
96
|
end
|
98
97
|
|
98
|
+
# start the web interface
|
99
|
+
Junkie::Webinterface::Interface.setup(@channels)
|
99
100
|
end
|
100
101
|
end
|
101
102
|
end
|
data/lib/junkie/version.rb
CHANGED
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
require 'sinatra-websocket'
|
3
|
+
require 'thin'
|
4
|
+
|
5
|
+
module Junkie
|
6
|
+
module Webinterface
|
7
|
+
|
8
|
+
# Class that represents the web interface for junkie. It is based on
|
9
|
+
# WebSockets, so that updates are sent to the connected clients.
|
10
|
+
#
|
11
|
+
class Interface < Sinatra::Base
|
12
|
+
include Log, Config
|
13
|
+
|
14
|
+
DEFAULT_CONFIG = {
|
15
|
+
port: 8080,
|
16
|
+
}
|
17
|
+
|
18
|
+
set :server, 'thin'
|
19
|
+
|
20
|
+
def self.setup(channels)
|
21
|
+
@@channels = channels
|
22
|
+
@@config = Config.get_config(self)
|
23
|
+
|
24
|
+
set :port, @@config[:port]
|
25
|
+
|
26
|
+
@@stats = Hash.new
|
27
|
+
|
28
|
+
# every connected client connects to the following channel, so infos
|
29
|
+
# pushed to this channel are transmitted to the clients
|
30
|
+
@@ws_channel = EM::Channel.new
|
31
|
+
|
32
|
+
# subscribe to the channel that holds the stats from various parts of
|
33
|
+
# junkie
|
34
|
+
@@channels[:info].subscribe do |info|
|
35
|
+
@@stats[info[:key]] = info
|
36
|
+
@@ws_channel.push(info)
|
37
|
+
end
|
38
|
+
|
39
|
+
run!
|
40
|
+
end
|
41
|
+
|
42
|
+
get '/' do
|
43
|
+
if !request.websocket?
|
44
|
+
@junkie_version = Junkie::VERSION
|
45
|
+
@server = request.host_with_port
|
46
|
+
erb :index
|
47
|
+
else
|
48
|
+
|
49
|
+
request.websocket do |ws|
|
50
|
+
ws.onopen do
|
51
|
+
log.debug("Opened WebSocket from #{ request.ip }")
|
52
|
+
|
53
|
+
# send all cached stats to the client
|
54
|
+
@@stats.values.each { |s| ws.send(s.to_json) }
|
55
|
+
|
56
|
+
@@ws_channel.subscribe do |info|
|
57
|
+
ws.send(info.to_json)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
ws.onclose do
|
62
|
+
log.debug("Closed WebSocket from #{ request.ip }")
|
63
|
+
# TODO unsubscribe from @@ws_channel
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8" />
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
6
|
+
<title>
|
7
|
+
</title>
|
8
|
+
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
|
9
|
+
<style>
|
10
|
+
.bigger {
|
11
|
+
font-size: 100% !important;
|
12
|
+
}
|
13
|
+
</style>
|
14
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
|
15
|
+
</script>
|
16
|
+
<script src="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.2.0/jquery.mobile-1.2.0.min.js">
|
17
|
+
</script>
|
18
|
+
</head>
|
19
|
+
<body>
|
20
|
+
<!-- Home -->
|
21
|
+
<div data-role="page" id="page1">
|
22
|
+
<div data-theme="a" data-role="header">
|
23
|
+
<h3 id="header_title">
|
24
|
+
Junkie Webapp (<%= @junkie_version %>)
|
25
|
+
</h3>
|
26
|
+
</div>
|
27
|
+
<div data-role="content">
|
28
|
+
<ul data-role="listview" id="data">
|
29
|
+
<li data-role="list-divider" id="stats">Stats</li>
|
30
|
+
|
31
|
+
<li data-role="list-divider">About</li>
|
32
|
+
<li>Stats Last Updated At<span class="ui-li-count bigger" id="last_update"></span></li>
|
33
|
+
<li>Junkie Host<span class="ui-li-count bigger" id="last_update"><%= @server %></span></li>
|
34
|
+
</ul>
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
</body>
|
38
|
+
|
39
|
+
<script type="text/javascript">
|
40
|
+
|
41
|
+
function format_stat(stat) {
|
42
|
+
return '<li data-key="' + stat.key +
|
43
|
+
'"><span class="ui-li-heading">' + stat.key +
|
44
|
+
'</span><span class="ui-li-desc">' + stat.desc +
|
45
|
+
'</span><span class="ui-li-count bigger">' + stat.value +
|
46
|
+
'</span></li>';
|
47
|
+
}
|
48
|
+
|
49
|
+
function addOrUpdateStat(stat) {
|
50
|
+
var statHtml = format_stat(stat);
|
51
|
+
$('li[data-key="' + stat.key + '"]').remove();
|
52
|
+
$(statHtml).insertAfter('#stats');
|
53
|
+
$('#data').listview('refresh');
|
54
|
+
}
|
55
|
+
|
56
|
+
function updateUpdatedAt() {
|
57
|
+
var time = new Date().toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1");
|
58
|
+
$("#last_update").text(time);
|
59
|
+
}
|
60
|
+
|
61
|
+
$(function () {
|
62
|
+
var ws = new WebSocket('ws://' + window.location.host + window.location.pathname);
|
63
|
+
ws.onopen = function() { console.log('websocket opened'); };
|
64
|
+
ws.onclose = function() { console.log('websocket closed'); };
|
65
|
+
ws.onmessage = function(m) {
|
66
|
+
updateUpdatedAt();
|
67
|
+
var obj = $.parseJSON(m.data);
|
68
|
+
addOrUpdateStat(obj);
|
69
|
+
};
|
70
|
+
});
|
71
|
+
</script>
|
72
|
+
</html>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: junkie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
@@ -171,6 +171,54 @@ dependencies:
|
|
171
171
|
- - ~>
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: 4.4.0
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: thin
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ! '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
type: :runtime
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
190
|
+
- !ruby/object:Gem::Dependency
|
191
|
+
name: sinatra
|
192
|
+
requirement: !ruby/object:Gem::Requirement
|
193
|
+
none: false
|
194
|
+
requirements:
|
195
|
+
- - ! '>='
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '0'
|
198
|
+
type: :runtime
|
199
|
+
prerelease: false
|
200
|
+
version_requirements: !ruby/object:Gem::Requirement
|
201
|
+
none: false
|
202
|
+
requirements:
|
203
|
+
- - ! '>='
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: '0'
|
206
|
+
- !ruby/object:Gem::Dependency
|
207
|
+
name: sinatra-websocket
|
208
|
+
requirement: !ruby/object:Gem::Requirement
|
209
|
+
none: false
|
210
|
+
requirements:
|
211
|
+
- - ! '>='
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
214
|
+
type: :runtime
|
215
|
+
prerelease: false
|
216
|
+
version_requirements: !ruby/object:Gem::Requirement
|
217
|
+
none: false
|
218
|
+
requirements:
|
219
|
+
- - ! '>='
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '0'
|
174
222
|
description: TV series management application
|
175
223
|
email:
|
176
224
|
- philipp-boehm@live.de
|
@@ -200,6 +248,8 @@ files:
|
|
200
248
|
- lib/junkie/pyload/observer.rb
|
201
249
|
- lib/junkie/reactor.rb
|
202
250
|
- lib/junkie/version.rb
|
251
|
+
- lib/junkie/webinterface/interface.rb
|
252
|
+
- lib/junkie/webinterface/views/index.erb
|
203
253
|
- spec/config_spec.rb
|
204
254
|
- spec/environment_spec.rb
|
205
255
|
- spec/fixtures/pyload_queue_data.rb
|