Module: J1App

Defined in:
lib/j1_app.rb,
lib/j1_app/j1_auth_manager/config.rb,
lib/j1_app/j1_auth_manager/helpers.rb,
lib/j1_app/j1_auth_manager/commands.rb,
lib/j1_app/j1_site_manager/static_site.rb,
lib/j1_app/j1_auth_manager/auth_manager.rb,
lib/j1_app/j1_auth_manager/helpers_disqus.rb,
lib/j1_app/j1_auth_manager/helpers_github.rb,
lib/j1_app/j1_auth_manager/helpers_patreon.rb,
lib/j1_app/j1_auth_manager/helpers_twitter.rb,
lib/j1_app/j1_auth_manager/helpers_facebook.rb

Overview


~/lib/j1_app/j1_auth_manager/omniauth/strategies/helpers_facebook.rb

Provides helper methods for the facebook omniauth strategy

Product/Info: jekyll.one

Copyright © 2019 Juergen Adams

J1 Template is licensed under the MIT License See: github.com/jekyll-one-org/j1_template/blob/master/LICENSE


NOTES


Defined Under Namespace

Modules: DisqusHelpers, FacebookHelpers, GithubHelpers, Helpers, PatreonHelpers, TwitterHelpers Classes: AuthManager, Commands, ConfigError, SiteManager

Class Method Summary collapse

Class Method Details

.active_providersObject



53
54
55
# File 'lib/j1_app/j1_auth_manager/config.rb', line 53

def self.active_providers
  auth_config['providers']['activated']
end

.auth?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/j1_app/j1_auth_manager/config.rb', line 35

def self.auth?
  !!auth_config['enabled']
end

.auth_configObject



28
29
30
# File 'lib/j1_app/j1_auth_manager/config.rb', line 28

def self.auth_config
  jekyll_config.fetch('j1_auth', {})
end

.conditions(arg) ⇒ Object



82
83
84
85
86
87
88
89
90
# File 'lib/j1_app/j1_auth_manager/config.rb', line 82

def self.conditions (arg)
  condition_profile = {}
  provider = arg
  provider_conditions = auth_config['providers']["#{provider}"]['conditions']
  provider_conditions.each do |key, value|
    condition_profile[key] = value
  end
  condition_profile
end

.config_fileObject



3
4
5
6
# File 'lib/j1_app/j1_auth_manager/config.rb', line 3

def self.config_file
  File.join(Dir.pwd, '_config.yml')
  # File.join(Dir.pwd, "_config.develop.yml")
end

.default_providerObject



57
58
59
# File 'lib/j1_app/j1_auth_manager/config.rb', line 57

def self.default_provider
  auth_config['providers']['activated'][0]
end

.destinationObject



24
25
26
# File 'lib/j1_app/j1_auth_manager/config.rb', line 24

def self.destination
  jekyll_config.fetch('destination', File.expand_path('_site', Dir.pwd))
end

.get_condition(arg) ⇒ Object



78
79
80
# File 'lib/j1_app/j1_auth_manager/config.rb', line 78

def self.get_condition(arg)
  auth_config['provider']['condition']["#{arg}"]
end

.jekyll_configObject



8
9
10
11
12
# File 'lib/j1_app/j1_auth_manager/config.rb', line 8

def self.jekyll_config
  @config ||= YAML.safe_load_file(config_file)
rescue StandardError
  {}
end

.permissionsObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/j1_app/j1_auth_manager/config.rb', line 61

def self.permissions
  permission_profile = {
      :protected   => [],
      :private   => []
  }

  active_providers = auth_config['providers']['activated']

  for p in active_providers do
    provider_permissions = auth_config['providers']["#{p}"]['permissions']
    provider_permissions.each do |perm|
      permission_profile[:"#{perm}"] << "#{p}"
    end
  end
  permission_profile
end

.public_contentObject



48
49
50
51
# File 'lib/j1_app/j1_auth_manager/config.rb', line 48

def self.public_content
  public_content = auth_config['content']['public']
  Regexp.new(public_content.join("|")) unless public_content.nil?
end

.siteObject



58
59
60
61
62
63
64
65
# File 'lib/j1_app.rb', line 58

def self.site
  Rack::Builder.new do
    use Rack::ShowExceptions                                                  # Middleware. Generate web-based error pages (for Rack)
    use Rack::Deflater                                                        # Middleware. Enable gzip compression for ALL web servers out of Rack
    use J1App::AuthManager                                                    # Middleware. Support authentication methods using OmniAuth      
    run J1App::SiteManager                                                    # Run J1App Manager to manage the (static) site as an (Rack-based) Web Application:
  end
end

.ssl?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/j1_app/j1_auth_manager/config.rb', line 39

def self.ssl?
  !!auth_config['ssl']
end

.template_configObject



18
19
20
21
22
# File 'lib/j1_app/j1_auth_manager/config.rb', line 18

def self.template_config
  @template_config ||= YAML.safe_load_file(template_config_file)
rescue StandardError
  {}
end

.template_config_fileObject



14
15
16
# File 'lib/j1_app/j1_auth_manager/config.rb', line 14

def self.template_config_file
  File.join(Dir.pwd, '_data/template_settings.yml')
end

.user_settingsObject



32
33
34
# File 'lib/j1_app/j1_auth_manager/config.rb', line 32

def self.
  template_config.fetch('user', {})
end

.whitelistObject



43
44
45
46
# File 'lib/j1_app/j1_auth_manager/config.rb', line 43

def self.whitelist
  whitelist = auth_config['whitelist']
  Regexp.new(whitelist.join("|")) unless whitelist.nil?
end