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_auth_manager/error_pages.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,
lib/j1_app/j1_site_manager/static_site.no-cross-origin.rb
Overview
Defined Under Namespace
Modules: DisqusHelpers, ErrorPages, FacebookHelpers, GithubHelpers, Helpers, PatreonHelpers, TwitterHelpers
Classes: AuthManager, Commands, ConfigError, SiteManager
Class Method Summary
collapse
Class Method Details
.active_providers ⇒ Object
116
117
118
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 116
def self.active_providers
auth_config['providers']['activated']
end
|
.auth? ⇒ Boolean
98
99
100
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 98
def self.auth?
!!auth_config['enabled']
end
|
.auth_config ⇒ Object
89
90
91
92
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 89
def self.auth_config
auth_settings['j1_auth']
end
|
.auth_config_data ⇒ Object
44
45
46
47
48
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 44
def self.auth_config_data
@auth ||= YAML.safe_load_file(auth_config_file)
rescue StandardError
{}
end
|
.auth_config_file ⇒ Object
39
40
41
42
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 39
def self.auth_config_file
File.join(J1App.project_path, '_data/modules/authentication.yml')
end
|
.auth_settings ⇒ Object
85
86
87
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 85
def self.auth_settings
auth_config_data.fetch('settings', {})
end
|
.conditions(arg) ⇒ Object
145
146
147
148
149
150
151
152
153
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 145
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
|
.default_provider ⇒ Object
120
121
122
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 120
def self.default_provider
auth_config['providers']['activated'][0]
end
|
.destination ⇒ Object
80
81
82
83
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 80
def self.destination
jekyll_config.fetch('destination', File.expand_path(J1App.project_path, '_site'))
end
|
.get_condition(arg) ⇒ Object
141
142
143
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 141
def self.get_condition(arg)
auth_config['provider']['condition']["#{arg}"]
end
|
.jekyll_config ⇒ Object
33
34
35
36
37
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 33
def self.jekyll_config
@config ||= YAML.safe_load_file(jekyll_config_file)
rescue StandardError
{}
end
|
.jekyll_config_file ⇒ Object
27
28
29
30
31
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 27
def self.jekyll_config_file
File.join(J1App.project_path, '_config.yml')
end
|
.middleware_data ⇒ Object
72
73
74
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 72
def self.middleware_data
private_data.fetch('middleware', {})
end
|
.oauth_data ⇒ Object
76
77
78
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 76
def self.oauth_data
middleware_data.fetch('oauth', {})
end
|
.permissions ⇒ Object
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 124
def self.permissions
permission_profile = {
:protected => [],
:private => []
}
active_providers = auth_config['providers']['activated']
active_providers.each { |p|
provider_permissions = auth_config['providers']["#{p}"]['permissions']
provider_permissions.each do |perm|
permission_profile[:"#{perm}"] << "#{p}"
end
}
permission_profile
end
|
.private_data ⇒ Object
66
67
68
69
70
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 66
def self.private_data
@private_data ||= YAML.safe_load_file(template_private_data_file)
rescue StandardError
{}
end
|
.project_path ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 5
def self.project_path
if ENV['J1_PROJECT_HOME'] != nil
ENV['J1_PROJECT_HOME']
elsif ARGV.grep(/config.ru/)[0] != nil
File.dirname(ARGV.grep(/config.ru/)[0])
else
File.join(Dir.pwd, "")
end
end
|
.public_content ⇒ Object
111
112
113
114
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 111
def self.public_content
public_content = auth_config['content']['public']
Regexp.new(public_content.join("|")) unless public_content.nil?
end
|
.site ⇒ Object
67
68
69
70
71
72
73
74
|
# File 'lib/j1_app.rb', line 67
def self.site
Rack::Builder.new do
use Rack::ShowExceptions use Rack::Deflater use J1App::AuthManager run J1App::SiteManager end
end
|
.ssl? ⇒ Boolean
102
103
104
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 102
def self.ssl?
!!auth_config['ssl']
end
|
.template_config ⇒ Object
55
56
57
58
59
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 55
def self.template_config
@template_config ||= YAML.safe_load_file(template_config_file)
rescue StandardError
{}
end
|
.template_config_file ⇒ Object
50
51
52
53
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 50
def self.template_config_file
File.join(J1App.project_path, '_data/j1_config.yml')
end
|
.template_private_data_file ⇒ Object
61
62
63
64
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 61
def self.template_private_data_file
File.join(J1App.project_path, '_data/private.yml')
end
|
.user_settings ⇒ Object
94
95
96
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 94
def self.user_settings
template_config.fetch('user', {})
end
|
.whitelist ⇒ Object
106
107
108
109
|
# File 'lib/j1_app/j1_auth_manager/config.rb', line 106
def self.whitelist
whitelist = auth_config['whitelist']
Regexp.new(whitelist.join("|")) unless whitelist.nil?
end
|