rails_app_generator 0.1.14 → 0.1.15

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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/CHANGELOG.md +7 -0
  4. data/after_templates/addons/acts_as_list/_.rb +62 -0
  5. data/after_templates/addons/acts_as_list/app/controllers/home_controller.rb +7 -0
  6. data/after_templates/addons/acts_as_list/app/controllers/todo_items_controller.rb +132 -0
  7. data/after_templates/addons/acts_as_list/app/models/todo_item.rb +23 -0
  8. data/after_templates/addons/acts_as_list/app/models/todo_list.rb +12 -0
  9. data/after_templates/addons/acts_as_list/app/views/home/index.html.erb +23 -0
  10. data/after_templates/addons/acts_as_list/app/views/layouts/_alerts.html.erb +2 -0
  11. data/after_templates/addons/acts_as_list/app/views/layouts/_footer.html.erb +3 -0
  12. data/after_templates/addons/acts_as_list/app/views/layouts/_navbar.html.erb +8 -0
  13. data/after_templates/addons/acts_as_list/app/views/layouts/application.html.erb +28 -0
  14. data/after_templates/addons/acts_as_list/app/views/todo_items/_todo_item.html.erb +21 -0
  15. data/after_templates/addons/acts_as_list/app/views/todo_items/index.html.erb +25 -0
  16. data/after_templates/addons/acts_as_list/config/routes.rb +15 -0
  17. data/after_templates/addons/acts_as_list/db/seeds.rb +17 -0
  18. data/lib/rails_app_generator/addons/acts_as_list.rb +26 -0
  19. data/lib/rails_app_generator/version.rb +1 -1
  20. data/package-lock.json +2 -2
  21. data/package.json +1 -1
  22. data/profiles/addons/acts_as_list.json +13 -0
  23. data/tasks/profile.thor +14 -3
  24. data/templates/thor_task/profile/{after_template.rb.tt → after_template.rb} +11 -1
  25. data/templates/thor_task/profile/app/controllers/home_controller.rb +7 -0
  26. data/templates/thor_task/profile/app/views/home/index.html.erb.tt +23 -0
  27. data/templates/thor_task/profile/app/views/layouts/_alerts.html.erb.tt +2 -0
  28. data/templates/thor_task/profile/app/views/layouts/_footer.html.erb.tt +3 -0
  29. data/templates/thor_task/profile/app/views/layouts/_navbar.html.erb +7 -0
  30. data/templates/thor_task/profile/app/views/layouts/application.html.erb.tt +28 -0
  31. data/templates/thor_task/profile/config/initializers/addon_name.rb +1 -0
  32. data/templates/thor_task/profile/db/seeds.rb +16 -0
  33. metadata +26 -4
  34. data/after_templates/addons/rails_html_sanitizer_xxx/home/index.html.erb +0 -31
  35. data/templates/thor_task/profile/home/index.html.erb.tt +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75a314b07d31b22d3aa8c2249efa2884d59f4d6ec2aa13966e52ded99aa8aa79
4
- data.tar.gz: ee79c7ebb7828f2cc5fe27ae226f107f841947185d3c21ba4f4a0e6fcb7b3323
3
+ metadata.gz: 1a70b5c05cd9a463bcfde6eeaf50a48380c37dc39a88e3c8239e145fee4b1934
4
+ data.tar.gz: 5c1bbda9632a77534a36943bc81594b14a38ab2654c3de3f61a19e8cb5b8d9d6
5
5
  SHA512:
6
- metadata.gz: 7011a7def931cb0ca1e5e7502372cad5da9f9887e2195b6f708963f1a34205cd74cd6812f877c77fa98faf3dc590d15f256319085af79416f98fd67480ddf0af
7
- data.tar.gz: 6ee2229ccce12d2dcba53b841125ac72cc2a07dfe6432b21029395460efb704e8621697c833fdc77fbaaf9520347aac08562adf16de6e17b86cd31284de678ce
6
+ metadata.gz: 43579cfcb2ca45ffeb1d7f8f504b7c480ab7e484f163c9af3e238fd5a066d26942e860167f7e2c91a1aa69b98ced19000538eacacee38a18b8382a6ea4201c7e
7
+ data.tar.gz: a099c2c9e2cb390101fccd6363a2957cbc58e049994f16ecde69a7545572b5e8fa472fa64dca63026c16da4601305f2e4615968ea507c4e1151f889625eb9b27
data/.rubocop.yml CHANGED
@@ -12,6 +12,7 @@ AllCops:
12
12
  - "spec/samples/**/*"
13
13
  - "a/**/*"
14
14
  - "after_templates/**/*"
15
+ - "templates/**/*"
15
16
 
16
17
  Metrics/BlockLength:
17
18
  Exclude:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.1.14](https://github.com/klueless-io/rails_app_generator/compare/v0.1.13...v0.1.14) (2022-08-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add twilio addon ([2a70a12](https://github.com/klueless-io/rails_app_generator/commit/2a70a1216dc9d7475289a154f6c7b8c4a2a80403))
7
+
1
8
  ## [0.1.13](https://github.com/klueless-io/rails_app_generator/compare/v0.1.12...v0.1.13) (2022-08-03)
2
9
 
3
10
 
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ # require 'pry'
4
+
5
+ # This "acts_as" extension provides the capabilities for sorting and reordering a number of objects in a list. The class that has this specified needs to have a "position" column defined as an integer on the mapped database table.
6
+ #
7
+ # exe/rag addons/acts_as_list
8
+
9
+ self.local_template_path = File.dirname(__FILE__)
10
+
11
+ gac 'base rails 7 image created'
12
+
13
+ add_controller('home', 'index')
14
+ route("root 'home#index'")
15
+
16
+ force_copy
17
+
18
+ add_scaffold('todo_list', 'name')
19
+ add_scaffold('todo_item', 'task', 'position:integer', 'todo_list:references')
20
+
21
+ copy_file 'app/controllers/home_controller.rb' , 'app/controllers/home_controller.rb'
22
+ copy_file 'app/controllers/todo_items_controller.rb' , 'app/controllers/todo_items_controller.rb'
23
+ copy_file 'app/models/todo_list.rb' , 'app/models/todo_list.rb'
24
+ copy_file 'app/models/todo_item.rb' , 'app/models/todo_item.rb'
25
+
26
+ copy_file 'app/views/home/index.html.erb' , 'app/views/home/index.html.erb'
27
+
28
+ copy_file 'app/views/layouts/_alerts.html.erb' , 'app/views/layouts/_alerts.html.erb'
29
+ copy_file 'app/views/layouts/_navbar.html.erb' , 'app/views/layouts/_navbar.html.erb'
30
+ copy_file 'app/views/layouts/_footer.html.erb' , 'app/views/layouts/_footer.html.erb'
31
+ template 'app/views/layouts/application.html.erb' , 'app/views/layouts/application.html.erb'
32
+
33
+ copy_file 'app/views/todo_items/index.html.erb' , 'app/views/todo_items/index.html.erb'
34
+ copy_file 'app/views/todo_items/_todo_item.html.erb' , 'app/views/todo_items/_todo_item.html.erb'
35
+
36
+ copy_file 'config/routes.rb' , 'config/routes.rb'
37
+
38
+ template 'db/seeds.rb' , 'db/seeds.rb'
39
+
40
+ after_bundle do
41
+ setup_db
42
+ end
43
+
44
+ def setup_db
45
+
46
+ db_migrate
47
+ rails_command('db:seed')
48
+ end
49
+
50
+ # Other template command examples
51
+ # css_install('tailwind')
52
+ # rails_command('db:migrate')
53
+ # bundle_add('hotwire-rails')
54
+ # rails_command('hotwire:install')
55
+ # run('bin/importmap pin sortablejs')
56
+ # run('npm install daisyui')
57
+ # create_file 'app/assets/stylesheets/custom-bootstrap-import.scss' , read_template('custom-bootstrap-import.scss')
58
+ # append_to_file 'app/assets/config/manifest.js' , read_template('manifest.js')
59
+ # insert_into_file 'app/views/layouts/application.html.erb', read_template('application.html.erb'),
60
+ # before: %( <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>)
61
+ # gsub_file 'app/views/layouts/application.html.erb', %(container mx-auto mt-28 px-5 flex), 'container mx-auto px-5'
62
+ # template 'home.css', 'app/assets/stylesheets/home.css'
@@ -0,0 +1,7 @@
1
+ class HomeController < ApplicationController
2
+ def index
3
+ end
4
+
5
+ def some_action
6
+ end
7
+ end
@@ -0,0 +1,132 @@
1
+ class TodoItemsController < ApplicationController
2
+ before_action :set_todo_item, only: %i[
3
+ show
4
+ edit
5
+ update
6
+ destroy
7
+ insert_at
8
+ move_lower
9
+ move_higher
10
+ move_to_bottom
11
+ move_to_top
12
+ remove_from_list
13
+ ]
14
+
15
+ before_action :set_todo_items, only: %i[
16
+ index
17
+ insert_at
18
+ move_lower
19
+ move_higher
20
+ move_to_bottom
21
+ move_to_top
22
+ remove_from_list
23
+ ]
24
+
25
+ # GET /todo_items or /todo_items.json
26
+ def index
27
+ end
28
+
29
+ # GET /todo_items/1 or /todo_items/1.json
30
+ def show
31
+ end
32
+
33
+ def insert_at
34
+ @todo_item.insert_at(2)
35
+ render :index, params
36
+ end
37
+
38
+ def move_lower
39
+ @todo_item.move_lower
40
+ render :index, params
41
+ end
42
+
43
+ def move_higher
44
+ @todo_item.move_higher
45
+ render :index, params
46
+ end
47
+
48
+ def move_to_bottom
49
+ @todo_item.move_to_bottom
50
+ render :index, params
51
+ end
52
+
53
+ def move_to_top
54
+ @todo_item.move_to_top
55
+ render :index, params
56
+ end
57
+
58
+ def remove_from_list
59
+ @todo_item.remove_from_list
60
+ render :index, params
61
+ end
62
+
63
+ # GET /todo_items/new
64
+ def new
65
+ @todo_item = TodoItem.new
66
+ end
67
+
68
+ # GET /todo_items/1/edit
69
+ def edit
70
+ end
71
+
72
+ # POST /todo_items or /todo_items.json
73
+ def create
74
+ @todo_item = TodoItem.new(todo_item_params)
75
+
76
+ respond_to do |format|
77
+ if @todo_item.save
78
+ format.html { redirect_to todo_item_url(@todo_item), notice: "Todo item was successfully created." }
79
+ format.json { render :show, status: :created, location: @todo_item }
80
+ else
81
+ format.html { render :new, status: :unprocessable_entity }
82
+ format.json { render json: @todo_item.errors, status: :unprocessable_entity }
83
+ end
84
+ end
85
+ end
86
+
87
+ # PATCH/PUT /todo_items/1 or /todo_items/1.json
88
+ def update
89
+ respond_to do |format|
90
+ if @todo_item.update(todo_item_params)
91
+ format.html { redirect_to todo_item_url(@todo_item), notice: "Todo item was successfully updated." }
92
+ format.json { render :show, status: :ok, location: @todo_item }
93
+ else
94
+ format.html { render :edit, status: :unprocessable_entity }
95
+ format.json { render json: @todo_item.errors, status: :unprocessable_entity }
96
+ end
97
+ end
98
+ end
99
+
100
+ # DELETE /todo_items/1 or /todo_items/1.json
101
+ def destroy
102
+ @todo_item.destroy
103
+
104
+ respond_to do |format|
105
+ format.html { redirect_to todo_items_url, notice: "Todo item was successfully destroyed." }
106
+ format.json { head :no_content }
107
+ end
108
+ end
109
+
110
+ def query_params
111
+ params.permit(:todo_list_id)
112
+ end
113
+ helper_method :query_params
114
+
115
+ private
116
+ # Use callbacks to share common setup or constraints between actions.
117
+ def set_todo_item
118
+ @todo_item = TodoItem.find(params[:id])
119
+ end
120
+
121
+ def set_todo_items
122
+ todo_list_id = params[:todo_list_id]
123
+
124
+ @todo_items = todo_list_id.nil? ? TodoItem.all : TodoItem.where(todo_list_id: todo_list_id)
125
+ @todo_items = @todo_items.order(:todo_list_id, :position)
126
+ end
127
+
128
+ # Only allow a list of trusted parameters through.
129
+ def todo_item_params
130
+ params.require(:todo_item).permit(:task, :position, :todo_list_id)
131
+ end
132
+ end
@@ -0,0 +1,23 @@
1
+ # == Schema Information
2
+ #
3
+ # Table name: todo_items
4
+ #
5
+ # id :integer not null, primary key
6
+ # position :integer
7
+ # task :string
8
+ # created_at :datetime not null
9
+ # updated_at :datetime not null
10
+ # todo_list_id :integer not null
11
+ #
12
+ # Indexes
13
+ #
14
+ # index_todo_items_on_todo_list_id (todo_list_id)
15
+ #
16
+ # Foreign Keys
17
+ #
18
+ # todo_list_id (todo_list_id => todo_lists.id)
19
+ #
20
+ class TodoItem < ApplicationRecord
21
+ belongs_to :todo_list
22
+ acts_as_list scope: :todo_list
23
+ end
@@ -0,0 +1,12 @@
1
+ # == Schema Information
2
+ #
3
+ # Table name: todo_lists
4
+ #
5
+ # id :integer not null, primary key
6
+ # name :string
7
+ # created_at :datetime not null
8
+ # updated_at :datetime not null
9
+ #
10
+ class TodoList < ApplicationRecord
11
+ has_many :todo_items, -> { order(position: :asc) }
12
+ end
@@ -0,0 +1,23 @@
1
+ <style>
2
+ .alert { color: red; }
3
+ .notice { color: green; }
4
+ </style>
5
+
6
+ <% flash.each do |type, msg| %><div class="<%= type %>"><%= msg %></div><% end %>
7
+ <% if flash.any? %><hr /><% end %>
8
+
9
+ <h1>Acts as list</h1>
10
+
11
+ <h2>This "acts_as" extension provides the capabilities for sorting and reordering a number of objects in a list. The class that has this specified needs to have a "position" column defined as an integer on the mapped database table.</h2>
12
+
13
+ <!--
14
+ Add/Remove as needed
15
+ -->
16
+
17
+ <!--
18
+ <= link_to 'Some Action', home_some_action_path %>
19
+
20
+ <= link_to 'Products', products_path %> |
21
+ <= link_to 'Posts', posts_path %> |
22
+ <= link_to 'People', people_path %>
23
+ -->
@@ -0,0 +1,2 @@
1
+ <% flash.each do |type, msg| %><div class="<%= type %>"><%= msg %></div><% end %>
2
+ <% if flash.any? %><hr /><% end %>
@@ -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 'ToDo List', todo_lists_path %> |
4
+ <%= link_to 'ToDo Items', todo_items_path %> |
5
+ <%= link_to 'People', todo_items_path(todo_list_id: TodoList.find_by(name: 'people')) %> |
6
+ <%= link_to 'Jobs', todo_items_path(todo_list_id: TodoList.find_by(name: 'jobs')) %>
7
+ <hr />
8
+ </header>
@@ -0,0 +1,28 @@
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
+ <style>
15
+ .alert { color: red; }
16
+ .notice { color: green; }
17
+ </style>
18
+ </head>
19
+
20
+ <body>
21
+ <%%= render 'layouts/navbar' %>
22
+ <main>
23
+ <%%= render 'layouts/alerts' %>
24
+ <%%= yield %>
25
+ </main>
26
+ <%%= render 'layouts/footer' %>
27
+ </body>
28
+ </html>
@@ -0,0 +1,21 @@
1
+ <tr>
2
+ <td>
3
+ <%= todo_item.task %>
4
+ </td>
5
+ <td>
6
+ <%= todo_item.position %>
7
+ </td>
8
+ <td>
9
+ <%= todo_item.todo_list.name %>
10
+ </td>
11
+ <td>
12
+ <%= link_to "Show", todo_item %> |
13
+ <%= link_to "Insert At #2", insert_at_todo_item_path(todo_item.id, **query_params) %> |
14
+ <%= link_to "Higher", move_higher_todo_item_path(todo_item.id, **query_params) %> |
15
+ <%= link_to "Lower", move_lower_todo_item_path(todo_item.id, **query_params) %> |
16
+ <%= link_to "Top", move_to_top_todo_item_path(todo_item.id, **query_params) %> |
17
+ <%= link_to "Bottom", move_to_bottom_todo_item_path(todo_item.id, **query_params) %> |
18
+ <%= link_to "Remove From List", remove_from_list_todo_item_path(todo_item.id, **query_params) %>
19
+ </td>
20
+ </tr>
21
+
@@ -0,0 +1,25 @@
1
+ <p style="color: green"><%= notice %></p>
2
+
3
+ <h1>Todo items</h1>
4
+
5
+ <div id="todo_items">
6
+ <table>
7
+ <thead>
8
+ <tr>
9
+ <th>Task</th>
10
+ <th>Position</th>
11
+ <th>List Name</th>
12
+ </tr>
13
+ </thead>
14
+ <tbody>
15
+
16
+ <% @todo_items.each do |todo_item| %>
17
+ <%= render todo_item %>
18
+ <% end %>
19
+
20
+ </tbody>
21
+ </table>
22
+
23
+ </div>
24
+
25
+ <%= link_to "New todo item", new_todo_item_path %>
@@ -0,0 +1,15 @@
1
+ Rails.application.routes.draw do
2
+ resources :todo_items do
3
+ member do
4
+ get :insert_at
5
+ get :move_lower
6
+ get :move_higher
7
+ get :move_to_bottom
8
+ get :move_to_top
9
+ get :remove_from_list
10
+ end
11
+ end
12
+ resources :todo_lists
13
+ root 'home#index'
14
+ get 'home/index'
15
+ end
@@ -0,0 +1,17 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
3
+ #
4
+ # User.find_or_create_by(email: "admin@admin.com") do |user|
5
+ # user.name = 'Admin'
6
+ # user.password = 'password'
7
+ # user.admin = true
8
+ # end
9
+
10
+ people = TodoList.create(name: 'people')
11
+ jobs = TodoList.create(name: 'jobs')
12
+ # lisa = User.create(email: 'lisa@site.com', name: 'lisa', password: 'password')
13
+
14
+ 5.times do |i|
15
+ TodoItem.create(todo_list: people, task: "Person Name #{i}", position: i)
16
+ TodoItem.create(todo_list: jobs , task: "Profession #{i}", position: i)
17
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsAppGenerator
4
+ # Custom add-ons for RailsAppGenerator
5
+ module AddOns
6
+ # Add ActsAsList to rails application
7
+ class ActsAsList < AddOn
8
+ depends_on :active_record
9
+ required_gem gem.version('acts_as_list', '1.0.4', <<~COMMENT)
10
+ This "acts_as" extension provides the capabilities for sorting and reordering a number of objects in a list.
11
+ The class that has this specified needs to have a "position" column defined as an integer on the mapped database table.
12
+ COMMENT
13
+
14
+ def apply
15
+ # say 'Setting up ActsAsList'
16
+ # template('acts_as_list_template.rb', 'target/acts_as_list.rb', force: true)
17
+ # template('app/javascript/stylesheets/components.scss')
18
+ # create_file('target/acts_as_list.rb', 'put your content here')
19
+ # directory 'app/template', 'app/target', force: true
20
+ # empty_directory 'app/target'
21
+ # inject_into_file('app/application.js', "some content")
22
+ # rails_command('tailwindcss:install')
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsAppGenerator
4
- VERSION = '0.1.14'
4
+ VERSION = '0.1.15'
5
5
  end
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "rails_app_generator",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "rails_app_generator",
9
- "version": "0.1.14",
9
+ "version": "0.1.15",
10
10
  "dependencies": {
11
11
  "daisyui": "^2.20.0"
12
12
  },
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rails_app_generator",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "Create new Rails Application with custom opinions",
5
5
  "scripts": {
6
6
  "release": "semantic-release"
@@ -0,0 +1,13 @@
1
+ {
2
+ "args": {
3
+ "app_path": "acts_as_list",
4
+ "destination_root": "/Users/davidcruwys/dev/kgems/rails_app_generator/a/addons"
5
+ },
6
+ "opts": {
7
+ "skip_git": true,
8
+ "skip_test": true,
9
+ "template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/addons/acts_as_list/_.rb",
10
+ "add_acts_as_list": true,
11
+ "add_annotate": true
12
+ }
13
+ }
data/tasks/profile.thor CHANGED
@@ -39,10 +39,21 @@ class Profile < Thor
39
39
  say "Creating profile #{name}"
40
40
  puts "Variant: #{options[:variant]}"
41
41
 
42
- template('profile/profile.json', profile_path("#{data.name_dash}.json"), force: options[:force])
43
- template('profile/after_template.rb', after_template_path('_.rb'), force: options[:force])
44
- template('profile/home/index.html.erb', after_template_path('home/index.html.erb'), force: options[:force])
42
+ template('profile/profile.json' , profile_path("#{data.name_dash}.json") , force: options[:force])
43
+ template('profile/after_template.rb' , after_template_path('_.rb') , force: options[:force])
44
+ template('profile/app/controllers/home_controller.rb' , after_template_path('app/controllers/home_controller.rb') , force: options[:force])
45
+ template('profile/app/views/home/index.html.erb' , after_template_path('app/views/home/index.html.erb') , force: options[:force])
46
+
47
+ copy_file('profile/app/views/layouts/_alerts.html.erb' , after_template_path('app/views/layouts/_alerts.html.erb') , force: options[:force])
48
+ copy_file('profile/app/views/layouts/_navbar.html.erb' , after_template_path('app/views/layouts/_navbar.html.erb') , force: options[:force])
49
+ copy_file('profile/app/views/layouts/_footer.html.erb' , after_template_path('app/views/layouts/_footer.html.erb') , force: options[:force])
50
+ copy_file('profile/app/views/layouts/application.html.erb' , after_template_path('app/views/layouts/application.html.erb') , force: options[:force])
51
+
52
+ copy_file('profile/db/seeds.rb' , after_template_path('db/seeds.rb') , force: options[:force])
53
+
54
+ copy_file('profile/config/initializers/addon_name.rb' , after_template_path("config/initializers/#{name}.rb") , force: options[:force])
45
55
  end
56
+
46
57
  # rubocop:enable Metrics/AbcSize
47
58
 
48
59
  # rubocop:disable Metrics/BlockLength
@@ -15,7 +15,17 @@ route("root 'home#index'")
15
15
 
16
16
  force_copy
17
17
 
18
- copy_file 'home/index.html.erb', 'app/views/home/index.html.erb'
18
+ copy_file 'app/controllers/home_controller.rb' , 'app/controllers/home_controller.rb'
19
+ copy_file 'app/views/home/index.html.erb' , 'app/views/home/index.html.erb'
20
+
21
+ copy_file 'app/views/layouts/_alerts.html.erb' , 'app/views/layouts/_alerts.html.erb'
22
+ copy_file 'app/views/layouts/_navbar.html.erb' , 'app/views/layouts/_navbar.html.erb'
23
+ copy_file 'app/views/layouts/_footer.html.erb' , 'app/views/layouts/_footer.html.erb'
24
+ template 'app/views/layouts/application.html.erb' , 'app/views/layouts/application.html.erb'
25
+
26
+ template 'db/seeds.rb' , 'db/seeds.rb'
27
+
28
+ copy_file 'config/initializers/<%= data.name_snake %>.rb' , 'config/initializers/<%= data.name_snake %>.rb'
19
29
 
20
30
  after_bundle do
21
31
  setup_db
@@ -0,0 +1,7 @@
1
+ class HomeController < ApplicationController
2
+ def index
3
+ end
4
+
5
+ def some_action
6
+ end
7
+ end
@@ -0,0 +1,23 @@
1
+ <style>
2
+ .alert { color: red; }
3
+ .notice { color: green; }
4
+ </style>
5
+
6
+ <%% flash.each do |type, msg| %><div class="<%%= type %>"><%%= msg %></div><%% end %>
7
+ <%% if flash.any? %><hr /><%% end %>
8
+
9
+ <h1><%= data.name_human %></h1>
10
+
11
+ <h2><%= data.description %></h2>
12
+
13
+ <!--
14
+ Add/Remove as needed
15
+ -->
16
+
17
+ <!--
18
+ <= link_to 'Some Action', home_some_action_path %>
19
+
20
+ <= link_to 'Products', products_path %> |
21
+ <= link_to 'Posts', posts_path %> |
22
+ <= link_to 'People', people_path %>
23
+ -->
@@ -0,0 +1,2 @@
1
+ <% flash.each do |type, msg| %><div class="<%= type %>"><%= msg %></div><% end %>
2
+ <% if flash.any? %><hr /><% end %>
@@ -0,0 +1,3 @@
1
+ <footer>
2
+ <hr />
3
+ </footer>
@@ -0,0 +1,7 @@
1
+ <header>
2
+ <= link_to 'Home', home_path %> |
3
+ <= link_to 'Products', products_path %> |
4
+ <= link_to 'Posts', posts_path %> |
5
+ <= link_to 'People', people_path %>
6
+ <hr />
7
+ </header>
@@ -0,0 +1,28 @@
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
+ <style>
15
+ .alert { color: red; }
16
+ .notice { color: green; }
17
+ </style>
18
+ </head>
19
+
20
+ <body>
21
+ <%%= render 'layouts/navbar' %>
22
+ <main>
23
+ <%%= render 'layouts/alerts' %>
24
+ <%%= yield %>
25
+ </main>
26
+ <%%= render 'layouts/footer' %>
27
+ </body>
28
+ </html>
@@ -0,0 +1 @@
1
+ # Custom initializer for rails application
@@ -0,0 +1,16 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
3
+ #
4
+ # User.find_or_create_by(email: "admin@admin.com") do |user|
5
+ # user.name = 'Admin'
6
+ # user.password = 'password'
7
+ # user.admin = true
8
+ # end
9
+
10
+ # david = User.create(email: 'david@site.com', name: 'david', password: 'password')
11
+ # bob = User.create(email: 'bob@site.com', name: 'bob', password: 'password')
12
+ # lisa = User.create(email: 'lisa@site.com', name: 'lisa', password: 'password')
13
+
14
+ # 10.times do |i|
15
+ # Post.create(title: "Post #{i}", body: "This is the body of post #{i}", user: User.all.sample)
16
+ # end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_app_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
@@ -160,6 +160,20 @@ files:
160
160
  - README.md
161
161
  - Rakefile
162
162
  - after_templates/README.md
163
+ - after_templates/addons/acts_as_list/_.rb
164
+ - after_templates/addons/acts_as_list/app/controllers/home_controller.rb
165
+ - after_templates/addons/acts_as_list/app/controllers/todo_items_controller.rb
166
+ - after_templates/addons/acts_as_list/app/models/todo_item.rb
167
+ - after_templates/addons/acts_as_list/app/models/todo_list.rb
168
+ - after_templates/addons/acts_as_list/app/views/home/index.html.erb
169
+ - after_templates/addons/acts_as_list/app/views/layouts/_alerts.html.erb
170
+ - after_templates/addons/acts_as_list/app/views/layouts/_footer.html.erb
171
+ - after_templates/addons/acts_as_list/app/views/layouts/_navbar.html.erb
172
+ - after_templates/addons/acts_as_list/app/views/layouts/application.html.erb
173
+ - after_templates/addons/acts_as_list/app/views/todo_items/_todo_item.html.erb
174
+ - after_templates/addons/acts_as_list/app/views/todo_items/index.html.erb
175
+ - after_templates/addons/acts_as_list/config/routes.rb
176
+ - after_templates/addons/acts_as_list/db/seeds.rb
163
177
  - after_templates/addons/honeybadger/_.rb
164
178
  - after_templates/addons/honeybadger/app/controllers/application_controller.rb
165
179
  - after_templates/addons/honeybadger/app/controllers/errors_controller.rb
@@ -169,7 +183,6 @@ files:
169
183
  - after_templates/addons/honeybadger/public/500.html
170
184
  - after_templates/addons/rails_html_sanitizer/_.rb
171
185
  - after_templates/addons/rails_html_sanitizer/home/index.html.erb
172
- - after_templates/addons/rails_html_sanitizer_xxx/home/index.html.erb
173
186
  - after_templates/addons/twilio_ruby/_.rb
174
187
  - after_templates/addons/twilio_ruby/app/controllers/home_controller.rb
175
188
  - after_templates/addons/twilio_ruby/app/views/home/index.html.erb
@@ -305,6 +318,7 @@ files:
305
318
  - exe/rag
306
319
  - lib/rails_app_generator.rb
307
320
  - lib/rails_app_generator/add_on.rb
321
+ - lib/rails_app_generator/addons/acts_as_list.rb
308
322
  - lib/rails_app_generator/addons/annotate.rb
309
323
  - lib/rails_app_generator/addons/continuous_integration.rb
310
324
  - lib/rails_app_generator/addons/devise.rb
@@ -365,6 +379,7 @@ files:
365
379
  - lib/rails_app_generator/version.rb
366
380
  - package-lock.json
367
381
  - package.json
382
+ - profiles/addons/acts_as_list.json
368
383
  - profiles/addons/honeybadger.json
369
384
  - profiles/addons/rails-html-sanitizer.json
370
385
  - profiles/addons/twilio_ruby.json
@@ -430,8 +445,15 @@ files:
430
445
  - templates/addons/scaffold/lib/templates/erb/scaffold/show.html.erb
431
446
  - templates/addons/services/app/services/application_service.rb
432
447
  - templates/thor_task/addon/addon.tt
433
- - templates/thor_task/profile/after_template.rb.tt
434
- - templates/thor_task/profile/home/index.html.erb.tt
448
+ - templates/thor_task/profile/after_template.rb
449
+ - templates/thor_task/profile/app/controllers/home_controller.rb
450
+ - templates/thor_task/profile/app/views/home/index.html.erb.tt
451
+ - templates/thor_task/profile/app/views/layouts/_alerts.html.erb.tt
452
+ - templates/thor_task/profile/app/views/layouts/_footer.html.erb.tt
453
+ - templates/thor_task/profile/app/views/layouts/_navbar.html.erb
454
+ - templates/thor_task/profile/app/views/layouts/application.html.erb.tt
455
+ - templates/thor_task/profile/config/initializers/addon_name.rb
456
+ - templates/thor_task/profile/db/seeds.rb
435
457
  - templates/thor_task/profile/profile.json.tt
436
458
  homepage: http://appydave.com/gems/rails_app_generator
437
459
  licenses:
@@ -1,31 +0,0 @@
1
- <h1>Testing HTML Sanitizer</h1>
2
-
3
- <p>Read more here <a href="https://github.com/rails/rails-html-sanitizer">rails-html-sanitizer</a></p>
4
-
5
- <textarea rows="4" cols="200">
6
- full_sanitizer = Rails::Html::FullSanitizer.new
7
- full_sanitizer.sanitize("<b>Bold</b> no more! <a href='more.html'>See more here</a>...")
8
- </textarea>
9
-
10
- <hr>
11
- <%=
12
- Rails::Html::FullSanitizer
13
- .new
14
- .sanitize("<b>Bold</b> no more! <a href='more.html'>See more here</a>...")
15
- %>
16
-
17
- <br/><br/><br/>
18
-
19
- <hr>
20
-
21
- <textarea rows="4" cols="200">
22
- link_sanitizer = Rails::Html::LinkSanitizer.new
23
- link_sanitizer.sanitize('<a href="example.com">Only the link text will be kept.</a>')
24
- # => Only the link text will be kept.
25
- </textarea>
26
-
27
- <%=
28
- Rails::Html::LinkSanitizer
29
- .new
30
- .sanitize('<a href="example.com">Only the link text will be kept.</a>')
31
- %>
@@ -1,13 +0,0 @@
1
- <h1><%= data.name_human %></h1>
2
-
3
- <h2><%= data.description %></h2>
4
-
5
- <!--
6
- Add/Remove as needed
7
- -->
8
-
9
- <!--
10
- <= link_to 'Products', products_path %> |
11
- <= link_to 'Posts', posts_path %> |
12
- <= link_to 'People', people_path %>
13
- -->