fuji_admin 0.1.1 → 0.1.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: ccce6482f20c02fb0e013ae881950edcad26f73b103598af0d4f50dc68c5e4ad
4
- data.tar.gz: 61dd4630982524c9d2fe94ee648a94a4530648761c271b7831bd3b3089a3baa7
3
+ metadata.gz: 4ced4ed49bdd67f0df172275fee1324778c378ae9e0ee99d3977e136ce819596
4
+ data.tar.gz: feb7791cec556d78eede014b8f9e3e531bfd31512cdb6fce9f60277e28a6dd20
5
5
  SHA512:
6
- metadata.gz: 484a5eaba8e30df55ac28e7afc7db3d19c5115759dec579f3d8d11149a18ad65ae4d4928ba14f33fde053729e406fe0cd9698b53d5f6f1e9a0032e088ea758d5
7
- data.tar.gz: fd2d4c1278dbb0643a734160e7efe9f6097de7cfeadd8d2549990ff093fb74ad7d717add8d91ce2c7a5f54f95870d87a4b1fe1eecbba9a8150fcaf52c0147fb0
6
+ metadata.gz: d233f8162d6fbd660000f429aaf480756385da78f4e58aa1ed73680c080afec0e117b1f143cfe6099651b03a009dc1af9cba699620ee8efa55255803dee339fd
7
+ data.tar.gz: 64b65816c0c78554be7afdc1c716133f49a98dc4c42dd37d367063f14f6e335b31ef7565294eb42f14d4e895fc01c0d7a7eda25439f2ab192461c007334ca9ef
@@ -1,19 +1,15 @@
1
1
  module FujiAdmin
2
- # Injects <meta> tags into ActiveAdmin's <head> so the palette JavaScript
3
- # can read the FujiAdmin config at runtime without requiring the host app
4
- # to touch its layout.
5
- #
6
- # Applied by prepending onto ActiveAdmin::Views::Pages::Base once AA is
7
- # loaded. If AA isn't present the prepend silently no-ops.
8
- module ActiveAdminPatch
9
- def build_active_admin_head
10
- super
11
- within @head do
12
- meta(name: "fuji-palette-picker", content: FujiAdmin.config.palette_picker.to_s)
13
- meta(name: "fuji-default-palette", content: FujiAdmin.config.default_palette.to_s)
14
- end
2
+ # Surfaces FujiAdmin.config to the browser by registering entries in each
3
+ # ActiveAdmin namespace's built-in `meta_tags` hash. AA renders those
4
+ # entries as <meta> tags inside <head> (lib/active_admin/views/pages/base.rb),
5
+ # so the palette JavaScript can read them on page load without any
6
+ # monkey-patching of arbre's view builders.
7
+ def self.install_meta_tags!
8
+ return unless defined?(::ActiveAdmin)
9
+
10
+ ActiveAdmin.application.namespaces.each do |namespace|
11
+ namespace.meta_tags["fuji-palette-picker"] = config.palette_picker.to_s
12
+ namespace.meta_tags["fuji-default-palette"] = config.default_palette.to_s
15
13
  end
16
14
  end
17
15
  end
18
-
19
- ActiveAdmin::Views::Pages::Base.prepend(FujiAdmin::ActiveAdminPatch) if defined?(::ActiveAdmin)
@@ -1,3 +1,3 @@
1
1
  module FujiAdmin
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/fuji_admin.rb CHANGED
@@ -16,8 +16,12 @@ module FujiAdmin
16
16
 
17
17
  module Rails
18
18
  class Engine < ::Rails::Engine
19
- initializer "fuji_admin.active_admin_patch", after: :load_config_initializers do
20
- require "fuji_admin/active_admin_patch" if defined?(::ActiveAdmin)
19
+ # Register meta tags after all initializers have run (so both
20
+ # FujiAdmin.configure and ActiveAdmin.setup have populated their state)
21
+ # and AA's namespaces are available to iterate.
22
+ config.after_initialize do
23
+ require "fuji_admin/active_admin_patch"
24
+ FujiAdmin.install_meta_tags!
21
25
  end
22
26
  end
23
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuji_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - barbariccorgi