Module: Decidim::OmniauthHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/decidim/omniauth_helper.rb
Overview
Helper that provides methods to enable or disable omniauth buttons
Instance Method Summary collapse
-
#normalize_provider_name(provider) ⇒ Object
Public: normalize providers names to they can be used for buttons and icons.
-
#oauth_icon(provider) ⇒ Object
Public: icon for omniauth buttons.
-
#provider_name(provider) ⇒ Object
Public: pretty print provider name.
Instance Method Details
#normalize_provider_name(provider) ⇒ Object
Public: normalize providers names to they can be used for buttons and icons.
8 9 10 11 12 |
# File 'app/helpers/decidim/omniauth_helper.rb', line 8 def normalize_provider_name(provider) return "x" if provider == :twitter provider.to_s.split("_").first end |
#oauth_icon(provider) ⇒ Object
Public: icon for omniauth buttons
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/helpers/decidim/omniauth_helper.rb', line 15 def oauth_icon(provider) info = current_organization.enabled_omniauth_providers[provider.to_sym] name = normalize_provider_name(provider) name = "twitter-x" if provider == :twitter name = "#{name}-fill" if info icon_path = info[:icon_path] return external_icon(icon_path) if icon_path name = info[:icon] if info[:icon] end icon(name) end |
#provider_name(provider) ⇒ Object
Public: pretty print provider name
33 34 35 |
# File 'app/helpers/decidim/omniauth_helper.rb', line 33 def provider_name(provider) provider.to_s.gsub(/_|-/, " ").camelize end |