bigbluebutton_rails 0.0.1

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.
Files changed (97) hide show
  1. data/.gitignore +6 -0
  2. data/.rspec +2 -0
  3. data/CHANGELOG.rdoc +6 -0
  4. data/Gemfile +4 -0
  5. data/Gemfile.lock +111 -0
  6. data/README.rdoc +147 -0
  7. data/Rakefile +37 -0
  8. data/app/controllers/bigbluebutton/rooms_controller.rb +193 -0
  9. data/app/controllers/bigbluebutton/servers_controller.rb +56 -0
  10. data/app/models/bigbluebutton_room.rb +16 -0
  11. data/app/models/bigbluebutton_server.rb +25 -0
  12. data/app/views/bigbluebutton/rooms/_form.html.erb +41 -0
  13. data/app/views/bigbluebutton/rooms/edit.html.erb +6 -0
  14. data/app/views/bigbluebutton/rooms/index.html.erb +34 -0
  15. data/app/views/bigbluebutton/rooms/join_wait.html.erb +27 -0
  16. data/app/views/bigbluebutton/rooms/new.html.erb +5 -0
  17. data/app/views/bigbluebutton/rooms/show.html.erb +35 -0
  18. data/app/views/bigbluebutton/servers/_form.html.erb +32 -0
  19. data/app/views/bigbluebutton/servers/edit.html.erb +6 -0
  20. data/app/views/bigbluebutton/servers/index.html.erb +27 -0
  21. data/app/views/bigbluebutton/servers/new.html.erb +5 -0
  22. data/app/views/bigbluebutton/servers/show.html.erb +31 -0
  23. data/bigbluebutton_rails.gemspec +27 -0
  24. data/config/locales/en.yml +18 -0
  25. data/config/routes.rb +2 -0
  26. data/lib/bigbluebutton_rails.rb +7 -0
  27. data/lib/bigbluebutton_rails/controller_methods.rb +52 -0
  28. data/lib/bigbluebutton_rails/rails.rb +11 -0
  29. data/lib/bigbluebutton_rails/rails/routes.rb +102 -0
  30. data/lib/bigbluebutton_rails/version.rb +3 -0
  31. data/lib/generators/bigbluebutton_rails/install_generator.rb +25 -0
  32. data/lib/generators/bigbluebutton_rails/public_generator.rb +17 -0
  33. data/lib/generators/bigbluebutton_rails/templates/migration.rb +31 -0
  34. data/lib/generators/bigbluebutton_rails/templates/public/images/loading.gif +0 -0
  35. data/lib/generators/bigbluebutton_rails/templates/public/javascripts/heartbeat.js +54 -0
  36. data/lib/generators/bigbluebutton_rails/templates/public/javascripts/jquery.min.js +16 -0
  37. data/lib/generators/bigbluebutton_rails/views_generator.rb +18 -0
  38. data/spec/bigbluebutton_rails_spec.rb +11 -0
  39. data/spec/controllers/bigbluebutton/rooms_controller_spec.rb +404 -0
  40. data/spec/controllers/bigbluebutton/servers_controller_spec.rb +78 -0
  41. data/spec/factories/bigbluebutton_room.rb +8 -0
  42. data/spec/factories/bigbluebutton_server.rb +6 -0
  43. data/spec/generators/install_generator_spec.rb +23 -0
  44. data/spec/generators/public_generator_spec.rb +32 -0
  45. data/spec/generators/views_generator_spec.rb +52 -0
  46. data/spec/models/bigbluebutton_room_spec.rb +48 -0
  47. data/spec/models/bigbluebutton_server_spec.rb +83 -0
  48. data/spec/rails_app/.gitignore +3 -0
  49. data/spec/rails_app/Rakefile +7 -0
  50. data/spec/rails_app/app/controllers/application_controller.rb +16 -0
  51. data/spec/rails_app/app/controllers/space_controller.rb +8 -0
  52. data/spec/rails_app/app/controllers/user_controller.rb +8 -0
  53. data/spec/rails_app/app/helpers/application_helper.rb +2 -0
  54. data/spec/rails_app/app/views/layouts/application.html.erb +14 -0
  55. data/spec/rails_app/app/views/space/index.html.erb +2 -0
  56. data/spec/rails_app/app/views/space/show.html.erb +2 -0
  57. data/spec/rails_app/app/views/user/index.html.erb +2 -0
  58. data/spec/rails_app/app/views/user/show.html.erb +2 -0
  59. data/spec/rails_app/config.ru +4 -0
  60. data/spec/rails_app/config/application.rb +45 -0
  61. data/spec/rails_app/config/boot.rb +10 -0
  62. data/spec/rails_app/config/database.yml +22 -0
  63. data/spec/rails_app/config/environment.rb +5 -0
  64. data/spec/rails_app/config/environments/development.rb +26 -0
  65. data/spec/rails_app/config/environments/production.rb +49 -0
  66. data/spec/rails_app/config/environments/test.rb +35 -0
  67. data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  68. data/spec/rails_app/config/initializers/inflections.rb +10 -0
  69. data/spec/rails_app/config/initializers/mime_types.rb +5 -0
  70. data/spec/rails_app/config/initializers/secret_token.rb +7 -0
  71. data/spec/rails_app/config/initializers/session_store.rb +8 -0
  72. data/spec/rails_app/config/locales/en.yml +5 -0
  73. data/spec/rails_app/config/routes.rb +14 -0
  74. data/spec/rails_app/db/seeds.rb +7 -0
  75. data/spec/rails_app/doc/README_FOR_APP +2 -0
  76. data/spec/rails_app/public/404.html +26 -0
  77. data/spec/rails_app/public/422.html +26 -0
  78. data/spec/rails_app/public/500.html +26 -0
  79. data/spec/rails_app/public/favicon.ico +0 -0
  80. data/spec/rails_app/public/images/rails.png +0 -0
  81. data/spec/rails_app/public/index.html +239 -0
  82. data/spec/rails_app/public/javascripts/application.js +2 -0
  83. data/spec/rails_app/public/javascripts/controls.js +965 -0
  84. data/spec/rails_app/public/javascripts/dragdrop.js +974 -0
  85. data/spec/rails_app/public/javascripts/effects.js +1123 -0
  86. data/spec/rails_app/public/javascripts/prototype.js +6001 -0
  87. data/spec/rails_app/public/javascripts/rails.js +191 -0
  88. data/spec/rails_app/public/robots.txt +5 -0
  89. data/spec/rails_app/public/stylesheets/.gitkeep +0 -0
  90. data/spec/rails_app/public/stylesheets/scaffold.css +56 -0
  91. data/spec/rails_app/script/rails +6 -0
  92. data/spec/rails_app/vendor/plugins/.gitkeep +0 -0
  93. data/spec/routing/bigbluebutton/rooms_routing_spec.rb +89 -0
  94. data/spec/routing/bigbluebutton/servers_routing_spec.rb +38 -0
  95. data/spec/spec_helper.rb +37 -0
  96. data/spec/support/matchers/have_same_attributes_as.rb +10 -0
  97. metadata +234 -0
@@ -0,0 +1,191 @@
1
+ (function() {
2
+ // Technique from Juriy Zaytsev
3
+ // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
4
+ function isEventSupported(eventName) {
5
+ var el = document.createElement('div');
6
+ eventName = 'on' + eventName;
7
+ var isSupported = (eventName in el);
8
+ if (!isSupported) {
9
+ el.setAttribute(eventName, 'return;');
10
+ isSupported = typeof el[eventName] == 'function';
11
+ }
12
+ el = null;
13
+ return isSupported;
14
+ }
15
+
16
+ function isForm(element) {
17
+ return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM'
18
+ }
19
+
20
+ function isInput(element) {
21
+ if (Object.isElement(element)) {
22
+ var name = element.nodeName.toUpperCase()
23
+ return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA'
24
+ }
25
+ else return false
26
+ }
27
+
28
+ var submitBubbles = isEventSupported('submit'),
29
+ changeBubbles = isEventSupported('change')
30
+
31
+ if (!submitBubbles || !changeBubbles) {
32
+ // augment the Event.Handler class to observe custom events when needed
33
+ Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap(
34
+ function(init, element, eventName, selector, callback) {
35
+ init(element, eventName, selector, callback)
36
+ // is the handler being attached to an element that doesn't support this event?
37
+ if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
38
+ (!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
39
+ // "submit" => "emulated:submit"
40
+ this.eventName = 'emulated:' + this.eventName
41
+ }
42
+ }
43
+ )
44
+ }
45
+
46
+ if (!submitBubbles) {
47
+ // discover forms on the page by observing focus events which always bubble
48
+ document.on('focusin', 'form', function(focusEvent, form) {
49
+ // special handler for the real "submit" event (one-time operation)
50
+ if (!form.retrieve('emulated:submit')) {
51
+ form.on('submit', function(submitEvent) {
52
+ var emulated = form.fire('emulated:submit', submitEvent, true)
53
+ // if custom event received preventDefault, cancel the real one too
54
+ if (emulated.returnValue === false) submitEvent.preventDefault()
55
+ })
56
+ form.store('emulated:submit', true)
57
+ }
58
+ })
59
+ }
60
+
61
+ if (!changeBubbles) {
62
+ // discover form inputs on the page
63
+ document.on('focusin', 'input, select, texarea', function(focusEvent, input) {
64
+ // special handler for real "change" events
65
+ if (!input.retrieve('emulated:change')) {
66
+ input.on('change', function(changeEvent) {
67
+ input.fire('emulated:change', changeEvent, true)
68
+ })
69
+ input.store('emulated:change', true)
70
+ }
71
+ })
72
+ }
73
+
74
+ function handleRemote(element) {
75
+ var method, url, params;
76
+
77
+ var event = element.fire("ajax:before");
78
+ if (event.stopped) return false;
79
+
80
+ if (element.tagName.toLowerCase() === 'form') {
81
+ method = element.readAttribute('method') || 'post';
82
+ url = element.readAttribute('action');
83
+ params = element.serialize();
84
+ } else {
85
+ method = element.readAttribute('data-method') || 'get';
86
+ url = element.readAttribute('href');
87
+ params = {};
88
+ }
89
+
90
+ new Ajax.Request(url, {
91
+ method: method,
92
+ parameters: params,
93
+ evalScripts: true,
94
+
95
+ onComplete: function(request) { element.fire("ajax:complete", request); },
96
+ onSuccess: function(request) { element.fire("ajax:success", request); },
97
+ onFailure: function(request) { element.fire("ajax:failure", request); }
98
+ });
99
+
100
+ element.fire("ajax:after");
101
+ }
102
+
103
+ function handleMethod(element) {
104
+ var method = element.readAttribute('data-method'),
105
+ url = element.readAttribute('href'),
106
+ csrf_param = $$('meta[name=csrf-param]')[0],
107
+ csrf_token = $$('meta[name=csrf-token]')[0];
108
+
109
+ var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
110
+ element.parentNode.insert(form);
111
+
112
+ if (method !== 'post') {
113
+ var field = new Element('input', { type: 'hidden', name: '_method', value: method });
114
+ form.insert(field);
115
+ }
116
+
117
+ if (csrf_param) {
118
+ var param = csrf_param.readAttribute('content'),
119
+ token = csrf_token.readAttribute('content'),
120
+ field = new Element('input', { type: 'hidden', name: param, value: token });
121
+ form.insert(field);
122
+ }
123
+
124
+ form.submit();
125
+ }
126
+
127
+
128
+ document.on("click", "*[data-confirm]", function(event, element) {
129
+ var message = element.readAttribute('data-confirm');
130
+ if (!confirm(message)) event.stop();
131
+ });
132
+
133
+ document.on("click", "a[data-remote]", function(event, element) {
134
+ if (event.stopped) return;
135
+ handleRemote(element);
136
+ event.stop();
137
+ });
138
+
139
+ document.on("click", "a[data-method]", function(event, element) {
140
+ if (event.stopped) return;
141
+ handleMethod(element);
142
+ event.stop();
143
+ });
144
+
145
+ document.on("submit", function(event) {
146
+ var element = event.findElement(),
147
+ message = element.readAttribute('data-confirm');
148
+ if (message && !confirm(message)) {
149
+ event.stop();
150
+ return false;
151
+ }
152
+
153
+ var inputs = element.select("input[type=submit][data-disable-with]");
154
+ inputs.each(function(input) {
155
+ input.disabled = true;
156
+ input.writeAttribute('data-original-value', input.value);
157
+ input.value = input.readAttribute('data-disable-with');
158
+ });
159
+
160
+ var element = event.findElement("form[data-remote]");
161
+ if (element) {
162
+ handleRemote(element);
163
+ event.stop();
164
+ }
165
+ });
166
+
167
+ document.on("ajax:after", "form", function(event, element) {
168
+ var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
169
+ inputs.each(function(input) {
170
+ input.value = input.readAttribute('data-original-value');
171
+ input.removeAttribute('data-original-value');
172
+ input.disabled = false;
173
+ });
174
+ });
175
+
176
+ Ajax.Responders.register({
177
+ onCreate: function(request) {
178
+ var csrf_meta_tag = $$('meta[name=csrf-token]')[0];
179
+
180
+ if (csrf_meta_tag) {
181
+ var header = 'X-CSRF-Token',
182
+ token = csrf_meta_tag.readAttribute('content');
183
+
184
+ if (!request.options.requestHeaders) {
185
+ request.options.requestHeaders = {};
186
+ }
187
+ request.options.requestHeaders[header] = token;
188
+ }
189
+ }
190
+ });
191
+ })();
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-Agent: *
5
+ # Disallow: /
File without changes
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
File without changes
@@ -0,0 +1,89 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bigbluebutton::RoomsController do
4
+ include Shoulda::Matchers::ActionController
5
+
6
+ describe "routing" do
7
+
8
+ # normal and scoped routes
9
+ ['bigbluebutton', 'webconference'].each do |prefix|
10
+
11
+ it {
12
+ {:get => "/#{prefix}/servers/1/rooms"}.
13
+ should route_to(:controller => "bigbluebutton/rooms", :action => "index", :server_id => "1")
14
+ }
15
+ it {
16
+ {:get => "/#{prefix}/servers/1/rooms/new"}.
17
+ should route_to(:controller => "bigbluebutton/rooms", :action => "new", :server_id => "1")
18
+ }
19
+ it {
20
+ {:get => "/#{prefix}/servers/1/rooms/1/edit"}.
21
+ should route_to(:controller => "bigbluebutton/rooms", :action => "edit", :server_id => "1", :id => "1")
22
+ }
23
+ it {
24
+ {:get => "/#{prefix}/servers/1/rooms/1"}.
25
+ should route_to(:controller => "bigbluebutton/rooms", :action => "show", :server_id => "1", :id => "1")
26
+ }
27
+ it {
28
+ {:put => "/#{prefix}/servers/1/rooms/1"}.
29
+ should route_to(:controller => "bigbluebutton/rooms", :action => "update", :server_id => "1", :id => "1")
30
+ }
31
+ it {
32
+ {:delete => "/#{prefix}/servers/1/rooms/1"}.
33
+ should route_to(:controller => "bigbluebutton/rooms", :action => "destroy", :server_id => "1", :id => "1")
34
+ }
35
+ it {
36
+ {:get => "/#{prefix}/servers/1/rooms/1/join"}.
37
+ should route_to(:controller => "bigbluebutton/rooms", :action => "join", :server_id => "1", :id => "1")
38
+ }
39
+ it {
40
+ {:get => "/#{prefix}/servers/1/rooms/1/running"}.
41
+ should route_to(:controller => "bigbluebutton/rooms", :action => "running", :server_id => "1", :id => "1")
42
+ }
43
+ it {
44
+ {:get => "/#{prefix}/servers/1/rooms/1/end"}.
45
+ should route_to(:controller => "bigbluebutton/rooms", :action => "end", :server_id => "1", :id => "1")
46
+ }
47
+
48
+ end
49
+
50
+ # room matchers inside users
51
+ it {
52
+ should route(:get, "/users/1/room/1").
53
+ to(:action => :show, :user_id => "1", :id => "1")
54
+ }
55
+ it {
56
+ should route(:get, "/users/1/room/1/join").
57
+ to(:action => :join, :user_id => "1", :id => "1")
58
+ }
59
+ it {
60
+ should route(:get, "/users/1/room/1/running").
61
+ to(:action => :running, :user_id => "1", :id => "1")
62
+ }
63
+ it {
64
+ should route(:get, "/users/1/room/1/end").
65
+ to(:action => :end, :user_id => "1", :id => "1")
66
+ }
67
+
68
+ # room matchers inside users/spaces
69
+ # FIXME shoulda-matcher is not working here, why?
70
+ it {
71
+ { :get => "/users/1/spaces/2/room/3" }.
72
+ should route_to(:controller => "bigbluebutton/rooms", :action => "show", :user_id => "1", :space_id => "2", :id => "3")
73
+ }
74
+ it {
75
+ { :get => "/users/1/spaces/2/room/3/join" }.
76
+ should route_to(:controller => "bigbluebutton/rooms", :action => "join", :user_id => "1", :space_id => "2", :id => "3")
77
+ }
78
+ it {
79
+ { :get => "/users/1/spaces/2/room/3/running" }.
80
+ should route_to(:controller => "bigbluebutton/rooms", :action => "running", :user_id => "1", :space_id => "2", :id => "3")
81
+ }
82
+ it {
83
+ { :get => "/users/1/spaces/2/room/3/end" }.
84
+ should route_to(:controller => "bigbluebutton/rooms", :action => "end", :user_id => "1", :space_id => "2", :id => "3")
85
+ }
86
+ end
87
+
88
+ end
89
+
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bigbluebutton::ServersController do
4
+ include Shoulda::Matchers::ActionController
5
+
6
+ describe "routing" do
7
+ it {
8
+ should route(:get, "/bigbluebutton/servers").
9
+ to(:action => :index)
10
+ }
11
+ it {
12
+ should route(:post, "/bigbluebutton/servers").
13
+ to(:action => :create)
14
+ }
15
+ it {
16
+ should route(:get, "/bigbluebutton/servers/new").
17
+ to(:action => :new)
18
+ }
19
+ it {
20
+ should route(:get, "/bigbluebutton/servers/1/edit").
21
+ to(:action => :edit, :id => 1)
22
+ }
23
+ it {
24
+ should route(:get, "/bigbluebutton/servers/1").
25
+ to(:action => :show, :id => 1)
26
+ }
27
+ it {
28
+ should route(:put, "/bigbluebutton/servers/1").
29
+ to(:action => :update, :id => 1)
30
+ }
31
+ it {
32
+ should route(:delete, "/bigbluebutton/servers/1").
33
+ to(:action => :destroy, :id => 1)
34
+ }
35
+ end
36
+
37
+ end
38
+
@@ -0,0 +1,37 @@
1
+ # Configure Rails Envinronment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require "rails_app/config/environment"
5
+ require "rails/test_help"
6
+ require "rspec/rails"
7
+ require "shoulda-matchers"
8
+
9
+ ActionMailer::Base.delivery_method = :test
10
+ ActionMailer::Base.perform_deliveries = true
11
+ ActionMailer::Base.default_url_options[:host] = "test.com"
12
+
13
+ Rails.backtrace_cleaner.remove_silencers!
14
+
15
+ # Configure capybara for integration testing
16
+ #require "capybara/rails"
17
+ #Capybara.default_driver = :rack_test
18
+ #Capybara.default_selector = :css
19
+
20
+ # Load support files
21
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
22
+
23
+ # Load Factories
24
+ require 'factory_girl'
25
+ require 'forgery'
26
+ Dir["#{ File.dirname(__FILE__)}/factories/*.rb"].each { |f| require f }
27
+
28
+ RSpec.configure do |config|
29
+ config.mock_with :rspec
30
+ config.use_transactional_fixtures = true
31
+ end
32
+
33
+ # To test generators
34
+ require "generator_spec/test_case"
35
+ require "generators/bigbluebutton_rails/install_generator"
36
+ require "generators/bigbluebutton_rails/views_generator"
37
+ require "generators/bigbluebutton_rails/public_generator"
@@ -0,0 +1,10 @@
1
+ # Compares the attributes of two models or hashes, ignoring attributes generated only when saving in the db
2
+ # Example: user1.should have_same_attributes_as(User.last)
3
+ RSpec::Matchers.define :have_same_attributes_as do |expected|
4
+ match do |actual|
5
+ ignored = ['id', 'updated_at', 'created_at']
6
+ actual_attr = actual.attributes unless actual.instance_of?(Hash)
7
+ expected_attr = expected.attributes unless expected.instance_of?(Hash)
8
+ actual_attr.except(*ignored) == expected_attr.except(*ignored)
9
+ end
10
+ end