rails_app_generator 0.2.38 → 0.2.41
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/after_templates/addons/avo/_.rb +11 -3
- data/after_templates/addons/avo/app/avo/resources/post_resource.rb +3 -0
- data/after_templates/addons/avo/app/avo/resources/user_resource.rb +1 -0
- data/after_templates/addons/avo/app/controllers/home_controller.rb +4 -0
- data/after_templates/addons/avo/app/models/post.rb +3 -2
- data/after_templates/addons/avo/app/models/user.rb +6 -0
- data/after_templates/addons/avo/app/services/seed_service.rb +9 -0
- data/after_templates/addons/avo/app/views/home/index.html.erb +4 -2
- data/after_templates/addons/avo/app/views/layouts/_navbar.html.erb +7 -1
- data/after_templates/addons/avo/db/seeds.rb +1 -1
- data/after_templates/addons/factory_bot_rails/_.rb +45 -0
- data/after_templates/addons/factory_bot_rails/app/controllers/home_controller.rb +8 -0
- data/after_templates/addons/factory_bot_rails/app/services/seed_service.rb +27 -0
- data/after_templates/addons/factory_bot_rails/app/views/home/index.html.erb +3 -0
- data/after_templates/addons/factory_bot_rails/app/views/home/reseed.html.erb +6 -0
- data/after_templates/addons/factory_bot_rails/app/views/layouts/_footer.html.erb +0 -0
- data/after_templates/addons/factory_bot_rails/app/views/layouts/_navbar.html.erb +6 -0
- data/after_templates/addons/factory_bot_rails/app/views/layouts/application.html.erb +29 -0
- data/after_templates/addons/factory_bot_rails/db/seeds.rb +1 -0
- data/after_templates/addons/factory_bot_rails/factories.rb +27 -0
- data/after_templates/addons/friendly_id/app/views/posts/_form.html.erb +32 -0
- data/after_templates/addons/friendly_id/app/views/posts/_post.html.erb +17 -0
- data/after_templates/addons/friendly_id/app/views/posts/_post.json.jbuilder +2 -0
- data/after_templates/addons/friendly_id/app/views/posts/edit.html.erb +10 -0
- data/after_templates/addons/friendly_id/app/views/posts/index.html.erb +14 -0
- data/after_templates/addons/friendly_id/app/views/posts/index.json.jbuilder +1 -0
- data/after_templates/addons/friendly_id/app/views/posts/new.html.erb +9 -0
- data/after_templates/addons/friendly_id/app/views/posts/show.json.jbuilder +1 -0
- data/after_templates/application/klueless/_.rb +99 -0
- data/after_templates/application/klueless/app/avo/dashboards/dashboard.rb +13 -0
- data/after_templates/application/klueless/app/avo/resources/db_schema_resource.rb +12 -0
- data/after_templates/application/klueless/app/avo/resources/rails_app_resource.rb +15 -0
- data/after_templates/application/klueless/app/avo/resources/rubocop_resource.rb +12 -0
- data/after_templates/application/klueless/app/avo/resources/table_count_resource.rb +12 -0
- data/after_templates/application/klueless/app/avo/resources/user_resource.rb +24 -0
- data/after_templates/application/klueless/app/controllers/home_controller.rb +12 -0
- data/after_templates/application/klueless/app/models/db_schema.rb +11 -0
- data/after_templates/application/klueless/app/models/rails_app.rb +3 -0
- data/after_templates/application/klueless/app/models/rubocop.rb +11 -0
- data/after_templates/application/klueless/app/models/table_count.rb +11 -0
- data/after_templates/application/klueless/app/queries/rubocop_log.psql +23 -0
- data/after_templates/application/klueless/app/queries/rubocop_log_query.rb +10 -0
- data/after_templates/application/klueless/app/queries/sql_query.rb +40 -0
- data/after_templates/application/klueless/app/services/seed_service.rb +7 -0
- data/after_templates/application/klueless/app/views/home/index.html.erb +6 -0
- data/after_templates/application/klueless/app/views/home/quick_signin.html.erb +3 -0
- data/after_templates/application/klueless/app/views/layouts/_footer.html.erb +0 -0
- data/after_templates/application/klueless/app/views/layouts/_navbar.html.erb +4 -0
- data/after_templates/application/klueless/app/views/layouts/application.html.erb +29 -0
- data/after_templates/application/klueless/config/initializers/avo.rb +101 -0
- data/after_templates/application/klueless/config/locales/en.yml +4 -0
- data/after_templates/application/klueless/db/seeds.rb +18 -0
- data/after_templates/application/printspeak/_.rb +65 -23
- data/after_templates/application/printspeak/db/seeds.rb +3 -3
- data/docs/last_run/app_generator_class.json +8 -0
- data/docs/last_run/app_generator_data.json +14 -12
- data/docs/last_run/rails_options_class.json +8 -0
- data/docs/last_run/rails_options_data.json +14 -13
- data/lib/rails_app_generator/addons/avo.rb +2 -0
- data/lib/rails_app_generator/addons/factory_bot_rails.rb +15 -0
- data/lib/rails_app_generator/addons/scenic.rb +38 -0
- data/lib/rails_app_generator/app_generator.rb +18 -0
- data/lib/rails_app_generator/rag_initializer.rb +1 -0
- data/lib/rails_app_generator/version.rb +1 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- data/profiles/addons/avo.json +1 -1
- data/profiles/addons/factory_bot_rails.json +14 -0
- data/profiles/application/klueless.json +23 -0
- data/profiles/application/printspeak.json +7 -1
- data/templates/Gemfile.erb +0 -1
- metadata +50 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f266923a169ab15ff8606551f4e023723d947f785513dc89083e0762fd2d568
|
4
|
+
data.tar.gz: 55093884128eff848ef3a6b21e415c3739530110590d58308bb7037674022744
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aaf2fc71ee43c3d12c73b2ab6c91e1c7b5aacd31740a17284b845eb60aff94058634b7d346910242777d1e7ae17d4d75cde624002e6b67b2c5b73e530a6668d2
|
7
|
+
data.tar.gz: c2c8a7dbb9d0cf975b4e02d19309147a3a90ae5a58da010b007eba9f2713d8289b6e3dbe1ee5caa04b33ef95a9d6c9eae31f97ec4480cad7969d4fdb1796642f
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
## [0.2.40](https://github.com/klueless-io/rails_app_generator/compare/v0.2.39...v0.2.40) (2022-08-23)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* add factory_bot_rails profile ([8a6a7ef](https://github.com/klueless-io/rails_app_generator/commit/8a6a7ef6c4b1b26003930776724cedaeb5232f84))
|
7
|
+
|
8
|
+
## [0.2.39](https://github.com/klueless-io/rails_app_generator/compare/v0.2.38...v0.2.39) (2022-08-23)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* add friendly_id profile, add factory_bot_rails addon ([75d51ce](https://github.com/klueless-io/rails_app_generator/commit/75d51ceb63a5a560977073b2a6199545c5c8d17f))
|
14
|
+
|
15
|
+
## [0.2.38](https://github.com/klueless-io/rails_app_generator/compare/v0.2.37...v0.2.38) (2022-08-22)
|
16
|
+
|
17
|
+
|
18
|
+
### Bug Fixes
|
19
|
+
|
20
|
+
* add friendly_id addon ([5c34df5](https://github.com/klueless-io/rails_app_generator/commit/5c34df5fdbca8bc6810bd3cc9343d8b799d63ac3))
|
21
|
+
|
1
22
|
## [0.2.37](https://github.com/klueless-io/rails_app_generator/compare/v0.2.36...v0.2.37) (2022-08-22)
|
2
23
|
|
3
24
|
|
@@ -18,13 +18,19 @@ after_bundle do
|
|
18
18
|
setup_customizations
|
19
19
|
setup_db
|
20
20
|
setup_avo
|
21
|
+
|
22
|
+
swap1 = ' resources :users'
|
23
|
+
swap2 = " devise_for :users, controllers: { sessions: 'users/sessions', registrations: 'users/registrations' }"
|
24
|
+
|
25
|
+
swap_lines('config/routes.rb', swap1, swap2)
|
21
26
|
end
|
22
27
|
|
23
28
|
def scaffolds
|
24
29
|
add_scaffold_controller('users', 'name', 'email')
|
25
|
-
# add_scaffold('author', 'name', 'email', 'bio:text')
|
26
30
|
add_scaffold('category', 'title', 'description:text')
|
27
|
-
add_scaffold('post', 'title content:text', 'published:boolean', 'user:references', 'category:references')
|
31
|
+
add_scaffold('post', 'title', 'content:text', 'published:boolean', 'user:references', 'category:references')
|
32
|
+
add_scaffold('comment', 'body:text', 'commentable:references{polymorphic}', 'user:references')
|
33
|
+
|
28
34
|
add_scaffold('location', 'name', 'description:text') #, 'photo:file')
|
29
35
|
add_scaffold('room', 'name', 'description:text', 'location:references') #, 'photo:file'
|
30
36
|
add_scaffold('booking', 'user:references', 'room:references', 'booked_at:datetime', 'booked_for:integer')
|
@@ -35,11 +41,12 @@ def setup_customizations
|
|
35
41
|
|
36
42
|
force_copy
|
37
43
|
|
38
|
-
add_controller('home', 'index', 'quick_signin')
|
44
|
+
add_controller('home', 'index', 'quick_signin', 'reseed')
|
39
45
|
|
40
46
|
directory "app/controllers"
|
41
47
|
directory "app/models"
|
42
48
|
directory "app/views"
|
49
|
+
directory "app/services"
|
43
50
|
template 'app/views/layouts/application.html.erb' , 'app/views/layouts/application.html.erb'
|
44
51
|
end
|
45
52
|
|
@@ -55,6 +62,7 @@ def setup_avo
|
|
55
62
|
|
56
63
|
generate('avo:resource Category')
|
57
64
|
generate('avo:resource Post')
|
65
|
+
generate('avo:resource Comment')
|
58
66
|
generate('avo:resource Location')
|
59
67
|
generate('avo:resource Room')
|
60
68
|
generate('avo:resource Booking')
|
@@ -22,4 +22,7 @@ class PostResource < Avo::BaseResource
|
|
22
22
|
|
23
23
|
# tutorial (related category): https://youtu.be/WgNK-oINFww?t=328
|
24
24
|
field :category, as: :belongs_to
|
25
|
+
|
26
|
+
# tutorial (related category with custom name): https://youtu.be/WgNK-oINFww?t=722
|
27
|
+
field :user, name: "Author", as: :belongs_to
|
25
28
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
class Post < ApplicationRecord
|
2
|
-
belongs_to :author, class_name: 'User', foreign_key: :user_id
|
2
|
+
# belongs_to :author, class_name: 'User', foreign_key: :user_id
|
3
|
+
belongs_to :user
|
3
4
|
belongs_to :category
|
4
5
|
|
5
6
|
# tutorial: https://youtu.be/WgNK-oINFww?t=209
|
6
7
|
def excerpt
|
7
|
-
ActionView::Base.full_sanitizer.sanitize(content).truncate(
|
8
|
+
ActionView::Base.full_sanitizer.sanitize(content).truncate(50)
|
8
9
|
end
|
9
10
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
-
<h1
|
1
|
+
<h1><%= I18n.t('application_name') %></h1>
|
2
2
|
|
3
|
-
<p>Avo abstracts away the common parts of building apps, letting your engineers work on your app's essential components
|
3
|
+
<p>Avo abstracts away the common parts of building apps, letting your engineers work on your app's essential components.</p>
|
4
|
+
|
5
|
+
<p>The result is a full-featured admin panel that works out of the box, ready to give to your end-users.</p>
|
@@ -1,13 +1,19 @@
|
|
1
1
|
<%= link_to 'Home', root_path %> |
|
2
|
+
<%= link_to 'Re-Seed', home_reseed_path %> |
|
2
3
|
<%= link_to 'Quick Sign In', home_quick_signin_path %> |
|
3
4
|
<%= link_to 'AVO', avo_path %>
|
5
|
+
<% if current_user %>
|
6
|
+
<br>
|
4
7
|
(
|
5
|
-
<%= link_to 'Posts', posts_path, class: 'simple_scaffold' %> |
|
6
8
|
<%= link_to 'Categories', categories_path, class: 'simple_scaffold' %> |
|
9
|
+
<%= link_to 'Posts', posts_path, class: 'simple_scaffold' %> |
|
10
|
+
<%= link_to 'Comments', comments_path, class: 'simple_scaffold' %> |
|
7
11
|
<%= link_to 'Authors', users_path, class: 'simple_scaffold' %>
|
8
12
|
)
|
9
13
|
(
|
10
14
|
<%= link_to 'Locations', locations_path, class: 'simple_scaffold' %> |
|
11
15
|
<%= link_to 'Rooms', rooms_path, class: 'simple_scaffold' %> |
|
16
|
+
<%= link_to 'Comments', comments_path, class: 'simple_scaffold' %> |
|
12
17
|
<%= link_to 'Bookings', bookings_path, class: 'simple_scaffold' %>
|
13
18
|
)
|
19
|
+
<% end %>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Provides Rails integration for factory_bot
|
4
|
+
#
|
5
|
+
# exe/rag addons/factory_bot_rails
|
6
|
+
|
7
|
+
self.local_template_path = File.dirname(__FILE__)
|
8
|
+
|
9
|
+
gac 'base rails 7 image created'
|
10
|
+
|
11
|
+
prepare_environment
|
12
|
+
|
13
|
+
after_bundle do
|
14
|
+
scaffolds
|
15
|
+
setup_customizations
|
16
|
+
setup_db
|
17
|
+
end
|
18
|
+
|
19
|
+
def scaffolds
|
20
|
+
add_scaffold('post', 'title', 'body:text', 'is_featured:boolean')
|
21
|
+
add_scaffold('person', 'first_name', 'last_name', 'email', 'password', 'address:text')
|
22
|
+
add_scaffold('project', 'name', 'status', 'budget:decimal', 'country', 'progress:integer')
|
23
|
+
end
|
24
|
+
|
25
|
+
def setup_customizations
|
26
|
+
route("root 'home#index'")
|
27
|
+
|
28
|
+
force_copy
|
29
|
+
|
30
|
+
add_controller('home', 'index', 'reseed')
|
31
|
+
|
32
|
+
directory "app/controllers"
|
33
|
+
directory "app/models"
|
34
|
+
directory "app/services"
|
35
|
+
directory "app/views"
|
36
|
+
template 'app/views/layouts/application.html.erb' , 'app/views/layouts/application.html.erb'
|
37
|
+
copy_file 'factories.rb', 'factories.rb'
|
38
|
+
end
|
39
|
+
|
40
|
+
def setup_db
|
41
|
+
template 'db/seeds.rb' , 'db/seeds.rb'
|
42
|
+
|
43
|
+
db_migrate
|
44
|
+
db_seed
|
45
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class SeedService
|
2
|
+
class << self
|
3
|
+
def seed
|
4
|
+
service = SeedService.new
|
5
|
+
service.call
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
reset
|
11
|
+
create
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def reset
|
17
|
+
Person.delete_all
|
18
|
+
Post.delete_all
|
19
|
+
Project.delete_all
|
20
|
+
end
|
21
|
+
|
22
|
+
def create
|
23
|
+
FactoryBot.create_list(:post, rand(10..20))
|
24
|
+
FactoryBot.create_list(:person, rand(10..20))
|
25
|
+
FactoryBot.create_list(:project, rand(10..20))
|
26
|
+
end
|
27
|
+
end
|
File without changes
|
@@ -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 @@
|
|
1
|
+
SeedService.seed
|
@@ -0,0 +1,27 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
# add_scaffold('post', 'title', 'body:text', 'is_featured:boolean')
|
3
|
+
# add_scaffold('person', 'first_name', 'last_name', 'email', 'password', 'is_featured:boolean', 'address:text')
|
4
|
+
# add_scaffold('project', 'status', 'budget:decimal', 'country', 'progress:integer')
|
5
|
+
|
6
|
+
factory :person do
|
7
|
+
first_name { Faker::Name.first_name }
|
8
|
+
last_name { Faker::Name.last_name }
|
9
|
+
email { Faker::Internet.email }
|
10
|
+
password { Faker::Internet.password }
|
11
|
+
address { Faker::Address.full_address }
|
12
|
+
end
|
13
|
+
|
14
|
+
factory :post do
|
15
|
+
title { Faker::Quote.famous_last_words }
|
16
|
+
body { Faker::Lorem.paragraphs(number: rand(4...10)).join("\n") }
|
17
|
+
is_featured { [true, false].sample }
|
18
|
+
end
|
19
|
+
|
20
|
+
factory :project do
|
21
|
+
name { Faker::App.name }
|
22
|
+
status { [:closed, :rejected, :failed, :loading, :running, :waiting, :done, :finalized, :archived, :finished].sample }
|
23
|
+
budget { Faker::Number.decimal(l_digits: 4) }
|
24
|
+
country { Faker::Address.country_code }
|
25
|
+
progress { Faker::Number.between(from: 0, to: 100) }
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,32 @@
|
|
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.label :slug, style: "display: block" %>
|
26
|
+
<%= form.text_field :slug %>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<div>
|
30
|
+
<%= form.submit %>
|
31
|
+
</div>
|
32
|
+
<% end %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<p style="color: green"><%= notice %></p>
|
2
|
+
|
3
|
+
<h1>Posts</h1>
|
4
|
+
|
5
|
+
<div id="posts">
|
6
|
+
<% @posts.each do |post| %>
|
7
|
+
<%= render post %>
|
8
|
+
<p>
|
9
|
+
<%= link_to "Show this post", post %>
|
10
|
+
</p>
|
11
|
+
<% end %>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<%= link_to "New post", new_post_path %>
|
@@ -0,0 +1 @@
|
|
1
|
+
json.array! @posts, partial: "posts/post", as: :post
|
@@ -0,0 +1 @@
|
|
1
|
+
json.partial! "posts/post", post: @post
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# No Code as a Service Rails Application Builder
|
4
|
+
#
|
5
|
+
# exe/rag application/klueless
|
6
|
+
|
7
|
+
self.local_template_path = File.dirname(__FILE__)
|
8
|
+
|
9
|
+
gac 'base rails 7 image created'
|
10
|
+
|
11
|
+
prepare_environment
|
12
|
+
|
13
|
+
after_bundle do
|
14
|
+
force_copy
|
15
|
+
create_db
|
16
|
+
scaffolds
|
17
|
+
setup_customizations
|
18
|
+
migrate_db
|
19
|
+
setup_avo
|
20
|
+
|
21
|
+
swap1 = ' resources :users'
|
22
|
+
swap2 = " devise_for :users, controllers: { sessions: 'users/sessions', registrations: 'users/registrations' }"
|
23
|
+
|
24
|
+
swap_lines('config/routes.rb', swap1, swap2)
|
25
|
+
end
|
26
|
+
|
27
|
+
def scaffolds
|
28
|
+
add_scaffold_controller('users', 'name', 'email')
|
29
|
+
|
30
|
+
add_scaffold('rails_app', 'name', 'user:references') # name of the rails_app
|
31
|
+
|
32
|
+
# no of records in each table per region
|
33
|
+
add_scaffold('table_count', 'data:jsonb', 'rails_app:references')
|
34
|
+
# add_scaffold('table_count_table', 'name', 'region', 'count:integer', 'table_count:references')
|
35
|
+
|
36
|
+
# rubocop logs
|
37
|
+
add_scaffold('rubocop', 'data:jsonb', 'rails_app:references') # import_date is known as created_at
|
38
|
+
|
39
|
+
# database schema
|
40
|
+
add_scaffold('db_schema', 'data:jsonb', 'rails_app:references')
|
41
|
+
# add_scaffold('db_schema_table', 'name', 'primary_key', 'primary_key_type', 'db_schema:references')
|
42
|
+
|
43
|
+
# add_scaffold('db_schema_column', 'name', 'type', 'precision:integer', 'scale:integer', 'default', 'array:boolean', 'null:boolean', 'limit:integer', 'db_schema_table:references')
|
44
|
+
# add_scaffold('db_schema_foreign_key', 'left', 'right', 'name', 'on_update', 'on_delete', 'column', 'db_schema_table:references')
|
45
|
+
# add_scaffold('db_schema_index', 'name', 'fields', 'using', 'order:jsonb', 'where', 'unique', 'db_schema_table:references')
|
46
|
+
# add_scaffold('db_schema_view', 'name', 'materialized:boolean', 'sql_definition', 'db_schema_table:references')
|
47
|
+
end
|
48
|
+
|
49
|
+
def setup_customizations
|
50
|
+
route("root 'home#index'")
|
51
|
+
|
52
|
+
force_copy
|
53
|
+
|
54
|
+
add_controller('home', 'index', 'quick_signin', 'reseed')
|
55
|
+
|
56
|
+
directory "app/controllers"
|
57
|
+
directory "app/models"
|
58
|
+
directory "app/views"
|
59
|
+
template 'app/views/layouts/application.html.erb', 'app/views/layouts/application.html.erb'
|
60
|
+
directory "app/queries"
|
61
|
+
end
|
62
|
+
|
63
|
+
def setup_avo
|
64
|
+
# generate('avo:install')
|
65
|
+
|
66
|
+
generate('avo:resource RailsApp')
|
67
|
+
generate('avo:resource TableCount')
|
68
|
+
generate('avo:resource Rubocop')
|
69
|
+
generate('avo:resource DbSchema')
|
70
|
+
generate('avo:resource User')
|
71
|
+
# generate('avo:dashboard Dashboard')
|
72
|
+
|
73
|
+
directory "app/avo"
|
74
|
+
directory "config/initializers"
|
75
|
+
directory "config/locales"
|
76
|
+
|
77
|
+
# # add devise support
|
78
|
+
# gsub_file 'config/initializers/avo.rb', %(# config.current_user_method = {}), 'config.current_user_method = :current_user'
|
79
|
+
end
|
80
|
+
|
81
|
+
def create_db
|
82
|
+
gsub_file('config/database.yml', ' encoding: unicode', db_development_settings)
|
83
|
+
db(drop: true, create: true)
|
84
|
+
end
|
85
|
+
|
86
|
+
def migrate_db
|
87
|
+
template 'db/seeds.rb' , 'db/seeds.rb'
|
88
|
+
|
89
|
+
db(migrate: true, seed: true)
|
90
|
+
end
|
91
|
+
|
92
|
+
def db_development_settings
|
93
|
+
<<-'RUBY'
|
94
|
+
encoding: unicode
|
95
|
+
host: <%= ENV['DATABASE_HOST'] %>
|
96
|
+
username: <%= ENV['DATABASE_USERNAME'] %>
|
97
|
+
password: <%= ENV['DATABASE_PASSWORD'] %>
|
98
|
+
RUBY
|
99
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Dashboard < Avo::Dashboards::BaseDashboard
|
2
|
+
self.id = "dashboard"
|
3
|
+
self.name = "Dashboard"
|
4
|
+
|
5
|
+
# self.description = "Tiny dashboard description"
|
6
|
+
# self.grid_cols = 3
|
7
|
+
# self.visible = -> do
|
8
|
+
# true
|
9
|
+
# end
|
10
|
+
|
11
|
+
# cards go here
|
12
|
+
# card UsersCount
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class DbSchemaResource < Avo::BaseResource
|
2
|
+
self.title = :display_name
|
3
|
+
self.includes = []
|
4
|
+
|
5
|
+
# self.search_query = ->(params:) do
|
6
|
+
# scope.ransack(id_eq: params[:q], m: "or").result(distinct: false)
|
7
|
+
# end
|
8
|
+
|
9
|
+
field :id, as: :id
|
10
|
+
# field :data, as: :textarea, only_on: [:edit]
|
11
|
+
# field :user_name, as: :text
|
12
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class RailsAppResource < Avo::BaseResource
|
2
|
+
self.title = :display_name
|
3
|
+
self.includes = []
|
4
|
+
|
5
|
+
# self.search_query = ->(params:) do
|
6
|
+
# scope.ransack(id_eq: params[:q], m: "or").result(distinct: false)
|
7
|
+
# end
|
8
|
+
|
9
|
+
field :id, as: :id
|
10
|
+
field :name, as: :text
|
11
|
+
|
12
|
+
field :db_schema, as: :has_one
|
13
|
+
field :table_count, as: :has_one
|
14
|
+
field :rubocop, as: :has_one
|
15
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class RubocopResource < Avo::BaseResource
|
2
|
+
self.title = :display_name
|
3
|
+
self.includes = []
|
4
|
+
|
5
|
+
# self.search_query = ->(params:) do
|
6
|
+
# scope.ransack(id_eq: params[:q], m: "or").result(distinct: false)
|
7
|
+
# end
|
8
|
+
|
9
|
+
field :id, as: :id
|
10
|
+
# field :data, as: :textarea, only_on: [:edit]
|
11
|
+
# field :user_name, as: :text
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class TableCountResource < Avo::BaseResource
|
2
|
+
self.title = :display_name
|
3
|
+
self.includes = []
|
4
|
+
|
5
|
+
# self.search_query = ->(params:) do
|
6
|
+
# scope.ransack(id_eq: params[:q], m: "or").result(distinct: false)
|
7
|
+
# end
|
8
|
+
|
9
|
+
field :id, as: :id
|
10
|
+
# field :data, as: :textarea, only_on: [:edit]
|
11
|
+
# field :user_name, as: :text
|
12
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# tutorial (user resource): https://youtu.be/WgNK-oINFww?t=599
|
2
|
+
class UserResource < Avo::BaseResource
|
3
|
+
# https://docs.avohq.io/2.0/resources.html#devise-password-optional
|
4
|
+
# you need to fill in the password when creating a new user,
|
5
|
+
# but when editing a user you can leave the password field empty
|
6
|
+
self.devise_password_optional = true
|
7
|
+
|
8
|
+
# tutorial (better search experience): https://youtu.be/WgNK-oINFww?t=649
|
9
|
+
self.title = :email
|
10
|
+
self.includes = []
|
11
|
+
|
12
|
+
self.search_query = ->(params:) do
|
13
|
+
scope
|
14
|
+
.ransack(id_eq: params[:q], name_cont: params[:q], email_cont: params[:q], m: "or")
|
15
|
+
.result(distinct: false)
|
16
|
+
end
|
17
|
+
|
18
|
+
field :id, as: :id
|
19
|
+
field :email, as: :gravatar, link_to_resource: true, as_avatar: true
|
20
|
+
field :name, as: :text
|
21
|
+
field :email, as: :text, as_description: true
|
22
|
+
field :password, as: :text
|
23
|
+
field :posts, as: :has_many
|
24
|
+
end
|