forked from External/greenlight
Merge pull request #117 from zach-chai/update_routes
Update routes to support relative root urls
This commit is contained in:
commit
adb0314701
|
@ -26,8 +26,7 @@ class @Meeting
|
||||||
if _meetingInstance
|
if _meetingInstance
|
||||||
return _meetingInstance
|
return _meetingInstance
|
||||||
meetingId = $(".page-wrapper").data('id')
|
meetingId = $(".page-wrapper").data('id')
|
||||||
if (type = location.pathname.split('/')[1]) != 'rooms'
|
type = $("body").data('resource')
|
||||||
type = 'meetings'
|
|
||||||
name = $('.meeting-user-name').val()
|
name = $('.meeting-user-name').val()
|
||||||
adminId = $(".page-wrapper").data('admin-id')
|
adminId = $(".page-wrapper").data('admin-id')
|
||||||
_meetingInstance = new Meeting(meetingId, type, name, adminId)
|
_meetingInstance = new Meeting(meetingId, type, name, adminId)
|
||||||
|
@ -42,12 +41,14 @@ class @Meeting
|
||||||
fullId = encodeURIComponent(adminId) + '/' + encodeURIComponent(meetingId)
|
fullId = encodeURIComponent(adminId) + '/' + encodeURIComponent(meetingId)
|
||||||
else
|
else
|
||||||
fullId = encodeURIComponent(meetingId)
|
fullId = encodeURIComponent(meetingId)
|
||||||
return @buildFullDomainURL() + '/' + type + '/' + fullId
|
return @buildRootURL() + '/' + type + '/' + fullId
|
||||||
|
|
||||||
@buildFullDomainURL: ->
|
@buildRootURL: ->
|
||||||
url = location.protocol + '//' + location.hostname
|
url = location.protocol + '//' + location.hostname
|
||||||
if location.port
|
if location.port
|
||||||
url += ':' + location.port
|
url += ':' + location.port
|
||||||
|
if GreenLight.relative_root
|
||||||
|
url += GreenLight.relative_root
|
||||||
return url
|
return url
|
||||||
|
|
||||||
# Sends the end meeting request
|
# Sends the end meeting request
|
||||||
|
|
|
@ -238,7 +238,7 @@ class @Recordings
|
||||||
|
|
||||||
getRecordingsURL: ->
|
getRecordingsURL: ->
|
||||||
if $(".page-wrapper.rooms").data('main-room')
|
if $(".page-wrapper.rooms").data('main-room')
|
||||||
base_url = '/rooms/'+Meeting.getInstance().getAdminId()
|
base_url = Meeting.buildRootURL()+'/'+$('body').data('resource')+'/'+Meeting.getInstance().getAdminId()
|
||||||
else
|
else
|
||||||
base_url = $('.meeting-url').val()
|
base_url = $('.meeting-url').val()
|
||||||
base_url+'/recordings'
|
base_url+'/recordings'
|
||||||
|
|
|
@ -29,4 +29,9 @@ class ApplicationController < ActionController::Base
|
||||||
@current_user ||= User.find_by(id: session[:user_id])
|
@current_user ||= User.find_by(id: session[:user_id])
|
||||||
end
|
end
|
||||||
helper_method :current_user
|
helper_method :current_user
|
||||||
|
|
||||||
|
def relative_root
|
||||||
|
Rails.configuration.relative_url_root || ""
|
||||||
|
end
|
||||||
|
helper_method :relative_root
|
||||||
end
|
end
|
||||||
|
|
|
@ -66,7 +66,7 @@ class BbbController < ApplicationController
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
base_url = "#{request.base_url}/#{params[:resource]}/#{meeting_path}"
|
base_url = "#{request.base_url}#{relative_root}/#{params[:resource]}/#{meeting_path}"
|
||||||
options[:meeting_logout_url] = base_url
|
options[:meeting_logout_url] = base_url
|
||||||
options[:hook_url] = "#{base_url}/callback"
|
options[:hook_url] = "#{base_url}/callback"
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,9 @@ class LandingController < ApplicationController
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if @user.encrypted_id != params[:id]
|
||||||
@meeting_id = params[:id]
|
@meeting_id = params[:id]
|
||||||
|
end
|
||||||
@meeting_running = bbb_get_meeting_info("#{@user.encrypted_id}-#{@meeting_id}")[:returncode]
|
@meeting_running = bbb_get_meeting_info("#{@user.encrypted_id}-#{@meeting_id}")[:returncode]
|
||||||
@main_room = @meeting_id.blank? || @meeting_id == @user.encrypted_id
|
@main_room = @meeting_id.blank? || @meeting_id == @user.encrypted_id
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,10 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def omniauth_login_url(provider)
|
||||||
|
"#{relative_root}/auth/#{provider}"
|
||||||
|
end
|
||||||
|
|
||||||
# Whether the current page is the page of a room/meeting or not
|
# Whether the current page is the page of a room/meeting or not
|
||||||
def on_room_or_meeting_page?
|
def on_room_or_meeting_page?
|
||||||
params[:id].present?
|
params[:id].present?
|
||||||
|
|
|
@ -44,7 +44,7 @@ class User < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def room_url
|
def room_url
|
||||||
"/rooms/#{encrypted_id}"
|
"#{Rails.configuration.relative_url_root}/rooms/#{encrypted_id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_encrypted_id
|
def set_encrypted_id
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<div><%= t('are_you', name: @user.name) %></div>
|
<div><%= t('are_you', name: @user.name) %></div>
|
||||||
<div class=""><%= link_to t('login'), '/users/login' %></div>
|
<div class=""><%= link_to t('login'), user_login_url %></div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -18,15 +18,15 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||||
<head>
|
<head>
|
||||||
<title>Greenlight</title>
|
<title>Greenlight</title>
|
||||||
<%= csrf_meta_tags %>
|
<%= csrf_meta_tags %>
|
||||||
<%= action_cable_meta_tag %>
|
<meta name="action-cable-url" content="<%= relative_root+Rails.configuration.action_cable.mount_path %>"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||||
|
|
||||||
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
||||||
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
|
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
|
||||||
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="app-background" data-controller="<%= params[:controller] %>" data-action="<%= params[:action] %>">
|
<body class="app-background" data-controller="<%= params[:controller] %>" data-action="<%= params[:action] %>" data-resource="<%= params[:resource] %>">
|
||||||
<!-- Messages -->
|
<!-- Messages -->
|
||||||
<div id='alerts'>
|
<div id='alerts'>
|
||||||
</div>
|
</div>
|
||||||
|
@ -53,6 +53,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
window.I18n = <%= client_translations.to_json.html_safe %>
|
window.I18n = <%= client_translations.to_json.html_safe %>
|
||||||
window.GreenLight = {};
|
window.GreenLight = {};
|
||||||
|
window.GreenLight.relative_root = "<%= relative_root %>"
|
||||||
window.GreenLight.META_LISTED = "<%= BbbApi::META_LISTED %>";
|
window.GreenLight.META_LISTED = "<%= BbbApi::META_LISTED %>";
|
||||||
window.GreenLight.META_TOKEN = "<%= BbbApi::META_TOKEN %>";
|
window.GreenLight.META_TOKEN = "<%= BbbApi::META_TOKEN %>";
|
||||||
window.GreenLight.META_HOOK_URL = "<%= BbbApi::META_HOOK_URL %>";
|
window.GreenLight.META_HOOK_URL = "<%= BbbApi::META_HOOK_URL %>";
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
<%= render layout: 'shared/center_panel' do %>
|
<%= render layout: 'shared/center_panel' do %>
|
||||||
<div class="center-block center-panel-content-size col-xs-12">
|
<div class="center-block center-panel-content-size col-xs-12">
|
||||||
<% if omniauth_providers_configured(:twitter) %>
|
<% if omniauth_providers_configured(:twitter) %>
|
||||||
<%= link_to '/auth/twitter', class: "signin-link signin-link-twitter" do %>
|
<%= link_to omniauth_login_url(:twitter), class: "signin-link signin-link-twitter" do %>
|
||||||
<div class="signin-button center-block">
|
<div class="signin-button center-block">
|
||||||
<div class="signin-icon-wrapper">
|
<div class="signin-icon-wrapper">
|
||||||
<%= image_tag("twitter_signin_logo.png", alt: "T", class: "signin-icon") %>
|
<%= image_tag("twitter_signin_logo.png", alt: "T", class: "signin-icon") %>
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if omniauth_providers_configured(:google) %>
|
<% if omniauth_providers_configured(:google) %>
|
||||||
<%= link_to '/auth/google', class: "signin-link signin-link-google" do %>
|
<%= link_to omniauth_login_url(:google), class: "signin-link signin-link-google" do %>
|
||||||
<div class="signin-button center-block">
|
<div class="signin-button center-block">
|
||||||
<div class="signin-icon-wrapper">
|
<div class="signin-icon-wrapper">
|
||||||
<%= image_tag("g-normal.png", alt: "G", class: "signin-icon") %>
|
<%= image_tag("g-normal.png", alt: "G", class: "signin-icon") %>
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<span><%= t('login_description') %></span>
|
<span><%= t('login_description') %></span>
|
||||||
<div><%= link_to t('login'), '/users/login' %></div>
|
<div><%= link_to t('login'), user_login_url %></div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -2,4 +2,6 @@
|
||||||
|
|
||||||
require_relative 'config/environment'
|
require_relative 'config/environment'
|
||||||
|
|
||||||
|
map Greenlight::Application.config.relative_url_root || "/" do
|
||||||
run Rails.application
|
run Rails.application
|
||||||
|
end
|
||||||
|
|
|
@ -19,7 +19,7 @@ Rails.application.routes.draw do
|
||||||
mount ActionCable.server => '/cable'
|
mount ActionCable.server => '/cable'
|
||||||
|
|
||||||
resources :users, only: [:edit, :update]
|
resources :users, only: [:edit, :update]
|
||||||
get '/users/login', to: 'sessions#new'
|
get '/users/login', to: 'sessions#new', as: :user_login
|
||||||
get '/users/logout', to: 'sessions#destroy', as: :user_logout
|
get '/users/logout', to: 'sessions#destroy', as: :user_logout
|
||||||
|
|
||||||
match '/auth/:provider/callback', to: 'sessions#create', via: [:get, :post]
|
match '/auth/:provider/callback', to: 'sessions#create', via: [:get, :post]
|
||||||
|
@ -28,29 +28,25 @@ Rails.application.routes.draw do
|
||||||
# There are two resources [meetings|rooms]
|
# There are two resources [meetings|rooms]
|
||||||
# meetings offer a landing page for NON authenticated users to create and join session in BigBlueButton
|
# meetings offer a landing page for NON authenticated users to create and join session in BigBlueButton
|
||||||
# rooms offer a customized landing page for authenticated users to create and join session in BigBlueButton
|
# rooms offer a customized landing page for authenticated users to create and join session in BigBlueButton
|
||||||
|
scope '/:resource', constraints: {resource: /meetings|rooms/} do
|
||||||
|
|
||||||
|
# room specific routes
|
||||||
|
scope '/:room_id' do
|
||||||
# recording routes for updating, deleting and viewing recordings
|
# recording routes for updating, deleting and viewing recordings
|
||||||
get '/rooms/:room_id/recordings', to: 'bbb#recordings', defaults: {format: 'json'}
|
get '/(:id)/recordings', to: 'bbb#recordings', defaults: {id: nil, format: 'json'}
|
||||||
patch '/rooms/:room_id/recordings/:record_id', to: 'bbb#update_recordings', defaults: {format: 'json'}
|
patch '/(:id)/recordings/:record_id', to: 'bbb#update_recordings', defaults: {id: nil, format: 'json'}
|
||||||
delete '/rooms/:room_id/recordings/:record_id', to: 'bbb#delete_recordings', defaults: {format: 'json'}
|
delete '/(:id)/recordings/:record_id', to: 'bbb#delete_recordings', defaults: {id: nil, format: 'json'}
|
||||||
get '/rooms/:room_id/:id/recordings', to: 'bbb#recordings', defaults: {format: 'json'}
|
|
||||||
patch '/rooms/:room_id/:id/recordings/:record_id', to: 'bbb#update_recordings', defaults: {format: 'json'}
|
|
||||||
delete '/rooms/:room_id/:id/recordings/:record_id', to: 'bbb#delete_recordings', defaults: {format: 'json'}
|
|
||||||
|
|
||||||
# room routes for joining, ending, waiting and refreshing authenticated meetings
|
delete '/:id/end', to: 'bbb#end', defaults: {format: 'json'}
|
||||||
get '/rooms/:room_id', to: 'landing#resource', resource: 'rooms'
|
get '/:id/wait', to: 'landing#wait_for_moderator'
|
||||||
get '/rooms/:room_id/:id', to: 'landing#resource', resource: 'rooms'
|
get '/:id/session_status_refresh', to: 'landing#session_status_refresh'
|
||||||
get '/rooms/:room_id/:id/join', to: 'bbb#join', resource: 'rooms', defaults: {format: 'json'}
|
end
|
||||||
delete '/rooms/:room_id/:id/end', to: 'bbb#end', defaults: {format: 'json'}
|
|
||||||
|
|
||||||
# routes shared between meetings and rooms
|
# routes shared between meetings and rooms
|
||||||
get '/:resource/:id', to: 'landing#resource', as: :resource
|
get '/(:room_id)/:id/join', to: 'bbb#join', defaults: {room_id: nil, format: 'json'}
|
||||||
get '/:resource/:id/join', to: 'bbb#join', as: :bbb_join, defaults: {format: 'json'}
|
get '/(:room_id)/:id', to: 'landing#resource', as: :meeting_room, defaults: {room_id: nil}
|
||||||
post '/:resource/:id/callback', to: 'bbb#callback' #, defaults: {format: 'json'}
|
post '/:id/callback', to: 'bbb#callback' #, defaults: {format: 'json'}
|
||||||
|
end
|
||||||
get '/:resource/:room_id/:id/wait', to: 'landing#wait_for_moderator'
|
|
||||||
get '/:resource/:room_id/:id/session_status_refresh', to: 'landing#session_status_refresh'
|
|
||||||
|
|
||||||
|
|
||||||
root to: 'landing#index', :resource => 'meetings'
|
root to: 'landing#index', :resource => 'meetings'
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,6 +10,8 @@ services:
|
||||||
- '.:/usr/src/app'
|
- '.:/usr/src/app'
|
||||||
volumes_from:
|
volumes_from:
|
||||||
- gem_cache
|
- gem_cache
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
expose:
|
expose:
|
||||||
- '3001'
|
- '3001'
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
|
|
Loading…
Reference in New Issue