forked from External/greenlight
Merge pull request #11 from jfederico/master
Fixes and refactoring to views and controllers
This commit is contained in:
commit
d26d4a86bd
1
Gemfile
1
Gemfile
|
@ -57,5 +57,6 @@ gem 'bigbluebutton-api-ruby'
|
||||||
|
|
||||||
gem 'bootstrap-sass', '3.3.0.0'
|
gem 'bootstrap-sass', '3.3.0.0'
|
||||||
gem 'bootstrap-social-rails', '~> 4.12'
|
gem 'bootstrap-social-rails', '~> 4.12'
|
||||||
|
gem 'font-awesome-rails'
|
||||||
gem 'jquery-ui-rails'
|
gem 'jquery-ui-rails'
|
||||||
gem 'jquery-datatables-rails', '~> 3.4.0'
|
gem 'jquery-datatables-rails', '~> 3.4.0'
|
||||||
|
|
|
@ -65,6 +65,8 @@ GEM
|
||||||
faraday (0.9.2)
|
faraday (0.9.2)
|
||||||
multipart-post (>= 1.2, < 3)
|
multipart-post (>= 1.2, < 3)
|
||||||
ffi (1.9.14)
|
ffi (1.9.14)
|
||||||
|
font-awesome-rails (4.6.3.1)
|
||||||
|
railties (>= 3.2, < 5.1)
|
||||||
globalid (0.3.7)
|
globalid (0.3.7)
|
||||||
activesupport (>= 4.1.0)
|
activesupport (>= 4.1.0)
|
||||||
hashie (3.4.4)
|
hashie (3.4.4)
|
||||||
|
@ -209,6 +211,7 @@ DEPENDENCIES
|
||||||
byebug
|
byebug
|
||||||
coffee-rails (~> 4.2)
|
coffee-rails (~> 4.2)
|
||||||
dotenv-rails
|
dotenv-rails
|
||||||
|
font-awesome-rails
|
||||||
jbuilder (~> 2.5)
|
jbuilder (~> 2.5)
|
||||||
jquery-datatables-rails (~> 3.4.0)
|
jquery-datatables-rails (~> 3.4.0)
|
||||||
jquery-rails
|
jquery-rails
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#url_form_button').click (function (event) {
|
$('#url_form_button').click (function (event) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : $(this).data ('url'),
|
url : $(this).data ('url'),
|
||||||
|
@ -36,7 +37,7 @@
|
||||||
|
|
||||||
$(document).on("turbolinks:load", function() {
|
$(document).on("turbolinks:load", function() {
|
||||||
if ($("body[data-controller=landing]").get(0)) {
|
if ($("body[data-controller=landing]").get(0)) {
|
||||||
if ($("body[data-action=index]").get(0)) {
|
if ($("body[data-action=meeting]").get(0) || $("body[data-action=room]").get(0)) {
|
||||||
initIndex();
|
initIndex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
// Bootstrap
|
// Bootstrap
|
||||||
@import "bootstrap-sprockets";
|
@import "bootstrap-sprockets";
|
||||||
@import "bootstrap";
|
@import "bootstrap";
|
||||||
|
@import "bootstrap-social";
|
||||||
|
@import "font-awesome";
|
||||||
|
|
||||||
.room {
|
.room {
|
||||||
.room-link {
|
.room-link {
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
class BbbController < ApplicationController
|
class BbbController < ApplicationController
|
||||||
include BbbHelper
|
|
||||||
|
|
||||||
# GET /join
|
# GET /join
|
||||||
# GET /join.json
|
# GET /join.json
|
||||||
def join
|
def join
|
||||||
logger.info params.to_json
|
|
||||||
if ( !params.has_key?(:id) )
|
if ( !params.has_key?(:id) )
|
||||||
render_response("missing_parameter", "meeting token was not included", :bad_request)
|
render_response("missing_parameter", "meeting token was not included", :bad_request)
|
||||||
elsif ( !params.has_key?(:name) )
|
elsif ( !params.has_key?(:name) )
|
||||||
render_response("missing_parameter", "user name was not included", :bad_request)
|
render_response("missing_parameter", "user name was not included", :bad_request)
|
||||||
else
|
else
|
||||||
bbb_join_url = bbb_join_url(params[:id], false, params[:name], false)
|
bbb_join_url = helpers.bbb_join_url(params[:id], false, params[:name], false, "#{request.base_url}/#{params[:resource]}/#{params[:id]}")
|
||||||
if bbb_join_url[:returncode]
|
if bbb_join_url[:returncode]
|
||||||
logger.info "#Execute the redirect"
|
logger.info "#Execute the redirect"
|
||||||
render_response("ok", "execute the redirect", :ok, {:join_url => bbb_join_url[:join_url]})
|
render_response("ok", "execute the redirect", :ok, {:join_url => bbb_join_url[:join_url]})
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
class LandingController < ApplicationController
|
class LandingController < ApplicationController
|
||||||
include LandingHelper
|
|
||||||
|
|
||||||
def index
|
def meeting
|
||||||
@refreshable = (params[:resource] == 'meeting' && !params.has_key?(:id))
|
@refreshable = (params[:resource] == 'meetings' && !params.has_key?(:id))
|
||||||
@meeting_token = params[:id] || @meeting_token = new_meeting_token
|
@meeting_token = params[:id] || @meeting_token = helpers.new_meeting_token
|
||||||
@meeting_url = landing_url(@meeting_token)
|
@resource = params[:resource]
|
||||||
|
@resource_url = meeting_url(@meeting_token)
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /token.json
|
# GET /token.json
|
||||||
def new_meeting
|
def new_meeting
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
meeting_url = landing_url(new_meeting_token)
|
meeting_url = meeting_url(helpers.new_meeting_token)
|
||||||
logger.info meeting_url
|
|
||||||
format.json { render :json => { :messageKey => "ok", :message => "New meeting URL created", :status => :ok, :response => { :meeting_url => meeting_url} }, :status => status }
|
format.json { render :json => { :messageKey => "ok", :message => "New meeting URL created", :status => :ok, :response => { :meeting_url => meeting_url} }, :status => status }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -19,6 +18,9 @@ class LandingController < ApplicationController
|
||||||
def room
|
def room
|
||||||
@room_name = params[:name]
|
@room_name = params[:name]
|
||||||
@user = User.find_by(username: @room_name)
|
@user = User.find_by(username: @room_name)
|
||||||
|
@meeting_token = @room_name
|
||||||
|
@resource = params[:resource]
|
||||||
|
@resource_url = room_url(@meeting_token)
|
||||||
if @user.nil?
|
if @user.nil?
|
||||||
redirect_to root_path
|
redirect_to root_path
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,15 +1,2 @@
|
||||||
module ApplicationHelper
|
module ApplicationHelper
|
||||||
def bbb_endpoint
|
|
||||||
Rails.application.secrets[:bbb_endpoint]
|
|
||||||
end
|
|
||||||
|
|
||||||
def bbb_secret
|
|
||||||
Rails.application.secrets[:bbb_secret]
|
|
||||||
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
|
end
|
||||||
|
|
|
@ -1,6 +1,20 @@
|
||||||
module BbbHelper
|
module BbbHelper
|
||||||
def bbb_join_url(meeting_token, meeting_recorded=false, user_fullname='User', user_is_moderator=false)
|
def bbb_endpoint
|
||||||
bbb ||= BigBlueButton::BigBlueButtonApi.new(helpers.bbb_endpoint + "api", bbb_secret, "0.8", true)
|
Rails.application.secrets[:bbb_endpoint]
|
||||||
|
end
|
||||||
|
|
||||||
|
def bbb_secret
|
||||||
|
Rails.application.secrets[:bbb_secret]
|
||||||
|
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
|
||||||
|
|
||||||
|
def bbb_join_url(meeting_token, meeting_recorded=false, user_fullname='User', user_is_moderator=false, meeting_logout_url=nil)
|
||||||
|
bbb ||= BigBlueButton::BigBlueButtonApi.new(bbb_endpoint + "api", bbb_secret, "0.8", true)
|
||||||
if !bbb
|
if !bbb
|
||||||
return { :returncode => false, :messageKey => "BBBAPICallInvalid", :message => "BBB API call invalid." }
|
return { :returncode => false, :messageKey => "BBBAPICallInvalid", :message => "BBB API call invalid." }
|
||||||
else
|
else
|
||||||
|
@ -14,7 +28,7 @@ module BbbHelper
|
||||||
logger.info "Message for the log file #{exc.key}: #{exc.message}"
|
logger.info "Message for the log file #{exc.key}: #{exc.message}"
|
||||||
|
|
||||||
# Prepare parameters for create
|
# Prepare parameters for create
|
||||||
logout_url = "#{request.base_url}/meeting/#{meeting_token}"
|
logout_url = meeting_logout_url || logout_url = "#{request.base_url}"
|
||||||
moderator_password = random_password(12)
|
moderator_password = random_password(12)
|
||||||
viewer_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 }
|
meeting_options = {:record => meeting_recorded.to_s, :logoutURL => logout_url, :moderatorPW => moderator_password, :attendeePW => viewer_password }
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
<div id="landing_page_footer_message">
|
||||||
|
<p>Bookmark this page to reuse this meeting URL, or click refresh button to generate a new meeting URL</p>
|
||||||
|
</div>
|
|
@ -0,0 +1,19 @@
|
||||||
|
<div id="landing_page_footer_oauth_append">
|
||||||
|
<% if current_user.nil? %>
|
||||||
|
<p>You can have a personal URL (with recordings) by signing in below</p>
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
<%= link_to('/auth/twitter', :class => "btn icon btn-lg btn-social-icon btn-twitter") do %>
|
||||||
|
<span class="fa fa-twitter"></span>
|
||||||
|
<% end %>
|
||||||
|
<%= link_to('/auth/google', :class => "btn icon btn-lg btn-social-icon btn-google") do %>
|
||||||
|
<span class="fa fa-google"></span>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<% else %>
|
||||||
|
<div>Hello <%= current_user.name %></div>
|
||||||
|
<div><%= link_to 'Personal Room', current_user.room_url %></div>
|
||||||
|
<div><%= link_to 'Logout', '/logout' %></div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -0,0 +1,28 @@
|
||||||
|
<div class="jumbotron">
|
||||||
|
<!-- Meeting URL -->
|
||||||
|
<h4 class="display-3">
|
||||||
|
<div id="landing_page_url" class="center-block">
|
||||||
|
<form id="url_form" class="form-inline">
|
||||||
|
<div class="form-group">
|
||||||
|
<span id="meeting_url"><%= @resource_url %></span>
|
||||||
|
</div>
|
||||||
|
<% if @refreshable %>
|
||||||
|
<button id="url_form_button" type="button" class="btn btn-default" data-url="<%= new_meeting_path() %>">
|
||||||
|
<span class="glyphicon glyphicon-refresh"></span>
|
||||||
|
</button>
|
||||||
|
<% end %>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
<!-- Join form -->
|
||||||
|
<div id="landing_page_join">
|
||||||
|
<form id="join_form" class="form-inline">
|
||||||
|
<div class="form-group">
|
||||||
|
<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 id="join_form_button" type="button" class="btn btn-success" data-url="<%= bbb_join_path(@resource, @meeting_token) %>">Join</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<figure class=highlight><pre><figcaption class="text" data-lang="text">
|
||||||
|
<p>Hi Everyone</p>
|
||||||
|
<p>The meeting will be at this URL</p>
|
||||||
|
<p><a id="text_meeting_url" href="<%= @resource_url %>"><%= @resource_url %></a></p>
|
||||||
|
<p>Please join!</p>
|
||||||
|
</figcaption></pre></figure>
|
|
@ -1,65 +0,0 @@
|
||||||
<div class='container'>
|
|
||||||
|
|
||||||
<!-- Body -->
|
|
||||||
<div class='body'>
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
<div class="jumbotron">
|
|
||||||
<!-- Meeting URL -->
|
|
||||||
<% if @refreshable %>
|
|
||||||
<h4 class="display-3">
|
|
||||||
<div id="landing_page_url" class="center-block">
|
|
||||||
<form id="url_form" class="form-inline">
|
|
||||||
<div class="form-group">
|
|
||||||
<span id="meeting_url"><%= @meeting_url %></span>
|
|
||||||
</div>
|
|
||||||
<button id="url_form_button" type="button" class="btn btn-default" data-url="<%= new_meeting_url() %>">
|
|
||||||
<span class="glyphicon glyphicon-refresh"></span>
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</h4>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<!-- Join form -->
|
|
||||||
<div id="landing_page_join">
|
|
||||||
<form id="join_form" class="form-inline">
|
|
||||||
<div class="form-group">
|
|
||||||
<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 id="join_form_button" type="button" class="btn btn-success" data-url="<%= bbb_join_path(@meeting_token) %>">Join</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<figure class=highlight><pre><figcaption class="text" data-lang="text">
|
|
||||||
<p>Hi Everyone</p>
|
|
||||||
<p>The meeting will be at this URL</p>
|
|
||||||
<p><a id="text_meeting_url" href="<%= @meeting_url %>"><%= @meeting_url %></a></p>
|
|
||||||
<p>Please join!</p>
|
|
||||||
</figcaption></pre></figure>
|
|
||||||
|
|
||||||
<div id="landing_page_footer_message">
|
|
||||||
<p>Bookmark this page to reuse this meeting URL, or click refresh button to generate a new meeting URL</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="landing_page_footer_oauth_append">
|
|
||||||
<% if current_user.nil? %>
|
|
||||||
<p>You can have a personal URL (with recordings) by signing in below</p>
|
|
||||||
<ul>
|
|
||||||
<li><%= link_to 'Twitter', '/auth/twitter' %></li>
|
|
||||||
<li><%= link_to 'Google', '/auth/google' %></li>
|
|
||||||
</ul>
|
|
||||||
<% else %>
|
|
||||||
<div>Hello <%= current_user.name %></div>
|
|
||||||
<div><%= link_to 'Personal Room', current_user.room_url %></div>
|
|
||||||
<div><%= link_to 'Logout', '/logout' %></div>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<!-- Body -->
|
||||||
|
<div class='body'>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<%= render 'landing/join_form' %>
|
||||||
|
|
||||||
|
<%= render 'landing/sharing_text' %>
|
||||||
|
|
||||||
|
<%= render 'landing/footer_message' %>
|
||||||
|
|
||||||
|
<%= render 'landing/footer_oauth_append' %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
|
@ -1,19 +1,26 @@
|
||||||
<div class="page-wrapper room">
|
<!-- Body -->
|
||||||
<div class="row">
|
<div class='body'>
|
||||||
<div class="col-sm-2 col-sm-offset-10">
|
|
||||||
<% if admin? %>
|
<div class="page-wrapper room">
|
||||||
<span class="user"><%= current_user.name %></span>
|
<div class="row">
|
||||||
<%= link_to "Logout", "/logout" %>
|
<div class="col-sm-2 col-sm-offset-10">
|
||||||
<% else %>
|
<% if admin? %>
|
||||||
<%= link_to "Login", "/auth/twitter" %>
|
<span class="user"><%= current_user.name %></span>
|
||||||
<% end %>
|
<%= link_to "Logout", "/logout" %>
|
||||||
</div>
|
<% else %>
|
||||||
</div>
|
<%= link_to "Login", "/auth/twitter" %>
|
||||||
<div class="row">
|
<% end %>
|
||||||
<div class="col-sm-4 col-sm-offset-4">
|
|
||||||
<div class="room-link">
|
|
||||||
Room Link: <%= link_to "/rooms/#{@room_name}", "/rooms/#{@room_name}" %>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<%= render 'landing/join_form' %>
|
||||||
|
|
||||||
|
<%= render 'landing/sharing_text' %>
|
||||||
|
|
||||||
|
<%= render 'landing/footer_message' %>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
get 'bbb/join/:id', to: 'bbb#join', as: :bbb_join
|
get 'bbb/join/:resource/:id', to: 'bbb#join', as: :bbb_join
|
||||||
|
|
||||||
|
get '/meetings/new', to: 'landing#new_meeting', as: :new_meeting
|
||||||
|
get '/meetings(/:id)', to: 'landing#meeting', as: :meeting, :resource => "meetings"
|
||||||
|
get '/rooms/:name', to: 'landing#room', as: :room, :resource => "rooms"
|
||||||
|
|
||||||
get '/meeting/new', to: 'landing#new_meeting', as: :new_meeting
|
|
||||||
get '/meeting(/:id)', to: 'landing#index', as: :landing, :resource => "meeting"
|
|
||||||
get '/auth/:provider/callback', to: 'sessions#create'
|
get '/auth/:provider/callback', to: 'sessions#create'
|
||||||
get '/logout', to: 'sessions#destroy'
|
get '/logout', to: 'sessions#destroy'
|
||||||
get '/rooms/:name', to: 'landing#room'
|
|
||||||
|
|
||||||
root to: 'landing#index', :resource => "meeting"
|
root to: 'landing#meeting', :resource => "meetings"
|
||||||
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue