<%= t("errors.migration_error.notice") %>
-<%= t("errors.migration_error.contact_admin") %>
-diff --git a/Gemfile b/Gemfile index 4a19fefb..62c0f7f8 100644 --- a/Gemfile +++ b/Gemfile @@ -63,6 +63,9 @@ gem 'http_accept_language' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development +# Markdown parsing. +gem 'redcarpet' + group :production do # Use a postgres database in production. gem 'pg', '~> 0.18' diff --git a/Gemfile.lock b/Gemfile.lock index 21744073..daafd4ef 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -189,6 +189,7 @@ GEM rb-fsevent (0.10.3) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) + redcarpet (3.4.0) redis (3.3.5) ref (2.0.0) rspec-core (3.7.1) @@ -296,6 +297,7 @@ DEPENDENCIES puma (~> 3.0) rails (~> 5.0.7) rails-controller-testing + redcarpet redis (~> 3.0) rspec-rails (~> 3.7) rubocop diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 60b489b9..fadc0d35 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -51,10 +51,6 @@ a { min-height: calc(100% - #{$header-height} - #{$footer-height}); } -.flex-center { - transform: translateY(25%); -} - .footer { height: $footer-height; width: 100%; @@ -103,5 +99,4 @@ a { .terms { overflow: scroll; height: 55vh; - white-space: pre-line; } diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 877cc49e..198ae8b7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class UsersController < ApplicationController - before_action :find_user, only: [:edit, :update] + before_action :find_user, only: [:edit, :update, :destroy] before_action :ensure_unauthenticated, only: [:new, :create] # POST /u @@ -72,6 +72,15 @@ class UsersController < ApplicationController end end + # DELETE /u/:user_uid + def destroy + if current_user && current_user == @user + @user.destroy + session.delete(:user_id) + end + redirect_to root_path + end + # GET /u/terms def terms redirect_to root_path unless current_user diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 85a8a4fa..dc932263 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -25,7 +25,22 @@ module ApplicationHelper Rails.configuration.allow_user_signup end + # Determines if the BigBlueButton endpoint is the default. def bigbluebutton_endpoint_default? Rails.configuration.bigbluebutton_endpoint_default == Rails.configuration.bigbluebutton_endpoint end + + # Parses markdown for rendering. + def markdown(text) + markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, + no_intra_emphasis: true, + fenced_code_blocks: true, + disable_indented_code_blocks: true, + autolink: true, + tables: true, + underline: true, + highlight: true) + + markdown.render(text).html_safe + end end diff --git a/app/models/room.rb b/app/models/room.rb index bc439f8a..10370c66 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -3,6 +3,8 @@ class Room < ApplicationRecord before_create :setup + before_destroy :delete_all_recordings + validates :name, presence: true belongs_to :owner, class_name: 'User', foreign_key: :user_id @@ -155,6 +157,12 @@ class Room < ApplicationRecord self.bbb_id = Digest::SHA1.hexdigest(Rails.application.secrets[:secret_key_base] + Time.now.to_i.to_s).to_s end + # Deletes all recordings associated with the room. + def delete_all_recordings + record_ids = recordings.map { |r| r[:recordID] } + delete_recording(record_ids) unless record_ids.empty? + end + # Generates a three character uid chunk. def uid_chunk charset = ("a".."z").to_a - %w(b i l o s) + ("2".."9").to_a - %w(5 8) diff --git a/app/models/user.rb b/app/models/user.rb index 88f253a3..4f1b31ac 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,6 +4,8 @@ class User < ApplicationRecord after_create :initialize_main_room before_save { email.try(:downcase!) } + before_destroy :destroy_rooms + has_many :rooms belongs_to :main_room, class_name: 'Room', foreign_key: :room_id, required: false @@ -83,6 +85,11 @@ class User < ApplicationRecord private + # Destory a users rooms when they are removed. + def destroy_rooms + rooms.destroy_all + end + # Initializes a room for the user and assign a BigBlueButton user id. def initialize_main_room self.uid = "gl-#{(0...12).map { (65 + rand(26)).chr }.join.downcase}" diff --git a/app/views/application/migration_error.html.erb b/app/views/application/migration_error.html.erb index 06d9d420..b1e90fc1 100644 --- a/app/views/application/migration_error.html.erb +++ b/app/views/application/migration_error.html.erb @@ -1,16 +1,12 @@ -
<%= t("errors.migration_error.contact_admin") %>
-<%= t("errors.migration_error.contact_admin") %>
+<%= t("errors.internal.help") %>
- - <%= t("go_back") %> - -<%= t("errors.internal.help") %>
+ + <%= t("go_back") %> +<%= t("errors.not_found.help") %>
- - <%= t("go_back") %> - -<%= t("errors.not_found.help") %>
+ + <%= t("go_back") %> +<%= t("errors.unprocessable.help") %>
- - <%= t("go_back") %> - -<%= t("errors.unprocessable.help") %>
+ + <%= t("go_back") %> +<%= Rails.configuration.terms %>
+ <%= markdown(Rails.configuration.terms) %>