bullet_train 1.0.23 → 1.0.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/documentation_support.rb +8 -0
- data/app/controllers/concerns/invite_only_support.rb +19 -0
- data/app/controllers/concerns/root_redirect.rb +11 -0
- data/app/helpers/base_helper.rb +6 -0
- data/config/routes.rb +13 -0
- data/lib/bullet_train/version.rb +1 -1
- data/lib/bullet_train.rb +86 -1
- data/lib/colorizer.rb +67 -0
- data/lib/string/emoji.rb +10 -0
- metadata +7 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 736f0b129992c87c1813769d963aa769e8677b8aa34114e1271358ea6cb315f2
|
4
|
+
data.tar.gz: ba9c8955e07d738664793dbfc25adcf66c31d57008e9e3a8e93f1a850c307019
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19c0375970f7a2f3399f18cf5549c57a6d289bd7cf32f4f858b8aba06656ca37c6561ae9dcd2972691de1db0f41bcbfea0b3c419f2568682d4f4199a7703da8d
|
7
|
+
data.tar.gz: 50a5943e0e7c03197d5eb7b4e7c7cfd74011706c1ee8363bd5e6e82c4947fa929ebe7a773eae856385fa78ce9b3c5ffa963cfd08e0ee7ae94ceb98e7288688d1
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module InviteOnlySupport
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
def invitation
|
5
|
+
return not_found unless invitation_only?
|
6
|
+
return not_found unless params[:key].present?
|
7
|
+
return not_found unless invitation_keys.include?(params[:key])
|
8
|
+
session[:invitation_key] = params[:key]
|
9
|
+
if user_signed_in?
|
10
|
+
redirect_to new_account_team_path
|
11
|
+
else
|
12
|
+
redirect_to new_user_registration_path
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def not_found
|
17
|
+
render file: "#{Rails.root}/public/404.html", layout: false, status: :not_found
|
18
|
+
end
|
19
|
+
end
|
data/config/routes.rb
CHANGED
@@ -1,6 +1,19 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
+
scope module: "public" do
|
3
|
+
root to: "home#index"
|
4
|
+
get "invitation" => "home#invitation", :as => "invitation"
|
5
|
+
|
6
|
+
if Rails.env.production? ? ENV["ENABLE_DOCS"].present? : true
|
7
|
+
get "docs", to: "home#docs"
|
8
|
+
get "docs/*page", to: "home#docs"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
2
12
|
namespace :account do
|
3
13
|
shallow do
|
14
|
+
# TODO we need to either implement a dashboard or deprecate this.
|
15
|
+
root to: "dashboard#index", as: "dashboard"
|
16
|
+
|
4
17
|
resource :two_factor, only: [:create, :destroy]
|
5
18
|
|
6
19
|
# user-level onboarding tasks.
|
data/lib/bullet_train/version.rb
CHANGED
data/lib/bullet_train.rb
CHANGED
@@ -7,11 +7,13 @@ require "bullet_train/super_load_and_authorize_resource"
|
|
7
7
|
require "bullet_train/has_uuid"
|
8
8
|
require "bullet_train/scope_validator"
|
9
9
|
|
10
|
+
require "colorizer"
|
11
|
+
require "string/emoji"
|
12
|
+
|
10
13
|
require "devise"
|
11
14
|
# require "devise-two-factor"
|
12
15
|
# require "rqrcode"
|
13
16
|
require "cancancan"
|
14
|
-
require "doorkeeper"
|
15
17
|
require "possessive"
|
16
18
|
require "sidekiq"
|
17
19
|
require "fastimage"
|
@@ -33,3 +35,86 @@ module BulletTrain
|
|
33
35
|
mattr_accessor :routing_concerns, default: []
|
34
36
|
mattr_accessor :linked_gems, default: ["bullet_train"]
|
35
37
|
end
|
38
|
+
|
39
|
+
def default_url_options_from_base_url
|
40
|
+
unless ENV["BASE_URL"].present?
|
41
|
+
if Rails.env.development?
|
42
|
+
ENV["BASE_URL"] ||= "http://localhost:3000"
|
43
|
+
else
|
44
|
+
raise "you need to define the value of ENV['BASE_URL'] in your environment. if you're on heroku, you can do this with `heroku config:add BASE_URL=https://your-app-name.herokuapp.com` (or whatever your configured domain is)."
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
parsed_base_url = URI.parse(ENV["BASE_URL"])
|
49
|
+
default_url_options = [:user, :password, :host, :port].map { |key| [key, parsed_base_url.send(key)] }.to_h
|
50
|
+
|
51
|
+
# the name of this property doesn't match up.
|
52
|
+
default_url_options[:protocol] = parsed_base_url.scheme
|
53
|
+
|
54
|
+
default_url_options.compact
|
55
|
+
end
|
56
|
+
|
57
|
+
def inbound_email_enabled?
|
58
|
+
ENV["INBOUND_EMAIL_DOMAIN"].present?
|
59
|
+
end
|
60
|
+
|
61
|
+
def subscriptions_enabled?
|
62
|
+
false
|
63
|
+
end
|
64
|
+
|
65
|
+
def free_trial?
|
66
|
+
ENV["STRIPE_FREE_TRIAL_LENGTH"].present?
|
67
|
+
end
|
68
|
+
|
69
|
+
def stripe_enabled?
|
70
|
+
ENV["STRIPE_CLIENT_ID"].present?
|
71
|
+
end
|
72
|
+
|
73
|
+
# 🚅 super scaffolding will insert new oauth providers above this line.
|
74
|
+
|
75
|
+
def webhooks_enabled?
|
76
|
+
true
|
77
|
+
end
|
78
|
+
|
79
|
+
def scaffolding_things_disabled?
|
80
|
+
ENV["HIDE_THINGS"].present? || ENV["HIDE_EXAMPLES"].present?
|
81
|
+
end
|
82
|
+
|
83
|
+
def sample_role_disabled?
|
84
|
+
ENV["HIDE_EXAMPLES"].present?
|
85
|
+
end
|
86
|
+
|
87
|
+
def demo?
|
88
|
+
ENV["DEMO"].present?
|
89
|
+
end
|
90
|
+
|
91
|
+
def cloudinary_enabled?
|
92
|
+
ENV["CLOUDINARY_URL"].present?
|
93
|
+
end
|
94
|
+
|
95
|
+
def two_factor_authentication_enabled?
|
96
|
+
ENV["TWO_FACTOR_ENCRYPTION_KEY"].present?
|
97
|
+
end
|
98
|
+
|
99
|
+
def any_oauth_enabled?
|
100
|
+
[
|
101
|
+
stripe_enabled?,
|
102
|
+
# 🚅 super scaffolding will insert new oauth provider checks above this line.
|
103
|
+
].select(&:present?).any?
|
104
|
+
end
|
105
|
+
|
106
|
+
def invitation_only?
|
107
|
+
ENV["INVITATION_KEYS"].present?
|
108
|
+
end
|
109
|
+
|
110
|
+
def invitation_keys
|
111
|
+
ENV["INVITATION_KEYS"].split(",").map(&:strip)
|
112
|
+
end
|
113
|
+
|
114
|
+
def font_awesome?
|
115
|
+
ENV["FONTAWESOME_NPM_AUTH_TOKEN"].present?
|
116
|
+
end
|
117
|
+
|
118
|
+
def multiple_locales?
|
119
|
+
@multiple_locales ||= I18n.available_locales.many?
|
120
|
+
end
|
data/lib/colorizer.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# https://makandracards.com/makandra/24449-hash-any-ruby-object-into-an-rgb-color
|
2
|
+
module Colorizer
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def colorize(object)
|
6
|
+
# Inspired by Jeremy Ruten (http://stackoverflow.com/questions/1698318/ruby-generate-a-random-hex-color)
|
7
|
+
hash = object.hash # hash an object, returns a Fixnum
|
8
|
+
trimmed_hash = hash & 0xffffff # trim the hash to the size of 6 hex digits (& is bit-wise AND)
|
9
|
+
hex_code = "%06x" % trimmed_hash # format as at least 6 hex digits, pad with zeros
|
10
|
+
"##{hex_code}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def colorize_similarly(object, saturation, lightness)
|
14
|
+
rnd = ((object.hash * 7) % 100) * 0.01
|
15
|
+
hsl_to_rgb(rnd, saturation, lightness)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def hsl_to_rgb(h, sl, l)
|
21
|
+
r = l
|
22
|
+
g = l
|
23
|
+
b = l
|
24
|
+
v = l <= 0.5 ? (l * (1.0 + sl)) : (l + sl - l * sl)
|
25
|
+
if v > 0
|
26
|
+
m = l + l - v
|
27
|
+
sv = (v - m) / v
|
28
|
+
h *= 6.0
|
29
|
+
sextant = h.floor
|
30
|
+
fract = h - sextant
|
31
|
+
vsf = v * sv * fract
|
32
|
+
mid1 = m + vsf
|
33
|
+
mid2 = v - vsf
|
34
|
+
case sextant
|
35
|
+
when 0
|
36
|
+
r = v
|
37
|
+
g = mid1
|
38
|
+
b = m
|
39
|
+
when 1
|
40
|
+
r = mid2
|
41
|
+
g = v
|
42
|
+
b = m
|
43
|
+
when 2
|
44
|
+
r = m
|
45
|
+
g = v
|
46
|
+
b = mid1
|
47
|
+
when 3
|
48
|
+
r = m
|
49
|
+
g = mid2
|
50
|
+
b = v
|
51
|
+
when 4
|
52
|
+
r = mid1
|
53
|
+
g = m
|
54
|
+
b = v
|
55
|
+
when 5
|
56
|
+
r = v
|
57
|
+
g = m
|
58
|
+
b = mid2
|
59
|
+
end
|
60
|
+
end
|
61
|
+
"##{hex_color_component(r)}#{hex_color_component(g)}#{hex_color_component(b)}"
|
62
|
+
end
|
63
|
+
|
64
|
+
def hex_color_component(i)
|
65
|
+
(i * 255).floor.to_s(16).rjust(2, "0")
|
66
|
+
end
|
67
|
+
end
|
data/lib/string/emoji.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullet_train
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Culver
|
@@ -122,20 +122,6 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: doorkeeper
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :runtime
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: possessive
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -387,7 +373,10 @@ files:
|
|
387
373
|
- app/controllers/concerns/account/users/controller_base.rb
|
388
374
|
- app/controllers/concerns/controllers/base.rb
|
389
375
|
- app/controllers/concerns/devise_current_attributes.rb
|
376
|
+
- app/controllers/concerns/documentation_support.rb
|
377
|
+
- app/controllers/concerns/invite_only_support.rb
|
390
378
|
- app/controllers/concerns/registrations/controller_base.rb
|
379
|
+
- app/controllers/concerns/root_redirect.rb
|
391
380
|
- app/controllers/concerns/sessions/controller_base.rb
|
392
381
|
- app/controllers/registrations_controller.rb
|
393
382
|
- app/controllers/sessions_controller.rb
|
@@ -402,6 +391,7 @@ files:
|
|
402
391
|
- app/helpers/account/teams_helper.rb
|
403
392
|
- app/helpers/account/users_helper.rb
|
404
393
|
- app/helpers/attributes_helper.rb
|
394
|
+
- app/helpers/base_helper.rb
|
405
395
|
- app/helpers/email_helper.rb
|
406
396
|
- app/helpers/images_helper.rb
|
407
397
|
- app/helpers/invitation_only_helper.rb
|
@@ -522,6 +512,8 @@ files:
|
|
522
512
|
- lib/bullet_train.rb
|
523
513
|
- lib/bullet_train/engine.rb
|
524
514
|
- lib/bullet_train/version.rb
|
515
|
+
- lib/colorizer.rb
|
516
|
+
- lib/string/emoji.rb
|
525
517
|
- lib/tasks/bullet_train_tasks.rake
|
526
518
|
homepage: https://github.com/bullet-train-co/bullet_train
|
527
519
|
licenses:
|