diff --git a/app/assets/javascripts/landing.js b/app/assets/javascripts/landing.js index 6f5c5ec1..d441eadd 100644 --- a/app/assets/javascripts/landing.js +++ b/app/assets/javascripts/landing.js @@ -15,6 +15,23 @@ } }); }); + $('#url_form_button').click (function (event) { + $.ajax({ + url : $(this).data ('url'), + dataType : "json", + async : true, + type : 'GET', + success : function(data) { + $('#meeting_url').html(data.response.meeting_url); + $('#text_meeting_url a').href(data.response.meeting_url); + $('#text_meeting_url span').html(data.response.meeting_url); + }, + error : function(xhr, status, error) { + }, + complete : function(xhr, status) { + } + }); + }); }; $(document).on("turbolinks:load", function() { diff --git a/app/controllers/bbb_controller.rb b/app/controllers/bbb_controller.rb index e51f7c36..9c9ef648 100644 --- a/app/controllers/bbb_controller.rb +++ b/app/controllers/bbb_controller.rb @@ -20,9 +20,6 @@ class BbbController < ApplicationController end end - def close - end - private def render_response(messageKey, message, status, response={}) respond_to do |format| diff --git a/app/controllers/landing_controller.rb b/app/controllers/landing_controller.rb index 08c3ff30..0c6c9e5e 100644 --- a/app/controllers/landing_controller.rb +++ b/app/controllers/landing_controller.rb @@ -2,8 +2,18 @@ class LandingController < ApplicationController include LandingHelper def index - @meeting_token = params[:id] || @meeting_token = rand.to_s[2..10] - @meeting_url = meeting_url(@meeting_token) + @refreshable = (params[:resource] == 'meeting' && !params.has_key?(:id)) + @meeting_token = params[:id] || @meeting_token = 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 + format.json { render :json => { :messageKey => "ok", :message => "New meeting URL created", :status => :ok, :response => { :meeting_url => meeting_url} }, :status => status } + end end def room diff --git a/app/helpers/landing_helper.rb b/app/helpers/landing_helper.rb index 3f9b3bc7..a9613176 100644 --- a/app/helpers/landing_helper.rb +++ b/app/helpers/landing_helper.rb @@ -1,9 +1,5 @@ module LandingHelper - def meeting_url(meeting_token) - _meeting_url = "#{request.original_url}" - _meeting_url += "meeting" if ( request.original_url == "#{request.base_url}/" ) - _meeting_url += "/" unless _meeting_url.end_with?('/') - _meeting_url += "#{meeting_token}" if !params.has_key?(:id) - _meeting_url.gsub(/\/+$/, '') + def new_meeting_token + rand.to_s[2..10] end end diff --git a/app/views/landing/index.html.erb b/app/views/landing/index.html.erb index fbd82246..f5765617 100644 --- a/app/views/landing/index.html.erb +++ b/app/views/landing/index.html.erb @@ -6,11 +6,20 @@
+ <% if @refreshable %>

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

+ <% end %>
@@ -27,7 +36,7 @@

Hi Everyone

The meeting will be at this URL

-

<%= @meeting_url %>

+

<%= @meeting_url %>

Please join!

diff --git a/config/routes.rb b/config/routes.rb index 09aa1490..87890b25 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,11 +1,12 @@ Rails.application.routes.draw do get 'bbb/join/:id', to: 'bbb#join', as: :bbb_join - get 'meeting(/:id)', to: 'landing#index' + 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 '/logout', to: 'sessions#destroy' get '/rooms/:name', to: 'landing#room' - root to: 'landing#index' + root to: 'landing#index', :resource => "meeting" # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end