ruby_cms 0.2.0.3 → 0.2.0.5
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -20
- data/app/views/layouts/ruby_cms/admin.html.erb +1 -1
- data/lib/generators/ruby_cms/install_generator.rb +37 -64
- data/lib/generators/ruby_cms/templates/admin.html.erb +1 -1
- data/lib/ruby_cms/engine.rb +5 -12
- data/lib/ruby_cms/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 747105700c925ba3d9140a015fa477116795644d8a99c52b3aee53c4e786678d
|
|
4
|
+
data.tar.gz: 8a7bf4cea26c24f7f73f5c6800c6a8dcfb784031a8f313bf2fb7e421fb8bbf31
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 78ebfe96b5853ad7ab9698bdc0fca3eaa568f6a02ae691d7ba007c804e4076afe5bde33380d966875f2e24eb72f554d6918408f8fbe04ab80b3644808c11f9ae
|
|
7
|
+
data.tar.gz: e410f195decbe969b4a873624e440b9331a47081a305bd504eea5a44c0ae90b63e6fe4d0b734fd72a01ea09c471cff7ee7c733eca971525fa9ff0c094b5e0e2c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -493,27 +493,9 @@ rails ruby_cms:css:compile_gem
|
|
|
493
493
|
### Faster Docker Builds (`assets:precompile`)
|
|
494
494
|
|
|
495
495
|
`assets:precompile` loads the Rails app in production mode and can be slow in Docker/Fly builds.
|
|
496
|
-
RubyCMS skips non-asset runtime initializers during this phase (navigation registration,
|
|
496
|
+
RubyCMS now skips non-asset runtime initializers during this phase (navigation registration,
|
|
497
497
|
dashboard registration, versioning hook, settings import, and permission seeding), which reduces
|
|
498
|
-
precompile overhead.
|
|
499
|
-
Ruby program name is `ruby` instead of `rails`.
|
|
500
|
-
|
|
501
|
-
**Tailwind CSS:** Do not add multiple `@source` globs that point at the same RubyCMS gem (e.g. both
|
|
502
|
-
`../../../../gems/ruby_cms/...` and `/usr/local/bundle/.../ruby_cms-*`). That scans the engine twice
|
|
503
|
-
and slows `tailwindcss:build` a lot. Instead, rely on [tailwindcss-rails engine support](https://github.com/rails/tailwindcss-rails#rails-engines-support-experimental):
|
|
504
|
-
|
|
505
|
-
1. RubyCMS ships `app/assets/tailwind/ruby_cms_engine/engine.css` with `@source` paths relative to the gem
|
|
506
|
-
(the directory matches Rails’ `engine_name` for `RubyCms::Engine`, which is `ruby_cms_engine`).
|
|
507
|
-
2. `rails tailwindcss:engines` (run automatically before `tailwindcss:build`) generates
|
|
508
|
-
`app/assets/builds/tailwind/ruby_cms_engine.css` in the host app.
|
|
509
|
-
3. In the host’s `app/assets/tailwind/application.css`, add **once**:
|
|
510
|
-
|
|
511
|
-
```css
|
|
512
|
-
@import "../builds/tailwind/ruby_cms_engine";
|
|
513
|
-
```
|
|
514
|
-
|
|
515
|
-
Place it next to your other `@import` lines (e.g. after `@import "tailwindcss";`). Remove any
|
|
516
|
-
hand-written `@source` lines aimed at the RubyCMS gem.
|
|
498
|
+
precompile overhead.
|
|
517
499
|
|
|
518
500
|
Recommended Docker layer order:
|
|
519
501
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<link rel="manifest" href="<%= asset_path("site.webmanifest") %>">
|
|
16
16
|
|
|
17
17
|
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
|
|
18
|
-
<%= stylesheet_link_tag "
|
|
18
|
+
<%= stylesheet_link_tag "ruby_cms/admin", "data-turbo-track": "reload" rescue nil %>
|
|
19
19
|
<%= stylesheet_link_tag "actiontext", "data-turbo-track": "reload" if asset_path("actiontext.css") rescue nil %>
|
|
20
20
|
<%= javascript_importmap_tags "admin" %>
|
|
21
21
|
</head>
|
|
@@ -21,7 +21,7 @@ module RubyCms
|
|
|
21
21
|
- If the host uses /admin already, remove or change those routes.
|
|
22
22
|
- Avoid root to: redirect("/admin") — use a real root or ruby_cms.unauthorized_redirect_path.
|
|
23
23
|
- Review config/initializers/ruby_cms.rb (session, CSP).
|
|
24
|
-
-
|
|
24
|
+
- RubyCMS admin styles are compiled once on install to app/assets/stylesheets/ruby_cms/admin.css.
|
|
25
25
|
- Visit /admin (sign in as the admin you configured).
|
|
26
26
|
|
|
27
27
|
Tracking:
|
|
@@ -215,7 +215,18 @@ module RubyCms
|
|
|
215
215
|
no_tasks do
|
|
216
216
|
def copy_admin_css(dest_dir)
|
|
217
217
|
admin_css_dest = dest_dir.join("admin.css")
|
|
218
|
+
precompiled_admin_css = RubyCms::Engine.root.join("app/assets/stylesheets/ruby_cms/admin.css")
|
|
219
|
+
if File.exist?(precompiled_admin_css) && File.size(precompiled_admin_css).to_i.positive?
|
|
220
|
+
FileUtils.cp(precompiled_admin_css, admin_css_dest)
|
|
221
|
+
return
|
|
222
|
+
end
|
|
223
|
+
|
|
218
224
|
RubyCms::Engine.compile_admin_css(admin_css_dest)
|
|
225
|
+
return if File.size(admin_css_dest).to_i > 64
|
|
226
|
+
|
|
227
|
+
say "⚠ Task css/copy: Generated admin.css is very small. " \
|
|
228
|
+
"Ensure RubyCMS ships precompiled CSS at app/assets/stylesheets/ruby_cms/admin.css.",
|
|
229
|
+
:yellow
|
|
219
230
|
end
|
|
220
231
|
|
|
221
232
|
def copy_components_css(src_dir, dest_dir)
|
|
@@ -478,8 +489,8 @@ module RubyCms
|
|
|
478
489
|
end
|
|
479
490
|
|
|
480
491
|
def configure_tailwind(tailwind_css)
|
|
481
|
-
|
|
482
|
-
|
|
492
|
+
remove_ruby_cms_tailwind_source(tailwind_css)
|
|
493
|
+
remove_ruby_cms_tailwind_content_paths
|
|
483
494
|
run "bin/rails tailwindcss:build" if File.exist?(tailwind_css)
|
|
484
495
|
# Importmap pins are provided by the engine via `ruby_cms/config/importmap.rb`.
|
|
485
496
|
add_importmap_pins
|
|
@@ -855,83 +866,45 @@ module RubyCms
|
|
|
855
866
|
end.join("\n")
|
|
856
867
|
end
|
|
857
868
|
|
|
858
|
-
#
|
|
859
|
-
#
|
|
860
|
-
|
|
869
|
+
# RubyCMS admin styles are precompiled to app/assets/stylesheets/ruby_cms/admin.css.
|
|
870
|
+
# Remove RubyCMS-specific Tailwind source globs to keep host-app builds fast.
|
|
871
|
+
# Not a generator task.
|
|
872
|
+
def remove_ruby_cms_tailwind_source(tailwind_css_path)
|
|
861
873
|
return unless tailwind_css_path.to_s.present? && File.exist?(tailwind_css_path)
|
|
862
874
|
|
|
863
875
|
content = File.read(tailwind_css_path)
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
injection = +"\n/* RubyCMS: Tailwind content via tailwindcss-rails engine (see ruby_cms README). */\n"
|
|
867
|
-
injection << "@import \"../builds/tailwind/ruby_cms_engine\";\n"
|
|
868
|
-
|
|
869
|
-
inserted = inject_ruby_cms_engine_import_after_tailwind!(tailwind_css_path, content, injection)
|
|
870
|
-
unless inserted
|
|
871
|
-
inject_into_file tailwind_css_path.to_s, after: /\A/ do
|
|
872
|
-
injection
|
|
873
|
-
end
|
|
874
|
-
end
|
|
876
|
+
cleaned_content = remove_legacy_ruby_cms_tailwind_sources(content)
|
|
877
|
+
return if cleaned_content == content
|
|
875
878
|
|
|
876
|
-
|
|
879
|
+
File.write(tailwind_css_path, cleaned_content)
|
|
880
|
+
say "✓ Task tailwind/source: Removed RubyCMS @source paths from tailwind entry CSS.",
|
|
881
|
+
:green
|
|
877
882
|
rescue StandardError => e
|
|
878
|
-
say "⚠ Task tailwind/source: Could not
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
def inject_ruby_cms_engine_import_after_tailwind!(tailwind_css_path, content, injection)
|
|
882
|
-
patterns = [
|
|
883
|
-
%(@import "tailwindcss";\n),
|
|
884
|
-
%(@import "tailwindcss";),
|
|
885
|
-
%(@import "tailwindcss"\n),
|
|
886
|
-
%(@import "tailwindcss")
|
|
887
|
-
]
|
|
888
|
-
patterns.each do |after_pattern|
|
|
889
|
-
next unless content.include?(after_pattern)
|
|
890
|
-
|
|
891
|
-
inject_into_file tailwind_css_path.to_s, after: after_pattern do
|
|
892
|
-
injection
|
|
893
|
-
end
|
|
894
|
-
return true
|
|
895
|
-
end
|
|
896
|
-
false
|
|
883
|
+
say "⚠ Task tailwind/source: Could not clean @source lines: #{e.message}. " \
|
|
884
|
+
"Check tailwind/application.css manually.",
|
|
885
|
+
:yellow
|
|
897
886
|
end
|
|
898
887
|
|
|
899
|
-
# Tailwind v3
|
|
900
|
-
def
|
|
888
|
+
# Remove RubyCMS content globs from Tailwind v3 config as well.
|
|
889
|
+
def remove_ruby_cms_tailwind_content_paths
|
|
901
890
|
config_path = Rails.root.join("config/tailwind.config.js")
|
|
902
891
|
return unless File.exist?(config_path)
|
|
903
892
|
|
|
904
893
|
content = File.read(config_path)
|
|
905
|
-
|
|
906
|
-
return if
|
|
907
|
-
|
|
908
|
-
inject = "#{patterns.map {|p| " \"#{p}\"," }.join("\n")}\n"
|
|
894
|
+
cleaned = content.gsub(/^\s*["']?[^"'\n]*ruby_cms[^"'\n]*["']?,?\s*$\n?/i, "")
|
|
895
|
+
return if cleaned == content
|
|
909
896
|
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
if content.match?(/content:\s*\[/)
|
|
913
|
-
gsub_file config_path.to_s, /content:\s*\[\s*\n/ do |match|
|
|
914
|
-
inserted = true
|
|
915
|
-
"#{match}#{inject}"
|
|
916
|
-
end
|
|
917
|
-
end
|
|
918
|
-
|
|
919
|
-
return unless inserted
|
|
920
|
-
|
|
921
|
-
say "✓ Task tailwind/content: Added RubyCMS paths to config/tailwind.config.js.", :green
|
|
897
|
+
File.write(config_path, cleaned)
|
|
898
|
+
say "✓ Task tailwind/content: Removed RubyCMS paths from tailwind.config.js.", :green
|
|
922
899
|
rescue StandardError => e
|
|
923
|
-
say "⚠ Task tailwind/content: Could not
|
|
900
|
+
say "⚠ Task tailwind/content: Could not clean tailwind.config.js: #{e.message}.", :yellow
|
|
924
901
|
end
|
|
925
902
|
|
|
926
|
-
def
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
"#{views}/**/*.erb",
|
|
931
|
-
"#{components}/**/*.rb"
|
|
932
|
-
]
|
|
903
|
+
def remove_legacy_ruby_cms_tailwind_sources(content)
|
|
904
|
+
content
|
|
905
|
+
.gsub(%r{^\s*/\*\s*Include RubyCMS views/components so Tailwind finds utility classes\.\s*\*/\s*$\n?}, "")
|
|
906
|
+
.gsub(/^\s*@source\s+"[^"\n]*ruby_cms[^"\n]*";\s*$\n?/i, "")
|
|
933
907
|
end
|
|
934
|
-
|
|
935
908
|
end
|
|
936
909
|
|
|
937
910
|
def run_migrate
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<link rel="manifest" href="<%= asset_path("site.webmanifest") %>">
|
|
16
16
|
|
|
17
17
|
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
|
|
18
|
-
<%= stylesheet_link_tag "
|
|
18
|
+
<%= stylesheet_link_tag "ruby_cms/admin", "data-turbo-track": "reload" rescue nil %>
|
|
19
19
|
<%= stylesheet_link_tag "actiontext", "data-turbo-track": "reload" rescue nil %>
|
|
20
20
|
<%= javascript_importmap_tags "admin" %>
|
|
21
21
|
</head>
|
data/lib/ruby_cms/engine.rb
CHANGED
|
@@ -100,8 +100,7 @@ module RubyCms
|
|
|
100
100
|
# For importmap: ensure engine's importmap is loaded
|
|
101
101
|
if app.config.respond_to?(:importmap)
|
|
102
102
|
app.config.importmap.paths << config.root.join("config/importmap.rb")
|
|
103
|
-
|
|
104
|
-
app.config.importmap.cache_sweepers << config.root.join("app/javascript/controllers/ruby_cms")
|
|
103
|
+
app.config.importmap.cache_sweepers << config.root.join("app/javascript")
|
|
105
104
|
end
|
|
106
105
|
end
|
|
107
106
|
|
|
@@ -263,18 +262,12 @@ module RubyCms
|
|
|
263
262
|
end
|
|
264
263
|
end
|
|
265
264
|
|
|
266
|
-
# True during asset pipeline tasks so we skip DB-heavy initializers (permissions, settings import).
|
|
267
|
-
# Detect by ARGV first: $PROGRAM_NAME is often "ruby" when using `ruby bin/rails`, which would
|
|
268
|
-
# miss the old rake/rails basename check; tailwindcss:build runs as a prerequisite of
|
|
269
|
-
# assets:precompile and keeps the same ARGV, but a standalone `rails tailwindcss:build` must match too.
|
|
270
265
|
def self.assets_precompile_phase?
|
|
271
|
-
argv = Array(ARGV).map(&:to_s)
|
|
272
|
-
return true if argv.include?("assets:precompile")
|
|
273
|
-
return true if argv.any? {|a| a.start_with?("tailwindcss:") }
|
|
274
|
-
return true if argv.include?("propshaft:compile")
|
|
275
|
-
|
|
276
266
|
command = File.basename($PROGRAM_NAME.to_s)
|
|
277
|
-
|
|
267
|
+
rake_assets_precompile = command == "rake" && ARGV.include?("assets:precompile")
|
|
268
|
+
rails_assets_precompile = command == "rails" && ARGV.include?("assets:precompile")
|
|
269
|
+
|
|
270
|
+
rake_assets_precompile || rails_assets_precompile
|
|
278
271
|
end
|
|
279
272
|
end
|
|
280
273
|
end
|
data/lib/ruby_cms/version.rb
CHANGED