panda-core 0.2.1 → 0.2.2

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: ae9cc770f537f0190416f1dece9c54ff839015625d0145a1bd97b77cb667455a
4
- data.tar.gz: e4f6286a4f7c6a20aa5c71ae5528f7203bcaf30ceddda2ea9c774bee6ffec66c
3
+ metadata.gz: '09471a6539fbe36d120f42bfba23f7a9bd8e37d40e743195a39edadc26b94957'
4
+ data.tar.gz: 1ab08eaade2fb243bbadde21429a98b096186d3819e22e60eccc9992c6ae4a48
5
5
  SHA512:
6
- metadata.gz: fa96a0fbfa58aaba72b3006455558736337f5cdfc504abf38af03db0e5697b599059a5a5501bc58d8b64cbac826f01122eea56f6a3e221de09d2eebfd57c478d
7
- data.tar.gz: b9b96c780035db586a4fc566512e67de2922a29cb551c28fd3d3af72c72dc2b8853ca8a55364aa2fb62d8cf34cd19976a4b7afb6ab611c276a6ee799c4a3c182
6
+ metadata.gz: b779fa184be2081acb8ec7a55f6442be40afcea490141c8c3d0eb7ee5c4e6a03ce22c1ac8e7d695708eb97426dea9a0aca9c940c5b74dcdaff962deda8962277
7
+ data.tar.gz: 41707c2d6c79d8df4f87d1837f08f34a29dd48cb26df8ab8e175c54deab59281ea57cc0d47e4a8fe3d7ba06d35bc2f87ef6b74023e6020b15871adf6b3100e22
@@ -12,4 +12,4 @@ module Panda
12
12
  end
13
13
  end
14
14
  end
15
- end
15
+ end
@@ -28,7 +28,7 @@ module Panda
28
28
  redirect_to admin_login_path, flash: {error: "You do not have permission to access the admin area"}
29
29
  return
30
30
  end
31
-
31
+
32
32
  session[:user_id] = user.id
33
33
  Panda::Core::Current.user = user
34
34
 
@@ -50,7 +50,7 @@ module Panda
50
50
  def failure
51
51
  message = params[:message] || "Authentication failed"
52
52
  strategy = params[:strategy] || "unknown"
53
-
53
+
54
54
  Rails.logger.error "OmniAuth failure: strategy=#{strategy}, message=#{message}"
55
55
  redirect_to admin_login_path, flash: {error: "Authentication failed: #{message}"}
56
56
  end
@@ -4,11 +4,11 @@ module Panda
4
4
  module Core
5
5
  class User < ApplicationRecord
6
6
  self.table_name = "panda_core_users"
7
-
7
+
8
8
  validates :email, presence: true, uniqueness: {case_sensitive: false}
9
9
 
10
10
  before_save :downcase_email
11
-
11
+
12
12
  # Scopes
13
13
  scope :admin, -> { where(admin: true) }
14
14
 
@@ -19,7 +19,7 @@ module Panda
19
19
  # Parse name into first and last
20
20
  full_name = auth_hash.info.name || "Unknown User"
21
21
  name_parts = full_name.split(" ", 2)
22
-
22
+
23
23
  create!(
24
24
  email: auth_hash.info.email.downcase,
25
25
  firstname: name_parts[0] || "Unknown",
@@ -32,7 +32,7 @@ module Panda
32
32
  def admin?
33
33
  admin == true
34
34
  end
35
-
35
+
36
36
  def name
37
37
  "#{firstname} #{lastname}".strip
38
38
  end
data/config/routes.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  Panda::Core::Engine.routes.draw do
2
2
  # Use the configured admin path (defaults to "/admin")
3
3
  admin_path = Panda::Core.configuration.admin_path.delete_prefix("/")
4
-
4
+
5
5
  scope path: admin_path, as: "admin" do
6
6
  get "/login", to: "admin/sessions#new", as: :login
7
-
7
+
8
8
  # OmniAuth routes - middleware handles /admin/auth/:provider automatically
9
9
  # We just need to define the callback routes
10
10
  get "/auth/:provider/callback", to: "admin/sessions#create", as: :auth_callback
@@ -14,7 +14,7 @@ Panda::Core::Engine.routes.draw do
14
14
 
15
15
  constraints Panda::Core::AdminConstraint.new do
16
16
  get "/", to: "admin/dashboard#show", as: :root
17
-
17
+
18
18
  # Profile management
19
19
  resource :my_profile, only: %i[edit update], controller: "admin/my_profile", path: "my_profile"
20
20
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'net/http'
4
- require 'fileutils'
5
- require 'json'
3
+ require "net/http"
4
+ require "fileutils"
5
+ require "json"
6
6
 
7
7
  module Panda
8
8
  module Core
@@ -41,7 +41,7 @@ module Panda
41
41
  def use_github_assets?
42
42
  # Use GitHub assets in production or when explicitly enabled
43
43
  Rails.env.production? ||
44
- ENV['PANDA_CORE_USE_GITHUB_ASSETS'] == 'true' ||
44
+ ENV["PANDA_CORE_USE_GITHUB_ASSETS"] == "true" ||
45
45
  !development_assets_available? ||
46
46
  ((Rails.env.test? || in_test_environment?) && compiled_assets_available?)
47
47
  end
@@ -61,15 +61,15 @@ module Panda
61
61
  src: js_url
62
62
  }
63
63
  # In CI environment, don't use defer to ensure immediate execution
64
- js_attrs[:defer] = true unless ENV['GITHUB_ACTIONS'] == 'true'
64
+ js_attrs[:defer] = true unless ENV["GITHUB_ACTIONS"] == "true"
65
65
 
66
- tags << content_tag(:script, '', js_attrs)
66
+ tags << content_tag(:script, "", js_attrs)
67
67
 
68
68
  # CSS tag if CSS bundle exists
69
69
  css_url = "#{base_url}panda-core-#{version}.css"
70
70
  if github_asset_exists?(version, "panda-core-#{version}.css")
71
71
  css_attrs = {
72
- rel: 'stylesheet',
72
+ rel: "stylesheet",
73
73
  href: css_url
74
74
  }
75
75
  tags << tag(:link, css_attrs)
@@ -80,7 +80,7 @@ module Panda
80
80
 
81
81
  def development_asset_tags(_options = {})
82
82
  # In test environment with CI, always use compiled assets
83
- if (Rails.env.test? || ENV['CI'].present?) && compiled_assets_available?
83
+ if (Rails.env.test? || ENV["CI"].present?) && compiled_assets_available?
84
84
  # Use the same logic as GitHub assets but with local paths
85
85
  version = asset_version
86
86
  js_url = "/panda-core-assets/panda-core-#{version}.js"
@@ -92,13 +92,13 @@ module Panda
92
92
  js_attrs = {
93
93
  src: js_url
94
94
  }
95
- js_attrs[:defer] = true unless ENV['GITHUB_ACTIONS'] == 'true'
96
- tags << content_tag(:script, '', js_attrs)
95
+ js_attrs[:defer] = true unless ENV["GITHUB_ACTIONS"] == "true"
96
+ tags << content_tag(:script, "", js_attrs)
97
97
 
98
98
  # CSS tag if exists
99
- if File.exist?(Rails.root.join('public', 'panda-core-assets', "panda-core-#{version}.css"))
99
+ if File.exist?(Rails.root.join("public", "panda-core-assets", "panda-core-#{version}.css"))
100
100
  css_attrs = {
101
- rel: 'stylesheet',
101
+ rel: "stylesheet",
102
102
  href: css_url
103
103
  }
104
104
  tags << tag(:link, css_attrs)
@@ -107,7 +107,7 @@ module Panda
107
107
  else
108
108
  # Development mode - use importmap
109
109
  tags = []
110
- tags << javascript_include_tag('panda/core/application', type: 'module')
110
+ tags << javascript_include_tag("panda/core/application", type: "module")
111
111
  end
112
112
  tags.join("\n").html_safe
113
113
  end
@@ -139,7 +139,7 @@ module Panda
139
139
  "/panda-core-assets/panda-core-#{version}.js"
140
140
  else
141
141
  # Return importmap path
142
- '/assets/panda/core/application.js'
142
+ "/assets/panda/core/application.js"
143
143
  end
144
144
  end
145
145
 
@@ -173,13 +173,13 @@ module Panda
173
173
  def compiled_assets_available?
174
174
  # Check if compiled assets exist in test location
175
175
  version = asset_version
176
- js_file = Rails.public_path.join('panda-core-assets', "panda-core-#{version}.js")
176
+ js_file = Rails.public_path.join("panda-core-assets", "panda-core-#{version}.js")
177
177
  js_file.exist?
178
178
  end
179
179
 
180
180
  def in_test_environment?
181
181
  # Additional check for test environment indicators
182
- ENV['CI'].present? || ENV['GITHUB_ACTIONS'].present? || ENV['RAILS_ENV'] == 'test'
182
+ ENV["CI"].present? || ENV["GITHUB_ACTIONS"].present? || ENV["RAILS_ENV"] == "test"
183
183
  end
184
184
 
185
185
  # Helper methods to match ActionView helpers
@@ -190,12 +190,12 @@ module Panda
190
190
  elsif v
191
191
  "#{k}=\"#{v}\""
192
192
  end
193
- end.compact.join(' ')
193
+ end.compact.join(" ")
194
194
 
195
195
  if content || block_given?
196
- "<#{name}#{attrs.present? ? " #{attrs}" : ''}>#{content || (block_given? ? yield : '')}</#{name}>"
196
+ "<#{name}#{attrs.present? ? " #{attrs}" : ""}>#{content || (block_given? ? yield : "")}</#{name}>"
197
197
  else
198
- "<#{name}#{attrs.present? ? " #{attrs}" : ''}><#{name}>"
198
+ "<#{name}#{attrs.present? ? " #{attrs}" : ""}><#{name}>"
199
199
  end
200
200
  end
201
201
 
@@ -206,14 +206,14 @@ module Panda
206
206
  elsif v
207
207
  "#{k}=\"#{v}\""
208
208
  end
209
- end.compact.join(' ')
209
+ end.compact.join(" ")
210
210
 
211
- "<#{name}#{attrs.present? ? " #{attrs}" : ''} />"
211
+ "<#{name}#{attrs.present? ? " #{attrs}" : ""} />"
212
212
  end
213
213
 
214
214
  def javascript_include_tag(source, options = {})
215
- options[:src] = source.start_with?('/') ? source : "/assets/#{source}"
216
- content_tag(:script, '', options)
215
+ options[:src] = source.start_with?("/") ? source : "/assets/#{source}"
216
+ content_tag(:script, "", options)
217
217
  end
218
218
  end
219
219
  end
@@ -45,7 +45,7 @@ module Panda
45
45
  # Allow POST requests for request phase (required for CSRF protection)
46
46
  config.allowed_request_methods = [:get, :post]
47
47
  end
48
-
48
+
49
49
  Panda::Core.configuration.authentication_providers.each do |provider_name, settings|
50
50
  case provider_name.to_s
51
51
  when "microsoft_graph"
@@ -19,9 +19,9 @@ module Panda
19
19
  # Create or update the user in the test database
20
20
  Panda::Core::User.find_or_create_by(email: email) do |u|
21
21
  # Split name into firstname and lastname
22
- parts = name.split(' ', 2)
22
+ parts = name.split(" ", 2)
23
23
  u.firstname = parts[0] || name
24
- u.lastname = parts[1] || ''
24
+ u.lastname = parts[1] || ""
25
25
  u.admin = is_admin
26
26
  end
27
27
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Panda
4
4
  module Core
5
- VERSION = "0.2.1"
5
+ VERSION = "0.2.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panda-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tasty Bamboo
8
8
  - James Inman
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2025-08-13 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: importmap-rails
@@ -411,8 +410,6 @@ files:
411
410
  - app/views/panda/core/admin/shared/_slideover.html.erb
412
411
  - config/initializers/panda_core.rb
413
412
  - config/routes.rb
414
- - db/migrate/20241210000003_add_current_theme_to_panda_core_users.rb
415
- - db/migrate/20250809000001_create_panda_core_users.rb
416
413
  - lib/generators/panda/core/authentication/templates/reek_spec.rb
417
414
  - lib/generators/panda/core/dev_tools/USAGE
418
415
  - lib/generators/panda/core/dev_tools/templates/lefthook.yml
@@ -450,7 +447,6 @@ metadata:
450
447
  homepage_uri: https://github.com/tastybamboo/panda-core
451
448
  source_code_uri: https://github.com/tastybamboo/panda-core
452
449
  changelog_uri: https://github.com/tastybamboo/panda-core/blob/main/CHANGELOG.md
453
- post_install_message:
454
450
  rdoc_options: []
455
451
  require_paths:
456
452
  - lib
@@ -465,8 +461,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
465
461
  - !ruby/object:Gem::Version
466
462
  version: '0'
467
463
  requirements: []
468
- rubygems_version: 3.5.22
469
- signing_key:
464
+ rubygems_version: 3.6.9
470
465
  specification_version: 4
471
466
  summary: Core libraries and development tools for Tasty Bamboo projects
472
467
  test_files: []
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class AddCurrentThemeToPandaCoreUsers < ActiveRecord::Migration[7.1]
4
- def change
5
- add_column :panda_core_users, :current_theme, :string, default: "default"
6
- end
7
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class CreatePandaCoreUsers < ActiveRecord::Migration[7.1]
4
- def change
5
- create_table :panda_core_users, id: :uuid do |t|
6
- t.string :firstname, null: false
7
- t.string :lastname, null: false
8
- t.string :email, null: false
9
- t.string :image_url
10
- t.boolean :admin, default: false, null: false
11
- t.timestamps
12
- end
13
-
14
- add_index :panda_core_users, :email, unique: true
15
- end
16
- end