talking_stick 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +40 -0
- data/.csslintrc +2 -0
- data/.eslintignore +1 -0
- data/.eslintrc +213 -0
- data/.rubocop.yml +1156 -0
- data/Changes.md +8 -0
- data/Gemfile +1 -0
- data/README.md +7 -6
- data/app/assets/javascripts/talking_stick/talking_stick/partner.js +8 -4
- data/app/assets/javascripts/talking_stick/talking_stick/rails_signaling.js +2 -2
- data/app/assets/javascripts/talking_stick/talking_stick.js.erb +19 -9
- data/app/controllers/talking_stick/application_controller.rb +1 -2
- data/app/controllers/talking_stick/participants_controller.rb +3 -4
- data/app/controllers/talking_stick/rooms_controller.rb +6 -5
- data/app/models/talking_stick/application_record.rb +5 -0
- data/app/models/talking_stick/participant.rb +2 -2
- data/app/models/talking_stick/room.rb +2 -2
- data/app/models/talking_stick/signal.rb +1 -1
- data/app/views/talking_stick/participants/_form.html.erb +1 -1
- data/app/views/talking_stick/participants/edit.html.erb +1 -1
- data/app/views/talking_stick/participants/index.html.erb +2 -2
- data/app/views/talking_stick/participants/new.html.erb +1 -1
- data/app/views/talking_stick/participants/show.html.erb +2 -2
- data/app/views/talking_stick/rooms/_form.html.erb +2 -2
- data/app/views/talking_stick/rooms/index.html.erb +4 -4
- data/app/views/talking_stick/rooms/show.html.erb +24 -22
- data/config/routes.rb +3 -3
- data/db/migrate/20150510181337_create_talking_stick_rooms.rb +1 -1
- data/db/migrate/20150510182258_create_talking_stick_participants.rb +1 -1
- data/db/migrate/20150511005922_create_talking_stick_signals.rb +1 -1
- data/db/migrate/20150722200822_add_slug_to_talking_stick_rooms.rb +1 -1
- data/lib/talking_stick/engine.rb +8 -2
- data/lib/talking_stick/version.rb +1 -1
- data/lib/talking_stick.rb +4 -0
- data/spec/dummy/config/application.rb +0 -4
- data/talking_stick.gemspec +3 -2
- data/vendor/assets/javascripts/talking_stick/adapter.js +2591 -181
- metadata +37 -12
data/Changes.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# develop
|
2
|
+
|
3
|
+
# [2.0.0](https://github.com/mojolingo/talking_stick/compare/v1.0.0...v2.0.0) - [2017-10-11](https://rubygems.org/gems/talking_stick/versions/2.0.0)
|
4
|
+
* *Breaking* HTML elements prefixed with `talking-stick-`
|
5
|
+
* Improve ability to embed this engine into existing Rails applications by disabling `isolate_engine`
|
6
|
+
* We dropped support for Rails < 4.2
|
7
|
+
* Support for Rails 4.2 and Rails 5.0
|
8
|
+
|
1
9
|
# [1.0.0](https://github.com/mojolingo/talking_stick/compare/v0.0.1...v1.0.0) - [2016-01-02](https://rubygems.org/gems/talking_stick/versions/1.0.0)
|
2
10
|
* First stable version of Talking Stick - see [README](https://github.com/mojolingo/talking_stick/blob/v1.0.0/README.md) for details
|
3
11
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
This gem provides easy [WebRTC](https://webrtc.org) communication in any Rails app.
|
4
4
|
|
5
|
+
[![Code Climate](https://codeclimate.com/github/mojolingo/talking_stick/badges/gpa.svg)](https://codeclimate.com/github/mojolingo/talking_stick)
|
5
6
|
|
6
7
|
## Goals
|
7
8
|
|
@@ -9,7 +10,7 @@ This gem provides easy [WebRTC](https://webrtc.org) communication in any Rails a
|
|
9
10
|
* Allow selecting audio or audio+video
|
10
11
|
* Pluggable signaling delivery technology
|
11
12
|
* Plug & Play functionality - works out of the box
|
12
|
-
* Focus on simplicity at the API level, while maximizing the
|
13
|
+
* Focus on simplicity at the API level, while maximizing the possibilities of integrating communication into existing Rails apps
|
13
14
|
|
14
15
|
## Installation
|
15
16
|
|
@@ -33,7 +34,7 @@ TalkingStick is built as a Rails Engine, and so follows those conventions.
|
|
33
34
|
3. Install and Run migration
|
34
35
|
To add the required models to your application, the migrations must be copied and run:
|
35
36
|
```
|
36
|
-
$ rake
|
37
|
+
$ rake talking_stick:install:migrations db:migrate
|
37
38
|
```
|
38
39
|
|
39
40
|
4. Import Assets
|
@@ -42,9 +43,9 @@ TalkingStick is built as a Rails Engine, and so follows those conventions.
|
|
42
43
|
```javascript
|
43
44
|
//= require talking_stick/application
|
44
45
|
```
|
45
|
-
|
46
|
+
|
46
47
|
And the following to your application's `assets/stylesheets/application.scss`:
|
47
|
-
|
48
|
+
|
48
49
|
```css
|
49
50
|
*= require talking_stick/application
|
50
51
|
```
|
@@ -139,8 +140,8 @@ The Talking Stick is a tradition among Native American (and other) cultures whic
|
|
139
140
|
|
140
141
|
This project is licensed under the MIT License. This project incorporates [Adapter.js from the WebRTC.org team](https://github.com/webrtc/adapter), which is licensed under the Apache license.
|
141
142
|
|
142
|
-
Copyright 2015 Mojo Lingo LLC
|
143
|
+
Copyright 2015-2016 Mojo Lingo LLC
|
143
144
|
|
144
|
-
Portions copyright 2014 The WebRTC project authors
|
145
|
+
Portions copyright 2014-2016 The WebRTC project authors
|
145
146
|
|
146
147
|
[Flikr2005](https://www.flickr.com/photos/flikr/371850310/) loading image courtesy Flickr user [Flikr](https://www.flickr.com/photos/flikr/)
|
@@ -105,9 +105,13 @@ TalkingStick.Partner.prototype.handleAnswer = function(answer) {
|
|
105
105
|
};
|
106
106
|
|
107
107
|
TalkingStick.Partner.prototype.handleRemoteICECandidate = function(candidate) {
|
108
|
+
var self = this;
|
108
109
|
candidate = new RTCIceCandidate(candidate);
|
109
|
-
|
110
|
-
this.peerConnection.addIceCandidate(candidate)
|
110
|
+
|
111
|
+
this.peerConnection.addIceCandidate(candidate)
|
112
|
+
.then(function() { self.log('trace', 'Added remote ICE candidate', candidate) })
|
113
|
+
.catch(function(reason) { self.log('error', 'Error adding remote ICE candidate: ', reason) } )
|
114
|
+
|
111
115
|
};
|
112
116
|
|
113
117
|
TalkingStick.Partner.prototype.handleLocalICECandidate = function(event) {
|
@@ -141,7 +145,8 @@ TalkingStick.Partner.prototype.disconnect = function() {
|
|
141
145
|
|
142
146
|
TalkingStick.Partner.prototype._attachMediaStream = function(stream) {
|
143
147
|
this.log('trace', 'Attaching media stream');
|
144
|
-
var el =
|
148
|
+
var el = this.videoElement[0];
|
149
|
+
el.srcObject = stream;
|
145
150
|
if (el) {
|
146
151
|
// Compatibility with Temasys plugin
|
147
152
|
// See https://temasys.atlassian.net/wiki/display/TWPP/How+to+integrate+the+Temasys+WebRTC+Plugin+into+your+website - "Attach streams"
|
@@ -158,4 +163,3 @@ TalkingStick.Partner._checkForConnection = function() {
|
|
158
163
|
this.trigger('connection_timeout');
|
159
164
|
}
|
160
165
|
};
|
161
|
-
|
@@ -2,7 +2,7 @@ TalkingStick.RailsSignaling = function(options) {
|
|
2
2
|
this.options = options;
|
3
3
|
this.roomUrl = options.url;
|
4
4
|
var self = this;
|
5
|
-
$('#localvideo').on('talking_stick.connected', function() { self.connected.apply(self)} );
|
5
|
+
$('#talking-stick-localvideo').on('talking_stick.connected', function() { self.connected.apply(self)} );
|
6
6
|
}
|
7
7
|
|
8
8
|
TalkingStick.RailsSignaling.prototype.connected = function() {
|
@@ -12,7 +12,7 @@ TalkingStick.RailsSignaling.prototype.connected = function() {
|
|
12
12
|
var pollingInterval = setInterval(function() {
|
13
13
|
signaling._updateRoom.apply(signaling);
|
14
14
|
}, 3000);
|
15
|
-
$('#localvideo').on('talking_stick.disconnected', function() { clearInterval(pollingInterval); });
|
15
|
+
$('#talking-stick-localvideo').on('talking_stick.disconnected', function() { clearInterval(pollingInterval); });
|
16
16
|
}
|
17
17
|
|
18
18
|
TalkingStick.RailsSignaling.prototype.sendICECandidate = function(to, candidate) {
|
@@ -7,8 +7,8 @@ var TalkingStick = (function(self) {
|
|
7
7
|
self.partners = {};
|
8
8
|
self._options = {
|
9
9
|
media: { audio: true, video: true },
|
10
|
-
localVideo: '#localvideo',
|
11
|
-
partnerVideos: '#partnervideos',
|
10
|
+
localVideo: '#talking-stick-localvideo',
|
11
|
+
partnerVideos: '#talking-stick-partnervideos',
|
12
12
|
connectionTimeout: 60000,
|
13
13
|
logLevel: 'error',
|
14
14
|
iceServers: [],
|
@@ -68,10 +68,10 @@ var TalkingStick = (function(self) {
|
|
68
68
|
};
|
69
69
|
|
70
70
|
self.detectDevices = function() {
|
71
|
-
if (typeof
|
71
|
+
if (typeof navigator.mediaDevices === 'undefined' || typeof navigator.mediaDevices.enumerateDevices === 'undefined') {
|
72
72
|
self.log('warning', 'MediaStreamTrack is not defined. We will not be able to offer device selection.');
|
73
73
|
} else {
|
74
|
-
|
74
|
+
navigator.mediaDevices.enumerateDevices().then(self.handleDevices);
|
75
75
|
}
|
76
76
|
};
|
77
77
|
|
@@ -82,8 +82,8 @@ var TalkingStick = (function(self) {
|
|
82
82
|
// Devices (SourceInfo) objects are read-only
|
83
83
|
// Make a copy of the data here so we can apply default labels
|
84
84
|
var tsDevice = {
|
85
|
-
id: "" + device.
|
86
|
-
label: "" + device.label,
|
85
|
+
id: "" + device.deviceId,
|
86
|
+
label: "" + (device.label || device.kind),
|
87
87
|
facing: "" + device.facing,
|
88
88
|
kind: "" + device.kind,
|
89
89
|
}
|
@@ -135,7 +135,7 @@ var TalkingStick = (function(self) {
|
|
135
135
|
self.localVideo[0].muted = true;
|
136
136
|
|
137
137
|
self.log('debug', 'Requesting user consent to access to input devices');
|
138
|
-
getUserMedia(self._options.media, self._handleUserMedia, self._handleUserMediaFailure);
|
138
|
+
navigator.getUserMedia(self._options.media, self._handleUserMedia, self._handleUserMediaFailure);
|
139
139
|
};
|
140
140
|
|
141
141
|
self.muteAudio = function() {
|
@@ -166,12 +166,22 @@ var TalkingStick = (function(self) {
|
|
166
166
|
return !self.myStream.getVideoTracks()[0].enabled;
|
167
167
|
}
|
168
168
|
|
169
|
+
self.toggleAudio = function () {
|
170
|
+
self.audioMuted() ? self.unmuteAudio() : self.muteAudio();
|
171
|
+
return self.audioMuted();
|
172
|
+
}
|
173
|
+
|
174
|
+
self.toggleVideo = function () {
|
175
|
+
self.videoMuted() ? self.unmuteVideo() : self.muteVideo();
|
176
|
+
return self.videoMuted();
|
177
|
+
}
|
178
|
+
|
169
179
|
self._handleUserMedia = function(stream) {
|
170
180
|
self.log('debug', 'User has granted access to input devices');
|
171
181
|
self.myStream = stream;
|
172
182
|
|
173
183
|
// The JS API requires the raw DOM element, not a jQuery wrapper
|
174
|
-
|
184
|
+
self.localVideo[0].srcObject = stream;
|
175
185
|
|
176
186
|
self.trigger('local_media_setup');
|
177
187
|
};
|
@@ -189,7 +199,7 @@ var TalkingStick = (function(self) {
|
|
189
199
|
self.connect = function(name) {
|
190
200
|
// Tell the server we're ready to start contacting the other participants
|
191
201
|
var data = {
|
192
|
-
|
202
|
+
talking_stick_participant: {
|
193
203
|
guid: self.guid,
|
194
204
|
name: name
|
195
205
|
}
|
@@ -31,7 +31,6 @@ module TalkingStick
|
|
31
31
|
|
32
32
|
respond_to do |format|
|
33
33
|
if @participant.save
|
34
|
-
format.html { redirect_to [@room, @participant], notice: 'Participant was successfully created.' }
|
35
34
|
format.json { render json: @participant }
|
36
35
|
else
|
37
36
|
render :new
|
@@ -42,7 +41,7 @@ module TalkingStick
|
|
42
41
|
# PATCH/PUT /participants/1
|
43
42
|
def update
|
44
43
|
if @participant.update(participant_params)
|
45
|
-
redirect_to
|
44
|
+
redirect_to talking_stick.room_path(@room), notice: 'Participant was successfully updated.'
|
46
45
|
else
|
47
46
|
render :edit
|
48
47
|
end
|
@@ -51,7 +50,7 @@ module TalkingStick
|
|
51
50
|
# DELETE /participants/1
|
52
51
|
def destroy
|
53
52
|
@participant.destroy
|
54
|
-
redirect_to
|
53
|
+
redirect_to talking_stick.room_path(@room), notice: 'Participant was successfully destroyed.'
|
55
54
|
end
|
56
55
|
|
57
56
|
private
|
@@ -66,7 +65,7 @@ module TalkingStick
|
|
66
65
|
|
67
66
|
# Only allow a trusted parameter "white list" through.
|
68
67
|
def participant_params
|
69
|
-
params.require(:
|
68
|
+
params.require(:talking_stick_participant).permit(:name, :ip, :guid)
|
70
69
|
end
|
71
70
|
end
|
72
71
|
end
|
@@ -50,7 +50,7 @@ module TalkingStick
|
|
50
50
|
@room = Room.new(room_params)
|
51
51
|
|
52
52
|
if @room.save
|
53
|
-
redirect_to @room, notice: 'Room was successfully created.'
|
53
|
+
redirect_to talking_stick.room_path(@room), url: talking_stick.room_path(@room), notice: 'Room was successfully created.'
|
54
54
|
else
|
55
55
|
render :new
|
56
56
|
end
|
@@ -59,7 +59,7 @@ module TalkingStick
|
|
59
59
|
# PATCH/PUT /rooms/1
|
60
60
|
def update
|
61
61
|
if @room.update(room_params)
|
62
|
-
redirect_to @room, notice: 'Room was successfully updated.'
|
62
|
+
redirect_to talking_stick.room_path(@room), notice: 'Room was successfully updated.'
|
63
63
|
else
|
64
64
|
render :edit
|
65
65
|
end
|
@@ -68,7 +68,7 @@ module TalkingStick
|
|
68
68
|
# DELETE /rooms/1
|
69
69
|
def destroy
|
70
70
|
@room.destroy
|
71
|
-
redirect_to rooms_url, notice: 'Room was successfully destroyed.'
|
71
|
+
redirect_to talking_stick.rooms_url, notice: 'Room was successfully destroyed.'
|
72
72
|
end
|
73
73
|
|
74
74
|
def signal
|
@@ -81,7 +81,8 @@ module TalkingStick
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def deliver_signals!
|
84
|
-
|
84
|
+
return [] unless @participant
|
85
|
+
data = TalkingStick::Signal.where recipient_id: @participant.id
|
85
86
|
|
86
87
|
# Destroy the signals as we return them, since they have been delivered
|
87
88
|
result = []
|
@@ -115,7 +116,7 @@ module TalkingStick
|
|
115
116
|
|
116
117
|
# Only allow a trusted parameter "white list" through.
|
117
118
|
def room_params
|
118
|
-
params.require(:
|
119
|
+
params.require(:talking_stick_room).permit(:name, :last_used)
|
119
120
|
end
|
120
121
|
|
121
122
|
def signal_params
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module TalkingStick
|
2
|
-
class Participant <
|
2
|
+
class Participant < ApplicationRecord
|
3
3
|
belongs_to :room
|
4
4
|
has_many :signals_sent, class_name: 'Signal', foreign_key: 'sender_id', dependent: :destroy
|
5
5
|
has_many :signals_received, class_name: 'Signal', foreign_key: 'recipient_id', dependent: :destroy
|
@@ -12,7 +12,7 @@ module TalkingStick
|
|
12
12
|
|
13
13
|
class << self
|
14
14
|
def remove_stale!(room)
|
15
|
-
self.where(
|
15
|
+
self.where(room_id: room.id).where('last_seen < ?', Time.now - 15.seconds).destroy_all
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module TalkingStick
|
2
|
-
class Room <
|
2
|
+
class Room < ApplicationRecord
|
3
3
|
has_many :participants, dependent: :destroy
|
4
4
|
has_many :signals, dependent: :destroy
|
5
5
|
|
@@ -7,7 +7,7 @@ module TalkingStick
|
|
7
7
|
|
8
8
|
def self.find_or_create(slug:)
|
9
9
|
slug = slug.parameterize
|
10
|
-
|
10
|
+
where(slug: slug).first || create(name: slug.titleize, slug: slug)
|
11
11
|
end
|
12
12
|
|
13
13
|
def to_param
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= form_for([@room, @participant]) do |f| %>
|
1
|
+
<%= form_for([@room, @participant], path: talking_stick.room_participant_path(@room, @participant)) do |f| %>
|
2
2
|
<% if @participant.errors.any? %>
|
3
3
|
<div id="error_explanation">
|
4
4
|
<h2><%= pluralize(@participant.errors.count, "error") %> prohibited this participant from being saved:</h2>
|
@@ -17,7 +17,7 @@
|
|
17
17
|
<td><%= participant.name %></td>
|
18
18
|
<td><%= participant.ip %></td>
|
19
19
|
<td><%= link_to 'Show', [@room, participant] %></td>
|
20
|
-
<td><%= link_to 'Edit', edit_room_participant_path(@room, participant) %></td>
|
20
|
+
<td><%= link_to 'Edit', talking_stick.edit_room_participant_path(@room, participant) %></td>
|
21
21
|
<td><%= link_to 'Destroy', [@room, participant], method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
22
22
|
</tr>
|
23
23
|
<% end %>
|
@@ -26,4 +26,4 @@
|
|
26
26
|
|
27
27
|
<br>
|
28
28
|
|
29
|
-
<%= link_to 'New Participant', new_room_participant_path(@room) %>
|
29
|
+
<%= link_to 'New Participant', talking_stick.new_room_participant_path(@room) %>
|
@@ -10,5 +10,5 @@
|
|
10
10
|
<%= @participant.ip %>
|
11
11
|
</p>
|
12
12
|
|
13
|
-
<%= link_to 'Edit', edit_room_participant_path(@room, @participant) %> |
|
14
|
-
<%= link_to 'Back', room_participants_path %>
|
13
|
+
<%= link_to 'Edit', talking_stick.edit_room_participant_path(@room, @participant) %> |
|
14
|
+
<%= link_to 'Back', talking_stick.room_participants_path %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= form_for(@room) do |f| %>
|
1
|
+
<%= form_for(@room, url: talking_stick.rooms_path) do |f| %>
|
2
2
|
<% if @room.errors.any? %>
|
3
3
|
<div id="error_explanation">
|
4
4
|
<h2><%= pluralize(@room.errors.count, "error") %> prohibited this room from being saved:</h2>
|
@@ -20,7 +20,7 @@
|
|
20
20
|
<div class="form-group">
|
21
21
|
<div id="form-submit-buttons" class="actions">
|
22
22
|
<p><%= f.submit "Save", class: 'btn btn-success' %>
|
23
|
-
<span><%= link_to 'Back', rooms_path, class: 'btn btn-default pull-right' %></span>
|
23
|
+
<span><%= link_to 'Back', talking_stick.rooms_path, class: 'btn btn-default pull-right' %></span>
|
24
24
|
</p>
|
25
25
|
</div>
|
26
26
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div class="container">
|
2
2
|
<p id="notice"><%= notice %></p>
|
3
3
|
|
4
|
-
<%= link_to t(:new_room), new_room_path, class: 'btn btn-success pull-right' %>
|
4
|
+
<%= link_to t(:new_room), talking_stick.new_room_path, class: 'btn btn-success pull-right' %>
|
5
5
|
|
6
6
|
<h1><%= t(:listing_rooms) %></h1>
|
7
7
|
|
@@ -22,9 +22,9 @@
|
|
22
22
|
<tr>
|
23
23
|
<td><%= room.name %></td>
|
24
24
|
<td><%= room.last_used.try(:strftime, "%b %d, %l:%M %P") || t(:last_used_never) %></td>
|
25
|
-
<td><%= link_to 'Enter', room %></td>
|
26
|
-
<td><%= link_to t(:edit), edit_room_path(room) %></td>
|
27
|
-
<td><%= link_to t(:destroy), room, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
25
|
+
<td><%= link_to 'Enter', talking_stick.room_path(room) %></td>
|
26
|
+
<td><%= link_to t(:edit), talking_stick.edit_room_path(room) %></td>
|
27
|
+
<td><%= link_to t(:destroy), talking_stick.room_path(room), method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
28
28
|
</tr>
|
29
29
|
<% end %>
|
30
30
|
</tbody>
|
@@ -1,10 +1,10 @@
|
|
1
1
|
<% content_for(:title) { "#{@room.name} Group Conversation" } %>
|
2
|
-
<div class="container-fluid" role="main" id="room" data-room-name="<%= @room.name %>">
|
2
|
+
<div class="container-fluid" role="main" id="talking-stick-room" data-room-name="<%= @room.name %>">
|
3
3
|
<div class="row">
|
4
4
|
<div class="col-xs-3">
|
5
5
|
<div class="row">
|
6
6
|
<div class="col-xs-12">
|
7
|
-
<div id="localvideo-container"></div>
|
7
|
+
<div id="talking-stick-localvideo-container"></div>
|
8
8
|
</div>
|
9
9
|
<div class="col-xs-12">
|
10
10
|
<span class="navbar-brand"><%= @room.name %></span>
|
@@ -12,12 +12,12 @@
|
|
12
12
|
</div>
|
13
13
|
</div>
|
14
14
|
<div class="col-xs-9">
|
15
|
-
<div id="partnervideos"></div>
|
15
|
+
<div id="talking-stick-partnervideos"></div>
|
16
16
|
</div>
|
17
17
|
</div>
|
18
18
|
</div>
|
19
19
|
|
20
|
-
<div class="modal fade" role="dialog" id="video-preview">
|
20
|
+
<div class="modal fade" role="dialog" id="talking-stick-video-preview">
|
21
21
|
<div class="modal-dialog">
|
22
22
|
<div class="modal-content">
|
23
23
|
<div class="modal-header">
|
@@ -25,12 +25,12 @@
|
|
25
25
|
<h3 class="modal-title"><%= t(:joining_room) %> "<%= @room.name %>"</h3>
|
26
26
|
</div>
|
27
27
|
<div class="modal-body">
|
28
|
-
<video id="localvideo" poster="<%= image_path 'talking_stick/line-spinner.svg' %>" autoplay=true></video>
|
29
|
-
<p id="
|
28
|
+
<video id="talking-stick-localvideo" poster="<%= image_path 'talking_stick/line-spinner.svg' %>" autoplay=true></video>
|
29
|
+
<p id="talking-stick-preview-instructions"><%= t(:video_grant_access) %></p>
|
30
30
|
</div>
|
31
31
|
<div class="modal-footer">
|
32
|
-
<button id="connect" type="button" class="btn btn-default btn-primary" data-dismiss="modal" disabled>Join</button>
|
33
|
-
<%= link_to "Exit",
|
32
|
+
<button id="talking-stick-connect" type="button" class="btn btn-default btn-primary" data-dismiss="modal" disabled>Join</button>
|
33
|
+
<%= link_to "Exit", "history.back()", class: 'btn btn-default' %>
|
34
34
|
</div>
|
35
35
|
</div><!-- /.modal-content -->
|
36
36
|
</div><!-- /.modal-dialog -->
|
@@ -38,44 +38,43 @@
|
|
38
38
|
|
39
39
|
<script type="text/javascript">
|
40
40
|
$(document).ready(function() {
|
41
|
-
$('#sim').click(sim);
|
42
41
|
// Attempt to keep the modal from scrolling vertically
|
43
42
|
// 300px is the approximate height of the modal, minus the video
|
44
|
-
$('#video-preview').find('video').height($(window).height() - 300);
|
45
|
-
$('#video-preview').modal({backdrop: 'static', keyboard: false, show: true});
|
43
|
+
$('#talking-stick-video-preview').find('video').height($(window).height() - 300);
|
44
|
+
$('#talking-stick-video-preview').modal({backdrop: 'static', keyboard: false, show: true});
|
46
45
|
var myGuid = TalkingStick.generateGUID();
|
47
46
|
// Use the least-common-denominator, Rails API, for WebRTC setup
|
48
47
|
var options = {
|
49
|
-
url: '<%= room_path %>',
|
48
|
+
url: '<%= talking_stick.room_path %>',
|
50
49
|
myGuid: myGuid,
|
51
50
|
};
|
52
51
|
var signalingEngine = new TalkingStick.RailsSignaling(options);
|
53
52
|
|
54
53
|
var options = {
|
55
54
|
guid: myGuid,
|
56
|
-
roomUrl: '<%= room_path %>',
|
55
|
+
roomUrl: '<%= talking_stick.room_path %>',
|
57
56
|
signalingEngine: signalingEngine,
|
58
57
|
logLevel: 'trace',
|
59
58
|
};
|
60
59
|
TalkingStick.init(options);
|
61
60
|
|
62
|
-
$('#connect').click(startSession);
|
61
|
+
$('#talking-stick-connect').click(startSession);
|
63
62
|
$(window).on('talking_stick.local_media_setup', function() {
|
64
|
-
$('#
|
65
|
-
$('
|
63
|
+
$('#talking-stick-preview-instructions').html('<%= t(:video_intro) %>');
|
64
|
+
$('#talking-stick-connect').attr('disabled', false);
|
66
65
|
});
|
67
66
|
});
|
68
67
|
|
69
68
|
function startSession() {
|
70
|
-
$('#localvideo').detach().appendTo('#localvideo-container');
|
71
|
-
$('#localvideo').height('auto');
|
69
|
+
$('#talking-stick-localvideo').detach().appendTo('#talking-stick-localvideo-container');
|
70
|
+
$('#talking-stick-localvideo').height('auto');
|
72
71
|
// Gotta restart and re-mute the video after moving it
|
73
|
-
$('#localvideo')[0].play();
|
72
|
+
$('#talking-stick-localvideo')[0].play();
|
74
73
|
TalkingStick.connect();
|
75
74
|
};
|
76
75
|
|
77
76
|
function resizeVideos() {
|
78
|
-
var videoCollection = $('#partnervideos video');
|
77
|
+
var videoCollection = $('#talking-stick-partnervideos video');
|
79
78
|
var numVideos = videoCollection.length;
|
80
79
|
var square = Math.sqrt(numVideos);
|
81
80
|
if (!isInt(square)) {
|
@@ -93,8 +92,8 @@ function cleanupPartner() {
|
|
93
92
|
function sim() {
|
94
93
|
var el = $(document.createElement('video'));
|
95
94
|
el.attr('poster', "<%= image_path 'talking_stick/line-spinner.svg' %>");
|
96
|
-
$('#partnervideos').append(el);
|
97
|
-
TalkingStick.localVideo = $('#localvideo');
|
95
|
+
$('#talking-stick-partnervideos').append(el);
|
96
|
+
TalkingStick.localVideo = $('#talking-stick-localvideo');
|
98
97
|
TalkingStick.trigger('partner.media', el);
|
99
98
|
}
|
100
99
|
|
@@ -106,6 +105,9 @@ function isInt(value){
|
|
106
105
|
}
|
107
106
|
}
|
108
107
|
|
108
|
+
$(window).on('talking_stick.new_partner', function(ev, partner) {
|
109
|
+
$('#talking-stick-partnervideos').append(partner.videoElement);
|
110
|
+
});
|
109
111
|
$(window).on('talking_stick.partner.media', resizeVideos);
|
110
112
|
$(window).on('talking_stick.partner.cleanup', cleanupPartner);
|
111
113
|
$(window).resize(resizeVideos);
|
data/config/routes.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
TalkingStick::Engine.routes.draw do
|
2
|
-
resources :rooms do
|
3
|
-
resources :participants do
|
4
|
-
post 'signals', to: 'rooms#signal'
|
2
|
+
resources :rooms, controller: 'talking_stick/rooms' do
|
3
|
+
resources :participants, controller: 'talking_stick/participants' do
|
4
|
+
post 'signals', to: 'talking_stick/rooms#signal'
|
5
5
|
end
|
6
6
|
end
|
7
7
|
end
|
data/lib/talking_stick/engine.rb
CHANGED
@@ -1,12 +1,18 @@
|
|
1
|
+
require "jquery-rails"
|
2
|
+
|
1
3
|
module TalkingStick
|
2
4
|
class Engine < ::Rails::Engine
|
3
|
-
|
5
|
+
engine_name "talking_stick"
|
4
6
|
|
5
7
|
config.generators do |g|
|
6
8
|
g.test_framework :rspec, :fixture => false
|
7
9
|
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
|
8
|
-
g.assets
|
10
|
+
g.assets true
|
9
11
|
g.helper false
|
10
12
|
end
|
13
|
+
|
14
|
+
initializer "talking_stick.assets.precompile" do |app|
|
15
|
+
app.config.assets.precompile += %w( application.js application.css )
|
16
|
+
end
|
11
17
|
end
|
12
18
|
end
|
data/lib/talking_stick.rb
CHANGED
@@ -24,9 +24,5 @@ module Dummy
|
|
24
24
|
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
25
25
|
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
26
26
|
# config.i18n.default_locale = :de
|
27
|
-
|
28
|
-
# Do not swallow errors in after_commit/after_rollback callbacks.
|
29
|
-
config.active_record.raise_in_transactional_callbacks = true
|
30
27
|
end
|
31
28
|
end
|
32
|
-
|
data/talking_stick.gemspec
CHANGED
@@ -17,13 +17,14 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.files = `git ls-files`.split("\n")
|
18
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
19
|
|
20
|
-
s.add_dependency 'rails', '
|
21
|
-
s.add_dependency 'jquery-rails', '
|
20
|
+
s.add_dependency 'rails', '>= 4.2', '< 5.1'
|
21
|
+
s.add_dependency 'jquery-rails', '>= 4.2'
|
22
22
|
|
23
23
|
s.add_development_dependency 'sqlite3'
|
24
24
|
s.add_development_dependency 'guard'
|
25
25
|
s.add_development_dependency 'guard-rspec'
|
26
26
|
s.add_development_dependency 'rspec-rails'
|
27
27
|
s.add_development_dependency 'capybara'
|
28
|
+
s.add_development_dependency 'byebug'
|
28
29
|
s.add_development_dependency 'factory_girl_rails'
|
29
30
|
end
|