geo_scaffold 0.1.3 → 0.1.4
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -3
- data/geo_scaffold.gif +0 -0
- data/install_geo_scaffold.gif +0 -0
- data/lib/generators/geo_scaffold/scaffold_generator.rb +2 -15
- data/lib/generators/geo_scaffold/templates/controller.rb +61 -59
- data/lib/generators/geo_scaffold/templates/helpers/helper.rb +1 -1
- data/lib/geo_scaffold/version.rb +1 -1
- metadata +4 -3
- data/geo_scaffold_demo.gif +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37f4e153574fa4e376e1a1eb7b77d66e47c99394096e95fc12f018c2d2ee5a5c
|
4
|
+
data.tar.gz: 75d922313c9287144215fd8df9127b83f010cf2108827ac20b8790f3ef2ba305
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3a5cf5b536dda13778288d9a73e35e913a6bf05824123a521be676c48ea95653314dd493072c70e0fe2723a5ea726cbf3545920c2265f644b9ad063e1e11552
|
7
|
+
data.tar.gz: 416db3d052f9ebedf25b0a6224a5dddba181e76f614f3caa6e331b42976068b8df4660a6e4c14903b96d131088a3e9d5f5c5b132cf6ea169356bb9b91249f727
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@ GeoScaffold generates views with [Geolonia Maps](https://geolonia.com/maps-dev/)
|
|
4
4
|
|
5
5
|
Geolonia Maps can be freely used without API key on [development environments](https://docs.geolonia.com/tutorial/002/#%E9%96%8B%E7%99%BA%E7%92%B0%E5%A2%83%E3%81%A7%E3%81%AE%E5%88%A9%E7%94%A8%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6) such as localhost, CodePen and JSFiddle etc.
|
6
6
|
|
7
|
-

|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
@@ -37,12 +37,14 @@ You may add attachment column like `photo` and it will be handled as an image.
|
|
37
37
|
% bin/rails g geo_scaffold:scaffold <resource name> name:string photo:attachment lat:float lng:float
|
38
38
|
```
|
39
39
|
|
40
|
-
|
40
|
+
In this case, you need to install Active Storage.
|
41
41
|
|
42
42
|
```
|
43
|
-
% bin/rails
|
43
|
+
% bin/rails active_storage:install
|
44
44
|
```
|
45
45
|
|
46
|
+

|
47
|
+
|
46
48
|
## Development
|
47
49
|
|
48
50
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/geo_scaffold.gif
ADDED
Binary file
|
Binary file
|
@@ -19,9 +19,9 @@ module GeoScaffold
|
|
19
19
|
|
20
20
|
hook_for :orm, as: :model
|
21
21
|
|
22
|
-
desc "Generates
|
22
|
+
desc "Generates model, controller and views for the model with the given NAME."
|
23
23
|
|
24
|
-
def
|
24
|
+
def copy_controller_file
|
25
25
|
template "controller.rb", File.join("app/controllers", "#{controller_file_name}_controller.rb")
|
26
26
|
end
|
27
27
|
|
@@ -40,19 +40,6 @@ module GeoScaffold
|
|
40
40
|
def copy_helper_files
|
41
41
|
template "helpers/helper.rb", File.join("app/helpers", "#{controller_file_name}_helper.rb")
|
42
42
|
end
|
43
|
-
|
44
|
-
protected
|
45
|
-
# def model_columns_for_attributes
|
46
|
-
# class_name.constantize.columns.reject do |column|
|
47
|
-
# column.name.to_s =~ /^(id|created_at|updated_at)$/
|
48
|
-
# end
|
49
|
-
# end
|
50
|
-
|
51
|
-
# def attributes
|
52
|
-
# model_columns_for_attributes.map do |column|
|
53
|
-
# Rails::Generators::GeneratedAttribute.new(column.name.to_s, column.type.to_s)
|
54
|
-
# end
|
55
|
-
# end
|
56
43
|
end
|
57
44
|
end
|
58
45
|
end
|
@@ -1,64 +1,66 @@
|
|
1
1
|
<% module_namespacing do -%>
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
2
|
+
class <%= plural_table_name.capitalize %>Controller < ApplicationController
|
3
|
+
before_action :set_<%= singular_table_name %>, only: %i[ show edit update destroy ]
|
4
|
+
|
5
|
+
# GET <%= route_url %>
|
6
|
+
def index
|
7
|
+
@<%= plural_table_name %> = <%= orm_class.all(class_name) %>
|
8
|
+
end
|
9
|
+
|
10
|
+
# GET <%= route_url %>/1
|
11
|
+
def show
|
12
|
+
end
|
13
|
+
|
14
|
+
# GET <%= route_url %>/new
|
15
|
+
def new
|
16
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name) %>
|
17
|
+
end
|
18
|
+
|
19
|
+
# GET <%= route_url %>/1/edit
|
20
|
+
def edit
|
21
|
+
end
|
22
|
+
|
23
|
+
# POST <%= route_url %>
|
24
|
+
def create
|
25
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %>
|
26
|
+
|
27
|
+
if @<%= orm_instance.save %>
|
28
|
+
redirect_to <%= redirect_resource_name %>, notice: <%= %("#{human_name} was successfully created.") %>
|
29
|
+
else
|
30
|
+
render :new, status: :unprocessable_entity
|
21
31
|
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
render :new, status: :unprocessable_entity
|
31
|
-
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# PATCH/PUT <%= route_url %>/1
|
35
|
+
def update
|
36
|
+
if @<%= orm_instance.update("#{singular_table_name}_params") %>
|
37
|
+
redirect_to <%= redirect_resource_name %>, notice: <%= %("#{human_name} was successfully updated.") %>
|
38
|
+
else
|
39
|
+
render :edit, status: :unprocessable_entity
|
32
40
|
end
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
end
|
42
|
+
|
43
|
+
# DELETE <%= route_url %>/1
|
44
|
+
def destroy
|
45
|
+
@<%= orm_instance.destroy %>
|
46
|
+
redirect_to <%= index_helper %>_url, notice: <%= %("#{human_name} was successfully destroyed.") %>, status: :see_other
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
# Use callbacks to share common setup or constraints between actions.
|
52
|
+
def set_<%= singular_table_name %>
|
53
|
+
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
41
54
|
end
|
42
|
-
|
43
|
-
#
|
44
|
-
def
|
45
|
-
|
46
|
-
|
55
|
+
|
56
|
+
# Only allow a list of trusted parameters through.
|
57
|
+
def <%= "#{singular_table_name}_params" %>
|
58
|
+
<%- if attributes_names.empty? -%>
|
59
|
+
params.fetch(:<%= singular_table_name %>, {})
|
60
|
+
<%- else -%>
|
61
|
+
params.require(:<%= singular_table_name %>).permit(<%= attributes.map { |a| ":#{a.name}" }.join(', ') %>)
|
62
|
+
<%- end -%>
|
47
63
|
end
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
def set_<%= singular_table_name %>
|
52
|
-
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
53
|
-
end
|
54
|
-
|
55
|
-
# Only allow a list of trusted parameters through.
|
56
|
-
def <%= "#{singular_table_name}_params" %>
|
57
|
-
<%- if attributes_names.empty? -%>
|
58
|
-
params.fetch(:<%= singular_table_name %>, {})
|
59
|
-
<%- else -%>
|
60
|
-
params.require(:<%= singular_table_name %>).permit(<%= attributes.map { |a| ":#{a.name}" }.join(', ') %>)
|
61
|
-
<%- end -%>
|
62
|
-
end
|
63
|
-
end
|
64
|
-
<% end -%>
|
64
|
+
|
65
|
+
end
|
66
|
+
<% end -%>
|
@@ -6,7 +6,7 @@ module <%= controller_class_name %>Helper
|
|
6
6
|
|
7
7
|
# To use variant of image, you need to add 'image_processing' gem to your Gemfile."
|
8
8
|
# html << "<strong><%= attribute.human_name %>:</strong> #{image_tag <%= singular_name %>.<%= attribute.column_name %>.variant(resize: "100x100^")}<br />" if <%= singular_name %>.<%= attribute.column_name %>.attached?
|
9
|
-
html << "<strong><%= attribute.human_name %>:</strong> #{image_tag <%= singular_name %>.<%= attribute.column_name
|
9
|
+
html << "<strong><%= attribute.human_name %>:</strong> #{image_tag <%= singular_name %>.<%= attribute.column_name %>, width: '100%'}<br />" if <%= singular_name %>.<%= attribute.column_name %>.attached?
|
10
10
|
|
11
11
|
<% else -%>
|
12
12
|
html << "<strong><%= attribute.human_name %>:</strong> #{<%= singular_name %>.<%= attribute.column_name %>}<br />"
|
data/lib/geo_scaffold/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geo_scaffold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Junya Ishihara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: GeoScaffold generates views with Geolonia Maps for a new resource that
|
14
14
|
has coordinates(lat and lng).
|
@@ -29,7 +29,8 @@ files:
|
|
29
29
|
- Rakefile
|
30
30
|
- bin/console
|
31
31
|
- bin/setup
|
32
|
-
-
|
32
|
+
- geo_scaffold.gif
|
33
|
+
- install_geo_scaffold.gif
|
33
34
|
- lib/generators/geo_scaffold/generator_helpers.rb
|
34
35
|
- lib/generators/geo_scaffold/scaffold_generator.rb
|
35
36
|
- lib/generators/geo_scaffold/templates/controller.rb
|
data/geo_scaffold_demo.gif
DELETED
Binary file
|