pompidou 0.1.0
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 +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/lib/generators/erb/pompidou/pompidou_generator.rb +65 -0
- data/lib/generators/erb/pompidou/templates/admin/_form.html.erb +44 -0
- data/lib/generators/erb/pompidou/templates/admin/edit.html.erb +11 -0
- data/lib/generators/erb/pompidou/templates/admin/index.html.erb +42 -0
- data/lib/generators/erb/pompidou/templates/admin/new.html.erb +10 -0
- data/lib/generators/erb/pompidou/templates/admin/show.html.erb +44 -0
- data/lib/generators/erb/pompidou/templates/public/index.html.erb +32 -0
- data/lib/generators/erb/pompidou/templates/public/show.html.erb +6 -0
- data/lib/generators/resource/USAGE +8 -0
- data/lib/generators/resource/resource_generator.rb +35 -0
- data/lib/generators/scaffold/USAGE +8 -0
- data/lib/generators/scaffold/scaffold_generator.rb +90 -0
- data/lib/generators/scaffold_controller/USAGE +1 -0
- data/lib/generators/scaffold_controller/scaffold_controller_generator.rb +34 -0
- data/lib/generators/scaffold_controller/templates/admin_controller.rb +62 -0
- data/lib/generators/scaffold_controller/templates/public_controller.rb +13 -0
- data/lib/pompidou.rb +10 -0
- data/lib/pompidou/generators.rb +9 -0
- data/lib/pompidou/railtie.rb +4 -0
- data/lib/pompidou/version.rb +3 -0
- data/pompidou.gemspec +26 -0
- metadata +138 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 9b0296a10e080dbfd9638aabc60e0ac9519f0e83
|
|
4
|
+
data.tar.gz: 0104ad84d89c9f3e71bdc63891749a73681fced9
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 44efeec41e422fed7e49d17346fa77ccb466d66a5dec5a189b1bd4fd0117bbe969db56582b7fbd91730b95e4c21a80cd86de170310ca1c7d98af280214f0aaa6
|
|
7
|
+
data.tar.gz: 7216d74b9351afceddab04d74c8d6e0b521bd72436ece6d568b7d779dda916cb1b94aa0582ecea1c5fbd732780d6f9d565e04a5b5bdbdf087610758a5848d799
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2015 John Friel
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Pompidou
|
|
2
|
+
|
|
3
|
+
TODO: Write a gem description
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'pompidou'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install pompidou
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
TODO: Write usage instructions here
|
|
24
|
+
|
|
25
|
+
## Contributing
|
|
26
|
+
|
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/pompidou/fork )
|
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require 'rails/generators/erb'
|
|
2
|
+
require 'rails/generators/resource_helpers'
|
|
3
|
+
|
|
4
|
+
module Erb # :nodoc:
|
|
5
|
+
module Generators # :nodoc:
|
|
6
|
+
class PompidouGenerator < Base # :nodoc:
|
|
7
|
+
include Rails::Generators::ResourceHelpers
|
|
8
|
+
|
|
9
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
10
|
+
|
|
11
|
+
argument :attributes, type: :array, default: [], banner: "field:type field:type"
|
|
12
|
+
|
|
13
|
+
def create_root_folder
|
|
14
|
+
empty_directory File.join("app/views/admin", controller_file_path)
|
|
15
|
+
empty_directory File.join("app/views/public", controller_file_path)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def copy_view_files
|
|
19
|
+
admin_views.each do |view|
|
|
20
|
+
Array(formats).each do |format|
|
|
21
|
+
filename = filename_with_extensions(view, format)
|
|
22
|
+
template "admin/#{filename}", File.join("app/views/admin", controller_file_path, filename)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
public_views.each do |view|
|
|
27
|
+
Array(formats).each do |format|
|
|
28
|
+
filename = filename_with_extensions(view, format)
|
|
29
|
+
template "public/#{filename}", File.join("app/views/public", controller_file_path, filename)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
protected
|
|
35
|
+
|
|
36
|
+
def admin_views
|
|
37
|
+
%w(index edit show new _form)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def public_views
|
|
41
|
+
%w(index show)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# The following four methods are copied from
|
|
45
|
+
# lib/rails/generators/erb.rb
|
|
46
|
+
def formats
|
|
47
|
+
format
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def format
|
|
51
|
+
:html
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def handler
|
|
55
|
+
:erb
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def filename_with_extensions(name, format)
|
|
59
|
+
[name, format, handler].compact.join(".")
|
|
60
|
+
end
|
|
61
|
+
# end copied methods
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<%%= form_for([:admin, @<%= singular_table_name %>]) do |f| %>
|
|
2
|
+
<%% if @<%= singular_table_name %>.errors.any? %>
|
|
3
|
+
<div class="row">
|
|
4
|
+
<div class="small-12 columns panel" id="error_explanation">
|
|
5
|
+
<h5><%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h5>
|
|
6
|
+
|
|
7
|
+
<ul>
|
|
8
|
+
<%% @<%= singular_table_name %>.errors.full_messages.each do |msg| %>
|
|
9
|
+
<li><%%= msg %></li>
|
|
10
|
+
<%% end %>
|
|
11
|
+
</ul>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
<%% end %>
|
|
15
|
+
|
|
16
|
+
<div class="row">
|
|
17
|
+
<div class="small-12 columns">
|
|
18
|
+
<fieldset>
|
|
19
|
+
<legend>Basic Info</legend>
|
|
20
|
+
|
|
21
|
+
<% attributes.each do |attribute| -%>
|
|
22
|
+
<% if attribute.password_digest? -%>
|
|
23
|
+
<%%= f.label :password %>
|
|
24
|
+
<%%= f.password_field :password %>
|
|
25
|
+
<%%= f.label :password_confirmation %>
|
|
26
|
+
<%%= f.password_field :password_confirmation %>
|
|
27
|
+
<% else -%>
|
|
28
|
+
<%- if attribute.reference? -%>
|
|
29
|
+
<%%= f.label :<%= attribute.column_name %> %>
|
|
30
|
+
<%%= f.<%= attribute.field_type %> :<%= attribute.column_name %> %>
|
|
31
|
+
<%- else -%>
|
|
32
|
+
<%%= f.label :<%= attribute.name %> %>
|
|
33
|
+
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
|
|
34
|
+
<%- end -%>
|
|
35
|
+
<% end -%>
|
|
36
|
+
<% end -%>
|
|
37
|
+
</fieldset>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<div class="small-12 columns actions">
|
|
41
|
+
<%%= f.submit nil, class: 'button small secondary radius' %>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
<%% end %>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<div class='row'>
|
|
2
|
+
<div class='small-12 columns'>
|
|
3
|
+
|
|
4
|
+
<h1><%= plural_table_name.humanize %></h1>
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
<%%= link_to 'New <%= human_name %>', new_admin_<%= singular_table_name %>_path %>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
<div class='row'>
|
|
14
|
+
<div class='small-12 columns'>
|
|
15
|
+
|
|
16
|
+
<table style='width:100%;'>
|
|
17
|
+
<thead>
|
|
18
|
+
<tr>
|
|
19
|
+
<% attributes.reject(&:password_digest?).each do |attribute| -%>
|
|
20
|
+
<th><%= attribute.human_name %></th>
|
|
21
|
+
<% end -%>
|
|
22
|
+
<th colspan="3"></th>
|
|
23
|
+
</tr>
|
|
24
|
+
</thead>
|
|
25
|
+
|
|
26
|
+
<tbody>
|
|
27
|
+
<%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
|
|
28
|
+
<tr>
|
|
29
|
+
<% attributes.reject(&:password_digest?).each do |attribute| -%>
|
|
30
|
+
<td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
|
|
31
|
+
<% end -%>
|
|
32
|
+
<td><%%= link_to 'Show', admin_<%= singular_table_name %>_path(<%= singular_table_name %>) %></td>
|
|
33
|
+
<td><%%= link_to 'Edit', edit_admin_<%= singular_table_name %>_path(<%= singular_table_name %>) %></td>
|
|
34
|
+
<td><%%= link_to 'Destroy', admin_<%= singular_table_name %>_path(<%= singular_table_name %>), method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
|
35
|
+
</tr>
|
|
36
|
+
<%% end %>
|
|
37
|
+
</tbody>
|
|
38
|
+
</table>
|
|
39
|
+
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<div class='row'>
|
|
2
|
+
<div class='small-12 columns'>
|
|
3
|
+
<div class='row'>
|
|
4
|
+
<div class='small-12 medium-7 large-9 columns'>
|
|
5
|
+
<h1><!-- Title attribute goes here --></h1>
|
|
6
|
+
<h5 class='subheader'><!-- subtitle or equivalent attribute goes here --></h5>
|
|
7
|
+
</div>
|
|
8
|
+
<div class='small-12 medium-5 large-3 columns text-right' style='margin-top:16px;'>
|
|
9
|
+
<ul class='button-group radius right'>
|
|
10
|
+
<li>
|
|
11
|
+
<%%= link_to 'Edit', edit_admin_<%= singular_table_name %>_path(@<%= singular_table_name %>), class: 'button tiny secondary' %>
|
|
12
|
+
</li>
|
|
13
|
+
<li>
|
|
14
|
+
<%%= link_to 'Back', admin_<%= index_helper %>_path, class: 'button tiny secondary' %>
|
|
15
|
+
</li>
|
|
16
|
+
<li>
|
|
17
|
+
<%%= link_to 'Delete', admin_<%= index_helper %>_path(id: @<%= singular_table_name %>), method: 'delete', data: {confirm: 'Are you sure?'}, class: 'button tiny secondary' %>
|
|
18
|
+
</li>
|
|
19
|
+
</ul>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
<div class='row'>
|
|
27
|
+
<div class='small-12 columns'>
|
|
28
|
+
<p id="notice"><%%= notice %></p>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<div class='row'>
|
|
33
|
+
<div class='small-12 columns'>
|
|
34
|
+
|
|
35
|
+
<% attributes.reject(&:password_digest?).each do |attribute| -%>
|
|
36
|
+
<p>
|
|
37
|
+
<strong><%= attribute.human_name %>:</strong>
|
|
38
|
+
<%%= @<%= singular_table_name %>.<%= attribute.name %> %>
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
<% end -%>
|
|
42
|
+
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<div class='row'>
|
|
2
|
+
<div class='small-12 columns'>
|
|
3
|
+
<h1>Public <%= plural_table_name %> View</h1>
|
|
4
|
+
<h5 class='subheader'>Customize meeee!</h5>
|
|
5
|
+
</div>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
<div class='row'>
|
|
9
|
+
<div class='small-12 columns'>
|
|
10
|
+
<table>
|
|
11
|
+
<thead>
|
|
12
|
+
<tr>
|
|
13
|
+
<% attributes.reject(&:password_digest?).each do |attribute| -%>
|
|
14
|
+
<th><%= attribute.human_name %></th>
|
|
15
|
+
<% end -%>
|
|
16
|
+
<th></th>
|
|
17
|
+
</tr>
|
|
18
|
+
</thead>
|
|
19
|
+
|
|
20
|
+
<tbody>
|
|
21
|
+
<%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
|
|
22
|
+
<tr>
|
|
23
|
+
<% attributes.reject(&:password_digest?).each do |attribute| -%>
|
|
24
|
+
<td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
|
|
25
|
+
<% end -%>
|
|
26
|
+
<td><%%= link_to 'Show', <%= singular_table_name %> %></td>
|
|
27
|
+
</tr>
|
|
28
|
+
<%% end %>
|
|
29
|
+
</tbody>
|
|
30
|
+
</table>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Pompidou
|
|
2
|
+
module Generators
|
|
3
|
+
class ResourceGenerator < Rails::Generators::NamedBase
|
|
4
|
+
|
|
5
|
+
# TODO -- Need to write the namespace code if it doesn't exist
|
|
6
|
+
|
|
7
|
+
def pompidou_routes
|
|
8
|
+
write_route admin_namespace_pattern
|
|
9
|
+
write_route public_namespace_pattern
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def write_route(pattern)
|
|
15
|
+
in_root do
|
|
16
|
+
inject_into_file(
|
|
17
|
+
'config/routes.rb',
|
|
18
|
+
"\n resources :#{file_name.pluralize}",
|
|
19
|
+
{ after: pattern, verbose: false, force: true }
|
|
20
|
+
)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def public_namespace_pattern
|
|
25
|
+
/^\s*scope\s*:module\s*=>\s*:public\s*do\s*$/
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def admin_namespace_pattern
|
|
29
|
+
/^\s*namespace\s*:admin\s*do\s*$/
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
require 'rails/generators/rails/resource/resource_generator'
|
|
2
|
+
require 'rails/generators/model_helpers'
|
|
3
|
+
require 'rails/generators/resource_helpers'
|
|
4
|
+
require 'active_support/core_ext/object/blank'
|
|
5
|
+
#require 'pry'
|
|
6
|
+
|
|
7
|
+
module Pompidou
|
|
8
|
+
module Generators
|
|
9
|
+
class ScaffoldGenerator < Rails::Generators::NamedBase
|
|
10
|
+
include Rails::Generators::ModelHelpers
|
|
11
|
+
include Rails::Generators::ResourceHelpers
|
|
12
|
+
|
|
13
|
+
argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
|
|
14
|
+
|
|
15
|
+
invoke 'active_record:model'
|
|
16
|
+
invoke 'pompidou:scaffold_controller'
|
|
17
|
+
invoke 'pompidou:resource'
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# Code for Rails' ModelGenerator
|
|
25
|
+
|
|
26
|
+
#module Rails
|
|
27
|
+
# module Generators
|
|
28
|
+
# class ModelGenerator < NamedBase # :nodoc:
|
|
29
|
+
# include Rails::Generators::ModelHelpers
|
|
30
|
+
#
|
|
31
|
+
# argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
|
|
32
|
+
# hook_for :orm, required: true
|
|
33
|
+
# end
|
|
34
|
+
# end
|
|
35
|
+
#end
|
|
36
|
+
#
|
|
37
|
+
#
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
#module Rails
|
|
41
|
+
# module Generators
|
|
42
|
+
# class ResourceGenerator < ModelGenerator # :nodoc:
|
|
43
|
+
# include ResourceHelpers
|
|
44
|
+
#
|
|
45
|
+
# hook_for :resource_controller, required: true do |controller|
|
|
46
|
+
# invoke controller, [ controller_name, options[:actions] ]
|
|
47
|
+
# end
|
|
48
|
+
#
|
|
49
|
+
# class_option :actions, type: :array, banner: "ACTION ACTION", default: [],
|
|
50
|
+
# desc: "Actions for the resource controller"
|
|
51
|
+
#
|
|
52
|
+
# hook_for :resource_route, required: true
|
|
53
|
+
# end
|
|
54
|
+
# end
|
|
55
|
+
#end
|
|
56
|
+
#
|
|
57
|
+
#
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
#module Rails
|
|
61
|
+
# module Generators
|
|
62
|
+
# class ScaffoldGenerator < ResourceGenerator # :nodoc:
|
|
63
|
+
# remove_hook_for :resource_controller
|
|
64
|
+
# remove_class_option :actions
|
|
65
|
+
#
|
|
66
|
+
# class_option :stylesheets, type: :boolean, desc: "Generate Stylesheets"
|
|
67
|
+
# class_option :stylesheet_engine, desc: "Engine for Stylesheets"
|
|
68
|
+
# class_option :assets, type: :boolean
|
|
69
|
+
# class_option :resource_route, type: :boolean
|
|
70
|
+
#
|
|
71
|
+
# def handle_skip
|
|
72
|
+
# @options = @options.merge(stylesheets: false) unless options[:assets]
|
|
73
|
+
# @options = @options.merge(stylesheet_engine: false) unless options[:stylesheets]
|
|
74
|
+
# end
|
|
75
|
+
#
|
|
76
|
+
# hook_for :scaffold_controller, required: true
|
|
77
|
+
#
|
|
78
|
+
# hook_for :assets do |assets|
|
|
79
|
+
# invoke assets, [controller_name]
|
|
80
|
+
# end
|
|
81
|
+
#
|
|
82
|
+
# hook_for :stylesheet_engine do |stylesheet_engine|
|
|
83
|
+
# if behavior == :invoke
|
|
84
|
+
# invoke stylesheet_engine, [controller_name]
|
|
85
|
+
# end
|
|
86
|
+
# end
|
|
87
|
+
# end
|
|
88
|
+
# end
|
|
89
|
+
#end
|
|
90
|
+
#
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
TODO
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'rails/generators/resource_helpers'
|
|
2
|
+
|
|
3
|
+
module Pompidou
|
|
4
|
+
module Generators
|
|
5
|
+
class ScaffoldControllerGenerator < Rails::Generators::NamedBase
|
|
6
|
+
include Rails::Generators::ResourceHelpers
|
|
7
|
+
|
|
8
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
9
|
+
|
|
10
|
+
check_class_collision suffix: "Controller"
|
|
11
|
+
|
|
12
|
+
class_option :orm, banner: "NAME", type: :string, required: true,
|
|
13
|
+
desc: "ORM to generate the controller for"
|
|
14
|
+
|
|
15
|
+
argument :attributes, type: :array, default: [], banner: "field:type field:type"
|
|
16
|
+
|
|
17
|
+
def create_controller_files
|
|
18
|
+
template(
|
|
19
|
+
"admin_controller.rb",
|
|
20
|
+
File.join('app/controllers/admin', controller_class_path, "#{controller_file_name}_controller.rb")
|
|
21
|
+
)
|
|
22
|
+
template(
|
|
23
|
+
"public_controller.rb",
|
|
24
|
+
File.join('app/controllers/public', controller_class_path, "#{controller_file_name}_controller.rb")
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
hook_for :template_engine, as: :pompidou
|
|
29
|
+
hook_for :test_framework, as: :scaffold
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
class Admin::<%= controller_class_name %>Controller < Admin::BaseController
|
|
2
|
+
before_action :set_<%= singular_table_name %>, only: [:show, :edit, :update, :destroy]
|
|
3
|
+
|
|
4
|
+
# GET /admin<%= route_url %>
|
|
5
|
+
def index
|
|
6
|
+
@<%= plural_table_name %> = <%= orm_class.all(class_name) %>
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# GET /admin<%= route_url %>/1
|
|
10
|
+
def show
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# GET /admin<%= route_url %>/new
|
|
14
|
+
def new
|
|
15
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name) %>
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# GET /admin<%= route_url %>/1/edit
|
|
19
|
+
def edit
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# POST /admin<%= route_url %>
|
|
23
|
+
def create
|
|
24
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %>
|
|
25
|
+
|
|
26
|
+
if @<%= orm_instance.save %>
|
|
27
|
+
redirect_to admin_<%= plural_table_name %>_path, notice: <%= "'#{human_name} was successfully created.'" %>
|
|
28
|
+
else
|
|
29
|
+
render :new
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# PATCH/PUT /admin<%= route_url %>/1
|
|
34
|
+
def update
|
|
35
|
+
if @<%= orm_instance.update("#{singular_table_name}_params") %>
|
|
36
|
+
redirect_to admin_<%= plural_table_name %>_path, notice: <%= "'#{human_name} was successfully updated.'" %>
|
|
37
|
+
else
|
|
38
|
+
render :edit
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# DELETE /admin<%= route_url %>/1
|
|
43
|
+
def destroy
|
|
44
|
+
@<%= orm_instance.destroy %>
|
|
45
|
+
redirect_to admin_<%= index_helper %>_url, notice: <%= "'#{human_name} was successfully destroyed.'" %>
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
50
|
+
def set_<%= singular_table_name %>
|
|
51
|
+
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Only allow a trusted parameter "white list" through.
|
|
55
|
+
def <%= "#{singular_table_name}_params" %>
|
|
56
|
+
<%- if attributes_names.empty? -%>
|
|
57
|
+
params[:<%= singular_table_name %>]
|
|
58
|
+
<%- else -%>
|
|
59
|
+
params.require(:<%= singular_table_name %>).permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>)
|
|
60
|
+
<%- end -%>
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class Public::<%= controller_class_name %>Controller < Public::BaseController
|
|
2
|
+
|
|
3
|
+
# GET <%= route_url %>
|
|
4
|
+
def index
|
|
5
|
+
@<%= plural_table_name %> = <%= orm_class.all(class_name) %>
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# GET <%= route_url %>/1
|
|
9
|
+
def show
|
|
10
|
+
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
data/lib/pompidou.rb
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
module Pompidou
|
|
2
|
+
module Generators
|
|
3
|
+
end
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
require "generators/erb/pompidou/pompidou_generator"
|
|
7
|
+
require "generators/scaffold_controller/scaffold_controller_generator"
|
|
8
|
+
require "generators/resource/resource_generator"
|
|
9
|
+
require "generators/scaffold/scaffold_generator"
|
data/pompidou.gemspec
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'pompidou/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "pompidou"
|
|
8
|
+
spec.version = Pompidou::VERSION
|
|
9
|
+
spec.authors = ["John Friel"]
|
|
10
|
+
spec.email = ["john@johnfriel.net"]
|
|
11
|
+
spec.summary = %q{A scaffolding generator that makes assumptions about your app}
|
|
12
|
+
spec.description = %q{A scaffolding generator that makes assumptions about your app}
|
|
13
|
+
spec.homepage = ""
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_runtime_dependency 'activesupport', '~> 4.0', '>= 4.0.1'
|
|
22
|
+
spec.add_runtime_dependency 'railties', '~> 4.0', '>= 4.0.1'
|
|
23
|
+
|
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
26
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: pompidou
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- John Friel
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-01-09 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: activesupport
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '4.0'
|
|
20
|
+
- - ">="
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: 4.0.1
|
|
23
|
+
type: :runtime
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
requirements:
|
|
27
|
+
- - "~>"
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '4.0'
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: 4.0.1
|
|
33
|
+
- !ruby/object:Gem::Dependency
|
|
34
|
+
name: railties
|
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '4.0'
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: 4.0.1
|
|
43
|
+
type: :runtime
|
|
44
|
+
prerelease: false
|
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
- - "~>"
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '4.0'
|
|
50
|
+
- - ">="
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: 4.0.1
|
|
53
|
+
- !ruby/object:Gem::Dependency
|
|
54
|
+
name: bundler
|
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
|
56
|
+
requirements:
|
|
57
|
+
- - "~>"
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: '1.7'
|
|
60
|
+
type: :development
|
|
61
|
+
prerelease: false
|
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
63
|
+
requirements:
|
|
64
|
+
- - "~>"
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: '1.7'
|
|
67
|
+
- !ruby/object:Gem::Dependency
|
|
68
|
+
name: rake
|
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
|
70
|
+
requirements:
|
|
71
|
+
- - "~>"
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: '10.0'
|
|
74
|
+
type: :development
|
|
75
|
+
prerelease: false
|
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
77
|
+
requirements:
|
|
78
|
+
- - "~>"
|
|
79
|
+
- !ruby/object:Gem::Version
|
|
80
|
+
version: '10.0'
|
|
81
|
+
description: A scaffolding generator that makes assumptions about your app
|
|
82
|
+
email:
|
|
83
|
+
- john@johnfriel.net
|
|
84
|
+
executables: []
|
|
85
|
+
extensions: []
|
|
86
|
+
extra_rdoc_files: []
|
|
87
|
+
files:
|
|
88
|
+
- ".gitignore"
|
|
89
|
+
- Gemfile
|
|
90
|
+
- LICENSE.txt
|
|
91
|
+
- README.md
|
|
92
|
+
- Rakefile
|
|
93
|
+
- lib/generators/erb/pompidou/pompidou_generator.rb
|
|
94
|
+
- lib/generators/erb/pompidou/templates/admin/_form.html.erb
|
|
95
|
+
- lib/generators/erb/pompidou/templates/admin/edit.html.erb
|
|
96
|
+
- lib/generators/erb/pompidou/templates/admin/index.html.erb
|
|
97
|
+
- lib/generators/erb/pompidou/templates/admin/new.html.erb
|
|
98
|
+
- lib/generators/erb/pompidou/templates/admin/show.html.erb
|
|
99
|
+
- lib/generators/erb/pompidou/templates/public/index.html.erb
|
|
100
|
+
- lib/generators/erb/pompidou/templates/public/show.html.erb
|
|
101
|
+
- lib/generators/resource/USAGE
|
|
102
|
+
- lib/generators/resource/resource_generator.rb
|
|
103
|
+
- lib/generators/scaffold/USAGE
|
|
104
|
+
- lib/generators/scaffold/scaffold_generator.rb
|
|
105
|
+
- lib/generators/scaffold_controller/USAGE
|
|
106
|
+
- lib/generators/scaffold_controller/scaffold_controller_generator.rb
|
|
107
|
+
- lib/generators/scaffold_controller/templates/admin_controller.rb
|
|
108
|
+
- lib/generators/scaffold_controller/templates/public_controller.rb
|
|
109
|
+
- lib/pompidou.rb
|
|
110
|
+
- lib/pompidou/generators.rb
|
|
111
|
+
- lib/pompidou/railtie.rb
|
|
112
|
+
- lib/pompidou/version.rb
|
|
113
|
+
- pompidou.gemspec
|
|
114
|
+
homepage: ''
|
|
115
|
+
licenses:
|
|
116
|
+
- MIT
|
|
117
|
+
metadata: {}
|
|
118
|
+
post_install_message:
|
|
119
|
+
rdoc_options: []
|
|
120
|
+
require_paths:
|
|
121
|
+
- lib
|
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
|
+
requirements:
|
|
124
|
+
- - ">="
|
|
125
|
+
- !ruby/object:Gem::Version
|
|
126
|
+
version: '0'
|
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0'
|
|
132
|
+
requirements: []
|
|
133
|
+
rubyforge_project:
|
|
134
|
+
rubygems_version: 2.2.2
|
|
135
|
+
signing_key:
|
|
136
|
+
specification_version: 4
|
|
137
|
+
summary: A scaffolding generator that makes assumptions about your app
|
|
138
|
+
test_files: []
|