Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Move ActionText video embed functionality from core to admin gem (#13685)

Damian Legawiec2d6a0c22cdf8
diff --git a/spree/core/app/models/action_text/video_embed.rb b/spree/admin/app/models/action_text/video_embed.rb
similarity index 100%
rename from spree/core/app/models/action_text/video_embed.rb
rename to spree/admin/app/models/action_text/video_embed.rb
diff --git a/spree/core/app/views/action_text/video_embeds/_thumbnail.html.erb b/spree/admin/app/views/action_text/video_embeds/_thumbnail.html.erb
similarity index 100%
rename from spree/core/app/views/action_text/video_embeds/_thumbnail.html.erb
rename to spree/admin/app/views/action_text/video_embeds/_thumbnail.html.erb
diff --git a/spree/core/app/views/action_text/video_embeds/_video_embed.html.erb b/spree/admin/app/views/action_text/video_embeds/_video_embed.html.erb
similarity index 100%
rename from spree/core/app/views/action_text/video_embeds/_video_embed.html.erb
rename to spree/admin/app/views/action_text/video_embeds/_video_embed.html.erb
diff --git a/spree/core/app/views/layouts/action_text/contents/_content.html.erb b/spree/admin/app/views/layouts/action_text/contents/_content.html.erb
similarity index 100%
rename from spree/core/app/views/layouts/action_text/contents/_content.html.erb
rename to spree/admin/app/views/layouts/action_text/contents/_content.html.erb
diff --git a/spree/core/config/initializers/oembed.rb b/spree/admin/config/initializers/oembed.rb
similarity index 100%
rename from spree/core/config/initializers/oembed.rb
rename to spree/admin/config/initializers/oembed.rb
diff --git a/spree/admin/config/locales/en.yml b/spree/admin/config/locales/en.yml
index efda2b1197..3afa205716 100644
--- a/spree/admin/config/locales/en.yml
+++ b/spree/admin/config/locales/en.yml
@@ -1,5 +1,8 @@
---
en:
+ action_text:
+ video_embed:
+ not_found: Can't embed a video using the provided URL
spree:
admin:
amount_spent: Amount spent
diff --git a/spree/core/db/migrate/20250217171018_create_action_text_video_embeds.rb b/spree/admin/db/migrate/20250217171018_create_action_text_video_embeds.rb
similarity index 100%
rename from spree/core/db/migrate/20250217171018_create_action_text_video_embeds.rb
rename to spree/admin/db/migrate/20250217171018_create_action_text_video_embeds.rb
diff --git a/spree/admin/lib/spree/admin.rb b/spree/admin/lib/spree/admin.rb
index 7f3aa8ee8c..20e276ede2 100644
--- a/spree/admin/lib/spree/admin.rb
+++ b/spree/admin/lib/spree/admin.rb
@@ -18,6 +18,7 @@ require 'spree/admin/callbacks'
require 'spree/admin/engine'
require 'spree/core/partials'
+require 'oembed'
require 'tinymce-rails'
require 'pagy'
diff --git a/spree/admin/lib/spree/admin/engine.rb b/spree/admin/lib/spree/admin/engine.rb
index de747abb94..71d1d240a5 100644
--- a/spree/admin/lib/spree/admin/engine.rb
+++ b/spree/admin/lib/spree/admin/engine.rb
@@ -257,6 +257,14 @@ module Spree
# Add app/subscribers to autoload paths
config.paths.add 'app/subscribers', eager_load: true
+ # Include admin engine migrations in the host app's migration paths
+ initializer 'spree.admin.migrations' do |app|
+ config.paths['db/migrate'].expanded.each do |expanded_path|
+ app.config.paths['db/migrate'] << expanded_path
+ ActiveRecord::Migrator.migrations_paths << expanded_path
+ end
+ end
+
# accessible via Rails.application.config.spree_admin
initializer 'spree.admin.environment', before: :load_config_initializers do |app|
app.config.spree_admin = Environment.new
diff --git a/spree/admin/spree_admin.gemspec b/spree/admin/spree_admin.gemspec
index 1915eb44a4..b8c68b6741 100644
--- a/spree/admin/spree_admin.gemspec
+++ b/spree/admin/spree_admin.gemspec
@@ -42,4 +42,5 @@ Gem::Specification.new do |s|
s.add_dependency 'stimulus-rails'
s.add_dependency 'tinymce-rails', '~> 6.8.5'
s.add_dependency 'pagy', '~> 43.0'
+ s.add_dependency 'ruby-oembed', '~> 0.18'
end
diff --git a/spree/core/config/locales/en.yml b/spree/core/config/locales/en.yml
index 94827f9833..eed4e3c4a3 100644
--- a/spree/core/config/locales/en.yml
+++ b/spree/core/config/locales/en.yml
@@ -1,8 +1,5 @@
---
en:
- action_text:
- video_embed:
- not_found: Can't embed a video using the provided URL
activemodel:
errors:
messages:
diff --git a/spree/core/lib/spree/core.rb b/spree/core/lib/spree/core.rb
index 8b5365d5d2..5d4096cff0 100644
--- a/spree/core/lib/spree/core.rb
+++ b/spree/core/lib/spree/core.rb
@@ -28,7 +28,7 @@ require 'state_machines-activerecord'
require 'active_storage_validations'
require 'wannabe_bool'
require 'geocoder'
-require 'oembed'
+
require 'safely_block'
require 'ar_lazy_preload'
require 'sqids'
diff --git a/spree/core/spree_core.gemspec b/spree/core/spree_core.gemspec
index 7c4d32e3d0..bb072d4388 100644
--- a/spree/core/spree_core.gemspec
+++ b/spree/core/spree_core.gemspec
@@ -49,7 +49,7 @@ Gem::Specification.new do |s|
s.add_dependency 'paranoia', '>= 2.4'
s.add_dependency 'ransack', '>= 4.1'
s.add_dependency 'rexml'
- s.add_dependency 'ruby-oembed', '~> 0.18'
+
s.add_dependency 'state_machines-activerecord', '~> 0.100'
s.add_dependency 'state_machines-activemodel', '~> 0.100'
s.add_dependency 'stringex'