forked from External/greenlight
add support for deploying to a subdirectory
This commit is contained in:
parent
ce6ec0acfb
commit
b2b2c641da
|
@ -15,6 +15,9 @@
|
|||
/public/system/**
|
||||
/public/assets/**
|
||||
|
||||
# Ignore production paths.
|
||||
/db/production
|
||||
|
||||
# Ignore all logfiles and tempfiles.
|
||||
/log/*
|
||||
/tmp/*
|
||||
|
|
|
@ -5,7 +5,7 @@ class RoomsController < ApplicationController
|
|||
|
||||
META_LISTED = "gl-listed"
|
||||
|
||||
# POST /r
|
||||
# POST /
|
||||
def create
|
||||
redirect_to root_path unless current_user
|
||||
|
||||
|
@ -24,7 +24,7 @@ class RoomsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# GET /r/:room_uid
|
||||
# GET /:room_uid
|
||||
def show
|
||||
if current_user && @room.owned_by?(current_user)
|
||||
@recordings = @room.recordings
|
||||
|
@ -34,7 +34,7 @@ class RoomsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# POST /r/:room_uid
|
||||
# POST /:room_uid
|
||||
def join
|
||||
opts = default_meeting_options
|
||||
|
||||
|
@ -59,7 +59,7 @@ class RoomsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# DELETE /r/:room_uid
|
||||
# DELETE /:room_uid
|
||||
def destroy
|
||||
# Don't delete the users home room.
|
||||
@room.destroy if @room != current_user.main_room
|
||||
|
@ -67,7 +67,7 @@ class RoomsController < ApplicationController
|
|||
redirect_to current_user.main_room
|
||||
end
|
||||
|
||||
# POST /r/:room_uid/start
|
||||
# POST /:room_uid/start
|
||||
def start
|
||||
# Join the user in and start the meeting.
|
||||
opts = default_meeting_options
|
||||
|
@ -80,13 +80,13 @@ class RoomsController < ApplicationController
|
|||
NotifyUserWaitingJob.set(wait: 5.seconds).perform_later(@room)
|
||||
end
|
||||
|
||||
# GET /r/:room_uid/logout
|
||||
# GET /:room_uid/logout
|
||||
def logout
|
||||
# Redirect the correct page.
|
||||
redirect_to @room
|
||||
end
|
||||
|
||||
# POST /r/:room_uid/home
|
||||
# POST /:room_uid/home
|
||||
def home
|
||||
current_user.main_room = @room
|
||||
current_user.save
|
||||
|
@ -94,7 +94,7 @@ class RoomsController < ApplicationController
|
|||
redirect_to @room
|
||||
end
|
||||
|
||||
# POST /r/:room_uid/:record_id
|
||||
# POST /:room_uid/:record_id
|
||||
def update_recording
|
||||
meta = {
|
||||
"meta_#{META_LISTED}": (params[:state] == "public")
|
||||
|
@ -104,7 +104,7 @@ class RoomsController < ApplicationController
|
|||
redirect_to @room if res[:updated]
|
||||
end
|
||||
|
||||
# DELETE /r/:room_uid/:record_id
|
||||
# DELETE /:room_uid/:record_id
|
||||
def delete_recording
|
||||
@room.delete_recording(params[:record_id])
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ class UsersController < ApplicationController
|
|||
before_action :find_user, only: [:edit, :update]
|
||||
before_action :ensure_unauthenticated, only: [:new, :create]
|
||||
|
||||
# POST /users
|
||||
# POST /u
|
||||
def create
|
||||
# Verify that GreenLight is configured to allow user signup.
|
||||
return unless Rails.configuration.allow_user_signup
|
||||
|
@ -28,7 +28,7 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# GET /users/:user_uid/edit
|
||||
# GET /u/:user_uid/edit
|
||||
def edit
|
||||
if current_user
|
||||
redirect_to current_user.room unless @user == current_user
|
||||
|
@ -37,41 +37,40 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# PATCH /users/:user_uid
|
||||
# PATCH /u/:user_uid
|
||||
def update
|
||||
# Update account information if passed.
|
||||
@user.name = user_params[:name] if user_params[:name]
|
||||
@user.email = user_params[:email] if user_params[:email]
|
||||
@user.image = user_params[:image] if user_params[:image]
|
||||
if params[:setting] == "password"
|
||||
# Update the users password.
|
||||
errors = {}
|
||||
|
||||
# Custom errors not generated by validations.
|
||||
errors = {}
|
||||
|
||||
# Verify that the provided password is correct.
|
||||
if user_params[:password]
|
||||
if @user.authenticate(user_params[:password])
|
||||
# Verify that the new passwords match.
|
||||
if user_params[:new_password] == user_params[:password_confirmation]
|
||||
@user.password = user_params[:new_password]
|
||||
else
|
||||
# New passwords don't match.
|
||||
errors[:password_confirmation] = "'s don't match"
|
||||
errors[:password_confirmation] = "doesn't match"
|
||||
end
|
||||
else
|
||||
# Original password is incorrect, can't update.
|
||||
errors[:password] = "is incorrect"
|
||||
end
|
||||
end
|
||||
|
||||
if @user.save!
|
||||
# Notify the use that their account has been updated.
|
||||
redirect_to edit_user_path(@user), notice: "Information successfully updated."
|
||||
if errors.empty? && @user.save
|
||||
# Notify the use that their account has been updated.
|
||||
redirect_to edit_user_path(@user), notice: "Information successfully updated."
|
||||
else
|
||||
# Append custom errors.
|
||||
errors.each do |k, v| @user.errors.add(k, v) end
|
||||
render :edit
|
||||
end
|
||||
else
|
||||
# Append custom errors.
|
||||
errors.each do |k, v| @user.errors.add(k, v) end
|
||||
|
||||
# Handle validation errors.
|
||||
render :edit
|
||||
# Update the core user attributes.
|
||||
if @user.update_attributes(user_params)
|
||||
redirect_to edit_user_path(@user), notice: "Information successfully updated."
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class Room < ApplicationRecord
|
|||
|
||||
# Determines the invite URL for the room.
|
||||
def invite_path
|
||||
"/r/#{uid}"
|
||||
"#{Rails.configuration.relative_url_root}/#{uid}"
|
||||
end
|
||||
|
||||
# Creates a meeting on the BigBlueButton server.
|
||||
|
|
|
@ -13,7 +13,7 @@ class User < ApplicationRecord
|
|||
uniqueness: { case_sensitive: false },
|
||||
format: {with: /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i }
|
||||
|
||||
validates :password, length: { minimum: 6 }, presence: true, confirmation: true, allow_blank: true, if: :greenlight_account?
|
||||
validates :password, length: { minimum: 6 }, confirmation: true, if: :greenlight_account?
|
||||
|
||||
# We don't want to require password validations on all accounts.
|
||||
has_secure_password(validations: false)
|
||||
|
@ -57,7 +57,7 @@ class User < ApplicationRecord
|
|||
end
|
||||
|
||||
def twitter_image(auth)
|
||||
auth['info']['image'].gsub!("_normal", "")
|
||||
auth['info']['image'].gsub("_normal", "")
|
||||
end
|
||||
|
||||
def google_name(auth)
|
||||
|
|
|
@ -2,4 +2,6 @@
|
|||
|
||||
require_relative 'config/environment'
|
||||
|
||||
run Rails.application
|
||||
map Greenlight::Application.config.relative_url_root || "/" do
|
||||
run Rails.application
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ require 'rails/all'
|
|||
# you've limited to :test, :development, or :production.
|
||||
Bundler.require(*Rails.groups)
|
||||
|
||||
module Greenlight20
|
||||
module Greenlight
|
||||
class Application < Rails::Application
|
||||
# Settings in config/environments/* take precedence over those specified here.
|
||||
# Application configuration should go into files in config/initializers
|
||||
|
|
|
@ -83,4 +83,11 @@ Rails.application.configure do
|
|||
|
||||
# Do not dump schema after migrations.
|
||||
config.active_record.dump_schema_after_migration = false
|
||||
|
||||
# Set the relative url root for deployment to a subdirectory.
|
||||
if ENV['RELATIVE_URL_ROOT'].present?
|
||||
config.relative_url_root = ENV['RELATIVE_URL_ROOT']
|
||||
else
|
||||
config.relative_url_root = ""
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,29 +5,12 @@ Rails.application.routes.draw do
|
|||
match '/422', to: 'errors#unprocessable', via: :all
|
||||
match '/500', to: 'errors#internal_error', via: :all
|
||||
|
||||
# Room resources.
|
||||
resources :rooms, only: [:create, :show, :destroy], param: :room_uid, path: '/r'
|
||||
|
||||
# Extended room routes.
|
||||
scope '/r/:room_uid' do
|
||||
post '/', to: 'rooms#join'
|
||||
post '/start', to: 'rooms#start', as: :start_room
|
||||
get '/logout', to: 'rooms#logout', as: :logout_room
|
||||
post '/home', to: 'rooms#home', as: :make_home
|
||||
|
||||
# Mange recordings.
|
||||
scope '/:record_id' do
|
||||
post '/', to: 'rooms#update_recording', as: :update_recording
|
||||
delete '/', to: 'rooms#delete_recording', as: :delete_recording
|
||||
end
|
||||
end
|
||||
|
||||
# Signup routes.
|
||||
get '/signup', to: 'users#new', as: :signup
|
||||
post '/signup', to: 'users#create', as: :create_user
|
||||
|
||||
# User resources.
|
||||
scope '/users' do
|
||||
scope '/u' do
|
||||
get '/:user_uid/edit', to: 'users#edit', as: :edit_user
|
||||
patch '/:user_uid/edit', to: 'users#update', as: :update_user
|
||||
|
||||
|
@ -45,5 +28,22 @@ Rails.application.routes.draw do
|
|||
match '/auth/:provider/callback', to: 'sessions#omniauth', via: [:get, :post], as: :omniauth_session
|
||||
get '/auth/failure', to: 'sessions#fail'
|
||||
|
||||
# Room resources.
|
||||
resources :rooms, only: [:create, :show, :destroy], param: :room_uid, path: '/'
|
||||
|
||||
# Extended room routes.
|
||||
scope '/:room_uid' do
|
||||
post '/', to: 'rooms#join'
|
||||
post '/start', to: 'rooms#start', as: :start_room
|
||||
get '/logout', to: 'rooms#logout', as: :logout_room
|
||||
post '/home', to: 'rooms#home', as: :make_home
|
||||
|
||||
# Mange recordings.
|
||||
scope '/:record_id' do
|
||||
post '/', to: 'rooms#update_recording', as: :update_recording
|
||||
delete '/', to: 'rooms#delete_recording', as: :delete_recording
|
||||
end
|
||||
end
|
||||
|
||||
root to: 'main#index'
|
||||
end
|
||||
|
|
|
@ -46,3 +46,12 @@ TWITTER_SECRET=
|
|||
# Omniauth. This will allow users to create an account at www.hostname.com/signup
|
||||
# and use that account to fully interact with GreenLight.
|
||||
ALLOW_GREENLIGHT_ACCOUNTS=false
|
||||
|
||||
# Prefix for the applications root URL.
|
||||
# Useful for deploying the application to a subdirectory, which is highly recommended
|
||||
# if deploying on a BigBlueButton server. Keep in mind that if you change this, you'll
|
||||
# have to update your authentication callback URL's to reflect this change.
|
||||
#
|
||||
# The recommended prefix is "/gl".
|
||||
#
|
||||
RELATIVE_URL_ROOT=/gl
|
||||
|
|
Loading…
Reference in New Issue