Module: Clavis::ViewHelpers

Defined in:
lib/clavis/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#clavis_oauth_button(provider, options = {}) ⇒ String

Generates an OAuth button for the specified provider

Parameters:

  • provider (Symbol)

    The provider to generate a button for

  • options (Hash) (defaults to: {})

    Options for the button

Options Hash (options):

  • :text (String)

    Custom text for the button

  • :class (String)

    Custom CSS class for the button

  • :icon (String)

    Custom icon for the button

  • :icon_class (String)

    Custom CSS class for the icon

  • :method (String)

    HTTP method for the button (default: :get)

  • :html (Hash)

    HTML attributes for the button

Returns:

  • (String)

    HTML for the button



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/clavis/view_helpers.rb', line 16

def clavis_oauth_button(provider, options = {})
  provider = provider.to_sym

  # Default options
  options = {
    text: clavis_default_button_text(provider),
    class: clavis_default_button_class(provider),
    icon: clavis_default_button_icon(provider),
    icon_class: clavis_default_icon_class(provider),
    method: :get,
    html: {}
  }.merge(options)

  # More aggressive Turbo disabling - ensure it works in all environments
  options[:html] ||= {}
  options[:html]["data-turbo"] = "false"
  options[:html]["data-turbo-frame"] = "_top"
  options[:html]["rel"] = "nofollow"

  # Generate the button with a direct path to the auth endpoint
  clavis_link_to(
    clavis_oauth_button_content(provider, options),
    clavis_auth_authorize_path(provider),
    method: options[:method],
    class: options[:class],
    **options[:html]
  ).html_safe
end