forked from External/greenlight
Rework for generalizing some methods
This commit is contained in:
parent
8d6904e183
commit
12aac189a8
|
@ -3,7 +3,6 @@ require 'digest/sha1'
|
|||
|
||||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery with: :exception
|
||||
include ApplicationHelper
|
||||
|
||||
def current_user
|
||||
@current_user ||= User.find_by(id: session[:user_id])
|
||||
|
|
|
@ -1,33 +1,51 @@
|
|||
class LandingController < ApplicationController
|
||||
|
||||
def meeting
|
||||
@refreshable = (params[:resource] == 'meetings' && !params.has_key?(:id))
|
||||
@meeting_token = params[:id] || @meeting_token = helpers.new_meeting_token
|
||||
@resource = params[:resource]
|
||||
@resource_url = meeting_url(@meeting_token)
|
||||
def index
|
||||
if params[:resource] == 'meetings'
|
||||
render_meeting
|
||||
elsif params[:resource] == 'rooms'
|
||||
render_room
|
||||
else
|
||||
render 'errors/error'
|
||||
end
|
||||
end
|
||||
|
||||
# GET /token.json
|
||||
def new_meeting
|
||||
respond_to do |format|
|
||||
meeting_url = meeting_url(helpers.new_meeting_token)
|
||||
meeting_url = resource_url('meetings', 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 meeting
|
||||
render_meeting
|
||||
end
|
||||
|
||||
def room
|
||||
@room_name = params[:name]
|
||||
@user = User.find_by(username: @room_name)
|
||||
@meeting_token = @room_name
|
||||
@resource = "rooms"
|
||||
@resource_url = room_url(@meeting_token)
|
||||
if @user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
render_room
|
||||
end
|
||||
|
||||
def admin?
|
||||
@user == current_user
|
||||
end
|
||||
helper_method :admin?
|
||||
private
|
||||
def render_meeting
|
||||
@resource = params[:resource]
|
||||
@meeting_token = params[:id] || @meeting_token = helpers.new_meeting_token
|
||||
@refreshable = (params[:resource] == 'meetings' && !params.has_key?(:id))
|
||||
render :action => 'meeting'
|
||||
end
|
||||
|
||||
def render_room
|
||||
@resource = params[:resource]
|
||||
@meeting_token = params[:id]
|
||||
@user = User.find_by(username: @meeting_token)
|
||||
if @user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
render :action => 'room'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ class SessionsController < ApplicationController
|
|||
@user = User.from_omniauth(request.env['omniauth.auth'])
|
||||
if @user.persisted?
|
||||
session[:user_id] = @user.id
|
||||
redirect_to controller: 'landing', action: 'room', name: @user.username
|
||||
redirect_to controller: 'landing', action: 'room', id: @user.username
|
||||
else
|
||||
@user.save!
|
||||
session[:user_id] = @user.id
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<div id="landing_page_url" class="center-block">
|
||||
<form id="url_form" class="form-inline">
|
||||
<div class="form-group">
|
||||
<span id="meeting_url"><%= @resource_url %></span>
|
||||
<span id="meeting_url"><%= resource_url(@resource, @meeting_token) %></span>
|
||||
</div>
|
||||
<% if @refreshable %>
|
||||
<button id="url_form_button" type="button" class="btn btn-default" data-url="<%= new_meeting_path() %>">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<figure class=highlight><pre><figcaption class="text" data-lang="text">
|
||||
<p>Hi Everyone</p>
|
||||
<p>The meeting will be at this URL</p>
|
||||
<p><a id="text_meeting_url" href="<%= @resource_url %>"><%= @resource_url %></a></p>
|
||||
<p><a id="text_meeting_url" href="<%= resource_url(@resource, @meeting_token) %>"><%= resource_url(@resource, @meeting_token) %></a></p>
|
||||
<p>Please join!</p>
|
||||
</figcaption></pre></figure>
|
||||
|
|
|
@ -4,8 +4,7 @@ Rails.application.routes.draw do
|
|||
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"
|
||||
get '/rooms/:name', to: 'landing#room', as: :room
|
||||
get '/:resource(/:id)', to: 'landing#index', as: :resource
|
||||
|
||||
get '/auth/:provider/callback', to: 'sessions#create'
|
||||
get '/logout', to: 'sessions#destroy'
|
||||
|
|
Loading…
Reference in New Issue