activeadmin_assets 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +13 -0
- data/lib/activeadmin_assets/assets/active_admin/features/batch_actions.js.gz +0 -0
- data/lib/activeadmin_assets/assets/active_admin/features/dark_mode_toggle.js.gz +0 -0
- data/lib/activeadmin_assets/assets/active_admin/features/filters.js.gz +0 -0
- data/lib/activeadmin_assets/assets/active_admin/features/has_many.js.gz +0 -0
- data/lib/activeadmin_assets/assets/active_admin/features/main_menu.js.gz +0 -0
- data/lib/activeadmin_assets/assets/active_admin/features/per_page.js.gz +0 -0
- data/lib/activeadmin_assets/assets/active_admin/utils/dom.js.gz +0 -0
- data/lib/activeadmin_assets/assets/active_admin.css.gz +0 -0
- data/lib/activeadmin_assets/assets/active_admin.js.gz +0 -0
- data/lib/activeadmin_assets/assets/flowbite.js.gz +0 -0
- data/lib/activeadmin_assets/assets/rails_ujs_esm.js.gz +0 -0
- data/lib/activeadmin_assets/compatibility_check.rb +16 -0
- data/lib/activeadmin_assets/middleware.rb +33 -0
- data/lib/activeadmin_assets/path.rb +12 -0
- data/lib/activeadmin_assets/railtie.rb +15 -0
- data/lib/activeadmin_assets/url_patch.rb +23 -0
- data/lib/activeadmin_assets/version.rb +5 -0
- data/lib/activeadmin_assets.rb +3 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0d923dc66ce84a31f0b8d63fa80bfecca10bf0ea68b16b47aff3b986ab891a94
|
4
|
+
data.tar.gz: 78d631e9c607b7abd459baf10ec67365952bf4ccf06337511cc84974b064b02a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6d682e3a5ea3144dbc32845fb97b990168e8dbccb20b16a564825f90bfccad04e6a208ccd2fc9650de3570aae417f4374205ce113779d21ac5cd4faf96405f54
|
7
|
+
data.tar.gz: 82a8bd5f4b4ff16ffb1aeafc33479a3e628e17d9f0bb81a27864f8fe7632cb7ce10d2830ecef4c69242b1073bb84dad0280058268a58761e8544ff260bb14e58
|
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Janosch Müller
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/activeadmin_assets.svg)](http://badge.fury.io/rb/activeadmin_assets)
|
2
|
+
[![Build Status](https://github.com/jaynetics/activeadmin_assets/actions/workflows/main.yml/badge.svg)](https://github.com/jaynetics/activeadmin_assets/actions)
|
3
|
+
[![Coverage](https://codecov.io/github/jaynetics/activeadmin_assets/graph/badge.svg?token=7fCHVrCeFv)](https://codecov.io/github/jaynetics/activeadmin_assets)
|
4
|
+
|
5
|
+
# ActiveAdminAssets
|
6
|
+
|
7
|
+
This gem is for you if you want to be able to run [ActiveAdmin](https://github.com/activeadmin/activeadmin) v4+ without any asset setup, e.g.:
|
8
|
+
|
9
|
+
- no `cssbundling-rails` or `tailwindcss-rails`
|
10
|
+
- no `sprockets` or `propshaft`
|
11
|
+
- no `assets:precompile` or similar build steps
|
12
|
+
|
13
|
+
Like the asset gems of old, it includes static copies of all required assets and injects them automatically.
|
14
|
+
|
15
|
+
## Caveats
|
16
|
+
|
17
|
+
- This will prevent you from customizing ActiveAdmin's tailwind config, making theming more hacky.
|
18
|
+
- This will prevent you from using tailwind classes that are not used by ActiveAdmin itself.
|
19
|
+
- This might break with ActiveAdmin updates, though I don't consider it likely so its not version-locked yet.
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
Add `activeadmin_assets` to your Gemfile.
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
That's it 😁. If you want, you can configure the path to serve static assets from:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
ActiveAdminAssets.path = '/x/admin-assets' # default: '/active_admin_assets'
|
31
|
+
```
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/jaynetics/activeadmin_assets.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
|
6
|
+
Dir['tasks/**/*.rake'].each { |file| load(file) }
|
7
|
+
|
8
|
+
RSpec::Core::RakeTask.new(:spec)
|
9
|
+
|
10
|
+
task default: [:css, :js, :generate_spec_app, :spec]
|
11
|
+
|
12
|
+
# ensure fresh assets are included when packaging the gem
|
13
|
+
task build: %i[css js]
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module ActiveAdminAssets
|
2
|
+
# Checks if custom/manual asset provisioning is in place.
|
3
|
+
# To be more thorough, this could also check for usage of new tailwind classes
|
4
|
+
# in any admin controllers or partials, though that might be a bit expensive.
|
5
|
+
module CompatibilityCheck
|
6
|
+
def self.call(app)
|
7
|
+
return unless %w[development test].include?(ENV['RAILS_ENV'])
|
8
|
+
|
9
|
+
customizations = Dir[app.root.join('app/assets/{builds,stylesheets}/active_admin.*')]
|
10
|
+
customizations.any? and warn ""\
|
11
|
+
"The activeadmin_assets gem is not compatible with providing core "\
|
12
|
+
"activeadmin assets yourself. Please remove either the gem "\
|
13
|
+
"or your custom files: #{customizations}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module ActiveAdminAssets
|
2
|
+
# Catches active admin asset requests and serves them from the gem.
|
3
|
+
class Middleware
|
4
|
+
def initialize(app, *)
|
5
|
+
@app = app
|
6
|
+
@regexp = /\A#{ActiveAdminAssets.path}(.+)/
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
serve(env[Rack::PATH_INFO]) || @app.call(env)
|
11
|
+
end
|
12
|
+
|
13
|
+
def serve(path)
|
14
|
+
return unless asset_path = path[@regexp, 1]
|
15
|
+
|
16
|
+
static_path = File.join(__dir__, 'assets', "#{asset_path}.gz")
|
17
|
+
send_data(static_path)
|
18
|
+
end
|
19
|
+
|
20
|
+
# This could be made more efficient with sendfile,
|
21
|
+
# perhaps after checking config.action_dispatch.x_sendfile_header
|
22
|
+
def send_data(path)
|
23
|
+
data = File.read(path)
|
24
|
+
headers = {
|
25
|
+
'cache-control' => 'public, max-age=86400',
|
26
|
+
'content-encoding' => 'gzip',
|
27
|
+
'content-length' => data.bytesize.to_s,
|
28
|
+
'content-type' => path['.css'] ? 'text/css' : 'text/javascript',
|
29
|
+
}
|
30
|
+
[200, headers, [data]]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'active_admin/version'
|
2
|
+
|
3
|
+
module ActiveAdminAssets
|
4
|
+
# Add VERSIONs to invalidate browser caches on gem updates.
|
5
|
+
def self.path
|
6
|
+
"#{@path || '/active_admin_assets'}/#{ActiveAdmin::VERSION}/#{VERSION}/"
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.path=(arg)
|
10
|
+
@path = arg && !arg.empty? && "/#{arg.gsub(%r{\A/|/\z}, '')}"
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails/railtie'
|
2
|
+
require 'rails/engine/railties'
|
3
|
+
|
4
|
+
module ActiveAdminAssets
|
5
|
+
class Railtie < ::Rails::Railtie
|
6
|
+
initializer 'activeadmin_assets.initializer' do |app|
|
7
|
+
ActiveAdminAssets::CompatibilityCheck.call(app)
|
8
|
+
app.middleware.insert(0, ActiveAdminAssets::Middleware)
|
9
|
+
end
|
10
|
+
|
11
|
+
ActiveSupport.on_load(:active_admin_controller) do
|
12
|
+
ActiveAdmin::LayoutHelper.prepend(ActiveAdminAssets::URLPatch)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ActiveAdminAssets
|
2
|
+
# Modify asset URLs for active admins assets:
|
3
|
+
# - prepend special path (includes VERSIONs to bust caches on gem updates)
|
4
|
+
# - prevent sprockets or propshaft from adding digests to the asset URLs
|
5
|
+
module URLPatch
|
6
|
+
def stylesheet_link_tag(path, ...)
|
7
|
+
return super unless active_admin_asset?(path)
|
8
|
+
|
9
|
+
tag.link(rel: :stylesheet, href: path_to_asset("#{path.chomp('.css')}.css"))
|
10
|
+
end
|
11
|
+
|
12
|
+
# this is called by importmap-rails, too
|
13
|
+
def path_to_asset(path, ...)
|
14
|
+
return super unless active_admin_asset?(path)
|
15
|
+
|
16
|
+
path.sub(%r{\A/?}, ActiveAdminAssets.path)
|
17
|
+
end
|
18
|
+
|
19
|
+
def active_admin_asset?(path)
|
20
|
+
%r{\A/?(?:active_admin|flowbite|rails_ujs_esm)(?:[/.]|\z)}.match?(path)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: activeadmin_assets
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Janosch Müller
|
8
|
+
bindir: bin
|
9
|
+
cert_chain: []
|
10
|
+
date: 2024-07-14 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: activeadmin
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 4.0.0.beta7
|
19
|
+
- - "<"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 5.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 4.0.0.beta7
|
29
|
+
- - "<"
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 5.0.0
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: importmap-rails
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 2.0.0
|
39
|
+
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.0.0
|
46
|
+
email:
|
47
|
+
- janosch84@gmail.com
|
48
|
+
executables: []
|
49
|
+
extensions: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
files:
|
52
|
+
- ".rspec"
|
53
|
+
- CHANGELOG.md
|
54
|
+
- LICENSE.txt
|
55
|
+
- README.md
|
56
|
+
- Rakefile
|
57
|
+
- lib/activeadmin_assets.rb
|
58
|
+
- lib/activeadmin_assets/assets/active_admin.css.gz
|
59
|
+
- lib/activeadmin_assets/assets/active_admin.js.gz
|
60
|
+
- lib/activeadmin_assets/assets/active_admin/features/batch_actions.js.gz
|
61
|
+
- lib/activeadmin_assets/assets/active_admin/features/dark_mode_toggle.js.gz
|
62
|
+
- lib/activeadmin_assets/assets/active_admin/features/filters.js.gz
|
63
|
+
- lib/activeadmin_assets/assets/active_admin/features/has_many.js.gz
|
64
|
+
- lib/activeadmin_assets/assets/active_admin/features/main_menu.js.gz
|
65
|
+
- lib/activeadmin_assets/assets/active_admin/features/per_page.js.gz
|
66
|
+
- lib/activeadmin_assets/assets/active_admin/utils/dom.js.gz
|
67
|
+
- lib/activeadmin_assets/assets/flowbite.js.gz
|
68
|
+
- lib/activeadmin_assets/assets/rails_ujs_esm.js.gz
|
69
|
+
- lib/activeadmin_assets/compatibility_check.rb
|
70
|
+
- lib/activeadmin_assets/middleware.rb
|
71
|
+
- lib/activeadmin_assets/path.rb
|
72
|
+
- lib/activeadmin_assets/railtie.rb
|
73
|
+
- lib/activeadmin_assets/url_patch.rb
|
74
|
+
- lib/activeadmin_assets/version.rb
|
75
|
+
homepage: https://github.com/jaynetics/activeadmin_assets
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata:
|
79
|
+
homepage_uri: https://github.com/jaynetics/activeadmin_assets
|
80
|
+
source_code_uri: https://github.com/jaynetics/activeadmin_assets
|
81
|
+
changelog_uri: https://github.com/jaynetics/activeadmin_assets/blob/main/CHANGELOG.md
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 3.1.0
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubygems_version: 3.6.0.dev
|
97
|
+
specification_version: 4
|
98
|
+
summary: Run ActiveAdmin v4 without asset setup.
|
99
|
+
test_files: []
|