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 e04b5ee3..fadc0d35 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -99,5 +99,4 @@ a { .terms { overflow: scroll; height: 55vh; - white-space: pre-line; } 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/views/users/terms.html.erb b/app/views/users/terms.html.erb index 8684b6a2..521cee63 100644 --- a/app/views/users/terms.html.erb +++ b/app/views/users/terms.html.erb @@ -6,7 +6,7 @@
-

<%= Rails.configuration.terms %>

+ <%= markdown(Rails.configuration.terms) %>
<%= button_to t("terms.accept"), terms_path, params: {accept: true}, class: "btn btn-primary btn-space" %>