forked from External/greenlight
GRN2-180: First stages of refactoring code for v2.4 (#748)
* Email rescues and authenticator concern * Application controller and helper clean up * Moved controller code out of helpers * More helper and email clean up * Cleaned up remaining helpers and create omniauth_options * Controller code clean up * restructured views structure * Restructured role code * Restructured profile and code clean up * Master merge * Added bbb server concern to deal with bbb calls * Bug fixes and changes after changes * rspec * More rubocop fixes
This commit is contained in:
@ -18,20 +18,8 @@
|
||||
|
||||
require 'bbb_api'
|
||||
require 'uri'
|
||||
require 'i18n/language/mapping'
|
||||
|
||||
module ApplicationHelper
|
||||
include MeetingsHelper
|
||||
include BbbApi
|
||||
include I18n::Language::Mapping
|
||||
|
||||
# Gets all configured omniauth providers.
|
||||
def configured_providers
|
||||
Rails.configuration.providers.select do |provider|
|
||||
Rails.configuration.send("omniauth_#{provider}")
|
||||
end
|
||||
end
|
||||
|
||||
# Determines which providers can show a login button in the login modal.
|
||||
def iconset_providers
|
||||
providers = configured_providers & [:google, :twitter, :office365, :ldap]
|
||||
@ -50,53 +38,9 @@ module ApplicationHelper
|
||||
end
|
||||
end
|
||||
|
||||
# Determine if Greenlight is configured to allow user signups.
|
||||
def allow_user_signup?
|
||||
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
|
||||
|
||||
# Returns language selection options
|
||||
def language_options
|
||||
locales = I18n.available_locales
|
||||
language_opts = [['<<<< ' + t("language_default") + ' >>>>', "default"]]
|
||||
locales.each do |locale|
|
||||
language_mapping = I18n::Language::Mapping.language_mapping_list[locale.to_s.gsub("_", "-")]
|
||||
language_opts.push([language_mapping["nativeName"], locale.to_s])
|
||||
end
|
||||
language_opts.sort
|
||||
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
|
||||
|
||||
def allow_greenlight_accounts?
|
||||
return Rails.configuration.allow_user_signup unless Rails.configuration.loadbalanced_configuration
|
||||
return false unless @user_domain && !@user_domain.empty? && Rails.configuration.allow_user_signup
|
||||
return false if @user_domain == "greenlight"
|
||||
# Proceed with retrieving the provider info
|
||||
begin
|
||||
provider_info = retrieve_provider_info(@user_domain, 'api2', 'getUserGreenlightCredentials')
|
||||
provider_info['provider'] == 'greenlight'
|
||||
rescue => e
|
||||
logger.info e
|
||||
false
|
||||
end
|
||||
# Determines if a form field needs the is-invalid class.
|
||||
def form_is_invalid?(obj, key)
|
||||
'is-invalid' unless obj.errors.messages[key].empty?
|
||||
end
|
||||
|
||||
# Return all the translations available in the client side through javascript
|
||||
@ -118,6 +62,13 @@ module ApplicationHelper
|
||||
current_user.main_room
|
||||
end
|
||||
|
||||
# Returns the action method of the current page
|
||||
def active_page
|
||||
route = Rails.application.routes.recognize_path(request.env['PATH_INFO'])
|
||||
|
||||
route[:action]
|
||||
end
|
||||
|
||||
def role_colour(role)
|
||||
role.colour || Rails.configuration.primary_color_default
|
||||
end
|
||||
|
Reference in New Issue
Block a user