forked from External/greenlight
Implemented join to BBB first approach
This commit is contained in:
3
app/assets/javascripts/bbb.coffee
Normal file
3
app/assets/javascripts/bbb.coffee
Normal file
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
3
app/assets/stylesheets/bbb.scss
Normal file
3
app/assets/stylesheets/bbb.scss
Normal file
@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the bbb controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
@ -1,3 +1,7 @@
|
||||
require 'bigbluebutton_api'
|
||||
require 'digest/sha1'
|
||||
|
||||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery with: :exception
|
||||
include ApplicationHelper
|
||||
end
|
||||
|
38
app/controllers/bbb_controller.rb
Normal file
38
app/controllers/bbb_controller.rb
Normal file
@ -0,0 +1,38 @@
|
||||
class BbbController < ApplicationController
|
||||
include BbbHelper
|
||||
|
||||
# GET /join
|
||||
# GET /join.json
|
||||
def join
|
||||
logger.info params.to_json
|
||||
if ( !params.has_key?(:id) )
|
||||
render_response("missing_parameter", "meeting token was not included", :bad_request)
|
||||
elsif ( !params.has_key?(:name) )
|
||||
render_response("missing_parameter", "user name was not included", :bad_request)
|
||||
else
|
||||
bbb_join_url = bbb_join_url(params[:id], false, params[:name], false)
|
||||
if bbb_join_url[:returncode]
|
||||
logger.info "#Execute the redirect"
|
||||
render_response("ok", "execute the redirect", :ok, {:join_url => bbb_join_url[:join_url]})
|
||||
else
|
||||
render_response("bigbluebutton_error", "join url could not be created", :internal_server_error)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def close
|
||||
end
|
||||
|
||||
private
|
||||
def render_response(messageKey, message, status, response={})
|
||||
respond_to do |format|
|
||||
if (status == :ok)
|
||||
format.html { render :template => "bbb/join" }
|
||||
format.json { render :json => { :messageKey => messageKey, :message => message, :status => status, :response => response }, :status => status }
|
||||
else
|
||||
format.html { render :template => "errors/error" }
|
||||
format.json { render :json => { :messageKey => messageKey, :message => message, :status => status, :response => response }, :status => status }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,6 +1,8 @@
|
||||
class LandingController < ApplicationController
|
||||
include LandingHelper
|
||||
|
||||
def index
|
||||
@meeting_token = params[:id] || @meeting_token = rand.to_s[2..10]
|
||||
@meeting_url = helpers.meeting_url(@meeting_token)
|
||||
@meeting_url = meeting_url(@meeting_token)
|
||||
end
|
||||
end
|
||||
|
@ -1,2 +1,24 @@
|
||||
module ApplicationHelper
|
||||
def bbb_endpoint
|
||||
logger.info APP_CONFIG
|
||||
#if ((defined? APP_CONFIG).to_s == 'constant') && (APP_CONFIG.has_key?('bbb_endpoint'))
|
||||
# APP_CONFIG['bbb_endpoint']
|
||||
#else
|
||||
'http://test-install.blindsidenetworks.com/bigbluebutton/'
|
||||
#end
|
||||
end
|
||||
|
||||
def bbb_secret
|
||||
#if (defined? APP_CONFIG).to_s == 'constant' && (APP_CONFIG.has_key? 'bbb_secret')
|
||||
# APP_CONFIG['bbb_secret']
|
||||
#else
|
||||
'8cd8ef52e8e101574e400365b55e11a6'
|
||||
#end
|
||||
end
|
||||
|
||||
def random_password(length)
|
||||
o = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten
|
||||
password = (0...length).map { o[rand(o.length)] }.join
|
||||
return password
|
||||
end
|
||||
end
|
||||
|
36
app/helpers/bbb_helper.rb
Normal file
36
app/helpers/bbb_helper.rb
Normal file
@ -0,0 +1,36 @@
|
||||
module BbbHelper
|
||||
def bbb_join_url(meeting_token, meeting_recorded=false, user_fullname='User', user_is_moderator=false)
|
||||
bbb ||= BigBlueButton::BigBlueButtonApi.new(helpers.bbb_endpoint + "api", bbb_secret, "0.8", true)
|
||||
if !bbb
|
||||
return { :returncode => false, :messageKey => "BBBAPICallInvalid", :message => "BBB API call invalid." }
|
||||
else
|
||||
meeting_id = (Digest::SHA1.hexdigest("Rails.application.secrets.secret_key_base"+meeting_token)).to_s
|
||||
|
||||
#See if the meeting is running
|
||||
begin
|
||||
bbb_meeting_info = bbb.get_meeting_info( meeting_id, nil )
|
||||
rescue BigBlueButton::BigBlueButtonException => exc
|
||||
logger.info "Message for the log file #{exc.key}: #{exc.message}"
|
||||
#This means that is not created, so create the meeting
|
||||
logout_url = "#{request.base_url}/bbb/close" #Closes the window after correct logout
|
||||
moderator_password = random_password(12)
|
||||
viewer_password = random_password(12)
|
||||
meeting_options = {:record => meeting_recorded.to_s, :logoutURL => logout_url, :moderatorPW => moderator_password, :attendeePW => viewer_password }
|
||||
bbb.create_meeting(meeting_token, meeting_id, meeting_options)
|
||||
|
||||
#And then get meeting info
|
||||
bbb_meeting_info = bbb.get_meeting_info( meeting_id, nil )
|
||||
end
|
||||
|
||||
#Get the join url
|
||||
if (user_is_moderator)
|
||||
password = bbb_meeting_info[:moderatorPW]
|
||||
else
|
||||
passord = bbb_meeting_info[:attendeePW]
|
||||
end
|
||||
join_url = bbb.join_meeting_url(meeting_id, user_fullname, password )
|
||||
return { :returncode => true, :join_url => join_url, :messageKey => "", :message => "" }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
2
app/views/bbb/end.html.erb
Normal file
2
app/views/bbb/end.html.erb
Normal file
@ -0,0 +1,2 @@
|
||||
<h1>Bbb#end</h1>
|
||||
<p>Find me in app/views/bbb/end.html.erb</p>
|
2
app/views/bbb/join.html.erb
Normal file
2
app/views/bbb/join.html.erb
Normal file
@ -0,0 +1,2 @@
|
||||
<h1>Bbb#join</h1>
|
||||
<p>Find me in app/views/bbb/join.html.erb</p>
|
2
app/views/errors/error.html.erb
Normal file
2
app/views/errors/error.html.erb
Normal file
@ -0,0 +1,2 @@
|
||||
<h1>Errors#error</h1>
|
||||
<p>Find me in app/views/errors/error.html.erb</p>
|
@ -13,13 +13,13 @@
|
||||
</h4>
|
||||
|
||||
<!-- Join form -->
|
||||
<div id="landing_page_join_form">
|
||||
<form class="form-inline">
|
||||
<div id="landing_page_join">
|
||||
<form id="join_form" class="form-inline">
|
||||
<div class="form-group">
|
||||
<label for="name" class="sr-only">Name</label>
|
||||
<input type="text" class="form-control input" id="name" placeholder="Your name">
|
||||
<label for="join_form_name" class="sr-only">Name</label>
|
||||
<input id="join_form_name" type="text" class="form-control input" id="name" placeholder="Your name" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success">Join</button>
|
||||
<button id="join_form_button" type="button" class="btn btn-success" data-url="<%= bbb_join_path(@meeting_token) %>">Join</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@ -38,11 +38,31 @@
|
||||
<div id="landing_page_footer_oauth_append">
|
||||
<p>You can have a personal URL (with recordings) by signing in below</p>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function($) {
|
||||
$('#join_form_button').click (function (event) {
|
||||
$.ajax({
|
||||
url : $(this).data ('url') + "?name=" + $('#join_form_name').val(),
|
||||
dataType : "json",
|
||||
async : true,
|
||||
type : 'GET',
|
||||
success : function(data) {
|
||||
$(location).attr("href", data.response.join_url);
|
||||
},
|
||||
error : function(xhr, status, error) {
|
||||
console.info(status);
|
||||
console.info(error);
|
||||
},
|
||||
complete : function(xhr, status) {
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user