diff --git a/app/assets/images/logo_with_text.png b/app/assets/images/logo_with_text.png new file mode 100644 index 00000000..6fa57f4f Binary files /dev/null and b/app/assets/images/logo_with_text.png differ diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 1197a293..be3a0880 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -52,12 +52,22 @@ a { text-decoration: none !important; } +.sessions { + background-color: white; +} + .start-block { background-color: white; border: 3px solid lightblue; border-radius: 4px; } +.start-button { + font-size: 26px; + position: absolute; + bottom: 0; +} + .main-large { font-size: 20px; } @@ -83,16 +93,12 @@ html, body { } .wrapper { - min-height:100%; - position:relative; + min-height: 100%; + position: relative; } .footer { width: 100%; - height: 70px; - position: absolute; - bottom: 0; - left: 0; text-align: center; } diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index e0a46491..d79897dd 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -4,6 +4,7 @@ class MainController < ApplicationController # GET / def index + @user = User.new end private diff --git a/app/controllers/rooms_controller.rb b/app/controllers/rooms_controller.rb index 26ab934e..0e1b5883 100644 --- a/app/controllers/rooms_controller.rb +++ b/app/controllers/rooms_controller.rb @@ -48,7 +48,7 @@ class RoomsController < ApplicationController # POST /r/:room_uid def join opts = default_meeting_options - + # If you're unauthenticated, you must enter a name to join the meeting. if params[:join_name] redirect_to @room.join_path(params[:join_name], opts) @@ -57,9 +57,9 @@ class RoomsController < ApplicationController # DELETE /r/:room_uid def destroy - @room.destroy + @room.destroy unless @room == current_user.main_room - redirect_to root_path + redirect_to current_user.main_room end # GET /r/:room_uid/start @@ -87,7 +87,11 @@ class RoomsController < ApplicationController # GET /r/:room_uid/logout def logout # Redirect the owner to their room. - redirect_to root_path + if current_user + redirect_to current_user.main_room + else + redirect_to root_path + end end # GET /r/:room_uid/sessions diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 46e3b05b..64ee6d8b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,5 @@ class UsersController < ApplicationController - + # GET /signup def new @user = User.new @@ -9,11 +9,11 @@ class UsersController < ApplicationController def create user = User.new(user_params) user.provider = "greenlight" - + if user.save - login(user) + login(user) else - render :new + end end @@ -25,6 +25,6 @@ class UsersController < ApplicationController private def user_params - params.require(:user).permit(:name, :email, :username, :password, :password_confirmation) + params.require(:user).permit(:name, :email, :password, :password_confirmation) end end diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb index df0d909b..4b40d120 100644 --- a/app/helpers/sessions_helper.rb +++ b/app/helpers/sessions_helper.rb @@ -1,9 +1,9 @@ module SessionsHelper + # Logs a user into GreenLight. def login(user) session[:user_id] = user.id - redirect_to root_path - #redirect_to room_path(user.room.uid) + redirect_to user.main_room end # Logs current user out of GreenLight. diff --git a/app/models/room.rb b/app/models/room.rb index fc371990..7a6da96d 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -1,10 +1,13 @@ class Room < ApplicationRecord - before_create :generate_uids + before_create :setup + + validates :name, presence: true belongs_to :user has_one :meeting + ROOM_ICONS = %w(circle star certificate play cloud heart square bookmark cog) RETURNCODE_SUCCESS = "SUCCESS" def to_param @@ -116,9 +119,11 @@ class Room < ApplicationRecord end # Generates a uid for the room and BigBlueButton. - def generate_uids - self.uid = [user.firstname, (0...8).map { (65 + rand(26)).chr }.join].join('-') + def setup + self.uid = [user.firstname, (0...8).map { (65 + rand(26)).chr }.join].join('-').downcase self.bbb_id = Digest::SHA1.hexdigest(Rails.application.secrets[:secret_key_base] + Time.now.to_i.to_s).to_s + + self.icon = ROOM_ICONS.sample end # Rereives the loadbalanced BigBlueButton credentials for a user. diff --git a/app/models/user.rb b/app/models/user.rb index f2189b0e..8f4cbebe 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,12 +1,12 @@ class User < ApplicationRecord - after_create :initialize_room + after_create :initialize_main_room before_save { email.downcase! unless email.nil? } has_many :rooms + belongs_to :main_room, class_name: 'Room', foreign_key: :room_id, required: false validates :name, length: { maximum: 24 }, presence: true - validates :username, presence: true validates :provider, presence: true validates :email, length: { maximum: 60 }, allow_nil: true, uniqueness: { case_sensitive: false }, @@ -27,6 +27,7 @@ class User < ApplicationRecord user.username = send("#{auth['provider']}_username", auth) user.email = send("#{auth['provider']}_email", auth) user.image = send("#{auth['provider']}_image", auth) + user.save! user end @@ -88,7 +89,8 @@ class User < ApplicationRecord private # Initializes a room for the user. - def initialize_room - Room.create(user_id: self.id, name: firstname + "'s Room") + def initialize_main_room + self.main_room = Room.create!(user: self, name: firstname + "'s Room") + self.save end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 2dcca813..90464892 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -32,12 +32,12 @@ <%= yield %> - <%= render "shared/footer" %> - <% if current_user %> <%= render "shared/modals/create_room_modal" %> <% end %> + + <%= render "shared/footer" %> diff --git a/app/views/main/index.html.erb b/app/views/main/index.html.erb index 8eab997f..9d8a8f60 100644 --- a/app/views/main/index.html.erb +++ b/app/views/main/index.html.erb @@ -1,28 +1,11 @@
- <% if current_user %> -

<%= "Welcome, #{current_user.firstname}." %>

- <% else %> -

Teach Students Online.

- <%= render "shared/modals/video_modal" %> - <% end %> +

Teach Students Online.

+ <%= render "shared/modals/video_modal" %> +
- <% if current_user %> -
- <% current_user.rooms.each do |room| %> -
- <%= link_to room do %> - <%= render "shared/components/room_block", room: room %> - <% end %> -
- <% end %> -
- -
- <% else %> - <%= render "shared/features" %> - <% end %> + <%= render "shared/features" %>
diff --git a/app/views/shared/_header.html.erb b/app/views/shared/_header.html.erb index a8d2bff0..54e2843e 100644 --- a/app/views/shared/_header.html.erb +++ b/app/views/shared/_header.html.erb @@ -2,16 +2,14 @@
<%= link_to root_path, class: "header-brand" do %> - <%= image_tag("bbb_logo.png", class: "header-brand-img") %> + <%= image_tag("logo_with_text.png", class: "header-brand-img") %> <% end %>
<% if current_user %> - + Create Room - <%= render "shared/modals/login_modal" %> - Sessions
<% else %> - + + + <%= render "shared/modals/login_modal" %> + <%= render "shared/modals/signup_modal" %> <% end %>
diff --git a/app/views/shared/_meeting_url.html.erb b/app/views/shared/_meeting_url.html.erb deleted file mode 100644 index 051604a4..00000000 --- a/app/views/shared/_meeting_url.html.erb +++ /dev/null @@ -1,42 +0,0 @@ - \ No newline at end of file diff --git a/app/views/shared/_sessions.html.erb b/app/views/shared/_sessions.html.erb new file mode 100644 index 00000000..be4cde5c --- /dev/null +++ b/app/views/shared/_sessions.html.erb @@ -0,0 +1,76 @@ +
+
+ + <%= render "shared/components/subtitle", subtitle: "Sessions" %> + +
+
+
+ + + + + + + + + + + + + <% 3.times do %> + + + + + + + + + + <% end %> + +
NameThumbnailsLengthUsersVisibility
+
Example Meeting
+
+ June 21, 2017 (about 3 hours ago) +
+
+ + + + +
+ Length +
+ 1 hr +
+
+ Users +
+ 4 +
+
+ Visibility +
+ Unlisted +
+ Presentation + Podcast + + +
+
+
+
+
+
diff --git a/app/views/shared/_start_meeting.html.erb b/app/views/shared/_start_meeting.html.erb index 3b05d2f9..be62209c 100644 --- a/app/views/shared/_start_meeting.html.erb +++ b/app/views/shared/_start_meeting.html.erb @@ -26,34 +26,3 @@ - - diff --git a/app/views/shared/components/_room_block.html.erb b/app/views/shared/components/_room_block.html.erb index c233df59..33f8922d 100644 --- a/app/views/shared/components/_room_block.html.erb +++ b/app/views/shared/components/_room_block.html.erb @@ -3,7 +3,9 @@
- + + +
<%= room.name %>
@@ -17,8 +19,10 @@ diff --git a/app/views/shared/components/_subtitle.html.erb b/app/views/shared/components/_subtitle.html.erb index 8b9a16d0..3025ac0a 100644 --- a/app/views/shared/components/_subtitle.html.erb +++ b/app/views/shared/components/_subtitle.html.erb @@ -1,5 +1,5 @@
-
+

<%= subtitle %>


diff --git a/app/views/shared/modals/_create_room_modal.html.erb b/app/views/shared/modals/_create_room_modal.html.erb index b0bb0987..94aa40e2 100644 --- a/app/views/shared/modals/_create_room_modal.html.erb +++ b/app/views/shared/modals/_create_room_modal.html.erb @@ -13,15 +13,14 @@ - <%= f.text_field :name, class: "form-control", placeholder: "Enter a room name...", autocomplete: :off %> -
+ <%= f.text_field :name, id: "room-name", class: "form-control", placeholder: "Enter a room name...", autocomplete: :off %>
<% end %> @@ -32,3 +31,15 @@ + + diff --git a/app/views/shared/modals/_login_modal.html.erb b/app/views/shared/modals/_login_modal.html.erb index 2d417612..cd9ae0f8 100644 --- a/app/views/shared/modals/_login_modal.html.erb +++ b/app/views/shared/modals/_login_modal.html.erb @@ -35,11 +35,7 @@ - - diff --git a/app/views/shared/modals/_signup_modal.html.erb b/app/views/shared/modals/_signup_modal.html.erb new file mode 100644 index 00000000..84f80241 --- /dev/null +++ b/app/views/shared/modals/_signup_modal.html.erb @@ -0,0 +1,38 @@ + diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb deleted file mode 100644 index e69de29b..00000000 diff --git a/app/views/users/settings.html.erb b/app/views/users/settings.html.erb index af1add04..4bd51ae3 100644 --- a/app/views/users/settings.html.erb +++ b/app/views/users/settings.html.erb @@ -3,13 +3,13 @@ <%= render "shared/components/subtitle", subtitle: "Settings" %>
-
+
-
+
@@ -58,7 +58,7 @@
-
+

diff --git a/config/routes.rb b/config/routes.rb index dbbb0349..4be78eea 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,8 +12,7 @@ Rails.application.routes.draw do get '/sessions', to: 'rooms#sessions', as: :sessions end - # Signup routes. - get '/signup', to: 'users#new' + # Signup route. post '/signup', to: 'users#create' # User settings. diff --git a/db/migrate/20180504131648_create_users.rb b/db/migrate/20180504131648_create_users.rb index 5bcb6b34..e7d4da27 100644 --- a/db/migrate/20180504131648_create_users.rb +++ b/db/migrate/20180504131648_create_users.rb @@ -1,6 +1,7 @@ class CreateUsers < ActiveRecord::Migration[5.0] def change create_table :users do |t| + t.belongs_to :room, index: true t.string :provider t.string :uid t.string :name diff --git a/db/migrate/20180504131705_create_rooms.rb b/db/migrate/20180504131705_create_rooms.rb index 2ba7ba75..e07d068d 100644 --- a/db/migrate/20180504131705_create_rooms.rb +++ b/db/migrate/20180504131705_create_rooms.rb @@ -5,6 +5,7 @@ class CreateRooms < ActiveRecord::Migration[5.0] t.string :name, index: true t.string :uid, index: true t.string :bbb_id, index: true + t.string :icon, index: true t.timestamps end diff --git a/db/schema.rb b/db/schema.rb index 47860038..238d641e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -17,15 +17,18 @@ ActiveRecord::Schema.define(version: 20180504131705) do t.string "name" t.string "uid" t.string "bbb_id" + t.string "icon" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["bbb_id"], name: "index_rooms_on_bbb_id" + t.index ["icon"], name: "index_rooms_on_icon" t.index ["name"], name: "index_rooms_on_name" t.index ["uid"], name: "index_rooms_on_uid" t.index ["user_id"], name: "index_rooms_on_user_id" end create_table "users", force: :cascade do |t| + t.integer "room_id" t.string "provider" t.string "uid" t.string "name" @@ -36,6 +39,7 @@ ActiveRecord::Schema.define(version: 20180504131705) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["password_digest"], name: "index_users_on_password_digest", unique: true + t.index ["room_id"], name: "index_users_on_room_id" end end