strada-rails 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/strada/scaffold/templates/edit.html.erb.tt +2 -2
- data/lib/generators/strada/scaffold/templates/index.html.erb.tt +1 -1
- data/lib/generators/strada/scaffold/templates/new.html.erb.tt +2 -2
- data/lib/generators/strada/scaffold/templates/show.html.erb.tt +1 -1
- data/lib/install/app/assets/stylesheets/strada.css +1 -1
- data/lib/install/app/javascript/controllers/bridge/nav_button_controller.js +4 -1
- data/lib/install/strada_with_bun.rb +28 -0
- data/lib/install/strada_with_importmap.rb +13 -7
- data/lib/install/strada_with_node.rb +16 -7
- data/lib/strada/version.rb +1 -1
- data/lib/tasks/strada_tasks.rake +21 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb9228de23e4d69eddc81e12af66c15a298b9b867024701af1e37c2a4fa33589
|
4
|
+
data.tar.gz: fdbfda34a88d91bfbf73084d3b0565686d89a92ec6a30b83d711b762dbb974f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f56d6ea102e136c7e5e9ea6ab74bdd9b12846c5294f1338bced53e52cb1d097e9087196edac25c5dcde42829c5a4bf13b774327910cbe1933150424d960576d
|
7
|
+
data.tar.gz: e626f6fb0a22c11ef2f734c2ffd94bd49088b1ea54af4181bbc811bd11431ab5cba306cd83c544e253d7088b7b13d8e4924d18221c539e4febb5b5b03cfcfee5
|
@@ -1,10 +1,10 @@
|
|
1
|
-
<h1 class="hide-on-
|
1
|
+
<h1 class="hide-on-native">Editing <%= human_name.downcase %></h1>
|
2
2
|
|
3
3
|
<%%= render "form", <%= singular_table_name %>: @<%= singular_table_name %> %>
|
4
4
|
|
5
5
|
<br>
|
6
6
|
|
7
|
-
<div class="hide-on-
|
7
|
+
<div class="hide-on-native">
|
8
8
|
<%%= link_to "Show this <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %> %> |
|
9
9
|
<%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %> %>
|
10
10
|
</div>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<p style="color: green" data-controller="bridge--flash-message"><%%= notice %></p>
|
3
3
|
<%% end %>
|
4
4
|
|
5
|
-
<h1 class="hide-on-
|
5
|
+
<h1 class="hide-on-native"><%= human_name.pluralize %></h1>
|
6
6
|
|
7
7
|
<div id="<%= plural_table_name %>">
|
8
8
|
<%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
|
@@ -1,9 +1,9 @@
|
|
1
|
-
<h1 class="hide-on-
|
1
|
+
<h1 class="hide-on-native">New <%= human_name.downcase %></h1>
|
2
2
|
|
3
3
|
<%%= render "form", <%= singular_table_name %>: @<%= singular_table_name %> %>
|
4
4
|
|
5
5
|
<br>
|
6
6
|
|
7
|
-
<div class="hide-on-
|
7
|
+
<div class="hide-on-native">
|
8
8
|
<%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %> %>
|
9
9
|
</div>
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<%%= render @<%= singular_table_name %> %>
|
6
6
|
|
7
7
|
<div>
|
8
|
-
<div class="hide-on-
|
8
|
+
<div class="hide-on-native">
|
9
9
|
<%%= link_to "Edit this <%= human_name.downcase %>", <%= edit_helper(type: :path) %>, data: { controller: "bridge--nav-button", bridge_title: "Edit" } %> |
|
10
10
|
<%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %> %>
|
11
11
|
</div>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
APPLICATION_LAYOUT_PATH = Rails.root.join("app/views/layouts/application.html.erb")
|
2
|
+
|
3
|
+
destination = Pathname(destination_root)
|
4
|
+
|
5
|
+
say "Copy bridge controllers"
|
6
|
+
directory "#{__dir__}/app/javascript/controllers/bridge", "app/javascript/controllers/bridge"
|
7
|
+
|
8
|
+
say "Update stimulus manifest"
|
9
|
+
rails_command "stimulus:manifest:update"
|
10
|
+
|
11
|
+
say "Copy strada stylesheet"
|
12
|
+
copy_file "#{__dir__}/app/assets/stylesheets/strada.css", "app/assets/stylesheets/strada.css"
|
13
|
+
|
14
|
+
unless destination.join("app/assets/application.css").exist?
|
15
|
+
if (stylesheets = Dir.glob "#{destination_root}/app/assets/stylesheets/application.*.{scss,css}").length > 0
|
16
|
+
insert_into_file stylesheets.first.to_s, %(@import 'strada.css';)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
say "Add hide-on-native style in application layout"
|
21
|
+
insert_into_file APPLICATION_LAYOUT_PATH.to_s, <<~ERB.indent(4).prepend("\n"), before: /^\s*<\/head>/
|
22
|
+
<% if turbo_native_app? %>
|
23
|
+
<style>.hide-on-native { display: none; }</style>
|
24
|
+
<% end %>
|
25
|
+
ERB
|
26
|
+
|
27
|
+
say "Install Strada"
|
28
|
+
run "bun add @hotwired/stimulus"
|
@@ -1,10 +1,6 @@
|
|
1
1
|
APPLICATION_LAYOUT_PATH = Rails.root.join("app/views/layouts/application.html.erb")
|
2
2
|
|
3
|
-
|
4
|
-
<% if turbo_native_app? %>
|
5
|
-
<style>.hide-on-mobile { display: none; }</style>
|
6
|
-
<% end %>
|
7
|
-
HTML
|
3
|
+
destination = Pathname(destination_root)
|
8
4
|
|
9
5
|
say "Copy bridge controllers"
|
10
6
|
directory "#{__dir__}/app/javascript/controllers/bridge", "app/javascript/controllers/bridge"
|
@@ -12,8 +8,18 @@ directory "#{__dir__}/app/javascript/controllers/bridge", "app/javascript/contro
|
|
12
8
|
say "Copy strada stylesheet"
|
13
9
|
copy_file "#{__dir__}/app/assets/stylesheets/strada.css", "app/assets/stylesheets/strada.css"
|
14
10
|
|
15
|
-
|
16
|
-
|
11
|
+
unless destination.join("app/assets/application.css").exist?
|
12
|
+
if (stylesheets = Dir.glob "#{destination_root}/app/assets/stylesheets/application.*.{scss,css}").length > 0
|
13
|
+
insert_into_file stylesheets.first.to_s, %(@import 'strada.css';)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
say "Add hide-on-native style in application layout"
|
18
|
+
insert_into_file APPLICATION_LAYOUT_PATH.to_s, <<~ERB.indent(4).prepend("\n"), before: /^\s*<\/head>/
|
19
|
+
<% if turbo_native_app? %>
|
20
|
+
<style>.hide-on-native { display: none; }</style>
|
21
|
+
<% end %>
|
22
|
+
ERB
|
17
23
|
|
18
24
|
say "Pin Strada"
|
19
25
|
say %(Appending: pin "@hotwired/strada", to: "strada.js", preload: true")
|
@@ -1,19 +1,28 @@
|
|
1
1
|
APPLICATION_LAYOUT_PATH = Rails.root.join("app/views/layouts/application.html.erb")
|
2
2
|
|
3
|
-
|
4
|
-
<% if turbo_native_app? %>
|
5
|
-
<style>.hide-on-mobile { display: none; }</style>
|
6
|
-
<% end %>
|
7
|
-
HTML
|
3
|
+
destination = Pathname(destination_root)
|
8
4
|
|
9
5
|
say "Copy bridge controllers"
|
10
6
|
directory "#{__dir__}/app/javascript/controllers/bridge", "app/javascript/controllers/bridge"
|
11
7
|
|
8
|
+
say "Update stimulus manifest"
|
9
|
+
rails_command "stimulus:manifest:update"
|
10
|
+
|
12
11
|
say "Copy strada stylesheet"
|
13
12
|
copy_file "#{__dir__}/app/assets/stylesheets/strada.css", "app/assets/stylesheets/strada.css"
|
14
13
|
|
15
|
-
|
16
|
-
|
14
|
+
unless destination.join("app/assets/application.css").exist?
|
15
|
+
if (stylesheets = Dir.glob "#{destination_root}/app/assets/stylesheets/application.*.{scss,css}").length > 0
|
16
|
+
insert_into_file stylesheets.first.to_s, %(@import 'strada.css';)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
say "Add hide-on-native style in application layout"
|
21
|
+
insert_into_file APPLICATION_LAYOUT_PATH.to_s, <<~ERB.indent(4).prepend("\n"), before: /^\s*<\/head>/
|
22
|
+
<% if turbo_native_app? %>
|
23
|
+
<style>.hide-on-native { display: none; }</style>
|
24
|
+
<% end %>
|
25
|
+
ERB
|
17
26
|
|
18
27
|
say "Install Strada"
|
19
28
|
run "yarn add @hotwired/strada"
|
data/lib/strada/version.rb
CHANGED
data/lib/tasks/strada_tasks.rake
CHANGED
@@ -2,12 +2,26 @@ def run_strada_install_template(path)
|
|
2
2
|
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/#{path}.rb", __dir__)}"
|
3
3
|
end
|
4
4
|
|
5
|
+
def install_strada_with_importmap?
|
6
|
+
Rails.root.join("config/importmap.rb").exist?
|
7
|
+
end
|
8
|
+
|
9
|
+
def install_strada_with_bun?
|
10
|
+
Rails.root.join("package.json").exist? && Rails.root.join("bun.config.js").exist?
|
11
|
+
end
|
12
|
+
|
13
|
+
def install_strada_with_node?
|
14
|
+
Rails.root.join("package.json").exist? && !Rails.root.join("bun.config.js").exist?
|
15
|
+
end
|
16
|
+
|
5
17
|
namespace :strada do
|
6
18
|
desc "Install Strada into the app"
|
7
19
|
task :install do
|
8
|
-
if
|
20
|
+
if install_strada_with_importmap?
|
9
21
|
Rake::Task["strada:install:importmap"].invoke
|
10
|
-
elsif
|
22
|
+
elsif install_strada_with_bun?
|
23
|
+
Rake::Task["strada:install:bun"].invoke
|
24
|
+
elsif install_strada_with_node?
|
11
25
|
Rake::Task["strada:install:node"].invoke
|
12
26
|
else
|
13
27
|
puts "You must either be running with node (package.json) or importmap-rails (config/importmap.rb) to use this gem."
|
@@ -24,5 +38,10 @@ namespace :strada do
|
|
24
38
|
task :node do
|
25
39
|
run_strada_install_template "strada_with_node"
|
26
40
|
end
|
41
|
+
|
42
|
+
desc "Install Stimulus on an app running bun"
|
43
|
+
task :bun do
|
44
|
+
run_strada_install_template "strada_with_bun"
|
45
|
+
end
|
27
46
|
end
|
28
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strada-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nixon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- lib/install/app/javascript/controllers/bridge/form_controller.js
|
59
59
|
- lib/install/app/javascript/controllers/bridge/menu_controller.js
|
60
60
|
- lib/install/app/javascript/controllers/bridge/nav_button_controller.js
|
61
|
+
- lib/install/strada_with_bun.rb
|
61
62
|
- lib/install/strada_with_importmap.rb
|
62
63
|
- lib/install/strada_with_node.rb
|
63
64
|
- lib/strada-rails.rb
|
@@ -85,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
86
|
- !ruby/object:Gem::Version
|
86
87
|
version: '0'
|
87
88
|
requirements: []
|
88
|
-
rubygems_version: 3.4.
|
89
|
+
rubygems_version: 3.4.20
|
89
90
|
signing_key:
|
90
91
|
specification_version: 4
|
91
92
|
summary: Create fully native controls, driven by your web app.
|