jrhicks-static-generators 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
@@ -22,6 +22,7 @@ rails_generators/static_scaffold/templates/helper.rb
22
22
  rails_generators/static_scaffold/templates/helper_test.rb
23
23
  rails_generators/static_scaffold/templates/layout.html.erb
24
24
  rails_generators/static_scaffold/templates/model.rb
25
+ rails_generators/static_scaffold/templates/paperclip_tokens.rb
25
26
  rails_generators/static_scaffold/templates/view_edit.html.erb
26
27
  rails_generators/static_scaffold/templates/view_index.html.erb
27
28
  rails_generators/static_scaffold/templates/view_new.html.erb
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('static-generators', '0.2.0') do |p|
5
+ Echoe.new('static-generators', '0.2.1') do |p|
6
6
  p.project = "staticgenerators"
7
7
  p.description = "Generate attractive interfaces that are easy to edit."
8
8
  p.url = "http://github.com/jrhicks/static-scaffolds"
@@ -3,6 +3,7 @@ class StaticAuthorizationGenerator < Rails::Generator::Base
3
3
  record do |m|
4
4
 
5
5
  # Migration
6
+ m.directory(File.join('db','migrate'))
6
7
  m.template(
7
8
  "migration.rb",
8
9
  File.join('db','migrate',"#{Time.now.strftime("%Y%m%d%H%M%S")}_static_authorization.rb"))
@@ -21,6 +21,17 @@ end
21
21
 
22
22
  class GeneratorSpecs < GenSpecFactory
23
23
 
24
+ def ascendant_columns
25
+ if ascendant
26
+ [ascendant[:key]]
27
+ else
28
+ []
29
+ end
30
+ end
31
+
32
+ def primary_columns
33
+ column_specs.keys.select {|k| column_specs[k][:type]==:primary_key }
34
+ end
24
35
 
25
36
  def table_name
26
37
  raise Exception("table_name method not implimented.")
@@ -51,7 +51,24 @@ class <%=class_name%>GenSpecs < GeneratorSpecs
51
51
  <%end -%>
52
52
  ]
53
53
  end
54
-
54
+
55
+ def form_groups
56
+ [
57
+ {:group_name=>"<%=model_name.titleize%>",
58
+ :attributes=> [
59
+ <%for c in column_names -%>
60
+ <%if guess_list_columns.include?(c) -%>
61
+ <%=c.to_sym.inspect%>,
62
+ <%else -%>
63
+ # <%=c.to_sym.inspect%>,
64
+ <%end -%>
65
+ <%end -%>
66
+ ]},
67
+ # {:group_name=>"Group 2",
68
+ # :attributes=> [
69
+ # ]},
70
+ ]
71
+ end
55
72
 
56
73
  def column_specs
57
74
  {
@@ -75,9 +92,12 @@ class <%=class_name%>GenSpecs < GeneratorSpecs
75
92
  def file_columns
76
93
  column_specs.select {|k,v| v[:type]==:file or v[:type]==:photo}
77
94
  end
95
+
96
+ def safe_form_groups
97
+ form_groups.map {|group| {:group_name=>group[:group_name], :attributes=>(group[:attributes]-ascendant_columns-primary_columns)}}
98
+ end
78
99
 
79
100
  def belongs_to
80
- # {:name=>"foo", :model=>"Foo", :key=>"foo_id"}
81
101
  [
82
102
  <%justifier = CodeJustifier.new(belongs_to_columns) -%>
83
103
  <%justifier.add_parameter {|o| ":name=>#{o.name.slice(0,o.name.length-3).inspect}, "} -%>
@@ -89,8 +109,7 @@ class <%=class_name%>GenSpecs < GeneratorSpecs
89
109
  ]
90
110
  end
91
111
 
92
- def ascendant
93
- # {:name=>"foo", :model=>"Foo", :key=>"foo_id"}
112
+ def ascendant
94
113
  <%justifier = CodeJustifier.new(belongs_to_columns) -%>
95
114
  <%justifier.add_parameter {|o| ":name=>#{o.name.slice(0,o.name.length-3).inspect}, "} -%>
96
115
  <%justifier.add_parameter {|o| ":model=>#{o.name.slice(0,o.name.length-3).camelize.inspect}, "} -%>
@@ -101,7 +120,6 @@ class <%=class_name%>GenSpecs < GeneratorSpecs
101
120
  end
102
121
 
103
122
  def has_many
104
- # {:name=>"foo", :model=>"Foo", :key=>"foo_id"}
105
123
  [
106
124
  <%justifier = CodeJustifier.new(has_many_columns) -%>
107
125
  <%justifier.add_parameter {|o| ":name=>#{o[:table].pluralize.inspect}, "} -%>
@@ -113,8 +131,7 @@ class <%=class_name%>GenSpecs < GeneratorSpecs
113
131
  ]
114
132
  end
115
133
 
116
- def desendants
117
- # {:name=>"foo", :model=>"Foo", :key=>"foo_id"}
134
+ def desendants
118
135
  [
119
136
  <%justifier = CodeJustifier.new(has_many_columns) -%>
120
137
  <%justifier.add_parameter {|o| ":name=>#{o[:table].pluralize.inspect}, "} -%>
@@ -0,0 +1,4 @@
1
+ require 'paperclip'
2
+ Paperclip::Attachment.interpolations[:custom_root_path] = proc do |attachment, style|
3
+ attachment.instance.paperclip_custom_root_path
4
+ end
@@ -1,18 +1,38 @@
1
1
  <%% title "New <%= gen_spec.singular_title %>" %>
2
2
  <h1>New <%= gen_spec.singular_name %></h1>
3
3
 
4
- <%% form_for(@<%= singular_name %>) do |f| %>
4
+ <%% form_for(@<%= gen_spec.singular_name %>) do |f| %>
5
5
  <%%= f.error_messages %>
6
-
7
- <% for attribute in attributes -%>
6
+ <% if gen_spec.ascendant -%>
7
+ <%%=f.hidden(<%=gen_spec.singular_name%>, <%=gen_spec.ascendant[:key].inspect%>)
8
+ <% end %>
9
+ <% for group in gen_spec.safe_form_groups -%>
10
+ <h2><%=group[:group_name]%></h2>
11
+ <% for attribute in group[:attributes] -%>
12
+ <%options=gen_spec.column_specs[attribute] -%>
8
13
  <p>
9
- <%%= f.label :<%= attribute.name %> %><br />
10
- <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
14
+ <%%= f.label <%= options[:label].inspect %> %><br />
15
+ <% case options[:type] -%>
16
+ <% when :file -%>
17
+ <%%= f.file_field :<%= attribute %> %>
18
+ <% when :string -%>
19
+ <%%= f.text_field :<%= attribute %> %>
20
+ <% when :foreign_key -%>
21
+ <%%= f.text_field :<%= attribute %> %>
22
+ <% when :photo -%>
23
+ <%%= f.file_field :<%= attribute %> %>
24
+ <% when :datetime -%>
25
+ <%%= f.text_field :<%= attribute %> %>
26
+ <% end -%>
11
27
  </p>
28
+ <% end -%>
12
29
  <% end -%>
13
30
  <p>
14
31
  <%%= f.submit 'Create' %>
15
32
  </p>
16
33
  <%% end %>
17
34
 
18
- <%%= link_to 'Back', <%= plural_name %>_path %>
35
+ <%%= link_to 'Back', <%= plural_name %>_path %>
36
+
37
+
38
+
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{static-generators}
5
- s.version = "0.2.0"
5
+ s.version = "0.2.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jeffrey Hicks"]
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.description = %q{Generate attractive interfaces that are easy to edit.}
11
11
  s.email = %q{jrhicks (at) gmail (dot) com}
12
12
  s.extra_rdoc_files = ["CHANGELOG", "lib/static_generators.rb", "LICENSE", "README.md", "tasks/deployment.rake", "TODO"]
13
- s.files = ["CHANGELOG", "lib/static_generators.rb", "LICENSE", "rails_generators/static_app/static_app_generator.rb", "rails_generators/static_app/templates/application_helper.rb", "rails_generators/static_app/templates/layout.html.erb", "rails_generators/static_app/templates/layout_helper.rb", "rails_generators/static_app/templates/sorttable.js", "rails_generators/static_app/templates/static_style.css", "rails_generators/static_app/USAGE", "rails_generators/static_authorization/static_authorization_generator.rb", "rails_generators/static_authorization/templates/migration.rb", "rails_generators/static_authorization/USAGE", "rails_generators/static_gen_specs/static_gen_specs_generator.rb", "rails_generators/static_gen_specs/templates/generator_specs.rb", "rails_generators/static_gen_specs/templates/model_gen_specs.rb", "rails_generators/static_gen_specs/USAGE", "rails_generators/static_scaffold/static_scaffold_generator.rb", "rails_generators/static_scaffold/templates/controller.rb", "rails_generators/static_scaffold/templates/functional_test.rb", "rails_generators/static_scaffold/templates/helper.rb", "rails_generators/static_scaffold/templates/helper_test.rb", "rails_generators/static_scaffold/templates/layout.html.erb", "rails_generators/static_scaffold/templates/model.rb", "rails_generators/static_scaffold/templates/view_edit.html.erb", "rails_generators/static_scaffold/templates/view_index.html.erb", "rails_generators/static_scaffold/templates/view_new.html.erb", "rails_generators/static_scaffold/templates/view_show.html.erb", "rails_generators/static_scaffold/USAGE", "Rakefile", "README.md", "static-generators.gemspec", "tasks/deployment.rake", "TODO", "USAGE", "Manifest"]
13
+ s.files = ["CHANGELOG", "lib/static_generators.rb", "LICENSE", "rails_generators/static_app/static_app_generator.rb", "rails_generators/static_app/templates/application_helper.rb", "rails_generators/static_app/templates/layout.html.erb", "rails_generators/static_app/templates/layout_helper.rb", "rails_generators/static_app/templates/sorttable.js", "rails_generators/static_app/templates/static_style.css", "rails_generators/static_app/USAGE", "rails_generators/static_authorization/static_authorization_generator.rb", "rails_generators/static_authorization/templates/migration.rb", "rails_generators/static_authorization/USAGE", "rails_generators/static_gen_specs/static_gen_specs_generator.rb", "rails_generators/static_gen_specs/templates/generator_specs.rb", "rails_generators/static_gen_specs/templates/model_gen_specs.rb", "rails_generators/static_gen_specs/USAGE", "rails_generators/static_scaffold/static_scaffold_generator.rb", "rails_generators/static_scaffold/templates/controller.rb", "rails_generators/static_scaffold/templates/functional_test.rb", "rails_generators/static_scaffold/templates/helper.rb", "rails_generators/static_scaffold/templates/helper_test.rb", "rails_generators/static_scaffold/templates/layout.html.erb", "rails_generators/static_scaffold/templates/model.rb", "rails_generators/static_scaffold/templates/paperclip_tokens.rb", "rails_generators/static_scaffold/templates/view_edit.html.erb", "rails_generators/static_scaffold/templates/view_index.html.erb", "rails_generators/static_scaffold/templates/view_new.html.erb", "rails_generators/static_scaffold/templates/view_show.html.erb", "rails_generators/static_scaffold/USAGE", "Rakefile", "README.md", "tasks/deployment.rake", "TODO", "USAGE", "Manifest", "static-generators.gemspec"]
14
14
  s.has_rdoc = true
15
15
  s.homepage = %q{http://github.com/jrhicks/static-scaffolds}
16
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Static-generators", "--main", "README.md"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jrhicks-static-generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeffrey Hicks
@@ -51,6 +51,7 @@ files:
51
51
  - rails_generators/static_scaffold/templates/helper_test.rb
52
52
  - rails_generators/static_scaffold/templates/layout.html.erb
53
53
  - rails_generators/static_scaffold/templates/model.rb
54
+ - rails_generators/static_scaffold/templates/paperclip_tokens.rb
54
55
  - rails_generators/static_scaffold/templates/view_edit.html.erb
55
56
  - rails_generators/static_scaffold/templates/view_index.html.erb
56
57
  - rails_generators/static_scaffold/templates/view_new.html.erb
@@ -58,11 +59,11 @@ files:
58
59
  - rails_generators/static_scaffold/USAGE
59
60
  - Rakefile
60
61
  - README.md
61
- - static-generators.gemspec
62
62
  - tasks/deployment.rake
63
63
  - TODO
64
64
  - USAGE
65
65
  - Manifest
66
+ - static-generators.gemspec
66
67
  has_rdoc: true
67
68
  homepage: http://github.com/jrhicks/static-scaffolds
68
69
  post_install_message: