Module: FujiAdmin
- Defined in:
- lib/fuji_admin.rb,
lib/fuji_admin/version.rb,
lib/fuji_admin/meta_tags.rb,
lib/fuji_admin/configuration.rb
Defined Under Namespace
Modules: Rails Classes: Configuration
Constant Summary collapse
- VERSION =
"1.2.0"- VIEWPORT =
Surfaces FujiAdmin.config and the responsive viewport hint to the browser by writing into AA’s head. We deliberately avoid ‘namespace.meta_tags`: AA renders that hash inside Arbre as `text_node(meta(…))`, and the inner `meta(…)` already auto-attaches to <head>, so each entry would render twice. Using `namespace.head` (a raw, html_safe string AA inserts once) sidesteps that.
"width=device-width, initial-scale=1".freeze
Class Method Summary collapse
- .apply_to_namespace(namespace) ⇒ Object
-
.config ⇒ Object
Access the current configuration singleton.
-
.configure {|config| ... } ⇒ Object
Yield the configuration to a block, e.g.
- .head_markup ⇒ Object
- .install_meta_tags! ⇒ Object
Class Method Details
.apply_to_namespace(namespace) ⇒ Object
32 33 34 |
# File 'lib/fuji_admin/meta_tags.rb', line 32 def self.apply_to_namespace(namespace) namespace.head = head_markup end |
.config ⇒ Object
Access the current configuration singleton.
8 9 10 |
# File 'lib/fuji_admin.rb', line 8 def config @config ||= Configuration.new end |
.configure {|config| ... } ⇒ Object
Yield the configuration to a block, e.g. in an initializer.
13 14 15 |
# File 'lib/fuji_admin.rb', line 13 def configure yield config end |
.head_markup ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/fuji_admin/meta_tags.rb', line 36 def self.head_markup <<~HTML.html_safe <meta name="viewport" content="#{VIEWPORT}"> <meta name="fuji-palette-picker" content="#{config.palette_picker}"> <meta name="fuji-default-palette" content="#{config.default_palette}"> HTML end |
.install_meta_tags! ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fuji_admin/meta_tags.rb', line 10 def self. return unless defined?(::ActiveAdmin) # Logged-out pages use a separate ERB layout that only renders # `application.meta_tags_for_logged_out_pages` (and ignores # `namespace.head`). We need viewport for mobile rendering and # `fuji-default-palette` so the login screen paints in the configured # brand colour. The picker UI itself is hidden for logged-out, so # `fuji-palette-picker` isn't needed there. ActiveAdmin.application. = ActiveAdmin.application..merge( viewport: VIEWPORT, "fuji-default-palette" => config.default_palette.to_s ) ActiveSupport::Notifications.subscribe(ActiveAdmin::Namespace::RegisterEvent) do |_name, _start, _finish, _id, payload| apply_to_namespace(payload[:active_admin_namespace]) end ActiveAdmin.application.namespaces.each { |ns| apply_to_namespace(ns) } end |