bullet_train 1.2.27 → 1.3.1
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/account/controllers/base.rb +2 -0
- data/app/controllers/concerns/account/memberships/controller_base.rb +2 -1
- data/app/controllers/concerns/account/teams/controller_base.rb +1 -1
- data/app/controllers/concerns/sessions/controller_base.rb +35 -0
- data/app/controllers/sessions_controller.rb +0 -32
- data/app/helpers/account/dates_helper.rb +41 -24
- data/app/helpers/account/markdown_helper.rb +8 -1
- data/app/helpers/account/users_helper.rb +43 -24
- data/app/helpers/attributes_helper.rb +7 -22
- data/app/helpers/invitation_only_helper.rb +9 -1
- data/app/javascript/controllers/bulk_actions_controller.js +1 -0
- data/app/models/billing/mock_limiter.rb +1 -1
- data/app/models/concerns/memberships/base.rb +17 -0
- data/app/models/concerns/records/base.rb +3 -1
- data/app/models/concerns/teams/base.rb +4 -8
- data/app/models/concerns/users/base.rb +15 -1
- data/app/views/account/memberships/_index.html.erb +1 -1
- data/app/views/account/onboarding/user_details/edit.html.erb +1 -0
- data/app/views/account/users/_form.html.erb +6 -4
- data/app/views/devise/registrations/new.html.erb +1 -1
- data/app/views/layouts/docs.html.erb +15 -3
- data/app/views/layouts/public.html.erb +31 -0
- data/config/locales/en/base.yml +9 -0
- data/config/locales/en/memberships.en.yml +3 -0
- data/config/locales/en/users.en.yml +5 -0
- data/docs/application-hash.md +25 -0
- data/docs/billing/stripe.md +3 -3
- data/docs/billing/usage.md +7 -7
- data/docs/field-partials/buttons.md +4 -4
- data/docs/field-partials/date-related-fields.md +13 -0
- data/docs/field-partials/file-field.md +1 -2
- data/docs/field-partials/super-select.md +23 -4
- data/docs/field-partials.md +24 -11
- data/docs/font-awesome-pro.md +1 -1
- data/docs/index.md +9 -8
- data/docs/indirection.md +5 -1
- data/docs/overriding.md +1 -1
- data/docs/seeds.md +3 -3
- data/docs/super-scaffolding/delegated-types.md +27 -24
- data/docs/super-scaffolding/options.md +24 -0
- data/docs/super-scaffolding/sortable.md +1 -1
- data/docs/super-scaffolding.md +7 -6
- data/docs/testing.md +1 -1
- data/docs/themes.md +4 -4
- data/docs/tunneling.md +2 -2
- data/docs/upgrades.md +7 -7
- data/docs/zapier.md +1 -1
- data/lib/bullet_train/configuration.rb +9 -3
- data/lib/bullet_train/resolver.rb +11 -6
- data/lib/bullet_train/version.rb +1 -1
- data/lib/bullet_train.rb +13 -8
- data/lib/tasks/bullet_train_tasks.rake +30 -0
- metadata +25 -8
- data/README.md +0 -29
@@ -48,7 +48,7 @@ We use `entryable_type:buttons` because we're going to allow people to choose wh
|
|
48
48
|
|
49
49
|
Super Scaffolding will have generated some initial button options for us already in `config/locales/en/entries.en.yml`. We'll want to update the attribute `name`, field `label` (which is shown on the form) and the available options to reflect the available Concrete Children like so:
|
50
50
|
|
51
|
-
```
|
51
|
+
```yaml
|
52
52
|
fields: &fields
|
53
53
|
entryable_type:
|
54
54
|
name: &entryable_type Entry Type
|
@@ -61,7 +61,7 @@ fields: &fields
|
|
61
61
|
|
62
62
|
We will add this block below in the next step on our `new.html.erb` page so you don't have to worry about it now, but with the options above in place, our buttons partial will now allow your users to select either a `Message` or a `Comment` before creating the `Entry` itself:
|
63
63
|
|
64
|
-
```
|
64
|
+
```erb
|
65
65
|
<% with_field_settings form: form do %>
|
66
66
|
<%= render 'shared/fields/buttons', method: :entryable_type, html_options: {autofocus: true} %>
|
67
67
|
<%# 🚅 super scaffolding will insert new fields above this line. %>
|
@@ -69,7 +69,8 @@ We will add this block below in the next step on our `new.html.erb` page so you
|
|
69
69
|
```
|
70
70
|
|
71
71
|
This will produce the following HTML:
|
72
|
-
|
72
|
+
|
73
|
+
```html
|
73
74
|
<div>
|
74
75
|
<label class="btn-toggle" data-controller="fields--button-toggle">
|
75
76
|
<input data-fields--button-toggle-target="shadowField" type="radio" value="Message" name="entry[entryable_type]" id="entry_entryable_type_message">
|
@@ -91,7 +92,7 @@ This will produce the following HTML:
|
|
91
92
|
|
92
93
|
By default, `app/views/account/entries/new.html.erb` has this reference to the shared `_form.html.erb`:
|
93
94
|
|
94
|
-
```
|
95
|
+
```erb
|
95
96
|
<%= render 'form', entry: @entry %>
|
96
97
|
```
|
97
98
|
|
@@ -102,7 +103,7 @@ However, in this workflow we actually need two steps:
|
|
102
103
|
|
103
104
|
The first of these two forms is actually not shared between `new.html.erb` and `edit.html.erb`, so we'll copy the contents of `_form.html.erb` into `new.html.erb` as a starting point, like so:
|
104
105
|
|
105
|
-
```
|
106
|
+
```erb
|
106
107
|
<% if @entry.entryable_type %>
|
107
108
|
<%= render 'form', entry: @entry %>
|
108
109
|
<% else %>
|
@@ -131,14 +132,14 @@ Here's a summary of the updates required when copying `_form.html.erb` into `new
|
|
131
132
|
|
132
133
|
We need to add a locale entry for the "Next Step" button in `config/locales/en/entries.en.yml`. This goes under the `buttons: &buttons` entry that is already present, like so:
|
133
134
|
|
134
|
-
```
|
135
|
+
```yaml
|
135
136
|
buttons: &buttons
|
136
137
|
next: Next Step
|
137
138
|
```
|
138
139
|
|
139
140
|
Also, sadly, the original locale file wasn't expecting any buttons in `new.html.erb` directly, so we need to include buttons on the `new` page in the same file, below `form: *form`, like so:
|
140
141
|
|
141
|
-
```
|
142
|
+
```yaml
|
142
143
|
new:
|
143
144
|
# ...
|
144
145
|
form: *form
|
@@ -149,7 +150,7 @@ new:
|
|
149
150
|
|
150
151
|
In `app/models/entry.rb`, we want to replace the default validation of `entryable_type` like so:
|
151
152
|
|
152
|
-
```
|
153
|
+
```ruby
|
153
154
|
ENTRYABLE_TYPES = I18n.t('entries.fields.entryable_type.options').keys.map(&:to_s)
|
154
155
|
|
155
156
|
validates :entryable_type, inclusion: {
|
@@ -163,7 +164,7 @@ This makes the locale file, where we define the options to present to the user,
|
|
163
164
|
|
164
165
|
Also, to make it easy to check the state of this validation, we'll add `entryable_type_valid?` as well:
|
165
166
|
|
166
|
-
```
|
167
|
+
```ruby
|
167
168
|
def entryable_type_valid?
|
168
169
|
ENTRYABLE_TYPES.include?(entryable_type)
|
169
170
|
end
|
@@ -177,13 +178,13 @@ In preparation for the second step, we need to configure `Entry` to accept [nest
|
|
177
178
|
|
178
179
|
In `app/models/entry.rb`, like so:
|
179
180
|
|
180
|
-
```
|
181
|
+
```ruby
|
181
182
|
accepts_nested_attributes_for :entryable
|
182
183
|
```
|
183
184
|
|
184
185
|
Also in `app/models/entry.rb`, [Rails will be expecting us](https://stackoverflow.com/questions/45295202/cannot-build-nested-polymorphic-associations-are-you-trying-to-build-a-polymor) to define the following method on the model:
|
185
186
|
|
186
|
-
```
|
187
|
+
```ruby
|
187
188
|
def build_entryable(params = {})
|
188
189
|
raise 'invalid entryable type' unless entryable_type_valid?
|
189
190
|
self.entryable = entryable_type.constantize.new(params)
|
@@ -192,13 +193,13 @@ end
|
|
192
193
|
|
193
194
|
Finally, in the [strong parameters](https://edgeguides.rubyonrails.org/action_controller_overview.html#strong-parameters) of `app/controllers/account/entries_controller.rb`, _directly below_ this line:
|
194
195
|
|
195
|
-
```
|
196
|
+
```ruby
|
196
197
|
# 🚅 super scaffolding will insert new arrays above this line.
|
197
198
|
```
|
198
199
|
|
199
200
|
And still within the `permit` parameters, add:
|
200
201
|
|
201
|
-
```
|
202
|
+
```ruby
|
202
203
|
entryable_attributes: [
|
203
204
|
:id,
|
204
205
|
|
@@ -216,7 +217,7 @@ entryable_attributes: [
|
|
216
217
|
|
217
218
|
Before we can present the second step to users, we need to react to the user's input from the first step and initialize either a `Message` or `Comment` object and associate `@entry` with it. We do this in the `new` action of `app/controllers/account/entries_controller.rb` and we can also use the `build_entryable` method we created earlier for this purpose, like so:
|
218
219
|
|
219
|
-
```
|
220
|
+
```ruby
|
220
221
|
def new
|
221
222
|
if @entry.entryable_type_valid?
|
222
223
|
@entry.build_entryable
|
@@ -230,19 +231,19 @@ end
|
|
230
231
|
|
231
232
|
Since we're now prompting for the entry type on the first step, we can remove the following from the second step in `app/views/account/entries/_form.html.erb`:
|
232
233
|
|
233
|
-
```
|
234
|
+
```erb
|
234
235
|
<%= render 'shared/fields/buttons', method: :entryable_type, html_options: {autofocus: true} %>
|
235
236
|
```
|
236
237
|
|
237
238
|
But we need to keep track of which entry type they selected, so we replace it with:
|
238
239
|
|
239
|
-
```
|
240
|
+
```erb
|
240
241
|
<%= form.hidden_field :entryable_type %>
|
241
242
|
```
|
242
243
|
|
243
244
|
Also, below that (and below the Super Scaffolding hook), we want to add the `Message` and `Comment` fields as [nested forms](https://guides.rubyonrails.org/form_helpers.html#nested-forms) like so:
|
244
245
|
|
245
|
-
```
|
246
|
+
```erb
|
246
247
|
<%= form.fields_for :entryable, entry.entryable do |entryable_form| %>
|
247
248
|
<%= entryable_form.hidden_field :id %>
|
248
249
|
<% with_field_settings form: entryable_form do %>
|
@@ -262,7 +263,7 @@ We add this _below_ the Super Scaffolding hook because we want any additional fi
|
|
262
263
|
|
263
264
|
Add the following in `app/views/account/entries/show.html.erb` under the Super Scaffolding hook shown in the example code below:
|
264
265
|
|
265
|
-
```
|
266
|
+
```erb
|
266
267
|
<%# 🚅 super scaffolding will insert new fields above this line. %>
|
267
268
|
|
268
269
|
<% with_attribute_settings object: @entry.entryable, strategy: :label do %>
|
@@ -278,7 +279,8 @@ Add the following in `app/views/account/entries/show.html.erb` under the Super S
|
|
278
279
|
This will ensure the various different attributes of the Concrete Children are properly presented. However, the `label` strategy for these attribute partials depend on the locales for the individual Concrete Children being defined, so we need to create those files now, as well:
|
279
280
|
|
280
281
|
`config/locales/en/messages.en.yml`:
|
281
|
-
|
282
|
+
|
283
|
+
```yaml
|
282
284
|
en:
|
283
285
|
messages: &messages
|
284
286
|
fields:
|
@@ -295,7 +297,8 @@ en:
|
|
295
297
|
```
|
296
298
|
|
297
299
|
`config/locales/en/comments.en.yml`:
|
298
|
-
|
300
|
+
|
301
|
+
```yaml
|
299
302
|
en:
|
300
303
|
comments: &comments
|
301
304
|
fields:
|
@@ -323,19 +326,19 @@ So everything should now be working as expected, and here's the crazy thing: **W
|
|
323
326
|
|
324
327
|
To now incorporate delegated types as put forward in the original documentation, we want to remove this line in `app/models/entry.rb`:
|
325
328
|
|
326
|
-
```
|
329
|
+
```ruby
|
327
330
|
belongs_to :entryable, polymorphic: true
|
328
331
|
```
|
329
332
|
|
330
333
|
And replace it with:
|
331
334
|
|
332
|
-
```
|
335
|
+
```ruby
|
333
336
|
delegated_type :entryable, types: %w[ Message Comment ]
|
334
337
|
```
|
335
338
|
|
336
339
|
We also want to follow the other steps seen there, such as defining an `Entryable` concern in `app/models/concerns/entryable.rb`, like so:
|
337
340
|
|
338
|
-
```
|
341
|
+
```ruby
|
339
342
|
module Entryable
|
340
343
|
extend ActiveSupport::Concern
|
341
344
|
|
@@ -347,7 +350,7 @@ end
|
|
347
350
|
|
348
351
|
And including the `Entryable` concern in both `app/models/message.rb` and `app/models/comment.rb` like so:
|
349
352
|
|
350
|
-
```
|
353
|
+
```ruby
|
351
354
|
include Entryable
|
352
355
|
```
|
353
356
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Super Scaffolding Options
|
2
|
+
|
3
|
+
There are different flags you can pass to the Super Scaffolding command which gives you more flexibility over creating your model. Add the flag of your choice to **the end** of the command for the option to take effect.
|
4
|
+
```
|
5
|
+
bin/super-scaffold crud Project Team description:text_field --sortable
|
6
|
+
```
|
7
|
+
|
8
|
+
Most of these include skipping particular functionalities, so take a look at what's available here and pass the flag that applies to your use-case.
|
9
|
+
|
10
|
+
| Option | Description |
|
11
|
+
|--------|-------------|
|
12
|
+
| `--sortable` | [Details here](/docs/super-scaffolding/sortable.md) |
|
13
|
+
| `--namespace=customers` | [Details here](/docs/namespacing.md) |
|
14
|
+
| `--sidebar="ti-world"` | Pass the Themify icon or Font Awesome icon of your choice to automatically add it to the navbar* |
|
15
|
+
| `--only-index` | Only scaffold the index view for a model"` |
|
16
|
+
| `--skip-views` | |
|
17
|
+
| `--skip-form` | |
|
18
|
+
| `--skip-locales` | |
|
19
|
+
| `--skip-api` | |
|
20
|
+
| `--skip-model` | |
|
21
|
+
| `--skip-controller` | |
|
22
|
+
| `--skip-routes` | |
|
23
|
+
|
24
|
+
*This option is only available for top-level models, which are models that are direct children of the `Team` model.
|
@@ -5,7 +5,7 @@ When issuing a `bin/super-scaffold crud` command, you can pass the `--sortable`
|
|
5
5
|
```
|
6
6
|
# E.g. Pages belong to a Site and are sortable via drag-and-drop:
|
7
7
|
rails g model Page site:references name:string path:text
|
8
|
-
bin/super-scaffold crud Page Site,Team name:
|
8
|
+
bin/super-scaffold crud Page Site,Team name:text_field path:text_area --sortable
|
9
9
|
```
|
10
10
|
|
11
11
|
The `--sortable` option:
|
data/docs/super-scaffolding.md
CHANGED
@@ -130,7 +130,7 @@ bin/super-scaffold crud-field Project status:buttons
|
|
130
130
|
|
131
131
|
By default, Super Scaffolding configures the buttons as "One", "Two", and "Three", but in this example you can edit those options in the `fields` section of `config/locales/en/projects.en.yml`. For example, you could specify the following options:
|
132
132
|
|
133
|
-
```
|
133
|
+
```yaml
|
134
134
|
planned: Planned
|
135
135
|
started: Started
|
136
136
|
completed: Completed
|
@@ -138,7 +138,7 @@ completed: Completed
|
|
138
138
|
|
139
139
|
If you want new `Project` models to be set to `planned` by default, you can add that to the migration file that was generated before running it, like so:
|
140
140
|
|
141
|
-
```
|
141
|
+
```ruby
|
142
142
|
add_column :projects, :status, :string, default: "planned"
|
143
143
|
```
|
144
144
|
|
@@ -170,7 +170,7 @@ There are two important things to point out here:
|
|
170
170
|
|
171
171
|
Finally, Super Scaffolding will prompt you to edit `app/models/project.rb` and implement the required logic in the `valid_leads` method. This is a template method that will be used to both populate the select field on the `Project` form, but also enforce some important security concerns in this multi-tenant system. In this case, you can define it as:
|
172
172
|
|
173
|
-
```
|
173
|
+
```ruby
|
174
174
|
def valid_leads
|
175
175
|
team.memberships.current_and_invited
|
176
176
|
end
|
@@ -220,7 +220,7 @@ Just note that the suffix of the field is `_ids` plural, and this is an attribut
|
|
220
220
|
|
221
221
|
The `crud-field` step will ask you to define the logic for the `valid_tags` method in `app/models/project.rb`. You can define it like so:
|
222
222
|
|
223
|
-
```
|
223
|
+
```ruby
|
224
224
|
def valid_tags
|
225
225
|
team.projects_tags
|
226
226
|
end
|
@@ -245,10 +245,11 @@ Only the files associated with `Scaffolding::CompletelyConcrete::TangibleThing`
|
|
245
245
|
|
246
246
|
You won't want your end users seeing the Super Scaffolding templates in your environment, so you can disable their presentation by setting `HIDE_THINGS` in your environment. For example, you can add the following to `config/application.yml`:
|
247
247
|
|
248
|
-
```
|
248
|
+
```yaml
|
249
249
|
HIDE_THINGS: true
|
250
250
|
```
|
251
251
|
|
252
252
|
## Advanced Examples
|
253
|
+
- [Super Scaffolding Options](/docs/super-scaffolding/options.md)
|
253
254
|
- [Super Scaffolding with Delegated Types](/docs/super-scaffolding/delegated-types.md)
|
254
|
-
- [Super Scaffolding with the `--sortable` option](/docs/super-scaffolding/sortable.md)
|
255
|
+
- [Super Scaffolding with the `--sortable` option](/docs/super-scaffolding/sortable.md)
|
data/docs/testing.md
CHANGED
data/docs/themes.md
CHANGED
@@ -25,7 +25,7 @@ You can also pass an annotated path to a view after running `bin/resolve --inter
|
|
25
25
|
|
26
26
|
To use a theme component, simply include it from "within" `shared` like so:
|
27
27
|
|
28
|
-
```
|
28
|
+
```erb
|
29
29
|
<%= render 'shared/fields/text_field', method: :text_field_value %>
|
30
30
|
```
|
31
31
|
|
@@ -40,7 +40,7 @@ This small piece of indirection buys us an incredible amount of power in buildin
|
|
40
40
|
Your application will automatically be configured to use your new theme whenever you run the eject command. You can run the below command to re-install the standard light theme.
|
41
41
|
```
|
42
42
|
> rake bullet_train:themes:light:install
|
43
|
-
```
|
43
|
+
```
|
44
44
|
|
45
45
|
## Additional Guidance and Principles
|
46
46
|
|
@@ -56,7 +56,7 @@ On the other hand, if you decide to try to build a theme from the ground up, you
|
|
56
56
|
|
57
57
|
#### ❌ Don’t do this, even in theme partials:
|
58
58
|
|
59
|
-
```
|
59
|
+
```erb
|
60
60
|
<%= render "themes/light/box" do |p| %>
|
61
61
|
...
|
62
62
|
<% end %>
|
@@ -64,7 +64,7 @@ On the other hand, if you decide to try to build a theme from the ground up, you
|
|
64
64
|
|
65
65
|
#### ✅ Instead, always do this:
|
66
66
|
|
67
|
-
```
|
67
|
+
```erb
|
68
68
|
<%= render "shared/box" do |p| %>
|
69
69
|
...
|
70
70
|
<% end %>
|
data/docs/tunneling.md
CHANGED
@@ -4,7 +4,7 @@ Before your application can take advantage of features that depend on incoming w
|
|
4
4
|
|
5
5
|
## Use a Paid Plan
|
6
6
|
|
7
|
-
You should specifically sign up for a paid account. Although ngrok offers a free plan, their $
|
7
|
+
You should specifically sign up for a paid account. Although ngrok offers a free plan, their $8/year or $10/month [paid plan](https://ngrok.com/pricing) will allow you to reserve a custom subdomain for reuse each time you spin up your tunnel. This is a critical productivity improvement, because in practice you'll end up configuring your tunnel URL in a bunch of different places like `config/application.yml` but also in external systems like when you [configure payment providers to deliver webhooks to you](/docs/billing/stripe.md).
|
8
8
|
|
9
9
|
## Usage
|
10
10
|
|
@@ -18,7 +18,7 @@ ngrok http 3000 --subdomain=YOUR-SUBDOMAIN
|
|
18
18
|
|
19
19
|
Before your Rails application will accept connections on your tunnel hostname, you need to update `config/application.yml` with:
|
20
20
|
|
21
|
-
```
|
21
|
+
```yaml
|
22
22
|
BASE_URL: https://YOUR-SUBDOMAIN.ngrok.io
|
23
23
|
```
|
24
24
|
|
data/docs/upgrades.md
CHANGED
@@ -27,20 +27,20 @@ git clean -d -f
|
|
27
27
|
### 2. Fetch the latest and greatest from the Bullet Train repository.
|
28
28
|
|
29
29
|
```
|
30
|
-
git fetch
|
31
|
-
|
30
|
+
git fetch bullet-train
|
31
|
+
```
|
32
32
|
|
33
33
|
### 3. Create a new "upgrade" branch off of your main branch.
|
34
34
|
|
35
35
|
```
|
36
36
|
git checkout main
|
37
|
-
git checkout -b updating-
|
37
|
+
git checkout -b updating-bullet-train
|
38
38
|
```
|
39
39
|
|
40
40
|
### 4. Merge in the newest stuff from Bullet Train and resolve any merge conflicts.
|
41
41
|
|
42
42
|
```
|
43
|
-
git merge
|
43
|
+
git merge bullet-train/main
|
44
44
|
```
|
45
45
|
|
46
46
|
It's quite possible you'll get some merge conflicts at this point. No big deal! Just go through and resolve them like you would if you were integrating code from another developer on your team. We tend to comment our code heavily, but if you have any questions about the code you're trying to understand, let us know on Discord!
|
@@ -62,9 +62,9 @@ rails test:system
|
|
62
62
|
|
63
63
|
```
|
64
64
|
git checkout main
|
65
|
-
git merge updating-
|
65
|
+
git merge updating-bullet-train
|
66
66
|
git push origin main
|
67
|
-
git branch -d updating-
|
67
|
+
git branch -d updating-bullet-train
|
68
68
|
```
|
69
69
|
|
70
|
-
Alternatively, if you're using GitHub, you can push the `updating-
|
70
|
+
Alternatively, if you're using GitHub, you can push the `updating-bullet-train` branch up and create a PR from it and let your CI integration do it's thing and then merge in the PR and delete the branch there. (That's what we typically do.)
|
data/docs/zapier.md
CHANGED
@@ -4,7 +4,7 @@ Bullet Train provides out-of-the-box support for Zapier. New Bullet Train projec
|
|
4
4
|
## Background
|
5
5
|
Zapier was designed to take advantage of an application's existing [REST API](/docs/api.md), [outgoing webhook capabilities](/docs/webhooks/outgoing.md), and OAuth2 authorization workflows. Thankfully for us, Bullet Train provides the first two and pre-configures Doorkeeper to provide the latter. We also have a smooth OAuth2 connection workflow that accounts for the mismatch between user-based OAuth2 and team-based multitenancy.
|
6
6
|
|
7
|
-
##
|
7
|
+
## Prerequisites
|
8
8
|
- You must be developing in an environment with [tunneling enabled](/docs/tunneling.md).
|
9
9
|
|
10
10
|
## Getting Started in Development
|
@@ -1,15 +1,21 @@
|
|
1
1
|
module BulletTrain
|
2
2
|
class Configuration
|
3
|
+
include Singleton
|
3
4
|
attr_accessor :strong_passwords
|
4
5
|
|
5
|
-
|
6
|
+
@@config = nil
|
6
7
|
|
7
8
|
def initialize
|
8
|
-
|
9
|
+
@@config = self
|
10
|
+
|
11
|
+
# Default values
|
12
|
+
@strong_passwords = true
|
9
13
|
end
|
10
14
|
|
11
15
|
class << self
|
12
|
-
|
16
|
+
def strong_passwords
|
17
|
+
@@config&.strong_passwords
|
18
|
+
end
|
13
19
|
end
|
14
20
|
end
|
15
21
|
end
|
@@ -75,7 +75,7 @@ module BulletTrain
|
|
75
75
|
|
76
76
|
# TODO: Use TerminalCommands to open this file
|
77
77
|
open_command = `which open`.present? ? "open" : "xdg-open"
|
78
|
-
exec "#{open_command} #{
|
78
|
+
exec "#{open_command} #{source_file[:absolute_path]}"
|
79
79
|
end
|
80
80
|
else
|
81
81
|
puts "Couldn't resolve `#{@needle}`.".red
|
@@ -89,22 +89,27 @@ module BulletTrain
|
|
89
89
|
package_name: nil,
|
90
90
|
}
|
91
91
|
|
92
|
-
result[:absolute_path] = file_path || class_path ||
|
92
|
+
result[:absolute_path] = file_path || class_path || locale_path || partial_path
|
93
93
|
|
94
94
|
# If we get the partial resolver template itself, that means we couldn't find the file.
|
95
|
-
if result[:absolute_path].match?("app/views/bullet_train/partial_resolver.html.erb")
|
96
|
-
puts "We could not
|
95
|
+
if result[:absolute_path].match?("app/views/bullet_train/partial_resolver.html.erb") || result[:absolute_path].nil?
|
96
|
+
puts "We could not resolve the value you're looking for: #{@needle}".red
|
97
97
|
puts ""
|
98
|
-
puts "
|
98
|
+
puts "If you're looking for a partial, please try passing the partial string in either of the following two ways:"
|
99
99
|
puts "1. Without underscore and extention: ".blue + "bin/resolve shared/attributes/code"
|
100
100
|
puts "2. Literal path with package name: ".blue + "bin/resolve bullet_train-themes/app/views/themes/base/attributes/_code.html.erb"
|
101
101
|
puts ""
|
102
|
+
puts "If you're looking for a locale, the key might not be implemented yet."
|
103
|
+
puts "Try adding your own custom text for the key to your locale file and try again."
|
102
104
|
exit
|
103
105
|
end
|
104
106
|
|
105
107
|
if result[:absolute_path]
|
106
108
|
if result[:absolute_path].include?("/bullet_train")
|
107
|
-
|
109
|
+
# This Regular Expression covers gem versions like bullet_train-1.2.26,
|
110
|
+
# and hashed versions of branches on GitHub like bullet_train-core-b00a02bd513c.
|
111
|
+
gem_version_regex = /[a-z|\-._0-9]*/
|
112
|
+
regex = /#{"bullet_train-core#{gem_version_regex}" if result[:absolute_path].include?("bullet_train-core")}\/bullet_train#{gem_version_regex}.*/
|
108
113
|
base_path = result[:absolute_path].scan(regex).pop
|
109
114
|
|
110
115
|
# Try to calculate which package the file is from, and what it's path is within that project.
|
data/lib/bullet_train/version.rb
CHANGED
data/lib/bullet_train.rb
CHANGED
@@ -42,11 +42,8 @@ module BulletTrain
|
|
42
42
|
mattr_accessor :base_class, default: "ApplicationRecord"
|
43
43
|
|
44
44
|
def self.configure
|
45
|
-
|
46
|
-
|
47
|
-
else
|
48
|
-
BulletTrain::Configuration.default
|
49
|
-
end
|
45
|
+
config = BulletTrain::Configuration.instance
|
46
|
+
yield(config) if block_given?
|
50
47
|
end
|
51
48
|
end
|
52
49
|
|
@@ -82,7 +79,7 @@ def inbound_email_enabled?
|
|
82
79
|
end
|
83
80
|
|
84
81
|
def billing_enabled?
|
85
|
-
defined?(BulletTrain::Billing)
|
82
|
+
ENV["STRIPE_SECRET_KEY"].present? && defined?(BulletTrain::Billing)
|
86
83
|
end
|
87
84
|
|
88
85
|
# TODO This should be in an initializer or something.
|
@@ -104,12 +101,20 @@ def webhooks_enabled?
|
|
104
101
|
true
|
105
102
|
end
|
106
103
|
|
104
|
+
def hide_things?
|
105
|
+
ActiveModel::Type::Boolean.new.cast(ENV["HIDE_THINGS"])
|
106
|
+
end
|
107
|
+
|
108
|
+
def hide_examples?
|
109
|
+
ActiveModel::Type::Boolean.new.cast(ENV["HIDE_EXAMPLES"])
|
110
|
+
end
|
111
|
+
|
107
112
|
def scaffolding_things_disabled?
|
108
|
-
|
113
|
+
hide_things? || hide_examples?
|
109
114
|
end
|
110
115
|
|
111
116
|
def sample_role_disabled?
|
112
|
-
|
117
|
+
hide_examples?
|
113
118
|
end
|
114
119
|
|
115
120
|
def demo?
|
@@ -40,11 +40,14 @@ namespace :bullet_train do
|
|
40
40
|
puts "\nOK, paste what you've got for us and hit <Return>!\n".blue
|
41
41
|
|
42
42
|
input = $stdin.gets.strip
|
43
|
+
# we only resolve the first line of user input and ignore the rest
|
43
44
|
$stdin.getc while $stdin.ready?
|
44
45
|
|
45
46
|
# Extract absolute paths from annotated views.
|
46
47
|
if input =~ /<!-- BEGIN (.*) -->/
|
47
48
|
input = $1
|
49
|
+
elsif input =~ /<!-- END (.*) -->/
|
50
|
+
input = $1
|
48
51
|
end
|
49
52
|
|
50
53
|
# Append the main application's path if the file is a local file.
|
@@ -72,6 +75,33 @@ namespace :bullet_train do
|
|
72
75
|
end
|
73
76
|
end
|
74
77
|
|
78
|
+
desc "Eject files from the Bullet Train's core logic to your application."
|
79
|
+
task :eject, [:type] => :environment do |task, args|
|
80
|
+
if args[:type] == "locales"
|
81
|
+
gem_names = I18n.t("framework_packages").map { |key, value| key.to_s }
|
82
|
+
gem_names.each do |gem|
|
83
|
+
puts "Searching for locales in #{gem}...".blue
|
84
|
+
gem_path = `bundle show #{gem}`.chomp
|
85
|
+
locales = Dir.glob("#{gem_path}/**/config/locales/**/*.yml").reject { |path| path.match?("dummy") }
|
86
|
+
next if locales.empty?
|
87
|
+
|
88
|
+
puts "Found locales. Ejecting to your application...".green
|
89
|
+
locales.each do |locale|
|
90
|
+
relative_path = locale.split("/config/locales").pop
|
91
|
+
path_parts = relative_path.split("/")
|
92
|
+
base_path = path_parts.join("/")
|
93
|
+
FileUtils.mkdir_p("./config/locales#{base_path}") unless Dir.exist?("./config/locales#{base_path}")
|
94
|
+
|
95
|
+
unless File.exist?("config/locales#{relative_path}")
|
96
|
+
puts "Ejecting #{relative_path}..."
|
97
|
+
File.new("config/locales#{relative_path}", "w")
|
98
|
+
`cp #{locale} config/locales#{relative_path}`
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
75
105
|
task :hack, [:all_options] => :environment do |t, arguments|
|
76
106
|
def stream(command, prefix = " ")
|
77
107
|
puts ""
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullet_train
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Culver
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: image_processing
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: cancancan
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -481,7 +495,6 @@ extra_rdoc_files: []
|
|
481
495
|
files:
|
482
496
|
- ".bt-link"
|
483
497
|
- MIT-LICENSE
|
484
|
-
- README.md
|
485
498
|
- Rakefile
|
486
499
|
- app/assets/config/bullet_train_manifest.js
|
487
500
|
- app/controllers/account/invitations_controller.rb
|
@@ -609,6 +622,7 @@ files:
|
|
609
622
|
- app/views/layouts/devise.html.erb
|
610
623
|
- app/views/layouts/docs.html.erb
|
611
624
|
- app/views/layouts/mailer.html.erb
|
625
|
+
- app/views/layouts/public.html.erb
|
612
626
|
- app/views/public/home/docs.html.erb
|
613
627
|
- app/views/showcase/engine/_stylesheets.html.erb
|
614
628
|
- app/views/user_mailer/invited.html.erb
|
@@ -667,6 +681,7 @@ files:
|
|
667
681
|
- docs/action-models.md
|
668
682
|
- docs/api.md
|
669
683
|
- docs/api/versioning.md
|
684
|
+
- docs/application-hash.md
|
670
685
|
- docs/application-options.md
|
671
686
|
- docs/authentication.md
|
672
687
|
- docs/billing/stripe.md
|
@@ -674,6 +689,7 @@ files:
|
|
674
689
|
- docs/desktop.md
|
675
690
|
- docs/field-partials.md
|
676
691
|
- docs/field-partials/buttons.md
|
692
|
+
- docs/field-partials/date-related-fields.md
|
677
693
|
- docs/field-partials/file-field.md
|
678
694
|
- docs/field-partials/super-select.md
|
679
695
|
- docs/font-awesome-pro.md
|
@@ -692,6 +708,7 @@ files:
|
|
692
708
|
- docs/seeds.md
|
693
709
|
- docs/super-scaffolding.md
|
694
710
|
- docs/super-scaffolding/delegated-types.md
|
711
|
+
- docs/super-scaffolding/options.md
|
695
712
|
- docs/super-scaffolding/sortable.md
|
696
713
|
- docs/teams.md
|
697
714
|
- docs/testing.md
|
@@ -710,12 +727,12 @@ files:
|
|
710
727
|
- lib/bullet_train/version.rb
|
711
728
|
- lib/colorizer.rb
|
712
729
|
- lib/tasks/bullet_train_tasks.rake
|
713
|
-
homepage: https://github.com/bullet-train-co/bullet_train
|
730
|
+
homepage: https://github.com/bullet-train-co/bullet_train-core/tree/main/bullet_train
|
714
731
|
licenses:
|
715
732
|
- MIT
|
716
733
|
metadata:
|
717
|
-
homepage_uri: https://github.com/bullet-train-co/bullet_train
|
718
|
-
source_code_uri: https://github.com/bullet-train-co/bullet_train
|
734
|
+
homepage_uri: https://github.com/bullet-train-co/bullet_train-core/tree/main/bullet_train
|
735
|
+
source_code_uri: https://github.com/bullet-train-co/bullet_train-core/tree/main/bullet_train
|
719
736
|
post_install_message: |2
|
720
737
|
If you're upgrading `bullet_train-*` Ruby gems and you run into any new
|
721
738
|
issues, you should probably also pull in updates from the Bullet Train
|
@@ -737,7 +754,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
737
754
|
version: '0'
|
738
755
|
requirements: []
|
739
756
|
rubygems_version: 3.4.10
|
740
|
-
signing_key:
|
757
|
+
signing_key:
|
741
758
|
specification_version: 4
|
742
759
|
summary: Bullet Train
|
743
760
|
test_files: []
|