rhino_project_core 0.25.0.beta.16 → 0.30.0.alpha.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: '089e1dbd80df2979c8b07724ff6fdb32716d7d6be4f3eebedfb1e18c69952610'
4
- data.tar.gz: 84bdac04576b5e2dc6cc2c198356526e17f6e4801af8abe31f9b31754699494b
3
+ metadata.gz: '09bab6f8b81658c76669317d949e44e1e0728d7be46cb80793fa2488ffcff097'
4
+ data.tar.gz: 571b132824ac728b7e8072095a106c9731350abe88ce69d74b46852fe3ada36f
5
5
  SHA512:
6
- metadata.gz: 7270b4f2a2e105178ab7913d0e9501bbcea8a7867edfdd71ef42d7b9fcf706b3ce1a8faafd3b102a9a7fe294924c3ed7e488ac4f865dd825cfe3d46256540a64
7
- data.tar.gz: 59ba86a48867cbd4b6c66769fd8971bb670b68a3bc608ac154cf1f9d51df88401a274bc7a2f16f26465d9fa3fa8e826728a21ca26621550355a965c9ac30ff85
6
+ metadata.gz: 134e615ee50fbfe6de3f37a04a633dc82b89cdcae1d7c2e881b2000f759bdabae4ff22d2e0912d9d642660ee4ff323238b2d134c4644552082dc2d05e252e896
7
+ data.tar.gz: 975781708959682419d2f40637cf1833dc316f05d353d12422de0074a1a541f63db49f06d7de18e084ecaaaad3460604df9ccaf929ba5ad1e6050b155e176e18
@@ -5,10 +5,12 @@ module Rhino
5
5
  module_function
6
6
 
7
7
  def strategies_metadata
8
+ params = { resource_class: "User" }
9
+
8
10
  strategies.each_with_object([]) do |strategy, array|
9
11
  array << {
10
12
  name: strategy,
11
- path: "#{::OmniAuth.config.path_prefix}/#{strategy}"
13
+ path: "#{::OmniAuth.config.path_prefix}/#{strategy}?#{params.to_param}"
12
14
  }
13
15
  end
14
16
  end
@@ -21,6 +23,8 @@ module Rhino
21
23
  match[1].downcase.to_sym
22
24
  end.uniq
23
25
 
26
+ strategies += [:developer] if Rails.env.development? && !Rake.try(:application)
27
+
24
28
  strategies
25
29
  end
26
30
 
@@ -5,7 +5,7 @@ module DeviseTokenAuth::ConfirmationsController::Extensions
5
5
  def show
6
6
  super
7
7
  rescue StandardError
8
- redirect_to ENV["RHINO_APP_URL"]
8
+ redirect_to ENV["FRONT_END_URL"]
9
9
  end
10
10
  end
11
11
 
@@ -4,6 +4,6 @@ class DeviseTokenAuth::PasswordsController
4
4
  # If there is an error preparing to edit the password, redirect to frontend
5
5
  # This would normally be an expired password token
6
6
  def render_edit_error
7
- redirect_to "#{ENV['RHINO_APP_URL']}/auth/reset-password/expired"
7
+ redirect_to "#{ENV['FRONT_END_URL']}/auth/reset-password/expired"
8
8
  end
9
9
  end
@@ -15,6 +15,8 @@ module Rhino
15
15
  class_option :db_port, type: :numeric, default: 5432, group: :database
16
16
  class_option :db_user, type: :string, group: :database
17
17
  class_option :db_password, type: :string, group: :database
18
+ class_option :redis_port, type: :numeric, default: 6379, group: :redis
19
+ class_option :redis_database, type: :numeric, default: 0, group: :redis
18
20
 
19
21
  attr_reader :server_port,
20
22
  :db_name,
@@ -22,6 +24,9 @@ module Rhino
22
24
  :db_port,
23
25
  :db_user,
24
26
  :db_password,
27
+ :redis_host,
28
+ :redis_port,
29
+ :redis_database,
25
30
  :dockerized
26
31
 
27
32
  source_root File.expand_path("templates", __dir__)
@@ -87,6 +92,18 @@ module Rhino
87
92
  options[:db_password] || ENV["DB_PASSWORD"] || ""
88
93
  end
89
94
 
95
+ def redis_host_default
96
+ options[:redis_host] || ENV["REDIS_HOST"] || "localhost"
97
+ end
98
+
99
+ def redis_port_default
100
+ options[:redis_port] || ENV["REDIS_PORT"]
101
+ end
102
+
103
+ def redis_database_default
104
+ options[:redis_database] || ENV["REDIS_DATABASE"]
105
+ end
106
+
90
107
  def dockerized_default
91
108
  options[:defaults] == "docker" ? "Y" : "N"
92
109
  end
@@ -97,6 +114,7 @@ module Rhino
97
114
  @server_port = ask_prompt("Port?", server_port_default)
98
115
 
99
116
  collect_database_info
117
+ collect_redis_info
100
118
  end
101
119
 
102
120
  def collect_docker_info
@@ -108,6 +126,9 @@ module Rhino
108
126
  @db_user = "postgres"
109
127
  @db_password = "password"
110
128
  @db_port = 5432
129
+ @redis_host = "redis"
130
+ @redis_port = 6379
131
+ @redis_database = 0
111
132
 
112
133
  puts <<~HERE
113
134
  The following docker configuration has been automatically set for you:
@@ -115,6 +136,9 @@ module Rhino
115
136
  Database port: #{db_port}
116
137
  Database user: #{db_user}
117
138
  Database password: #{db_password}
139
+ Redis host: #{redis_host}
140
+ Redis port: #{redis_port}
141
+ Redis database: #{redis_database}
118
142
  HERE
119
143
  end
120
144
 
@@ -128,6 +152,14 @@ module Rhino
128
152
  nil
129
153
  end
130
154
 
155
+ def collect_redis_info
156
+ @redis_host ||= ask_prompt("Redis host?", redis_host_default)
157
+ @redis_port ||= ask_prompt("Redis port?", redis_port_default)
158
+ @redis_database ||= ask_prompt("Redis database?", redis_database_default)
159
+
160
+ nil
161
+ end
162
+
131
163
  def project_file(file)
132
164
  File.join(project_dir, file)
133
165
  end
@@ -1,20 +1,22 @@
1
1
  PORT=<%= server_port %>
2
2
 
3
- RHINO_APP_URL=http://localhost:$PORT
3
+ # Server
4
+ ROOT_URL=http://localhost:$PORT
5
+ FRONT_END_URL=http://localhost:$PORT
4
6
 
5
7
  DB_NAME=<%= db_name %>
6
8
  DB_HOST=<%= db_host %>
7
9
  DB_PORT=<%= db_port %>
8
10
  DB_USERNAME=<%= db_user %>
9
11
  DB_PASSWORD=<%= db_password %>
12
+ REDIS_HOST=<%= redis_host %>
13
+ REDIS_PORT=<%= redis_port %>
14
+ REDIS_DATABASE=<%= redis_database %>
10
15
 
11
- # Production
12
-
13
- #RHINO_PUBLIC_ROLLBAR_ACCESS_TOKEN=
14
-
15
- #RHINO_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_...
16
- #RHINO_STRIPE_SECRET_KEY=sk_...
16
+ # Client
17
+ VITE_API_ROOT_PATH=$ROOT_URL
17
18
 
19
+ # Production server:
18
20
  SENDGRID_API_KEY=<api-key>
19
21
 
20
22
  #AWS_ACCESS_KEY=
@@ -26,6 +28,13 @@ SENDGRID_API_KEY=<api-key>
26
28
  #AZURE_ACCOUNT_NAME="azure_acc_name"
27
29
  #AZURE_CONTAINER="container-test"
28
30
 
31
+ #STRIPE_PUBLISHABLE_KEY=pk_...
32
+ #STRIPE_SECRET_KEY=sk_...
33
+
29
34
  #AUTH_GOOGLE_OAUTH2_CLIENT_ID=
30
35
  #AUTH_GOOGLE_OAUTH2_SECRET_KEY=
31
36
 
37
+ ROLLBAR_ACCESS_TOKEN=
38
+
39
+ # Production client:
40
+ VITE_ROLLBAR_ACCESS_TOKEN=
@@ -11,7 +11,6 @@ module Rhino
11
11
  class_option :owner, type: :string, desc: "The model is owned by the reference attribute", group: :owner
12
12
  class_option :base_owner, type: :boolean, default: false, desc: "The model is owned by the base owner", group: :owner
13
13
  class_option :global_owner, type: :boolean, default: false, desc: "The model is globally owned", group: :owner
14
- class_option :skip_admin, type: :boolean, default: false, desc: "Skip generating ActiveAdmin resources", group: :admin
15
14
 
16
15
  # Parent source paths
17
16
  def source_paths
@@ -53,10 +52,6 @@ module Rhino
53
52
  end
54
53
  end
55
54
 
56
- def active_admin_resource
57
- generate "rhino:admin", class_name unless options[:skip_admin]
58
- end
59
-
60
55
  protected
61
56
  def check_ownership
62
57
  raise Thor::Error, "Exactly one owner must be defined on a reference or globally" unless base_owner? ^ global_owner? ^ reference_owner?
@@ -66,6 +66,6 @@ DeviseTokenAuth.setup do |config|
66
66
  # send email, set it to true. (This is a setting for compatibility)
67
67
  # config.send_confirmation_email = true
68
68
 
69
- config.default_confirm_success_url = "#{ENV['RHINO_APP_URL']}/auth/signin"
70
- config.default_password_reset_url = "#{ENV['RHINO_APP_URL']}/auth/reset-password"
69
+ config.default_confirm_success_url = "#{ENV['FRONT_END_URL']}/auth/signin"
70
+ config.default_password_reset_url = "#{ENV['FRONT_END_URL']}/auth/reset-password"
71
71
  end
@@ -11,8 +11,6 @@ module Rhino
11
11
  included do
12
12
  attribute :url
13
13
  attribute :url_attachment
14
- attribute :previews, :json, default: {}
15
- attribute :representations, :json, default: {}
16
14
  attribute :variants, :json, default: {}
17
15
 
18
16
  rhino_policy :active_storage_attachment
@@ -25,35 +23,20 @@ module Rhino
25
23
  url(attachment, disposition: :attachment)
26
24
  end
27
25
 
28
- def representations
29
- return unless representable?
26
+ def variants
27
+ # Not everything may be processed into a variant based on mime type
28
+ return unless variable?
30
29
 
31
30
  record.attachment_reflections[self.name]&.named_variants&.keys&.index_with do |v|
32
- representation = representation(v)
31
+ variant = variant(v)
33
32
 
34
33
  {
35
- url: url(representation),
36
- url_attachment: url_attachment(representation)
34
+ url: url(variant),
35
+ url_attachment: url_attachment(variant)
37
36
  }
38
37
  end
39
38
  end
40
39
 
41
- # FIXME: Cache for performance
42
- def previews
43
- # Not everything may be processed into a preview based on mime type
44
- return unless previewable?
45
-
46
- representations
47
- end
48
-
49
- # FIXME: Cache for performance
50
- def variants
51
- # Not everything may be processed into a variant based on mime type
52
- return unless variable?
53
-
54
- representations
55
- end
56
-
57
40
  def display_name
58
41
  filename.to_s
59
42
  end
@@ -61,7 +44,7 @@ module Rhino
61
44
 
62
45
  class_methods do
63
46
  def readable_properties
64
- super + [ "previews", "representations", "variants", "signed_id"]
47
+ super + [ "variants", "signed_id"]
65
48
  end
66
49
  end
67
50
 
@@ -13,7 +13,7 @@ module Rhino
13
13
  @param = params[:order]
14
14
 
15
15
  # Always append id to the end of the order clause to ensure a stable sort for pagination
16
- result = apply_order.order(scope.primary_key.to_sym)
16
+ result = apply_order.order(scope.primary_key)
17
17
  @app.resolve(result, params)
18
18
  end
19
19
 
data/lib/rhino/version.rb CHANGED
@@ -8,9 +8,9 @@ module Rhino
8
8
 
9
9
  module VERSION
10
10
  MAJOR = 0
11
- MINOR = 25
11
+ MINOR = 30
12
12
  TINY = 0
13
- PRE = "beta.16"
13
+ PRE = "alpha.1"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhino_project_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.0.beta.16
4
+ version: 0.30.0.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Rosevear
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 2025-03-29 00:00:00.000000000 Z
11
+ date: 2024-12-08 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: rails
@@ -15,20 +16,20 @@ dependencies:
15
16
  requirements:
16
17
  - - "~>"
17
18
  - !ruby/object:Gem::Version
18
- version: 8.0.0
19
+ version: 7.2.0
19
20
  - - ">="
20
21
  - !ruby/object:Gem::Version
21
- version: 8.0.0
22
+ version: 7.2.0
22
23
  type: :runtime
23
24
  prerelease: false
24
25
  version_requirements: !ruby/object:Gem::Requirement
25
26
  requirements:
26
27
  - - "~>"
27
28
  - !ruby/object:Gem::Version
28
- version: 8.0.0
29
+ version: 7.2.0
29
30
  - - ">="
30
31
  - !ruby/object:Gem::Version
31
- version: 8.0.0
32
+ version: 7.2.0
32
33
  - !ruby/object:Gem::Dependency
33
34
  name: activeadmin
34
35
  requirement: !ruby/object:Gem::Requirement
@@ -49,14 +50,14 @@ dependencies:
49
50
  requirements:
50
51
  - - '='
51
52
  - !ruby/object:Gem::Version
52
- version: 12.0.0
53
+ version: 11.0.0
53
54
  type: :runtime
54
55
  prerelease: false
55
56
  version_requirements: !ruby/object:Gem::Requirement
56
57
  requirements:
57
58
  - - '='
58
59
  - !ruby/object:Gem::Version
59
- version: 12.0.0
60
+ version: 11.0.0
60
61
  - !ruby/object:Gem::Dependency
61
62
  name: analytics-ruby
62
63
  requirement: !ruby/object:Gem::Requirement
@@ -91,14 +92,14 @@ dependencies:
91
92
  requirements:
92
93
  - - '='
93
94
  - !ruby/object:Gem::Version
94
- version: 2.16.0
95
+ version: 2.15.0
95
96
  type: :runtime
96
97
  prerelease: false
97
98
  version_requirements: !ruby/object:Gem::Requirement
98
99
  requirements:
99
100
  - - '='
100
101
  - !ruby/object:Gem::Version
101
- version: 2.16.0
102
+ version: 2.15.0
102
103
  - !ruby/object:Gem::Dependency
103
104
  name: countries
104
105
  requirement: !ruby/object:Gem::Requirement
@@ -133,14 +134,14 @@ dependencies:
133
134
  requirements:
134
135
  - - '='
135
136
  - !ruby/object:Gem::Version
136
- version: 1.2.5
137
+ version: 1.2.4
137
138
  type: :runtime
138
139
  prerelease: false
139
140
  version_requirements: !ruby/object:Gem::Requirement
140
141
  requirements:
141
142
  - - '='
142
143
  - !ruby/object:Gem::Version
143
- version: 1.2.5
144
+ version: 1.2.4
144
145
  - !ruby/object:Gem::Dependency
145
146
  name: friendly_id
146
147
  requirement: !ruby/object:Gem::Requirement
@@ -387,7 +388,6 @@ files:
387
388
  - app/controllers/rhino/crud_controller.rb
388
389
  - app/controllers/rhino/simple_controller.rb
389
390
  - app/controllers/rhino/simple_stream_controller.rb
390
- - app/helpers/rhino/env_helper.rb
391
391
  - app/helpers/rhino/omniauth_helper.rb
392
392
  - app/helpers/rhino/policy_helper.rb
393
393
  - app/helpers/rhino/segment_helper.rb
@@ -395,7 +395,6 @@ files:
395
395
  - app/models/rhino/current.rb
396
396
  - app/models/rhino/user.rb
397
397
  - app/overrides/active_record/nested_error_override.rb
398
- - app/overrides/activeadmin/resource_dsl_override.rb
399
398
  - app/overrides/activestorage/direct_uploads_controller_override.rb
400
399
  - app/overrides/activestorage/redirect_controller_override.rb
401
400
  - app/overrides/activestorage/redirect_representation_controller_override.rb
@@ -427,8 +426,6 @@ files:
427
426
  - lib/commands/rhino/module/new_command.rb
428
427
  - lib/commands/rhino/module/rails_command.rb
429
428
  - lib/commands/rhino/module/test_command.rb
430
- - lib/generators/rhino/admin/admin_generator.rb
431
- - lib/generators/rhino/admin/templates/resource.rb.tt
432
429
  - lib/generators/rhino/dev/setup/setup_generator.rb
433
430
  - lib/generators/rhino/dev/setup/templates/env.tt
434
431
  - lib/generators/rhino/dev/setup/templates/prepare-commit-msg
@@ -511,6 +508,7 @@ homepage: ''
511
508
  licenses:
512
509
  - MIT
513
510
  metadata: {}
511
+ post_install_message:
514
512
  rdoc_options: []
515
513
  require_paths:
516
514
  - lib
@@ -525,7 +523,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
525
523
  - !ruby/object:Gem::Version
526
524
  version: '0'
527
525
  requirements: []
528
- rubygems_version: 3.6.2
526
+ rubygems_version: 3.5.22
527
+ signing_key:
529
528
  specification_version: 4
530
529
  summary: ''
531
530
  test_files: []
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Rhino
4
- module EnvHelper
5
- module_function
6
-
7
- def rhino_env_tag
8
- # Filter environment variables to get only those starting with "RHINO_PUBLIC"
9
- rhino_public_env = ENV.select { |key, _| key.start_with?("RHINO_PUBLIC") }
10
-
11
- # Create a JavaScript object with the environment variables
12
- js_env = rhino_public_env.transform_keys { |key| key.sub("RHINO_PUBLIC_", "") }
13
-
14
- # Create a JavaScript snippet that initializes window.rhino.env
15
- js_code = <<~JS
16
- (function() {
17
- window.rhino = window.rhino || {};
18
- window.rhino.env = window.rhino.env || {};
19
- var env = #{js_env.to_json};
20
- for (var key in env) {
21
- if (Object.prototype.hasOwnProperty.call(env, key)) {
22
- window.rhino.env[key] = env[key];
23
- }
24
- }
25
- })();
26
- JS
27
-
28
- # Return as a script tag
29
- javascript_tag(js_code)
30
- end
31
- end
32
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_admin/resource_dsl"
4
-
5
- module ActiveAdmin
6
- # This is the class where all the register blocks are evaluated.
7
- class ResourceDSL
8
- # Runs in the context of the ResourceDSL
9
- def rhino_filters
10
- klass = self.config.resource_class_name.constantize
11
- klass.ransackable_filters.each do |attr|
12
- filter attr.to_sym
13
- end
14
- end
15
-
16
- # Runs in the context of the controller
17
- def rhino_permit_params(permitted: [])
18
- permit_params do
19
- klass = self.active_admin_config.resource_class_name.constantize
20
-
21
- permitted += klass.creatable_properties.map(&:to_sym) if params[:action] == "create"
22
- permitted += klass.updatable_properties.map(&:to_sym) if params[:action] == "update"
23
-
24
- # Allow owner and other references to be assigned or changed by admin
25
- # All possible relations
26
- references = klass.describe[:properties].select { |_p, d| d[:type] == :reference }.keys
27
-
28
- # Restrict to the valid create/update properties
29
- references.select! { |r| permitted.include?(r.to_sym) }
30
- permitted += references.map { |r| klass.reflections[r].foreign_key }
31
-
32
- permitted.uniq
33
- end
34
- end
35
- end
36
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rails/generators"
4
-
5
- module Rhino
6
- class AdminGenerator < Rails::Generators::NamedBase
7
- source_root File.expand_path("templates", __dir__)
8
-
9
- def admin
10
- template "resource.rb", "app/admin/#{file_path.tr('/', '_').pluralize}.rb" unless options[:skip_admin]
11
- end
12
- end
13
- end
@@ -1,4 +0,0 @@
1
- ActiveAdmin.register <%= class_name %> do
2
- rhino_filters
3
- rhino_permit_params
4
- end