network_executive 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,13 +13,29 @@
13
13
  document.addEventListener('mousemove', function(e) {
14
14
  clearTimeout( autoHideTimer );
15
15
 
16
- if( !osd.contains('active') ) {
16
+ if( !osd.classList.contains('active') ) {
17
17
  osd.classList.add('active');
18
+
19
+ renderGuide();
18
20
  }
19
21
 
20
22
  autoHideTimer = setTimeout(autoHide, 1000);
21
23
  });
22
24
 
25
+ // Fetch and display Guide Data
26
+ function renderGuide() {
27
+ var xhr = new XMLHttpRequest();
28
+
29
+ xhr.addEventListener('readystatechange', function(e) {
30
+ if( xhr.readyState == 4 && xhr.status == 200) {
31
+ document.getElementById('lineup').innerHTML = xhr.responseText;
32
+ }
33
+ });
34
+
35
+ xhr.open('GET', 'lineup.html', true);
36
+ xhr.send();
37
+ }
38
+
23
39
  // Update the timestamp
24
40
  var months = 'January February March April May June July August September October November December'.split(' ');
25
41
  setInterval(function() {
@@ -8,7 +8,7 @@
8
8
 
9
9
  document.getElementById('smpte_message').innerHTML = 'Establishing uplink...';
10
10
 
11
- var source = new EventSource('../tune_in/' + channel);
11
+ var source = new EventSource('tune_in/' + channel);
12
12
 
13
13
  source.addEventListener('open', function(e) {
14
14
  document.getElementById('smpte_message').innerHTML = 'Awaiting transmission...';
@@ -30,4 +30,33 @@
30
30
  }
31
31
  .osd-now-date {
32
32
  display: block;
33
+ }
34
+
35
+ #osd table {
36
+ width: 100%;
37
+ border-spacing: .25em;
38
+ border-collapse: separate;
39
+ font-size: 1.5em;
40
+ }
41
+ #osd td,
42
+ #osd th {
43
+ height: 1em;
44
+ padding: 0 .25em;
45
+ overflow: hidden;
46
+ text-overflow: ellipsis;
47
+ white-space: nowrap;
48
+ }
49
+ .guide-time {
50
+ text-align: left;
51
+ }
52
+ .guide-channel {
53
+ text-align: right;
54
+ text-transform: capitalize;
55
+ }
56
+ .guide-program {
57
+ background: rgba(0,0,0,.33);
58
+ }
59
+ #osd a {
60
+ color: #fff;
61
+ text-decoration: none;
33
62
  }
@@ -0,0 +1,11 @@
1
+ module NetworkExecutive
2
+ class LineupController < NetworkExecutive::ApplicationController
3
+
4
+ respond_to :html, :json
5
+
6
+ def index
7
+ respond_with @lineup = Lineup.new
8
+ end
9
+
10
+ end
11
+ end
@@ -1,9 +1,4 @@
1
1
  module NetworkExecutive
2
2
  class NetworkController < NetworkExecutive::ApplicationController
3
-
4
- def index
5
- @channels = NetworkExecutive::Network.channels
6
- end
7
-
8
3
  end
9
4
  end
@@ -1,6 +1,7 @@
1
1
  # Represents a channel's programming line up for a given time span.
2
2
  module NetworkExecutive
3
3
  # TODO: Why does this subclass Hash?
4
+ # TODO: This is an ugly data structure. Refactor.
4
5
  class Lineup < Hash
5
6
 
6
7
  Interval = 15 # In minutes.
@@ -16,10 +17,8 @@ module NetworkExecutive
16
17
  def generate
17
18
  with_each_channel do |channel, lineup|
18
19
  lineup << {
19
- name: channel.display_name,
20
- schedule: whats_on?( channel ) do |show|
21
- show.program_name.titleize
22
- end
20
+ channel: channel,
21
+ schedule: whats_on?( channel )
23
22
  }
24
23
  end
25
24
  end
@@ -40,6 +39,11 @@ module NetworkExecutive
40
39
  @stop_time
41
40
  end
42
41
 
42
+ # TODO: Add test
43
+ def times
44
+ self[:channels].first[:schedule].collect { |s| s[:time] }
45
+ end
46
+
43
47
  private
44
48
 
45
49
  # Rounds the specific time to the nearest interval
@@ -59,7 +63,11 @@ module NetworkExecutive
59
63
  # TODO: Decouple
60
64
  def whats_on?( channel )
61
65
  channel.whats_on?( start_time, stop_time, interval:Interval ) do |show|
62
- yield show
66
+ if block_given?
67
+ yield show
68
+ else
69
+ show
70
+ end
63
71
  end
64
72
  end
65
73
  end
@@ -0,0 +1,26 @@
1
+ <table>
2
+ <thead>
3
+ <tr>
4
+ <td></td>
5
+ <% @lineup.times.each do |t| %>
6
+ <th class="guide-time">
7
+ <%= t.strftime '%l:%M' %>
8
+ </th>
9
+ <% end %>
10
+ </tr>
11
+ </thead>
12
+ <tbody>
13
+ <% @lineup[:channels].each do |ch| %>
14
+ <tr>
15
+ <th class="guide-channel">
16
+ <%= link_to ch[:channel], channel_path(ch[:channel]) %>
17
+ </th>
18
+ <% ch[:schedule].each do |sch| %>
19
+ <td class="guide-program">
20
+ <%= sch[:program].program_name.titleize %>
21
+ </td>
22
+ <% end %>
23
+ </tr>
24
+ <% end %>
25
+ </tbody>
26
+ </table>
@@ -6,6 +6,7 @@
6
6
  <title>Network Executive: <%= network_name %></title>
7
7
  <link href='//fonts.googleapis.com/css?family=Lekton:400,700|Quicksand:300,400,700' rel='stylesheet' type='text/css'>
8
8
  <%= stylesheet_link_tag 'network_executive/application', media:'all' %>
9
+ <base href="<%= network_executive.root_url %>"/>
9
10
  </head>
10
11
  <body>
11
12
  <iframe id="program" class="gui-comp"></iframe>
@@ -27,11 +28,7 @@
27
28
  </aside>
28
29
  </h1>
29
30
  </header>
30
- <article>
31
- <% @channels.each do |channel| %>
32
- <a href="channels/<%= channel.name %>" class="channel"><%= channel.display_name %></a>
33
- <% end %>
34
- </article>
31
+ <article id="lineup"></article>
35
32
  </div>
36
33
 
37
34
  <%= javascript_include_tag 'application' %>
data/config/routes.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  NetworkExecutive::Engine.routes.draw do
2
2
  mount NetworkExecutive::Station => '/tune_in', as:'station'
3
3
 
4
- match 'channels/:channel_name' => 'network#index'
4
+ match 'channels/:channel_name' => 'network#index', as: :channel
5
+
6
+ match 'lineup' => 'lineup#index', as: :lineup
5
7
 
6
8
  root to:'network#index'
7
9
  end
@@ -1,3 +1,3 @@
1
1
  module NetworkExecutive
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -20,7 +20,8 @@ Gem::Specification.new do |gem|
20
20
  gem.add_dependency 'activesupport', '~> 3.2.0'
21
21
  gem.add_dependency 'faye-websocket', '~> 0.4.6'
22
22
 
23
- gem.add_runtime_dependency 'sass-rails', '~> 3.2'
23
+ gem.add_runtime_dependency 'sass-rails'
24
+ gem.add_runtime_dependency 'uglifier'
24
25
 
25
26
  gem.add_development_dependency 'awesome_print'
26
27
  gem.add_development_dependency 'rails', '~> 3.2.8'
@@ -69,20 +69,14 @@ describe NetworkExecutive::Lineup do
69
69
 
70
70
  it { should be_an Array }
71
71
 
72
- it 'should contain a channel name' do
73
- subject.first[:name].should == 'channel a'
72
+ it 'should contain a channel' do
73
+ subject.first[:channel].should == channel
74
74
  end
75
75
 
76
76
  it 'should contain an array of scheduled programs' do
77
77
  subject.first[:schedule].should be_an Array
78
78
  end
79
79
 
80
- it 'should transform the program name' do
81
- show.should_receive :program_name
82
-
83
- subject
84
- end
85
-
86
80
  it 'should ask the channel what is on' do
87
81
  args = [ Time.now, 1.5.hours.from_now, kind_of(Hash) ]
88
82
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: network_executive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-09-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &2164453740 !ruby/object:Gem::Requirement
16
+ requirement: &2164741200 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2164453740
24
+ version_requirements: *2164741200
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: faye-websocket
27
- requirement: &2164451980 !ruby/object:Gem::Requirement
27
+ requirement: &2164740660 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,21 +32,32 @@ dependencies:
32
32
  version: 0.4.6
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2164451980
35
+ version_requirements: *2164740660
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sass-rails
38
- requirement: &2164470220 !ruby/object:Gem::Requirement
38
+ requirement: &2164740240 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
- - - ~>
41
+ - - ! '>='
42
42
  - !ruby/object:Gem::Version
43
- version: '3.2'
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2164740240
47
+ - !ruby/object:Gem::Dependency
48
+ name: uglifier
49
+ requirement: &2164739680 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
44
55
  type: :runtime
45
56
  prerelease: false
46
- version_requirements: *2164470220
57
+ version_requirements: *2164739680
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: awesome_print
49
- requirement: &2164469320 !ruby/object:Gem::Requirement
60
+ requirement: &2164739000 !ruby/object:Gem::Requirement
50
61
  none: false
51
62
  requirements:
52
63
  - - ! '>='
@@ -54,10 +65,10 @@ dependencies:
54
65
  version: '0'
55
66
  type: :development
56
67
  prerelease: false
57
- version_requirements: *2164469320
68
+ version_requirements: *2164739000
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: rails
60
- requirement: &2164467640 !ruby/object:Gem::Requirement
71
+ requirement: &2164737960 !ruby/object:Gem::Requirement
61
72
  none: false
62
73
  requirements:
63
74
  - - ~>
@@ -65,10 +76,10 @@ dependencies:
65
76
  version: 3.2.8
66
77
  type: :development
67
78
  prerelease: false
68
- version_requirements: *2164467640
79
+ version_requirements: *2164737960
69
80
  - !ruby/object:Gem::Dependency
70
81
  name: rspec-rails
71
- requirement: &2152099960 !ruby/object:Gem::Requirement
82
+ requirement: &2164736120 !ruby/object:Gem::Requirement
72
83
  none: false
73
84
  requirements:
74
85
  - - ~>
@@ -76,10 +87,10 @@ dependencies:
76
87
  version: '2.11'
77
88
  type: :development
78
89
  prerelease: false
79
- version_requirements: *2152099960
90
+ version_requirements: *2164736120
80
91
  - !ruby/object:Gem::Dependency
81
92
  name: fakefs
82
- requirement: &2152096360 !ruby/object:Gem::Requirement
93
+ requirement: &2164734300 !ruby/object:Gem::Requirement
83
94
  none: false
84
95
  requirements:
85
96
  - - ~>
@@ -87,10 +98,10 @@ dependencies:
87
98
  version: 0.4.0
88
99
  type: :development
89
100
  prerelease: false
90
- version_requirements: *2152096360
101
+ version_requirements: *2164734300
91
102
  - !ruby/object:Gem::Dependency
92
103
  name: timecop
93
- requirement: &2152095400 !ruby/object:Gem::Requirement
104
+ requirement: &2164749660 !ruby/object:Gem::Requirement
94
105
  none: false
95
106
  requirements:
96
107
  - - ~>
@@ -98,7 +109,7 @@ dependencies:
98
109
  version: 0.4.5
99
110
  type: :development
100
111
  prerelease: false
101
- version_requirements: *2152095400
112
+ version_requirements: *2164749660
102
113
  description: An experimental application used to drive displays hung around an office.
103
114
  email:
104
115
  - dlindahl@customink.com
@@ -123,6 +134,7 @@ files:
123
134
  - app/assets/stylesheets/network_executive/osd.css
124
135
  - app/assets/stylesheets/network_executive/smpte.css
125
136
  - app/controllers/network_executive/application_controller.rb
137
+ - app/controllers/network_executive/lineup_controller.rb
126
138
  - app/controllers/network_executive/network_controller.rb
127
139
  - app/helpers/network_executive/network_helper.rb
128
140
  - app/models/network_executive/channel.rb
@@ -133,6 +145,7 @@ files:
133
145
  - app/models/network_executive/program.rb
134
146
  - app/models/network_executive/program_schedule.rb
135
147
  - app/models/network_executive/viewer.rb
148
+ - app/views/network_executive/lineup/index.html.erb
136
149
  - app/views/network_executive/network/index.html.erb
137
150
  - bin/net_exec
138
151
  - config/routes.rb
@@ -218,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
231
  version: '0'
219
232
  segments:
220
233
  - 0
221
- hash: -2613508738067958450
234
+ hash: 240315876043303011
222
235
  requirements: []
223
236
  rubyforge_project:
224
237
  rubygems_version: 1.8.10