bullet_train 1.6.24 → 1.6.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 708a366b5a3bdffa47379d99b19a3694541bf26c2040eacb762a4a67762e4bb0
4
- data.tar.gz: 0d615787ce778281522e6d7c13c1ce56c83938df41b8fb6472d78dee3f6304f3
3
+ metadata.gz: d3e2fd3aba6cf448d187f5e547da2a4805c2f4fca950c7404d4860fa0b3d9d2c
4
+ data.tar.gz: 5d36424ce555adb7799cddf0ec7dcc8f3c518d1816259011eb0ad3ec050da9fa
5
5
  SHA512:
6
- metadata.gz: 20abc5aa4f3ff18243f7a182e8cda7dd732660eccf3c2e927b28bb9c1b8a4f757d8159b93a73fa0696fa5d9d691e0d2089b4c5274d96edb464357cdc4f6c45de
7
- data.tar.gz: 0ecb17393d0c22c6b1700567571e12b08ed5675dc307267c8e3fe658d51b78fd30783675b1bfb3a1e6fb6b5040a17ed883c27d62e95532cbcb7ce3d31e58b66a
6
+ metadata.gz: 125b3a8f12808dbe1bef928909814ff82404d2a74e163e9995a305d1eb09e47efaaf5d08b26b26008daca30cad879bb0dc02f7eff2e5f3de7521703423097b8b
7
+ data.tar.gz: 63b2848fb196682e54184ad9fe7ed5955e0f0f0cc99044cdb7ff6b9bf2e2832cd35b6386e26e5a66213ba1ee632a1da714e67d097f4e7e7eddcaea57451549d1
@@ -1,13 +1,9 @@
1
1
  module Account::MarkdownHelper
2
2
  def markdown(string)
3
- if defined?(Commonmarker.to_html)
4
- Commonmarker.to_html(string, options: {
5
- extensions: {header_ids: true},
6
- plugins: {syntax_highlighter: {theme: "InspiredGitHub"}},
7
- render: {width: 120, unsafe: true}
8
- }).html_safe
9
- else
10
- CommonMarker.render_html(string, :UNSAFE, [:table]).html_safe
11
- end
3
+ Commonmarker.to_html(string, options: {
4
+ extensions: {header_ids: true},
5
+ plugins: {syntax_highlighter: {theme: "InspiredGitHub"}},
6
+ render: {width: 120, unsafe: true}
7
+ }).html_safe
12
8
  end
13
9
  end
@@ -30,7 +30,7 @@
30
30
  <div class="sm:col-span-2">
31
31
  <%= render 'shared/fields/super_select', form: f, method: :time_zone,
32
32
  choices: time_zone_options_for_select(@user.time_zone, nil, ActiveSupport::TimeZone),
33
- other_options: {search: true, required: true} %>
33
+ other_options: {search: true, required: true, use_browser_time_zone: true} %>
34
34
  </div>
35
35
  </div>
36
36
 
@@ -60,14 +60,18 @@
60
60
  // figure out the rails timezone value.
61
61
  var railsValue = jsTimezoneMapping[jstz.determine().name()];
62
62
 
63
- // set the form accordingly.
64
- var $option = $("#user_time_zone option[value=\"" + railsValue + "\"]")
65
- $option.prop('selected', true);
63
+ var useBrowserTimeZone = $("#user_time_zone")[0].dataset.useBrowserTimeZone
66
64
 
67
- // update the select2 as well. is there a better way to handle this?
68
- // why don't _they_ handle this for us?
69
- $("#select2-user_time_zone-container").attr('title', $option.text());
70
- $("#select2-user_time_zone-container").text($option.text());
65
+ if (useBrowserTimeZone == "true") {
66
+ // set the form accordingly.
67
+ var $option = $("#user_time_zone option[value=\"" + railsValue + "\"]")
68
+ $option.prop('selected', true);
69
+
70
+ // update the select2 as well. is there a better way to handle this?
71
+ // why don't _they_ handle this for us?
72
+ $("#select2-user_time_zone-container").attr('title', $option.text());
73
+ $("#select2-user_time_zone-container").text($option.text());
74
+ }
71
75
 
72
76
  });
73
77
  </script>
@@ -63,9 +63,9 @@ Don't forget to run `bundle install` and `rails restart`.
63
63
  You can get detailed information about using Super Scaffolding to generate different types of Action Models like so:
64
64
 
65
65
  ```
66
- bin/super-scaffold action-model:targets-many
67
- bin/super-scaffold action-model:targets-one
68
- bin/super-scaffold action-model:targets-one-parent
66
+ rails generate super_scaffold:action_model:targets_many
67
+ rails generate super_scaffold:action_model:targets_one
68
+ rails generate super_scaffold:action_model:targets_one_parent
69
69
  ```
70
70
 
71
71
  ## Basic Example
@@ -73,13 +73,13 @@ bin/super-scaffold action-model:targets-one-parent
73
73
  ### 1. Generate and scaffold an example `Project` model.
74
74
 
75
75
  ```
76
- bin/super-scaffold crud Project Team name:text_field
76
+ rails generate super_scaffold Project Team name:text_field
77
77
  ```
78
78
 
79
79
  ### 2. Generate and scaffold an archive action for projects.
80
80
 
81
81
  ```
82
- bin/super-scaffold action-model:targets-many Archive Project Team
82
+ rails generate super_scaffold:action_model:targets_many Archive Project Team
83
83
  ```
84
84
 
85
85
  ### 3. Implement the action logic.
@@ -61,6 +61,21 @@ Here is the same example, with search enabled:
61
61
  html_options: {multiple: true}, other_options: {search: true} %>
62
62
  </code></pre>
63
63
 
64
+ ## Overriding Browser Time Zone
65
+
66
+ When using super-select with Time Zone options, passing `use_browser_time_zone:
67
+ false` will override the automatic setting of the timezone value from the
68
+ browser.
69
+
70
+
71
+ Here is the an example setting the selected value to `@user.time_zone` which
72
+ will not be overridden by the browser time zone.
73
+
74
+ <pre><code><%= render 'shared/fields/super_select', form: f, method: :time_zone,
75
+ choices: time_zone_options_for_select(@user.time_zone, nil, ActiveSupport::TimeZone),
76
+ other_options: {search: true, required: true, use_browser_time_zone: false } %>
77
+ </code></pre>
78
+
64
79
  ## Accepting New Entries
65
80
 
66
81
  Here is an example allowing a new option to be entered by the user:
@@ -43,6 +43,14 @@ rails generate super_scaffold
43
43
  | `rails generate super_scaffold:join_model` | Scaffolds a join model (must have two existing models to join before scaffolding) |
44
44
  | `rails generate super_scaffold:oauth_provider` | Scaffolds logic to use OAuth2 with the provider of your choice |
45
45
 
46
+ The following commands are for use specifically with [Action Models](action-models).
47
+
48
+ | `rails generate` Command | Scaffolding Type |
49
+ |--------------------------|------------------|
50
+ | `rails generate super_scaffold:action_models:targets_many` | Generates an action that targets many records |
51
+ | `rails generate super_scaffold:action_models:targets_one` | Generates an action that targets one record |
52
+ | `rails generate super_scaffold:action_models:targets_one_parent` | Generates an action that targets the parent of the specified model |
53
+
46
54
  ## Examples
47
55
 
48
56
  ### 1. Basic CRUD Scaffolding
@@ -113,7 +113,7 @@ module BulletTrain
113
113
  package_name: nil,
114
114
  }
115
115
 
116
- result[:absolute_path] = file_path || class_path || locale_path || partial_path
116
+ result[:absolute_path] = file_path || class_path || locale_path || js_or_stylesheet_path || partial_path
117
117
 
118
118
  # If we get the partial resolver template itself, that means we couldn't find the file.
119
119
  if result[:absolute_path].match?("app/views/bullet_train/partial_resolver.html.erb") || result[:absolute_path].nil?
@@ -251,10 +251,47 @@ module BulletTrain
251
251
  nil
252
252
  end
253
253
 
254
+ # In this search, we prioritize files in local themes
255
+ # and then look in theme gems if nothing is found.
256
+ def js_or_stylesheet_path
257
+ file_name = @needle.split("/").last
258
+
259
+ # Prioritize the current theme and fall back to
260
+ # the default `light` theme if nothing is found locally.
261
+ puts "Searching under current theme: #{current_theme.blue}"
262
+
263
+ asset_globs = [
264
+ "*.js", # Include JavaScript files under the app's root directory.
265
+ "app/assets/javascript/**/*.#{current_theme}.js",
266
+ "app/assets/javascript/#{current_theme}/**/*.js",
267
+ "app/assets/stylesheets/**/*.#{current_theme}.css",
268
+ "app/assets/stylesheets/#{current_theme}/**/*.css",
269
+ ]
270
+
271
+ files = Dir.glob(asset_globs).reject { |file| file.match?("/builds/") }
272
+ absolute_file_path = files.find { |file| file.end_with?(file_name) }
273
+
274
+ if absolute_file_path
275
+ absolute_file_path
276
+ else
277
+ # Search for the file in its respective gem. Fall back to the `light` theme if no gem is available.
278
+ gem_path = [`bundle show bullet_train-themes-#{current_theme}`, `bundle show bullet_train-themes-light`].map(&:chomp).find(&:present?)
279
+ return nil unless gem_path
280
+
281
+ # At this point we can be more generic since we're inside the gem.
282
+ files = Dir.glob(["#{gem_path}/**/*.js", "#{gem_path}/**/*.css"])
283
+ files.find { |file| file.end_with?(file_name) }
284
+ end
285
+ end
286
+
254
287
  def ejected_theme?
255
- current_theme_symbol = File.read("#{Rails.root}/app/helpers/application_helper.rb").split("\n").find { |str| str.match?(/\s+:.*/) }
256
- current_theme = current_theme_symbol.delete(":").strip
257
288
  current_theme != "light" && Dir.exist?("#{Rails.root}/app/assets/stylesheets/#{current_theme}")
258
289
  end
290
+
291
+ def current_theme
292
+ msmn = Masamune::AbstractSyntaxTree.new(Rails.root.join("app/helpers/application_helper.rb").read)
293
+ current_theme_def = msmn.method_definitions.find { |node| node.token_value == "current_theme" }
294
+ msmn.symbols.find { |sym| sym.line_number == current_theme_def.line_number + 1 }.token_value
295
+ end
259
296
  end
260
297
  end
@@ -1,3 +1,3 @@
1
1
  module BulletTrain
2
- VERSION = "1.6.24"
2
+ VERSION = "1.6.26"
3
3
  end
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.6.24
4
+ version: 1.6.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-02 00:00:00.000000000 Z
11
+ date: 2024-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard
@@ -394,14 +394,14 @@ dependencies:
394
394
  requirements:
395
395
  - - ">="
396
396
  - !ruby/object:Gem::Version
397
- version: '0'
397
+ version: 1.0.0
398
398
  type: :runtime
399
399
  prerelease: false
400
400
  version_requirements: !ruby/object:Gem::Requirement
401
401
  requirements:
402
402
  - - ">="
403
403
  - !ruby/object:Gem::Version
404
- version: '0'
404
+ version: 1.0.0
405
405
  - !ruby/object:Gem::Dependency
406
406
  name: extended_email_reply_parser
407
407
  requirement: !ruby/object:Gem::Requirement