rails_base 0.52.0 → 0.53.1

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: 49a6f3f545c70a5045aab5964650918d5971ccd195465c99cfb31f5b52d8f35a
4
- data.tar.gz: 62e24a02559c26fec20198a64dae3c81d89c24980114f86877596ce220369a01
3
+ metadata.gz: d20109ef6d422bfe9f2d9ea381e0bae71bfd9cb9a3585554f97fb378baf00d50
4
+ data.tar.gz: '08666f477b07d62d5fffd6505785b12b643bc9164ccd1c038585f7d895fa78c7'
5
5
  SHA512:
6
- metadata.gz: 293b06679c6c80ec1e5d723063691520c65a0ce1b341e7ae82cbd6e91820915f26a2d1dd9bc96e7b730f16b8bebaa9723a323dbdeafb1ae4e907a7400c875fe6
7
- data.tar.gz: 469479e874c28b6c3658c040c44e8010d7f8790dcec873cf1fb954b26eff1210e2473cfc0388784e949400b0373a4d438c404ce346f2e10fe0932041d76972a9
6
+ metadata.gz: b67025f0a012ed6c7024671a048f74026f30b9870115f13f5c2ff047f1a5fed7e5b31e61c2074a8f193d5cdd8392465deaa816c6a651d9cfb6f2788de4bcfeb0
7
+ data.tar.gz: 3b44a97ffc9ebd160941fe29b517d1ab114b61250562a6a51d4cf72cb29702233b31b39c6aa550664527b1e78a787600549dba4c06e96c9b9c2feb2b838b30e3
@@ -11,7 +11,6 @@
11
11
  // about supported directives.
12
12
  //
13
13
  // = require rails-ujs
14
- // = require activestorage
15
14
  // = require turbolinks
16
15
  // = require_tree .
17
16
 
@@ -1,6 +1,6 @@
1
1
  module RailsBase::AppearanceHelper
2
- APPEARANCE_MODE_COOKIE = "_#{Rails.application.class.parent_name}_appearance_mode".gsub(' ', '-').downcase
3
- APPEARANCE_MODE_ACTUAL_COOKIE = "_#{Rails.application.class.parent_name}_appearance_actual_mode".gsub(' ', '-').downcase
2
+ APPEARANCE_MODE_COOKIE = "_#{RailsBase.app_name}_appearance_mode".gsub(' ', '-').downcase
3
+ APPEARANCE_MODE_ACTUAL_COOKIE = "_#{RailsBase.app_name}_appearance_actual_mode".gsub(' ', '-').downcase
4
4
  APPEARANCE_TEXT_CLASS = RailsBase::Configuration::Display::Text::APPEARANCE_TEXT_CLASS
5
5
 
6
6
  VIEWPORT_EXTRA_SMALL = 'xs'.freeze
@@ -1,6 +1,6 @@
1
1
  module RailsBase::ApplicationHelper
2
2
 
3
- TIMEZONE_OFFSET_COOKIE = "_#{Rails.application.class.parent_name}_timeoffset"
3
+ TIMEZONE_OFFSET_COOKIE = "_#{RailsBase.app_name}_timeoffset"
4
4
  TIMEZONE_SESSION_NAME = TIMEZONE_THREAD_NAME = :tz_info
5
5
 
6
6
  def browser
@@ -4,19 +4,19 @@ class RailsBase::EmailVerificationMailer < RailsBase::ApplicationMailer
4
4
  def email_verification(user:, url:)
5
5
  @user = user
6
6
  @sso_url_for_user = url
7
- mail(to: @user.email, subject: "Welcome to #{Rails.application.class.parent_name}")
7
+ mail(to: @user.email, subject: "Welcome to #{RailsBase.app_name}")
8
8
  end
9
9
 
10
10
  def forgot_password(user:, url:)
11
11
  @user = user
12
12
  @sso_url_for_user = url
13
- mail(to: @user.email, subject: "#{Rails.application.class.parent_name}: Forgot Password")
13
+ mail(to: @user.email, subject: "#{RailsBase.app_name}: Forgot Password")
14
14
  end
15
15
 
16
16
  def event(user:, event:, msg: nil)
17
17
  @user = user
18
18
  @event = event
19
19
  @msg = msg
20
- mail(to: @user.email, subject: "#{Rails.application.class.parent_name}: #{event}")
20
+ mail(to: @user.email, subject: "#{RailsBase.app_name}: #{event}")
21
21
  end
22
22
  end
@@ -4,13 +4,13 @@ class RailsBase::EventMailer < RailsBase::ApplicationMailer
4
4
  def send_sso(user:, message:)
5
5
  @user = user
6
6
  @message = message
7
- mail(to: user.email, subject: "#{Rails.application.class.parent_name}: SSO login", template_name: 'event')
7
+ mail(to: user.email, subject: "#{RailsBase.app_name}: SSO login", template_name: 'event')
8
8
  # event(user: user, event: 'SSO login', message: message)
9
9
  end
10
10
 
11
11
  def event(user:, event:, message:)
12
12
  @user = user
13
13
  @message = message
14
- mail(to: @user.email, subject: "#{Rails.application.class.parent_name}: #{event}", template_name: 'event')
14
+ mail(to: @user.email, subject: "#{RailsBase.app_name}: #{event}", template_name: 'event')
15
15
  end
16
16
  end
@@ -6,7 +6,7 @@ module RailsBase
6
6
  columns.each do |column|
7
7
  next unless [:datetime].include?(column.type)
8
8
 
9
- # This is actually pretty cool. If you set the thrad corectly, you can
9
+ # This is actually pretty cool. If you set the thread corectly, you can
10
10
  define_method("#{column.name}") do
11
11
  thread_tz = Thread.current[RailsBase::ApplicationController::TIMEZONE_THREAD_NAME]
12
12
  return super() if thread_tz.nil?
@@ -97,7 +97,7 @@ class ShortLivedData < RailsBase::ApplicationRecord
97
97
  # only update if count is valid and we can add things -- save db call
98
98
  return false unless used_count_valid?
99
99
 
100
- update_attributes(exclusive_use_count: exclusive_use_count + 1)
100
+ update(exclusive_use_count: exclusive_use_count + 1)
101
101
  end
102
102
 
103
103
  def invalid_reason
@@ -126,7 +126,7 @@ class ShortLivedData < RailsBase::ApplicationRecord
126
126
  end
127
127
 
128
128
  def user=(u)
129
- update_attributes(user_id: u.id)
129
+ update(user_id: u.id)
130
130
  u.id
131
131
  end
132
132
  end
data/app/models/user.rb CHANGED
@@ -50,7 +50,7 @@ class User < RailsBase::ApplicationRecord
50
50
  end
51
51
 
52
52
  define_method("admin_#{admin_method}!") do
53
- update_attributes!(admin: admin_method)
53
+ update!(admin: admin_method)
54
54
  end
55
55
 
56
56
  #### metods on the class
@@ -109,7 +109,7 @@ class User < RailsBase::ApplicationRecord
109
109
  return if last_known_timezone == tz_name
110
110
 
111
111
  Rails.logger.info { "#{id}: Setting tz_name: #{tz_name}" }
112
- update_attributes(last_known_timezone: tz_name, last_known_timezone_update: Time.now )
112
+ update(last_known_timezone: tz_name, last_known_timezone_update: Time.now )
113
113
  end
114
114
 
115
115
  def timezone
@@ -14,7 +14,7 @@ module RailsBase
14
14
 
15
15
  original_value = model_row.public_send(attribute)
16
16
  begin
17
- model_row.update_attributes!(attribute => sanitized_value)
17
+ model_row.update!(attribute => sanitized_value)
18
18
  rescue ActiveRecord::RecordInvalid => e
19
19
  context.fail!(message: "Failed to update [#{attribute}] with #{sanitized_value} on #{model}##{model_row.id}. #{e.message}")
20
20
  rescue StandardError
@@ -20,6 +20,7 @@
20
20
  <link href="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/css/bootstrap4-toggle.min.css" rel="stylesheet">
21
21
  <script src="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/js/bootstrap4-toggle.min.js"></script>
22
22
  <script src="https://unpkg.com/sticky-table-headers"></script>
23
+ <script src="https://kit.fontawesome.com/3b649de495.js" crossorigin="anonymous"></script>
23
24
 
24
25
  <%=
25
26
  if RailsBase.config.app.favicon_path
@@ -125,6 +126,34 @@
125
126
  </footer>
126
127
  <% end %>
127
128
  </div>
129
+
130
+ <% if RailsBase.appearance.back_to_top.enable? %>
131
+ <a id="rails-base-back-to-top" class="btn btn-light btn-lg back-to-top" role="button"><i class="fas fa-chevron-up"></i></a>
132
+ <script type="text/javascript">
133
+ $(document).ready(function(){
134
+ $(window).scroll(function () {
135
+ if ($(this).scrollTop() > 100) {
136
+ $('#rails-base-back-to-top').fadeIn();
137
+ } else {
138
+ $('#rails-base-back-to-top').fadeOut();
139
+ }
140
+ });
141
+ $('#rails-base-back-to-top').click(function () {
142
+ $('body,html').animate({
143
+ scrollTop: 0
144
+ }, 400);
145
+ });
146
+ });
147
+ </script>
148
+ <style type="text/css">
149
+ .back-to-top {
150
+ position: fixed;
151
+ bottom: 50px;
152
+ right: 25px;
153
+ display: none;
154
+ }
155
+ </style>
156
+ <% end %>
128
157
 
129
158
  <script>
130
159
  modify_layout();
@@ -168,7 +197,7 @@
168
197
 
169
198
  // Attempt to set timezone on every request
170
199
  set_cookie('<%= RailsBase::ApplicationController::TIMEZONE_OFFSET_COOKIE %>', new Date().getTimezoneOffset())
171
- });
200
+ });
172
201
  <% end %>
173
202
  <% if Rails.env == 'production' %>
174
203
  // Disable console logging
@@ -69,7 +69,7 @@
69
69
  <div class="col-md-10 offset-md-1 text-center">
70
70
  <div class="row">
71
71
  <div class="col-md-9">
72
- <%= f.submit "Sign Up for #{Rails.application.class.parent_name}", class: "btn btn_success btn-block #{submit_klass}" %>
72
+ <%= f.submit "Sign Up for #{RailsBase.app_name}", class: "btn btn_success btn-block #{submit_klass}" %>
73
73
  </div>
74
74
  <div class="col-md-3">
75
75
  <a class="btn btn_primary btn-block" href="<%=RailsBase.url_routes.new_user_session_path%>" role="button">Have an Account? Sign In</a>
@@ -7,7 +7,7 @@
7
7
  </br>
8
8
  </br>
9
9
  Best wishes,</br>
10
- <%= Rails.application.class.parent_name %> team
10
+ <%= RailsBase.app_name %> team
11
11
 
12
12
  </p>
13
13
  </br>
@@ -9,7 +9,7 @@
9
9
  </p>
10
10
  <% end %>
11
11
  <p>
12
- If this is in error please login to your account: <a href=<%= RailsBase::ApplicationMailer::CONTACT_URL %>> Login link for <%= Rails.application.class.parent_name %> </a>
12
+ If this is in error please login to your account: <a href=<%= RailsBase::ApplicationMailer::CONTACT_URL %>> Login link for <%= RailsBase.app_name %> </a>
13
13
  </p>
14
14
 
15
15
  </br>
@@ -8,3 +8,4 @@
8
8
  </div>
9
9
  </div>
10
10
  </div>
11
+
@@ -1,3 +1,4 @@
1
+ require 'singleton'
1
2
  require 'rails_base/configuration/admin'
2
3
  require 'rails_base/configuration/mfa'
3
4
  require 'rails_base/configuration/authentication'
@@ -13,6 +14,8 @@ require 'rails_base/configuration/active_job'
13
14
 
14
15
  module RailsBase
15
16
  class Config
17
+ include Singleton
18
+
16
19
  VARIABLES = {
17
20
  admin: nil,
18
21
  mfa: nil,
@@ -211,8 +211,6 @@ module RailsBase
211
211
  admin_page_filter.flatten!
212
212
  end
213
213
 
214
- private
215
-
216
214
  def convenience_methods
217
215
  # defines instance methods like
218
216
  # user.at_least_super?
@@ -16,27 +16,27 @@ module RailsBase
16
16
  },
17
17
  web_name_logged_in: {
18
18
  type: :string_proc,
19
- default: ->(user) { Rails.application.class.parent_name },
19
+ default: ->(user) { RailsBase.app_name },
20
20
  description: 'Name of the application when authenticated user is present. Name in the tab of the browser. Allows for dynamic tab names'
21
21
  },
22
22
  web_name_logged_out: {
23
23
  type: :string_proc,
24
- default: ->(*) { Rails.application.class.parent_name },
24
+ default: ->(*) { RailsBase.app_name },
25
25
  description: 'Name of the application when no authenticated user. Name in the tab of the browser. Allows for dynamic tab names'
26
26
  },
27
27
  web_title_logged_in: {
28
28
  type: :string_proc,
29
- default: ->(user) { Rails.application.class.parent_name },
29
+ default: ->(user) { RailsBase.app_name },
30
30
  description: 'Title in nav for the web when logged in. String or proc accepted. When proc, current user will be passed in.'
31
31
  },
32
32
  web_title_logged_out: {
33
33
  type: :string_proc,
34
- default: ->(*) { Rails.application.class.parent_name },
34
+ default: ->(*) { RailsBase.app_name },
35
35
  description: 'Title in nav for the web when logged in. String or proc accepted. When proc, current user will be passed in.'
36
36
  },
37
37
  communication_name: {
38
38
  type: :string_proc,
39
- default: ->(*) { Rails.application.class.parent_name },
39
+ default: ->(*) { RailsBase.app_name },
40
40
  description: 'Name used when communicating with users.'
41
41
  },
42
42
  favicon_path: {
@@ -1,18 +1,19 @@
1
1
  require 'rails_base/configuration/base'
2
- require 'rails_base/configuration/display/table_header'
3
- require 'rails_base/configuration/display/table_body'
2
+ require 'rails_base/configuration/display/back_to_top'
4
3
  require 'rails_base/configuration/display/background_color'
5
- require 'rails_base/configuration/display/navbar'
6
- require 'rails_base/configuration/display/text'
7
- require 'rails_base/configuration/display/footer'
4
+ require 'rails_base/configuration/display/btn_danger'
5
+ require 'rails_base/configuration/display/btn_dark'
6
+ require 'rails_base/configuration/display/btn_info'
7
+ require 'rails_base/configuration/display/btn_light'
8
8
  require 'rails_base/configuration/display/btn_primary'
9
9
  require 'rails_base/configuration/display/btn_secondary'
10
10
  require 'rails_base/configuration/display/btn_success'
11
- require 'rails_base/configuration/display/btn_danger'
12
11
  require 'rails_base/configuration/display/btn_warning'
13
- require 'rails_base/configuration/display/btn_info'
14
- require 'rails_base/configuration/display/btn_light'
15
- require 'rails_base/configuration/display/btn_dark'
12
+ require 'rails_base/configuration/display/footer'
13
+ require 'rails_base/configuration/display/navbar'
14
+ require 'rails_base/configuration/display/table_body'
15
+ require 'rails_base/configuration/display/table_header'
16
+ require 'rails_base/configuration/display/text'
16
17
 
17
18
  module RailsBase
18
19
  module Configuration
@@ -35,10 +36,11 @@ module RailsBase
35
36
  :navbar,
36
37
  :text,
37
38
  :footer,
39
+ :back_to_top,
38
40
 
39
41
  ] + BUTTONS
40
42
 
41
- SKIP_DOWNSTREAM_CLASSES = [:footer]
43
+ SKIP_DOWNSTREAM_CLASSES = [:footer, :back_to_top]
42
44
  DARK_MODE = :dark
43
45
  LIGHT_MODE = :light
44
46
  MATCH_OS = :match_os
@@ -83,7 +85,9 @@ module RailsBase
83
85
  @bg_color = Configuration::Display::BackgroundColor.new
84
86
  @navbar = Configuration::Display::Navbar.new
85
87
  @text = Configuration::Display::Text.new
88
+
86
89
  @footer = Configuration::Display::Footer.new
90
+ @back_to_top = Configuration::Display::BackTotop.new
87
91
 
88
92
  @btn_primary = Configuration::Display::BtnPrimary.new
89
93
  @btn_secondary = Configuration::Display::BtnSecondary.new
@@ -0,0 +1,20 @@
1
+ require 'rails_base/configuration/base'
2
+
3
+ module RailsBase
4
+ module Configuration
5
+ module Display
6
+ class BackTotop < Base
7
+
8
+ DEFAULT_VALUES = {
9
+ enable: {
10
+ type: :boolean,
11
+ default: true,
12
+ description: 'Enable Back to top icon on all pages',
13
+ },
14
+ }
15
+
16
+ attr_accessor *DEFAULT_VALUES.keys
17
+ end
18
+ end
19
+ end
20
+ end
@@ -12,7 +12,7 @@ module RailsBase
12
12
  'RailsBase::MfaAuthController' => [:mfa_code],
13
13
  'RailsBase::SecondaryAuthenticationController' => [:static, :after_email_login_session_new, :forgot_password],
14
14
  }
15
- DEFAULT_FOOTER_HTML = "© 2021 Year of the Rona: Bad Ass Rails Starter <a href='https://github.com/matt-taylor/' target='_blank'>@matt-taylor</a>"
15
+ DEFAULT_FOOTER_HTML = "© #{DateTime.now.year} Year of the Rona: Bad Ass Rails Starter built by <a href='https://github.com/matt-taylor/' target='_blank'>@matt-taylor</a>"
16
16
 
17
17
  DEFAULT_VALUES = {
18
18
  enable: {
@@ -1,18 +1,26 @@
1
1
  module RailsBase
2
2
  class Engine < ::Rails::Engine
3
3
  isolate_namespace RailsBase
4
+ ActiveSupport::Reloader.to_prepare do
5
+ if RailsBase.___execute_initializer___?
6
+ RailsBase.config.admin.convenience_methods
7
+
8
+ RailsBase::ApplicationRecord.descendants.each do |model|
9
+ model._magically_defined_time_objects
10
+ end
11
+ end
12
+ end
4
13
 
5
14
  initializer 'instantiate RailsBase configs' do |_app|
6
- RailsBase.config if ___execute_initializer___?
15
+ RailsBase.config if RailsBase.___execute_initializer___?
7
16
  end
8
17
 
9
18
  initializer 'remove write access to RailsBase config', after: 'after_initialize' do |app|
10
- RailsBase::Configuration::Base._unset_allow_write! if ___execute_initializer___?
19
+ RailsBase::Configuration::Base._unset_allow_write! if RailsBase.___execute_initializer___?
11
20
  end
12
21
 
13
22
  initializer 'define magic convenionce methods for converting team', after: 'active_record.initialize_database' do |app|
14
- if ___execute_initializer___?
15
- raise
23
+ if RailsBase.___execute_initializer___?
16
24
  # need to eager load Models
17
25
  Rails.application.eager_load!
18
26
 
@@ -39,13 +47,6 @@ module RailsBase
39
47
  end
40
48
  end
41
49
 
42
- def ___execute_initializer___?
43
- # Only execute when not doing DB actions
44
- boolean = defined?(ARGV) ? true : false # for when no ARGVs are provided, we know its a railsc or rails s explicit
45
- boolean = false if boolean && ARGV[0]&.include?('db') # when its the DB rake tasks
46
- boolean = false if boolean && ARGV[0]&.include?('asset') # when its an asset
47
- boolean = false if boolean && ARGV[0]&.include?(':') # else this delim should never be included
48
- boolean = false if ENV['SKIP_CUSTOM_INIT']=='true' # explicitly set the variable to skip shit
49
- end
50
+
50
51
  end
51
52
  end
@@ -1,7 +1,7 @@
1
1
  module RailsBase
2
2
  MAJOR = '0'
3
- MINOR = '52'
4
- PATCH = '0'
3
+ MINOR = '53'
4
+ PATCH = '1'
5
5
  VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}"
6
6
 
7
7
  def self.print_version
data/lib/rails_base.rb CHANGED
@@ -17,10 +17,31 @@ require 'rails_base/admin/action_cache'
17
17
  require 'rails_base/config'
18
18
 
19
19
  module RailsBase
20
+
21
+ # Rails 6 does not play nice with this function -- Find a different work around
22
+ def self.___execute_initializer___?
23
+ # Only execute when not doing DB actions
24
+ boolean = defined?(ARGV) ? true : false # for when no ARGVs are provided, we know its a railsc or rails s explicit
25
+ boolean = false if boolean && ARGV[0]&.include?('db') # when its the DB rake tasks
26
+ boolean = false if boolean && ARGV[0]&.include?('asset') # when its an asset
27
+ boolean = false if boolean && ARGV[0]&.include?(':') # else this delim should never be included
28
+ boolean = false if ENV['SKIP_CUSTOM_INIT']=='true' # explicitly set the variable to skip shit
29
+
30
+ boolean
31
+ end
32
+
20
33
  def self.url_routes
21
34
  Rails.application.routes.url_helpers
22
35
  end
23
36
 
37
+ def self.app_name
38
+ if ::Rails::VERSION::MAJOR >= 6
39
+ ::Rails.application.class.module_parent_name
40
+ else
41
+ ::Rails.application.class.parent_name
42
+ end
43
+ end
44
+
24
45
  def self.route_exist?(path)
25
46
  Rails.application.routes.recognize_path(path)
26
47
  true
@@ -35,7 +56,7 @@ module RailsBase
35
56
  end
36
57
 
37
58
  def self.config
38
- @config ||= RailsBase::Config.new
59
+ @config ||= RailsBase::Config.instance
39
60
  end
40
61
 
41
62
  def self.appearance
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_base
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.52.0
4
+ version: 0.53.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Taylor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-02 00:00:00.000000000 Z
11
+ date: 2021-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -409,7 +409,6 @@ files:
409
409
  - app/assets/images/rails_base/favicon.ico
410
410
  - app/assets/javascripts/rails_base/admin.js
411
411
  - app/assets/javascripts/rails_base/application.js
412
- - app/assets/javascripts/rails_base/cable.js
413
412
  - app/assets/javascripts/rails_base/mfa_auth.coffee
414
413
  - app/assets/javascripts/rails_base/secondary_authentication.coffee
415
414
  - app/assets/javascripts/rails_base/sessions.js
@@ -568,6 +567,7 @@ files:
568
567
  - lib/rails_base/configuration/appearance.rb
569
568
  - lib/rails_base/configuration/authentication.rb
570
569
  - lib/rails_base/configuration/base.rb
570
+ - lib/rails_base/configuration/display/back_to_top.rb
571
571
  - lib/rails_base/configuration/display/background_color.rb
572
572
  - lib/rails_base/configuration/display/btn_danger.rb
573
573
  - lib/rails_base/configuration/display/btn_dark.rb
@@ -613,7 +613,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
613
613
  - !ruby/object:Gem::Version
614
614
  version: '0'
615
615
  requirements: []
616
- rubygems_version: 3.2.15
616
+ rubygems_version: 3.2.22
617
617
  signing_key:
618
618
  specification_version: 4
619
619
  summary: Rails engine that takes care of the stuff you dont want to!
@@ -1,13 +0,0 @@
1
- // Action Cable provides the framework to deal with WebSockets in Rails.
2
- // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3
- //
4
- //= require action_cable
5
- //= require_self
6
- //= require_tree ./channels
7
-
8
- (function() {
9
- this.App || (this.App = {});
10
-
11
- App.cable = ActionCable.createConsumer();
12
-
13
- }).call(this);