scaffold_cn 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/scaffold_cn/USAGE +4 -11
- data/lib/generators/scaffold_cn/scaffold_cn_generator.rb +18 -10
- data/lib/generators/scaffold_cn/templates/lib/templates/slim/scaffold/_form.html.slim +14 -0
- data/lib/generators/scaffold_cn/templates/lib/templates/slim/scaffold/edit.html.slim +8 -0
- data/lib/generators/scaffold_cn/templates/lib/templates/slim/scaffold/index.html.slim +23 -0
- data/lib/generators/scaffold_cn/templates/lib/templates/slim/scaffold/new.html.slim +5 -0
- data/lib/generators/scaffold_cn/templates/lib/templates/slim/scaffold/show.html.slim +11 -0
- data/lib/scaffold_cn/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20db374be069a7b0529846e3c980a99851cf9ed0
|
4
|
+
data.tar.gz: ddc0e6021a7b350a9d085e1118e926a4ba24615f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 896bda0d63ef494ed1306d5120852b30492931ee1ec059b67f36d7c99eec491828759dd08ab43c15f6e0e7ebba6a73eb03b843d683aff65ffee71a977890e595
|
7
|
+
data.tar.gz: da3871c9e1e3b524f5475532dbb4c4aba6cd17e165d6a1ea2df74e405031c43475b8fb1b7772cc9b87fa2ffc102b81f1b49dd1654b1811c4fbbb4de70bff448a
|
@@ -1,15 +1,8 @@
|
|
1
1
|
Description:
|
2
2
|
Translate the scaffold templates to zh_CN.
|
3
3
|
|
4
|
-
|
5
|
-
rails g scaffold_cn
|
4
|
+
Usage:
|
5
|
+
rails g scaffold_cn [type]
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
lib/templates/erb/scaffold/edit.html.erb
|
10
|
-
lib/templates/erb/scaffold/index.html.erb
|
11
|
-
lib/templates/erb/scaffold/new.html.erb
|
12
|
-
lib/templates/erb/scaffold/show.html.erb
|
13
|
-
|
14
|
-
config/locales/model.yml
|
15
|
-
config/locales/zh-CN.yml
|
7
|
+
The type is 'erb' or 'slim'.
|
8
|
+
For example, 'rails g scaffold_cn erb'
|
@@ -1,20 +1,28 @@
|
|
1
|
-
|
2
|
-
class Scaffold_cnGenerator < Rails::Generators::Base
|
1
|
+
class ScaffoldCnGenerator < Rails::Generators::NamedBase
|
2
|
+
#class Scaffold_cnGenerator < Rails::Generators::Base
|
3
3
|
source_root File.expand_path('../templates', __FILE__)
|
4
4
|
|
5
5
|
def generate_scaffold_cn
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
type = plural_name.singularize
|
7
|
+
puts "generate #{type} template files ..."
|
8
|
+
types = ['erb', 'slim']
|
9
|
+
if types.include? type
|
10
|
+
templates = [
|
11
|
+
"lib/templates/#{type}/scaffold/_form.html.#{type}",
|
12
|
+
"lib/templates/#{type}/scaffold/edit.html.#{type}",
|
13
|
+
"lib/templates/#{type}/scaffold/index.html.#{type}",
|
14
|
+
"lib/templates/#{type}/scaffold/new.html.#{type}",
|
15
|
+
"lib/templates/#{type}/scaffold/show.html.#{type}",
|
12
16
|
'config/locales/defaults.zh_CN.yml',
|
13
17
|
'config/locales/models.zh_CN.yml',
|
14
18
|
'config/locales/views.zh_CN.yml',
|
15
19
|
'config/locales/devise.zh_CN.yml']
|
16
|
-
|
17
|
-
|
20
|
+
templates.each do |path|
|
21
|
+
copy_file path, path
|
22
|
+
end
|
23
|
+
else
|
24
|
+
puts "The type '#{type}' not support yet."
|
25
|
+
puts "You can choose one from [ #{types.join(',')} ]"
|
18
26
|
end
|
19
27
|
end
|
20
28
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
= form_for @<%= singular_table_name %> do |f|
|
2
|
+
- if @<%= singular_table_name %>.errors.any?
|
3
|
+
#error_explanation
|
4
|
+
h2 = "#{pluralize(@<%= singular_table_name %>.errors.count, "error")} prohibited this <%= singular_table_name %> from being saved:"
|
5
|
+
ul
|
6
|
+
- @<%= singular_table_name %>.errors.full_messages.each do |message|
|
7
|
+
li = message
|
8
|
+
|
9
|
+
<% attributes.each do |attribute| -%>
|
10
|
+
.field
|
11
|
+
= f.label :<%= attribute.name %>
|
12
|
+
= f.<%= attribute.field_type %> :<%= attribute.name %>
|
13
|
+
<% end -%>
|
14
|
+
.actions = f.submit t(:submit)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
h1 = <%= human_name %>.model_name.human + t(:index)
|
2
|
+
|
3
|
+
table
|
4
|
+
tr
|
5
|
+
<% attributes.each do |attribute| -%>
|
6
|
+
th = <%= human_name %>.human_attribute_name("<%= attribute.name %>")
|
7
|
+
<% end -%>
|
8
|
+
th
|
9
|
+
th
|
10
|
+
th
|
11
|
+
|
12
|
+
- @<%= plural_table_name %>.each do |<%= singular_table_name %>|
|
13
|
+
tr
|
14
|
+
<% attributes.each do |attribute| -%>
|
15
|
+
td = <%= singular_table_name %>.<%= attribute.name %>
|
16
|
+
<% end -%>
|
17
|
+
td = link_to t(:show), <%= singular_table_name %>
|
18
|
+
td = link_to t(:edit), edit_<%= singular_table_name %>_path(<%= singular_table_name %>)
|
19
|
+
td = link_to t(:delete), <%= singular_table_name %>, :confirm => t(:confirm_delete), :method => :delete
|
20
|
+
|
21
|
+
br
|
22
|
+
|
23
|
+
= link_to (t(:new) + <%= human_name %>.model_name.human), new_<%= singular_table_name %>_path
|
@@ -0,0 +1,11 @@
|
|
1
|
+
p#notice = notice
|
2
|
+
|
3
|
+
<% attributes.each do |attribute| -%>
|
4
|
+
p
|
5
|
+
strong = <%= human_name %>.human_attribute_name("<%= attribute.name %>") + ':'
|
6
|
+
= @<%= singular_table_name %>.<%= attribute.name %>
|
7
|
+
<% end -%>
|
8
|
+
|
9
|
+
= link_to t(:edit), edit_<%= singular_table_name %>_path(@<%= singular_table_name %>)
|
10
|
+
'|
|
11
|
+
= link_to t(:back), <%= index_helper %>_path
|
data/lib/scaffold_cn/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scaffold_cn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- homeway
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -41,6 +41,11 @@ files:
|
|
41
41
|
- lib/generators/scaffold_cn/templates/lib/templates/erb/scaffold/index.html.erb
|
42
42
|
- lib/generators/scaffold_cn/templates/lib/templates/erb/scaffold/new.html.erb
|
43
43
|
- lib/generators/scaffold_cn/templates/lib/templates/erb/scaffold/show.html.erb
|
44
|
+
- lib/generators/scaffold_cn/templates/lib/templates/slim/scaffold/_form.html.slim
|
45
|
+
- lib/generators/scaffold_cn/templates/lib/templates/slim/scaffold/edit.html.slim
|
46
|
+
- lib/generators/scaffold_cn/templates/lib/templates/slim/scaffold/index.html.slim
|
47
|
+
- lib/generators/scaffold_cn/templates/lib/templates/slim/scaffold/new.html.slim
|
48
|
+
- lib/generators/scaffold_cn/templates/lib/templates/slim/scaffold/show.html.slim
|
44
49
|
- lib/generators/scaffold_cn/USAGE
|
45
50
|
- lib/scaffold_cn/version.rb
|
46
51
|
- lib/scaffold_cn.rb
|