add support for deploying to a subdirectory

This commit is contained in:
Josh
2018-06-18 10:28:47 -04:00
parent ce6ec0acfb
commit b2b2c641da
10 changed files with 74 additions and 54 deletions

View File

@ -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])

View File

@ -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