talking_stick 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +15 -0
  5. data/LICENSE.md +50 -0
  6. data/README.md +111 -0
  7. data/Rakefile +32 -0
  8. data/app/assets/images/talking_stick/.keep +0 -0
  9. data/app/assets/javascripts/talking_stick/application.js +15 -0
  10. data/app/assets/javascripts/talking_stick/talking_stick.js +141 -0
  11. data/app/assets/javascripts/talking_stick/talking_stick/partner.js +100 -0
  12. data/app/assets/javascripts/talking_stick/talking_stick/rails_signaling.js +117 -0
  13. data/app/assets/stylesheets/talking_stick/application.css +15 -0
  14. data/app/controllers/talking_stick/application_controller.rb +4 -0
  15. data/app/controllers/talking_stick/participants_controller.rb +72 -0
  16. data/app/controllers/talking_stick/rooms_controller.rb +122 -0
  17. data/app/helpers/talking_stick/application_helper.rb +4 -0
  18. data/app/models/talking_stick/participant.rb +18 -0
  19. data/app/models/talking_stick/room.rb +6 -0
  20. data/app/models/talking_stick/signal.rb +17 -0
  21. data/app/views/layouts/talking_stick/application.html.erb +14 -0
  22. data/app/views/talking_stick/participants/_form.html.erb +25 -0
  23. data/app/views/talking_stick/participants/edit.html.erb +6 -0
  24. data/app/views/talking_stick/participants/index.html.erb +29 -0
  25. data/app/views/talking_stick/participants/new.html.erb +5 -0
  26. data/app/views/talking_stick/participants/show.html.erb +14 -0
  27. data/app/views/talking_stick/rooms/_form.html.erb +25 -0
  28. data/app/views/talking_stick/rooms/edit.html.erb +6 -0
  29. data/app/views/talking_stick/rooms/index.html.erb +29 -0
  30. data/app/views/talking_stick/rooms/new.html.erb +5 -0
  31. data/app/views/talking_stick/rooms/show.html.erb +40 -0
  32. data/bin/rails +12 -0
  33. data/config/routes.rb +7 -0
  34. data/db/migrate/20150510181337_create_talking_stick_rooms.rb +10 -0
  35. data/db/migrate/20150510182258_create_talking_stick_participants.rb +14 -0
  36. data/db/migrate/20150511005922_create_talking_stick_signals.rb +12 -0
  37. data/lib/talking_stick.rb +4 -0
  38. data/lib/talking_stick/engine.rb +12 -0
  39. data/lib/talking_stick/version.rb +3 -0
  40. data/lib/tasks/talking_stick_tasks.rake +4 -0
  41. data/spec/dummy/README.rdoc +28 -0
  42. data/spec/dummy/Rakefile +6 -0
  43. data/spec/dummy/app/assets/images/.keep +0 -0
  44. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  45. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  46. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  47. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  48. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  49. data/spec/dummy/app/mailers/.keep +0 -0
  50. data/spec/dummy/app/models/.keep +0 -0
  51. data/spec/dummy/app/models/concerns/.keep +0 -0
  52. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  53. data/spec/dummy/bin/bundle +3 -0
  54. data/spec/dummy/bin/rails +4 -0
  55. data/spec/dummy/bin/rake +4 -0
  56. data/spec/dummy/bin/setup +29 -0
  57. data/spec/dummy/config.ru +4 -0
  58. data/spec/dummy/config/application.rb +32 -0
  59. data/spec/dummy/config/boot.rb +5 -0
  60. data/spec/dummy/config/database.yml +25 -0
  61. data/spec/dummy/config/environment.rb +5 -0
  62. data/spec/dummy/config/environments/development.rb +41 -0
  63. data/spec/dummy/config/environments/production.rb +79 -0
  64. data/spec/dummy/config/environments/test.rb +42 -0
  65. data/spec/dummy/config/initializers/assets.rb +11 -0
  66. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  67. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  68. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  69. data/spec/dummy/config/initializers/inflections.rb +16 -0
  70. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  71. data/spec/dummy/config/initializers/session_store.rb +3 -0
  72. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  73. data/spec/dummy/config/locales/en.yml +23 -0
  74. data/spec/dummy/config/routes.rb +4 -0
  75. data/spec/dummy/config/secrets.yml +22 -0
  76. data/spec/dummy/lib/assets/.keep +0 -0
  77. data/spec/dummy/log/.keep +0 -0
  78. data/spec/dummy/public/404.html +67 -0
  79. data/spec/dummy/public/422.html +67 -0
  80. data/spec/dummy/public/500.html +66 -0
  81. data/spec/dummy/public/favicon.ico +0 -0
  82. data/spec/models/talking_stick/participant_spec.rb +7 -0
  83. data/spec/models/talking_stick/room_spec.rb +7 -0
  84. data/spec/spec_helper.rb +13 -0
  85. data/talking_stick.gemspec +27 -0
  86. data/vendor/assets/javascripts/talking_stick/adapter.js +243 -0
  87. metadata +258 -0
@@ -0,0 +1,5 @@
1
+ <h1>New Participant</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', room_participants_path %>
@@ -0,0 +1,14 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <strong>Name:</strong>
5
+ <%= @participant.name %>
6
+ </p>
7
+
8
+ <p>
9
+ <strong>Ip:</strong>
10
+ <%= @participant.ip %>
11
+ </p>
12
+
13
+ <%= link_to 'Edit', edit_room_participant_path(@room, @participant) %> |
14
+ <%= link_to 'Back', room_participants_path %>
@@ -0,0 +1,25 @@
1
+ <%= form_for(@room) do |f| %>
2
+ <% if @room.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@room.errors.count, "error") %> prohibited this room from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @room.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br>
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :last_used %><br>
20
+ <%= f.datetime_select :last_used %>
21
+ </div>
22
+ <div class="actions">
23
+ <%= f.submit %>
24
+ </div>
25
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing Room</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @room %> |
6
+ <%= link_to 'Back', rooms_path %>
@@ -0,0 +1,29 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <h1>Listing Rooms</h1>
4
+
5
+ <table>
6
+ <thead>
7
+ <tr>
8
+ <th>Name</th>
9
+ <th>Last used</th>
10
+ <th colspan="3"></th>
11
+ </tr>
12
+ </thead>
13
+
14
+ <tbody>
15
+ <% @rooms.each do |room| %>
16
+ <tr>
17
+ <td><%= room.name %></td>
18
+ <td><%= room.last_used %></td>
19
+ <td><%= link_to 'Show', room %></td>
20
+ <td><%= link_to 'Edit', edit_room_path(room) %></td>
21
+ <td><%= link_to 'Destroy', room, method: :delete, data: { confirm: 'Are you sure?' } %></td>
22
+ </tr>
23
+ <% end %>
24
+ </tbody>
25
+ </table>
26
+
27
+ <br>
28
+
29
+ <%= link_to 'New Room', new_room_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New Room</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', rooms_path %>
@@ -0,0 +1,40 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <strong>Name:</strong>
5
+ <%= @room.name %>
6
+ </p>
7
+
8
+ <p>
9
+ <button id="connect">Connect to room</button>
10
+ </p>
11
+
12
+ <video id="localvideo"></video>
13
+ <div id="partnerVideos"></div>
14
+
15
+ <%= link_to 'Edit', edit_room_path(@room) %> |
16
+ <%= link_to 'Back', rooms_path %>
17
+
18
+ <script type="text/javascript">
19
+ $(document).ready(function() {
20
+ var myGuid = TalkingStick.generateGUID();
21
+ // Use the least-common-denominator, Rails API, for WebRTC setup
22
+ var options = {
23
+ url: '<%= room_path %>',
24
+ myGuid: myGuid,
25
+ };
26
+ var signalingEngine = new TalkingStick.RailsSignaling(options);
27
+
28
+ var options = {
29
+ guid: myGuid,
30
+ localVideo: $('#localvideo'),
31
+ roomUrl: '<%= room_path %>',
32
+ signalingEngine: signalingEngine,
33
+ logLevel: 'debug',
34
+ };
35
+ TalkingStick.init(options);
36
+
37
+ $('#connect').click(TalkingStick.connect);
38
+
39
+ });
40
+ </script>
data/bin/rails ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/talking_stick/engine', __FILE__)
6
+
7
+ # Set up gems listed in the Gemfile.
8
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
9
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
10
+
11
+ require 'rails/all'
12
+ require 'rails/engine/commands'
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ TalkingStick::Engine.routes.draw do
2
+ resources :rooms do
3
+ resources :participants do
4
+ post 'signals', to: 'rooms#signal'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ class CreateTalkingStickRooms < ActiveRecord::Migration
2
+ def change
3
+ create_table :talking_stick_rooms do |t|
4
+ t.string :name
5
+ t.timestamp :last_used
6
+
7
+ t.timestamps null: false
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ class CreateTalkingStickParticipants < ActiveRecord::Migration
2
+ def change
3
+ create_table :talking_stick_participants do |t|
4
+ t.string :name
5
+ t.string :ip
6
+ t.string :guid, index: true
7
+ t.timestamp :joined_at
8
+ t.timestamp :last_seen
9
+ t.belongs_to :room, index: true
10
+
11
+ t.timestamps null: false
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ class CreateTalkingStickSignals < ActiveRecord::Migration
2
+ def change
3
+ create_table :talking_stick_signals do |t|
4
+ t.belongs_to :room
5
+ t.belongs_to :sender, class_name: "TalkingStick::Participant", index: true
6
+ t.belongs_to :recipient, class_name: "TalkingStick::Participant", index: true
7
+ t.string :signal_type
8
+ t.text :data
9
+ t.timestamps null: false
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ require "talking_stick/engine"
2
+
3
+ module TalkingStick
4
+ end
@@ -0,0 +1,12 @@
1
+ module TalkingStick
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace TalkingStick
4
+
5
+ config.generators do |g|
6
+ g.test_framework :rspec, :fixture => false
7
+ g.fixture_replacement :factory_girl, :dir => 'spec/factories'
8
+ g.assets false
9
+ g.helper false
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module TalkingStick
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :talking_stick do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
File without changes
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+
7
+ Dir.chdir APP_ROOT do
8
+ # This script is a starting point to setup your application.
9
+ # Add necessary setup steps to this file:
10
+
11
+ puts "== Installing dependencies =="
12
+ system "gem install bundler --conservative"
13
+ system "bundle check || bundle install"
14
+
15
+ # puts "\n== Copying sample files =="
16
+ # unless File.exist?("config/database.yml")
17
+ # system "cp config/database.yml.sample config/database.yml"
18
+ # end
19
+
20
+ puts "\n== Preparing database =="
21
+ system "bin/rake db:setup"
22
+
23
+ puts "\n== Removing old logs and tempfiles =="
24
+ system "rm -f log/*"
25
+ system "rm -rf tmp/cache"
26
+
27
+ puts "\n== Restarting application server =="
28
+ system "touch tmp/restart.txt"
29
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,32 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ # Pick the frameworks you want:
4
+ require "active_record/railtie"
5
+ require "action_controller/railtie"
6
+ require "action_mailer/railtie"
7
+ require "action_view/railtie"
8
+ require "sprockets/railtie"
9
+ # require "rails/test_unit/railtie"
10
+
11
+ Bundler.require(*Rails.groups)
12
+ require "talking_stick"
13
+
14
+ module Dummy
15
+ class Application < Rails::Application
16
+ # Settings in config/environments/* take precedence over those specified here.
17
+ # Application configuration should go into files in config/initializers
18
+ # -- all .rb files in that directory are automatically loaded.
19
+
20
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
21
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
22
+ # config.time_zone = 'Central Time (US & Canada)'
23
+
24
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
25
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
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
+ end
31
+ end
32
+
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ #
7
+ default: &default
8
+ adapter: sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ development:
13
+ <<: *default
14
+ database: db/development.sqlite3
15
+
16
+ # Warning: The database defined as "test" will be erased and
17
+ # re-generated from your development database when you run "rake".
18
+ # Do not set this db to the same as development or production.
19
+ test:
20
+ <<: *default
21
+ database: db/test.sqlite3
22
+
23
+ production:
24
+ <<: *default
25
+ database: db/production.sqlite3