rails_app_generator 0.2.22 → 0.2.23

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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/after_templates/addons/devise/_.rb +70 -0
  4. data/after_templates/addons/devise/app/controllers/home_controller.rb +4 -0
  5. data/after_templates/addons/devise/app/controllers/posts_controller.rb +81 -0
  6. data/after_templates/addons/devise/app/models/post.rb +11 -0
  7. data/after_templates/addons/devise/app/models/user.rb +17 -0
  8. data/after_templates/addons/devise/app/views/home/index.html.erb +40 -0
  9. data/after_templates/addons/devise/app/views/layouts/_footer.html.erb +1 -0
  10. data/after_templates/addons/devise/app/views/layouts/_navbar.html.erb +10 -0
  11. data/after_templates/addons/devise/app/views/layouts/application.html.erb +38 -0
  12. data/after_templates/addons/devise/app/views/posts/_form.html.erb +27 -0
  13. data/after_templates/addons/devise/app/views/posts/_post.html.erb +14 -0
  14. data/after_templates/addons/devise/app/views/posts/index.html.erb +12 -0
  15. data/after_templates/addons/devise/app/views/posts/show.html.erb +8 -0
  16. data/after_templates/addons/devise/db/seeds.rb +11 -0
  17. data/after_templates/rag/devise/_.rb +14 -17
  18. data/after_templates/rag/devise/app/controllers/home_controller.rb +4 -0
  19. data/after_templates/rag/devise/{post → app/controllers}/posts_controller.rb +0 -0
  20. data/after_templates/rag/devise/{post → app/models}/post.rb +0 -0
  21. data/after_templates/rag/devise/app/views/home/index.html.erb +3 -0
  22. data/after_templates/rag/devise/app/views/layouts/_footer.html.erb +3 -0
  23. data/after_templates/rag/devise/app/views/layouts/_navbar.html.erb +8 -0
  24. data/after_templates/rag/devise/app/views/layouts/application.html.erb +24 -0
  25. data/after_templates/rag/devise/{post → app/views/post}/_post.html.erb +0 -0
  26. data/after_templates/rag/test/_.rb +64 -0
  27. data/after_templates/rag/test/app/controllers/home_controller.rb +4 -0
  28. data/after_templates/rag/test/app/views/home/index.html.erb +3 -0
  29. data/after_templates/rag/test/app/views/layouts/_footer.html.erb +1 -0
  30. data/after_templates/rag/test/app/views/layouts/_navbar.html.erb +5 -0
  31. data/after_templates/rag/test/app/views/layouts/application.html.erb +29 -0
  32. data/after_templates/rag/test/db/seeds.rb +7 -0
  33. data/after_templates/rag/testy/_.rb +64 -0
  34. data/after_templates/rag/testy/app/controllers/home_controller.rb +4 -0
  35. data/after_templates/rag/testy/app/views/home/index.html.erb +3 -0
  36. data/after_templates/rag/testy/app/views/layouts/_footer.html.erb +1 -0
  37. data/after_templates/rag/testy/app/views/layouts/_navbar.html.erb +5 -0
  38. data/after_templates/rag/testy/app/views/layouts/application.html.erb +29 -0
  39. data/after_templates/rag/testy/db/seeds.rb +7 -0
  40. data/lib/rails_app_generator/addon.rb +20 -2
  41. data/lib/rails_app_generator/addons/devise.rb +111 -0
  42. data/lib/rails_app_generator/addons/devise_old.rb +1 -40
  43. data/lib/rails_app_generator/app_generator.rb +9 -1
  44. data/lib/rails_app_generator/gem_query.rb +34 -0
  45. data/lib/rails_app_generator/rag_initializer.rb +1 -0
  46. data/lib/rails_app_generator/version.rb +1 -1
  47. data/lib/rails_app_generator.rb +1 -0
  48. data/package-lock.json +2 -2
  49. data/package.json +1 -1
  50. data/profiles/addons/devise.json +16 -0
  51. data/profiles/rag/testy.json +12 -0
  52. data/tasks/addon.thor +7 -3
  53. data/tasks/profile.thor +3 -3
  54. data/templates/Gemfile.erb +1 -0
  55. data/{after_templates/rag/devise/turbo_controller.rb → templates/addons/devise/app/controllers/turbo_devise_controller.rb} +4 -10
  56. data/templates/addons/devise/app/controllers/users/registrations_controller.rb +62 -0
  57. data/templates/addons/devise/app/views/devise/registrations/edit.html.erb +40 -54
  58. data/templates/addons/devise/app/views/devise/registrations/new.html.erb +32 -43
  59. data/templates/addons/devise/app/views/layouts/_alerts.html.erb +2 -0
  60. data/{after_templates/rag → templates/addons}/devise/config/initializers/devise_turbo.rb +1 -1
  61. data/templates/thor_task/profile/after_template.rb +1 -1
  62. data/templates/thor_task/profile/app/views/layouts/_footer.html.erb.tt +1 -3
  63. data/templates/thor_task/profile/app/views/layouts/_navbar.html.erb +5 -8
  64. data/templates/thor_task/profile/app/views/layouts/application.html.erb.tt +8 -2
  65. data/templates/thor_task/profile/db/seeds.rb +2 -11
  66. metadata +46 -17
  67. data/after_templates/rag/devise/application.html.erb +0 -20
  68. data/tasks/gem_info.rb +0 -47
  69. data/templates/addons/devise/app/views/devise/confirmations/new.html.erb +0 -24
  70. data/templates/addons/devise/app/views/devise/passwords/edit.html.erb +0 -34
  71. data/templates/addons/devise/app/views/devise/passwords/new.html.erb +0 -23
  72. data/templates/addons/devise/app/views/devise/sessions/new.html.erb +0 -33
  73. data/templates/addons/devise/app/views/devise/shared/_error_messages.html.erb +0 -15
  74. data/templates/addons/devise/app/views/devise/shared/_form_wrap.html.erb +0 -5
  75. data/templates/addons/devise/app/views/devise/shared/_links.html.erb +0 -25
  76. data/templates/addons/devise/app/views/devise/unlocks/new.html.erb +0 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e643271882d2a6f9c9d1e5e417196dbefb08f94c8e7cefe866a7d8493edfaa1
4
- data.tar.gz: 07b93158af7720c52a2384473c3af1605fb7c0f47c031726bc6c3d95888a2c99
3
+ metadata.gz: 0367fdfc5ef1cc2337ac14d29480e9cca42c03decae87bf581d556f6d035535c
4
+ data.tar.gz: a2a9b0008371f06e895fbd8644f12cd52f3ac76a4b6a0caca15275989afbf1d0
5
5
  SHA512:
6
- metadata.gz: 37df302b97eb73a61e0dbc69006c4cc442e3f22a1f37b9e5af94f87fcab9791dccd803f1b28d0919da839fd0f78deeb40b58bc5261e82b34d1494b55b2c4d024
7
- data.tar.gz: 044e8a0f8da4e0915b10fd894c28af8b062d5907bf216fd3afc56f285d32906a2aba767a09baeaece33e41bed0222d39498b337de4669fb2a009695db6902a8f
6
+ metadata.gz: c82cfe7377e2980c71185d5907c7654c89d21367abd4ee592be41a73a94a21259f655827227af469864036c7a5d548b639bea2909531a32128a1474b8e58e9f3
7
+ data.tar.gz: 36f4e3400f0e51f304ef962baefc0ebfcf573642cd6005ad7a0c21337d1a75078a9ad3599b12e85742e3141dd5b7b3e795cb1d10805ee56d9675cea28a5fefbf
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.2.22](https://github.com/klueless-io/rails_app_generator/compare/v0.2.21...v0.2.22) (2022-08-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * update avo profile ([79a3f36](https://github.com/klueless-io/rails_app_generator/commit/79a3f366f9f95e29a5f003a815c1fc963d796179))
7
+ * update avo profile ([2830ddf](https://github.com/klueless-io/rails_app_generator/commit/2830ddff3fd327d2c162ef1e0128dc525b3a493c))
8
+
1
9
  ## [0.2.21](https://github.com/klueless-io/rails_app_generator/compare/v0.2.20...v0.2.21) (2022-08-12)
2
10
 
3
11
 
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Based on guidance from:
4
+ # Rails 7 - Intro to Devise
5
+ # https://www.youtube.com/watch?v=m3uhldUGVes
6
+ #
7
+ # exe/rag addons/devise
8
+
9
+ self.local_template_path = File.dirname(__FILE__)
10
+
11
+ gac 'base rails 7 image created'
12
+
13
+ prepare_environment
14
+
15
+ after_bundle do
16
+ scaffolds
17
+ setup_customizations
18
+ setup_db
19
+ end
20
+
21
+ def scaffolds
22
+ add_scaffold('post', 'title', 'body:text', 'views:integer', 'user:references')
23
+ end
24
+
25
+ def setup_db
26
+ template 'db/seeds.rb' , 'db/seeds.rb'
27
+
28
+ db_migrate
29
+ db_seed
30
+ end
31
+
32
+ def setup_customizations
33
+ route("root 'home#index'")
34
+
35
+ force_copy
36
+
37
+ add_controller('home', 'index')
38
+
39
+ directory "app/controllers"
40
+ directory "app/models"
41
+ directory "app/views"
42
+ template 'app/views/layouts/application.html.erb' , 'app/views/layouts/application.html.erb'
43
+ end
44
+
45
+ # Other template command examples
46
+ # prepare_environment
47
+ # bundle_install
48
+ # css_install('tailwind')
49
+ # rails_command('db:migrate')
50
+ # rails_command('db:migrate')
51
+ # bundle_add('hotwire-rails')
52
+ # rails_command('hotwire:install')
53
+ # run('bin/importmap pin sortablejs')
54
+ # run('npm install daisyui')
55
+ # rubocop
56
+ #
57
+ # directory 'app/assets/images'
58
+ # create_file 'app/assets/stylesheets/custom-bootstrap-import.scss' , read_template('custom-bootstrap-import.scss')
59
+ # append_to_file 'app/assets/config/manifest.js' , read_template('manifest.js')
60
+ # insert_into_file 'app/views/layouts/application.html.erb', read_template('application.html.erb'),
61
+ # before: %( <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>)
62
+ # gsub_file 'app/views/layouts/application.html.erb', %(container mx-auto mt-28 px-5 flex), 'container mx-auto px-5'
63
+ # template 'home.css', 'app/assets/stylesheets/home.css'
64
+ #
65
+ # add_controller('page', 'benefits', 'faq', 'terms', 'privacy', '--skip-routes')
66
+ # route(<<-'RUBY')
67
+ # PageController.action_methods.each do |action|
68
+ # get "/#{action}", to: "page##{action}", as: "page_#{action}"
69
+ # end
70
+ # RUBY
@@ -0,0 +1,4 @@
1
+ class HomeController < ApplicationController
2
+ def index
3
+ end
4
+ end
@@ -0,0 +1,81 @@
1
+ class PostsController < ApplicationController
2
+ before_action :authenticate_user!, except: %i[show index]
3
+ before_action :set_post, only: %i[show edit update destroy]
4
+ before_action :require_permission, only: %i[edit destroy]
5
+
6
+ def index
7
+ @posts = Post.all.order(updated_at: :desc)
8
+ end
9
+
10
+ def show
11
+ @post.update(views: @post.views + 1)
12
+ end
13
+
14
+ def new
15
+ @post = Post.new
16
+ end
17
+
18
+ def edit
19
+ end
20
+
21
+ def create
22
+ @post = Post.new(post_params)
23
+ @post.user = current_user
24
+
25
+ respond_to do |format|
26
+ if @post.save
27
+ format.html { redirect_to post_url(@post), notice: "Post was successfully created." }
28
+ format.json { render :show, status: :created, location: @post }
29
+ else
30
+ format.html { render :new, status: :unprocessable_entity }
31
+ format.json { render json: @post.errors, status: :unprocessable_entity }
32
+ end
33
+ end
34
+ end
35
+
36
+ def update
37
+ respond_to do |format|
38
+ if @post.update(post_params)
39
+ format.html { redirect_to post_url(@post), notice: "Post was successfully updated." }
40
+ format.json { render :show, status: :ok, location: @post }
41
+ else
42
+ format.html { render :edit, status: :unprocessable_entity }
43
+ format.json { render json: @post.errors, status: :unprocessable_entity }
44
+ end
45
+ end
46
+ end
47
+
48
+ def destroy
49
+ @post.destroy
50
+
51
+ respond_to do |format|
52
+ format.html { redirect_to posts_url, notice: "Post was successfully destroyed." }
53
+ format.json { head :no_content }
54
+ end
55
+ end
56
+
57
+ private
58
+ def set_post
59
+ @post = Post.find(params[:id])
60
+ end
61
+
62
+ def post_params
63
+ params.require(:post).permit(:title, :body, :views, :user_id)
64
+ end
65
+
66
+ def require_permission
67
+ current_user_name = current_user.name.capitalize
68
+ post_user_name = @post.user.name.capitalize
69
+ post_user_name_plural = "#{post_user_name}#{post_user_name.ends_with?('s') ? "'" : "s"}"
70
+
71
+ flash.notice = "#{current_user_name} is trying to #{action_name} #{post_user_name_plural} post."
72
+
73
+ return if current_user.admin? # Administrators can do anything
74
+ return if current_user.moderator? && action_name == "edit" # Moderators can edit any post (but not delete)
75
+ return if current_user.user? && @post.user == current_user # Users can edit or delete their own posts
76
+
77
+ flash.alert = "You do not have permission to #{action_name} #{post_user_name_plural} post."
78
+
79
+ redirect_back(fallback_location: root_path)
80
+ end
81
+ end
@@ -0,0 +1,11 @@
1
+ class Post < ApplicationRecord
2
+ after_initialize :set_views, if: :new_record?
3
+
4
+ belongs_to :user
5
+
6
+ private
7
+
8
+ def set_views
9
+ self.views ||= 0
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ class User < ApplicationRecord
2
+ after_initialize :set_default_role, if: :new_record?
3
+
4
+ # Include default devise modules. Others available are:
5
+ # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
6
+ devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable
7
+
8
+ has_many :posts
9
+
10
+ enum role: { user: 0, moderator: 1, admin: 9 }
11
+
12
+ private
13
+
14
+ def set_default_role
15
+ self.role ||= :user
16
+ end
17
+ end
@@ -0,0 +1,40 @@
1
+ <h1>Devise</h1>
2
+
3
+ <h4>Using a simple Enum based Role for permissions</h4>
4
+
5
+ <ul>
6
+ <li>Anyone can view posts</li>
7
+ <li>Only signed in users can create, update or delete a post</li>
8
+ <li>If role <b>user</b>, you can update and delete your own posts only</li>
9
+ <li>If role <b>moderator</b>, you can update any post, but only delete your own posts</li>
10
+ <li>If role <b>admin</b>, you can update or delete any post</li>
11
+ </ul>
12
+
13
+ <h3>Sample users and passwords</h3>
14
+
15
+ <style>
16
+ table {
17
+ border-collapse: collapse;
18
+ }
19
+ th, td {
20
+ border: 1px solid #ccc;
21
+ padding: 5px;
22
+ }
23
+ </style>
24
+
25
+ <table style='width: 600px;'>
26
+ <tr>
27
+ <th>Name</th>
28
+ <th>Email</th>
29
+ <th>Role</th>
30
+ <th>Password</th>
31
+ </tr>
32
+ <% User.all.each do |user| %>
33
+ <tr>
34
+ <td><%= user.name %></td>
35
+ <td><%= user.email %></td>
36
+ <td><%= user.role %></td>
37
+ <td>password</td>
38
+ </tr>
39
+ <% end %>
40
+ </table>
@@ -0,0 +1,10 @@
1
+ <%= link_to 'Home', root_path %>
2
+ | <%= link_to 'Posts', posts_path %>
3
+ <% if current_user %>
4
+ <%= current_user.name || current_user.email %>
5
+ | <%= link_to 'Edit', edit_user_registration_path %>
6
+ | <%= link_to 'Sign Out', destroy_user_session_path, data: { turbo_method: :delete } %>
7
+ <% else %>
8
+ | <%= link_to 'Sign Up', new_user_registration_path %>
9
+ | <%= link_to 'Sign In', new_user_session_path %>
10
+ <% end%>
@@ -0,0 +1,38 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= camelized %></title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <%%= csrf_meta_tags %>
7
+ <%%= csp_meta_tag %>
8
+
9
+ <%- if options[:skip_hotwire] || options[:skip_javascript] -%>
10
+ <%%= stylesheet_link_tag "application" %>
11
+ <%- else -%>
12
+ <%%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
13
+ <%- end -%>
14
+ <%%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
15
+ <style>
16
+ .notice {
17
+ color: green;
18
+ }
19
+ .alert {
20
+ color: red;
21
+ }
22
+ </style>
23
+ </head>
24
+
25
+ <body>
26
+ <header>
27
+ <%%= render 'layouts/navbar' %>
28
+ <hr />
29
+ <%%= render 'layouts/alerts' %>
30
+ </header>
31
+ <main>
32
+ <%%= yield %>
33
+ </main>
34
+ <footer>
35
+ <%%= render 'layouts/footer' %>
36
+ </footer>
37
+ </body>
38
+ </html>
@@ -0,0 +1,27 @@
1
+ <%= form_with(model: post) do |form| %>
2
+ <% if post.errors.any? %>
3
+ <div style="color: red">
4
+ <h2><%= pluralize(post.errors.count, "error") %> prohibited this post from being saved:</h2>
5
+
6
+ <ul>
7
+ <% post.errors.each do |error| %>
8
+ <li><%= error.full_message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div>
15
+ <%= form.label :title, style: "display: block" %>
16
+ <%= form.text_field :title %>
17
+ </div>
18
+
19
+ <div>
20
+ <%= form.label :body, style: "display: block" %>
21
+ <%= form.text_area :body %>
22
+ </div>
23
+
24
+ <div>
25
+ <%= form.submit %>
26
+ </div>
27
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <div id="<%= dom_id post %>">
2
+ <h3>posted by <%= post.user.name || post.user.email %></h4>
3
+ <h4><%= pluralize(post.views, 'view') %></h4>
4
+
5
+ <p>
6
+ <strong>Title:</strong>
7
+ <%= post.title %>
8
+ </p>
9
+
10
+ <p>
11
+ <strong>Body:</strong>
12
+ <%= post.body %>
13
+ </p>
14
+ </div>
@@ -0,0 +1,12 @@
1
+ <h1>Posts</h1>
2
+
3
+ <div id="posts">
4
+ <% @posts.each do |post| %>
5
+ <%= render post %>
6
+ <p>
7
+ <%= link_to "Show this post", post %>
8
+ </p>
9
+ <% end %>
10
+ </div>
11
+
12
+ <%= link_to "New post", new_post_path %>
@@ -0,0 +1,8 @@
1
+ <%= render @post %>
2
+
3
+ <div>
4
+ <%= link_to "Edit this post", edit_post_path(@post) %> |
5
+ <%= link_to "Back to posts", posts_path %>
6
+
7
+ <%= button_to "Destroy this post", @post, method: :delete %>
8
+ </div>
@@ -0,0 +1,11 @@
1
+ david = User.create(email: 'david@site.com', name: 'david', password: 'password', password_confirmation: 'password', role: :admin)
2
+ james = User.create(email: 'james@site.com', name: 'james', password: 'password', password_confirmation: 'password')
3
+ sally = User.create(email: 'sally@site.com', name: 'sally', password: 'password', password_confirmation: 'password', role: :moderator)
4
+
5
+ 10.times do
6
+ Post.create(
7
+ title: "Post #{Faker::Lorem.words(number: rand(1..3)).join(' ')}",
8
+ body: "#{Faker::Lorem.sentences(number: 8).join("<br />")}",
9
+ views: 0,
10
+ user: User.all.sample)
11
+ end
@@ -7,35 +7,32 @@ self.local_template_path = File.dirname(__FILE__)
7
7
 
8
8
  gac 'base rails 7 image created'
9
9
 
10
- # generate('devise:views')
10
+ prepare_environment
11
11
 
12
+ add_controller('home', 'index')
12
13
  add_scaffold('post', 'title', 'body:text')
13
- route("root 'posts#index'")
14
+ # route("root 'posts#index'")
15
+ # generate('devise:views')
14
16
 
15
17
  force_copy
16
18
 
17
- copy_file 'application_controller.rb' , 'app/controllers/application_controller.rb'
18
- copy_file 'turbo_controller.rb' , 'app/controllers/turbo_controller.rb'
19
+ directory "app/controllers"
20
+ directory "app/views"
19
21
 
20
- copy_file 'layouts/_alerts.html.erb' , 'app/views/layouts/_alerts.html.erb'
21
- copy_file 'layouts/_navbar.html.erb' , 'app/views/layouts/_navbar.html.erb'
22
- copy_file 'layouts/_footer.html.erb' , 'app/views/layouts/_footer.html.erb'
23
- template 'layouts/application.html.erb' , 'app/views/layouts/application.html.erb'
22
+ # copy_file 'application_controller.rb' , 'app/controllers/application_controller.rb'
24
23
 
25
- copy_file 'config/initializers/devise_turbo.rb' , 'config/initializers/devise_turbo.rb'
26
-
27
- copy_file 'post/posts_controller.rb' , 'app/controllers/posts_controller.rb'
28
- copy_file 'post/_post.html.erb' , 'app/views/posts/_post.html.erb'
29
- copy_file 'post/post.rb' , 'app/models/post.rb'
24
+ # copy_file 'layouts/_alerts.html.erb' , 'app/views/layouts/_alerts.html.erb'
25
+ # copy_file 'layouts/_navbar.html.erb' , 'app/views/layouts/_navbar.html.erb'
26
+ # copy_file 'layouts/_footer.html.erb' , 'app/views/layouts/_footer.html.erb'
27
+ # template 'layouts/application.html.erb' , 'app/views/layouts/application.html.erb'
30
28
 
31
29
  copy_file 'user.rb' , 'app/models/user.rb'
32
30
 
33
- copy_file 'application.html.erb' , 'app/views/layouts/application.html.erb'
34
- copy_file 'application_controller.rb' , 'app/controllers/application_controller.rb'
35
-
36
- add_migration('add_user_to_posts', 'user:belongs_to')
31
+ # copy_file 'application.html.erb' , 'app/views/layouts/application.html.erb'
32
+ # copy_file 'application_controller.rb' , 'app/controllers/application_controller.rb'
37
33
 
38
34
  after_bundle do
35
+ add_migration('add_user_to_posts', 'user:belongs_to')
39
36
  db_migrate
40
37
 
41
38
  append_to_file('db/seeds.rb', read_template('seed_data.rb'))
@@ -0,0 +1,4 @@
1
+ class HomeController < ApplicationController
2
+ def index
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ <h1>Devise</h1>
2
+
3
+ <p></p>
@@ -0,0 +1,3 @@
1
+ <footer>
2
+ <hr />
3
+ </footer>
@@ -0,0 +1,8 @@
1
+ <header>
2
+ <%= link_to 'Home', root_path %> |
3
+ <%# link_to 'Some Action', home_some_action_path %> |
4
+ <%# link_to 'Products', products_path %> |
5
+ <%# link_to 'Posts', posts_path %> |
6
+ <%# link_to 'People', people_path %>
7
+ <hr />
8
+ </header>
@@ -0,0 +1,24 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= camelized %></title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <%%= csrf_meta_tags %>
7
+ <%%= csp_meta_tag %>
8
+
9
+ <%- if options[:skip_hotwire] || options[:skip_javascript] -%>
10
+ <%%= stylesheet_link_tag "application" %>
11
+ <%- else -%>
12
+ <%%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
13
+ <%- end -%>
14
+ </head>
15
+
16
+ <body>
17
+ <%%= render 'layouts/navbar' %>
18
+ <%%= render 'layouts/alert' %>
19
+ <main>
20
+ <%%= yield %>
21
+ </main>
22
+ <%%= render 'layouts/footer' %>
23
+ </body>
24
+ </html>
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Description goes here
4
+ #
5
+ # exe/rag addons/test
6
+
7
+ self.local_template_path = File.dirname(__FILE__)
8
+
9
+ gac 'base rails 7 image created'
10
+
11
+ prepare_environment
12
+
13
+ add_controller('home', 'index')
14
+
15
+ route("root 'home#index'")
16
+
17
+ force_copy
18
+
19
+ directory "app/controllers"
20
+ directory "app/views/home"
21
+ directory "app/views/layouts"
22
+ template 'app/views/layouts/application.html.erb' , 'app/views/layouts/application.html.erb'
23
+
24
+ template 'db/seeds.rb' , 'db/seeds.rb'
25
+
26
+ after_bundle do
27
+ setup_db
28
+ end
29
+
30
+ def setup_db
31
+ # add_scaffold('post', 'title', 'body:text', 'user:references')
32
+ # add_scaffold('people', 'first_name', 'last_name', 'age:integer', 'address:text')
33
+ # add_scaffold('product', 'name', 'price:integer')
34
+
35
+ # db_migrate
36
+ # db_seed
37
+ end
38
+
39
+ # Other template command examples
40
+ # prepare_environment
41
+ # bundle_install
42
+ # css_install('tailwind')
43
+ # rails_command('db:migrate')
44
+ # rails_command('db:migrate')
45
+ # bundle_add('hotwire-rails')
46
+ # rails_command('hotwire:install')
47
+ # run('bin/importmap pin sortablejs')
48
+ # run('npm install daisyui')
49
+ # rubocop
50
+ #
51
+ # directory 'app/assets/images'
52
+ # create_file 'app/assets/stylesheets/custom-bootstrap-import.scss' , read_template('custom-bootstrap-import.scss')
53
+ # append_to_file 'app/assets/config/manifest.js' , read_template('manifest.js')
54
+ # insert_into_file 'app/views/layouts/application.html.erb', read_template('application.html.erb'),
55
+ # before: %( <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>)
56
+ # gsub_file 'app/views/layouts/application.html.erb', %(container mx-auto mt-28 px-5 flex), 'container mx-auto px-5'
57
+ # template 'home.css', 'app/assets/stylesheets/home.css'
58
+ #
59
+ # add_controller('page', 'benefits', 'faq', 'terms', 'privacy', '--skip-routes')
60
+ # route(<<-'RUBY')
61
+ # PageController.action_methods.each do |action|
62
+ # get "/#{action}", to: "page##{action}", as: "page_#{action}"
63
+ # end
64
+ # RUBY
@@ -0,0 +1,4 @@
1
+ class HomeController < ApplicationController
2
+ def index
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ <h1>Test</h1>
2
+
3
+ <p>Description goes here</p>
@@ -0,0 +1,5 @@
1
+ <%= link_to 'Home', root_path %>
2
+ <%# link_to 'Products', products_path %>
3
+ <%# link_to 'Posts', posts_path %>
4
+ <%# link_to 'People', people_path %>
5
+ <hr />
@@ -0,0 +1,29 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= camelized %></title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <%%= csrf_meta_tags %>
7
+ <%%= csp_meta_tag %>
8
+
9
+ <%- if options[:skip_hotwire] || options[:skip_javascript] -%>
10
+ <%%= stylesheet_link_tag "application" %>
11
+ <%- else -%>
12
+ <%%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
13
+ <%- end -%>
14
+ </head>
15
+
16
+ <body>
17
+ <header>
18
+ <%%= render 'layouts/navbar' %>
19
+ <hr />
20
+ </header>
21
+ <main>
22
+ <%%= yield %>
23
+ </main>
24
+ <footer>
25
+ <%%= render 'layouts/footer' %>
26
+ </footer>
27
+ </body>
28
+ </html>
29
+
@@ -0,0 +1,7 @@
1
+ # david = User.create(email: 'david@site.com', name: 'david', password: 'password')
2
+ # james = User.create(email: 'james@site.com', name: 'james', password: 'password')
3
+ # sally = User.create(email: 'sally@site.com', name: 'sally', password: 'password')
4
+
5
+ # 10.times do |i|
6
+ # Post.create(title: "Post #{i}", body: "This is the body of post #{i}", user: User.all.sample)
7
+ # end