From ad807b636b31d5202582151fd5e9f62815c925ec Mon Sep 17 00:00:00 2001 From: jfederico Date: Tue, 18 Oct 2016 17:17:05 -0400 Subject: [PATCH 1/6] Removed reference to helper from LandingController --- app/controllers/landing_controller.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/controllers/landing_controller.rb b/app/controllers/landing_controller.rb index 0c6c9e5e..9129b250 100644 --- a/app/controllers/landing_controller.rb +++ b/app/controllers/landing_controller.rb @@ -1,17 +1,14 @@ class LandingController < ApplicationController - include LandingHelper - def index @refreshable = (params[:resource] == 'meeting' && !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) end # GET /token.json def new_meeting respond_to do |format| - meeting_url = landing_url(new_meeting_token) - logger.info meeting_url + meeting_url = landing_url(helpers.new_meeting_token) format.json { render :json => { :messageKey => "ok", :message => "New meeting URL created", :status => :ok, :response => { :meeting_url => meeting_url} }, :status => status } end end From d4a9fd9147704c17a4c1bb05c339b034478364f6 Mon Sep 17 00:00:00 2001 From: jfederico Date: Tue, 18 Oct 2016 17:25:06 -0400 Subject: [PATCH 2/6] Cleaned up code --- app/controllers/bbb_controller.rb | 4 +--- app/controllers/landing_controller.rb | 1 + app/helpers/application_helper.rb | 13 ------------- app/helpers/bbb_helper.rb | 16 +++++++++++++++- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/controllers/bbb_controller.rb b/app/controllers/bbb_controller.rb index 9c9ef648..926aa33c 100644 --- a/app/controllers/bbb_controller.rb +++ b/app/controllers/bbb_controller.rb @@ -1,16 +1,14 @@ 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) + bbb_join_url = helpers.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]}) diff --git a/app/controllers/landing_controller.rb b/app/controllers/landing_controller.rb index 9129b250..6965767c 100644 --- a/app/controllers/landing_controller.rb +++ b/app/controllers/landing_controller.rb @@ -1,4 +1,5 @@ class LandingController < ApplicationController + def index @refreshable = (params[:resource] == 'meeting' && !params.has_key?(:id)) @meeting_token = params[:id] || @meeting_token = helpers.new_meeting_token diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0a20de1d..de6be794 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,15 +1,2 @@ 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 diff --git a/app/helpers/bbb_helper.rb b/app/helpers/bbb_helper.rb index 9a3a6fc0..94901495 100644 --- a/app/helpers/bbb_helper.rb +++ b/app/helpers/bbb_helper.rb @@ -1,6 +1,20 @@ module BbbHelper + 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 + 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) + bbb ||= BigBlueButton::BigBlueButtonApi.new(bbb_endpoint + "api", bbb_secret, "0.8", true) if !bbb return { :returncode => false, :messageKey => "BBBAPICallInvalid", :message => "BBB API call invalid." } else From f195cff339f539fe6119b4b2a222fceabee2d30d Mon Sep 17 00:00:00 2001 From: jfederico Date: Tue, 18 Oct 2016 18:12:11 -0400 Subject: [PATCH 3/6] Added icons to social buttons --- Gemfile | 1 + Gemfile.lock | 3 +++ app/assets/stylesheets/landing.scss | 2 ++ app/views/landing/index.html.erb | 13 +++++++++---- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 3409daf9..88051b89 100644 --- a/Gemfile +++ b/Gemfile @@ -57,5 +57,6 @@ gem 'bigbluebutton-api-ruby' gem 'bootstrap-sass', '3.3.0.0' gem 'bootstrap-social-rails', '~> 4.12' +gem 'font-awesome-rails' gem 'jquery-ui-rails' gem 'jquery-datatables-rails', '~> 3.4.0' diff --git a/Gemfile.lock b/Gemfile.lock index b24c67ff..e946530f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -65,6 +65,8 @@ GEM faraday (0.9.2) multipart-post (>= 1.2, < 3) ffi (1.9.14) + font-awesome-rails (4.6.3.1) + railties (>= 3.2, < 5.1) globalid (0.3.7) activesupport (>= 4.1.0) hashie (3.4.4) @@ -209,6 +211,7 @@ DEPENDENCIES byebug coffee-rails (~> 4.2) dotenv-rails + font-awesome-rails jbuilder (~> 2.5) jquery-datatables-rails (~> 3.4.0) jquery-rails diff --git a/app/assets/stylesheets/landing.scss b/app/assets/stylesheets/landing.scss index 3bcfc498..48ad3a1c 100644 --- a/app/assets/stylesheets/landing.scss +++ b/app/assets/stylesheets/landing.scss @@ -5,6 +5,8 @@ // Bootstrap @import "bootstrap-sprockets"; @import "bootstrap"; +@import "bootstrap-social"; +@import "font-awesome"; .room { .room-link { diff --git a/app/views/landing/index.html.erb b/app/views/landing/index.html.erb index 261fbf55..79b6e9b7 100644 --- a/app/views/landing/index.html.erb +++ b/app/views/landing/index.html.erb @@ -47,10 +47,15 @@ - - From 061f9c794a9d8c94cce6ef517301e85917799c2a Mon Sep 17 00:00:00 2001 From: jfederico Date: Wed, 19 Oct 2016 13:43:58 -0400 Subject: [PATCH 5/6] Refactored meetings resource and breaked up view into components --- app/assets/javascripts/landing.js | 3 +- app/controllers/bbb_controller.rb | 2 +- app/controllers/landing_controller.rb | 10 +-- app/helpers/bbb_helper.rb | 4 +- app/views/landing/_footer_message.html.erb | 3 + .../landing/_footer_oauth_append.html.erb | 19 ++++++ app/views/landing/_join_form.html.erb | 28 ++++++++ app/views/landing/_sharing_text.html.erb | 6 ++ app/views/landing/index.html.erb | 68 ------------------- app/views/landing/meeting.html.erb | 14 ++++ app/views/landing/room.html.erb | 37 ++++++---- config/routes.rb | 9 +-- 12 files changed, 108 insertions(+), 95 deletions(-) create mode 100644 app/views/landing/_footer_message.html.erb create mode 100644 app/views/landing/_footer_oauth_append.html.erb create mode 100644 app/views/landing/_join_form.html.erb create mode 100644 app/views/landing/_sharing_text.html.erb delete mode 100644 app/views/landing/index.html.erb create mode 100644 app/views/landing/meeting.html.erb diff --git a/app/assets/javascripts/landing.js b/app/assets/javascripts/landing.js index 4aeefe17..b3e24d18 100644 --- a/app/assets/javascripts/landing.js +++ b/app/assets/javascripts/landing.js @@ -15,6 +15,7 @@ } }); }); + $('#url_form_button').click (function (event) { $.ajax({ url : $(this).data ('url'), @@ -36,7 +37,7 @@ $(document).on("turbolinks:load", function() { 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(); } } diff --git a/app/controllers/bbb_controller.rb b/app/controllers/bbb_controller.rb index 926aa33c..3a3c9c11 100644 --- a/app/controllers/bbb_controller.rb +++ b/app/controllers/bbb_controller.rb @@ -8,7 +8,7 @@ class BbbController < ApplicationController elsif ( !params.has_key?(:name) ) render_response("missing_parameter", "user name was not included", :bad_request) else - bbb_join_url = helpers.bbb_join_url(params[:id], false, params[:name], false) + bbb_join_url = helpers.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]}) diff --git a/app/controllers/landing_controller.rb b/app/controllers/landing_controller.rb index 6965767c..d2ac0059 100644 --- a/app/controllers/landing_controller.rb +++ b/app/controllers/landing_controller.rb @@ -1,21 +1,23 @@ class LandingController < ApplicationController - def index - @refreshable = (params[:resource] == 'meeting' && !params.has_key?(:id)) + def meeting + @refreshable = (params[:resource] == 'meetings' && !params.has_key?(:id)) @meeting_token = params[:id] || @meeting_token = helpers.new_meeting_token - @meeting_url = landing_url(@meeting_token) + @resource_url = meeting_url(@meeting_token) end # GET /token.json def new_meeting respond_to do |format| - meeting_url = landing_url(helpers.new_meeting_token) + meeting_url = meeting_url(helpers.new_meeting_token) format.json { render :json => { :messageKey => "ok", :message => "New meeting URL created", :status => :ok, :response => { :meeting_url => meeting_url} }, :status => status } end end def room @room_name = params[:name] + @meeting_token = @room_name + @resource_url = room_url(@meeting_token) @user = User.find_by(username: @room_name) if @user.nil? redirect_to root_path diff --git a/app/helpers/bbb_helper.rb b/app/helpers/bbb_helper.rb index 94901495..91130568 100644 --- a/app/helpers/bbb_helper.rb +++ b/app/helpers/bbb_helper.rb @@ -13,7 +13,7 @@ module BbbHelper return password end - def bbb_join_url(meeting_token, meeting_recorded=false, user_fullname='User', user_is_moderator=false) + 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 return { :returncode => false, :messageKey => "BBBAPICallInvalid", :message => "BBB API call invalid." } @@ -28,7 +28,7 @@ module BbbHelper logger.info "Message for the log file #{exc.key}: #{exc.message}" # 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) viewer_password = random_password(12) meeting_options = {:record => meeting_recorded.to_s, :logoutURL => logout_url, :moderatorPW => moderator_password, :attendeePW => viewer_password } diff --git a/app/views/landing/_footer_message.html.erb b/app/views/landing/_footer_message.html.erb new file mode 100644 index 00000000..40f7b7f2 --- /dev/null +++ b/app/views/landing/_footer_message.html.erb @@ -0,0 +1,3 @@ + diff --git a/app/views/landing/_footer_oauth_append.html.erb b/app/views/landing/_footer_oauth_append.html.erb new file mode 100644 index 00000000..8aa4a36f --- /dev/null +++ b/app/views/landing/_footer_oauth_append.html.erb @@ -0,0 +1,19 @@ + + diff --git a/app/views/landing/_join_form.html.erb b/app/views/landing/_join_form.html.erb new file mode 100644 index 00000000..0e55c48b --- /dev/null +++ b/app/views/landing/_join_form.html.erb @@ -0,0 +1,28 @@ +
+ +

+
+
+
+ <%= @resource_url %> +
+ <% if @refreshable %> + + <% end %> +
+
+

+ + +
+
+
+ + +
+ +
+
+
diff --git a/app/views/landing/_sharing_text.html.erb b/app/views/landing/_sharing_text.html.erb new file mode 100644 index 00000000..ba6f925d --- /dev/null +++ b/app/views/landing/_sharing_text.html.erb @@ -0,0 +1,6 @@ +
+

Hi Everyone

+

The meeting will be at this URL

+

<%= @resource_url %>

+

Please join!

+
diff --git a/app/views/landing/index.html.erb b/app/views/landing/index.html.erb deleted file mode 100644 index 1390a279..00000000 --- a/app/views/landing/index.html.erb +++ /dev/null @@ -1,68 +0,0 @@ - - -
- -
-
- - <% if @refreshable %> -

-
-
-
- <%= @meeting_url %> -
- -
-
-

- <% end %> - - -
-
-
- - -
- -
-
-
- -
-

Hi Everyone

-

The meeting will be at this URL

-

<%= @meeting_url %>

-

Please join!

-
- - - - -
- -
- - diff --git a/app/views/landing/meeting.html.erb b/app/views/landing/meeting.html.erb new file mode 100644 index 00000000..09d83a96 --- /dev/null +++ b/app/views/landing/meeting.html.erb @@ -0,0 +1,14 @@ + +
+ +
+ <%= render 'landing/join_form' %> + + <%= render 'landing/sharing_text' %> + + <%= render 'landing/footer_message' %> + + <%= render 'landing/footer_oauth_append' %> +
+ +
diff --git a/app/views/landing/room.html.erb b/app/views/landing/room.html.erb index fc853c47..e20a3125 100644 --- a/app/views/landing/room.html.erb +++ b/app/views/landing/room.html.erb @@ -1,19 +1,26 @@ -
-
-
- <% if admin? %> - <%= current_user.name %> - <%= link_to "Logout", "/logout" %> - <% else %> - <%= link_to "Login", "/auth/twitter" %> - <% end %> -
-
-
-
- - +
diff --git a/config/routes.rb b/config/routes.rb index eb01cbbd..e051a894 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,5 @@ 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"