ruby_cms 0.2.0.4 → 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
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
|
@@ -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,114 +866,44 @@ module RubyCms
|
|
|
855
866
|
end.join("\n")
|
|
856
867
|
end
|
|
857
868
|
|
|
858
|
-
#
|
|
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.
|
|
859
871
|
# Not a generator task.
|
|
860
|
-
def
|
|
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
|
-
return if
|
|
876
|
+
cleaned_content = remove_legacy_ruby_cms_tailwind_sources(content)
|
|
877
|
+
return if cleaned_content == content
|
|
866
878
|
|
|
867
|
-
|
|
879
|
+
File.write(tailwind_css_path, cleaned_content)
|
|
880
|
+
say "✓ Task tailwind/source: Removed RubyCMS @source paths from tailwind entry CSS.",
|
|
881
|
+
:green
|
|
868
882
|
rescue StandardError => e
|
|
869
|
-
say "⚠ Task tailwind/source: Could not
|
|
883
|
+
say "⚠ Task tailwind/source: Could not clean @source lines: #{e.message}. " \
|
|
884
|
+
"Check tailwind/application.css manually.",
|
|
885
|
+
:yellow
|
|
870
886
|
end
|
|
871
887
|
|
|
872
|
-
# Tailwind v3
|
|
873
|
-
def
|
|
888
|
+
# Remove RubyCMS content globs from Tailwind v3 config as well.
|
|
889
|
+
def remove_ruby_cms_tailwind_content_paths
|
|
874
890
|
config_path = Rails.root.join("config/tailwind.config.js")
|
|
875
891
|
return unless File.exist?(config_path)
|
|
876
892
|
|
|
877
893
|
content = File.read(config_path)
|
|
878
|
-
|
|
879
|
-
return if
|
|
880
|
-
|
|
881
|
-
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
|
|
882
896
|
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
if content.match?(/content:\s*\[/)
|
|
886
|
-
gsub_file config_path.to_s, /content:\s*\[\s*\n/ do |match|
|
|
887
|
-
inserted = true
|
|
888
|
-
"#{match}#{inject}"
|
|
889
|
-
end
|
|
890
|
-
end
|
|
891
|
-
|
|
892
|
-
return unless inserted
|
|
893
|
-
|
|
894
|
-
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
|
|
895
899
|
rescue StandardError => e
|
|
896
|
-
say "⚠ Task tailwind/content: Could not
|
|
900
|
+
say "⚠ Task tailwind/content: Could not clean tailwind.config.js: #{e.message}.", :yellow
|
|
897
901
|
end
|
|
898
902
|
|
|
899
|
-
def
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
"#{views}/**/*.erb",
|
|
904
|
-
"#{components}/**/*.rb"
|
|
905
|
-
]
|
|
906
|
-
end
|
|
907
|
-
|
|
908
|
-
def build_gem_source_lines(tailwind_css_path)
|
|
909
|
-
css_dir = Pathname.new(tailwind_css_path).dirname
|
|
910
|
-
gem_views = path_relative_to_css_or_absolute(RubyCms::Engine.root.join("app/views"),
|
|
911
|
-
css_dir)
|
|
912
|
-
gem_components = path_relative_to_css_or_absolute(
|
|
913
|
-
RubyCms::Engine.root.join("app/components"), css_dir
|
|
914
|
-
)
|
|
915
|
-
[
|
|
916
|
-
%(@source "#{gem_views}/**/*.erb";),
|
|
917
|
-
%(@source "#{gem_components}/**/*.rb";)
|
|
918
|
-
]
|
|
919
|
-
end
|
|
920
|
-
|
|
921
|
-
def path_relative_to_css_or_absolute(target_path, css_dir)
|
|
922
|
-
Pathname.new(target_path).relative_path_from(css_dir).to_s
|
|
923
|
-
rescue ArgumentError
|
|
924
|
-
# Different mount/volume: fall back to absolute path.
|
|
925
|
-
Pathname.new(target_path).to_s
|
|
926
|
-
end
|
|
927
|
-
|
|
928
|
-
def inject_tailwind_source(tailwind_css_path, content, gem_source_lines)
|
|
929
|
-
to_inject = build_tailwind_source_injection(gem_source_lines)
|
|
930
|
-
inserted = try_insert_after_patterns?(tailwind_css_path, content, to_inject)
|
|
931
|
-
inject_at_start(tailwind_css_path, to_inject) unless inserted
|
|
932
|
-
say "✓ Task tailwind/source: Added @source for RubyCMS views/components to " \
|
|
933
|
-
"tailwind/application.css.",
|
|
934
|
-
:green
|
|
935
|
-
end
|
|
936
|
-
|
|
937
|
-
def build_tailwind_source_injection(gem_source_lines)
|
|
938
|
-
to_inject = +"\n/* Include RubyCMS views/components so Tailwind finds utility classes. */\n"
|
|
939
|
-
Array(gem_source_lines).each {|line| to_inject << line << "\n" }
|
|
940
|
-
to_inject << "\n"
|
|
941
|
-
to_inject
|
|
942
|
-
end
|
|
943
|
-
|
|
944
|
-
def try_insert_after_patterns?(tailwind_css_path, content, to_inject)
|
|
945
|
-
patterns = [
|
|
946
|
-
%(@import "tailwindcss";\n),
|
|
947
|
-
%(@import "tailwindcss";),
|
|
948
|
-
%(@import "tailwindcss"\n),
|
|
949
|
-
%(@import "tailwindcss")
|
|
950
|
-
]
|
|
951
|
-
patterns.each do |after_pattern|
|
|
952
|
-
next unless content.include?(after_pattern)
|
|
953
|
-
|
|
954
|
-
inject_into_file tailwind_css_path.to_s, after: after_pattern do
|
|
955
|
-
to_inject
|
|
956
|
-
end
|
|
957
|
-
return true
|
|
958
|
-
end
|
|
959
|
-
false
|
|
960
|
-
end
|
|
961
|
-
|
|
962
|
-
def inject_at_start(tailwind_css_path, to_inject)
|
|
963
|
-
inject_into_file tailwind_css_path.to_s, after: /\A/ do
|
|
964
|
-
to_inject
|
|
965
|
-
end
|
|
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, "")
|
|
966
907
|
end
|
|
967
908
|
end
|
|
968
909
|
|
|
@@ -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/version.rb
CHANGED