jrhicks-static-generators 0.1.8 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +4 -3
- data/Rakefile +1 -1
- data/rails_generators/static_gen_specs/templates/model_gen_specs.rb +10 -5
- data/rails_generators/static_scaffold/static_scaffold_generator.rb +5 -0
- data/rails_generators/static_scaffold/templates/model.rb +15 -39
- data/static-generators.gemspec +2 -2
- metadata +2 -2
data/Manifest
CHANGED
@@ -8,9 +8,9 @@ rails_generators/static_app/templates/layout_helper.rb
|
|
8
8
|
rails_generators/static_app/templates/sorttable.js
|
9
9
|
rails_generators/static_app/templates/static_style.css
|
10
10
|
rails_generators/static_app/USAGE
|
11
|
-
rails_generators/
|
12
|
-
rails_generators/
|
13
|
-
rails_generators/
|
11
|
+
rails_generators/static_authorization/static_authorization_generator.rb
|
12
|
+
rails_generators/static_authorization/templates/migration.rb
|
13
|
+
rails_generators/static_authorization/USAGE
|
14
14
|
rails_generators/static_gen_specs/static_gen_specs_generator.rb
|
15
15
|
rails_generators/static_gen_specs/templates/generator_specs.rb
|
16
16
|
rails_generators/static_gen_specs/templates/model_gen_specs.rb
|
@@ -29,6 +29,7 @@ rails_generators/static_scaffold/templates/view_show.html.erb
|
|
29
29
|
rails_generators/static_scaffold/USAGE
|
30
30
|
Rakefile
|
31
31
|
README.md
|
32
|
+
static-generators.gemspec
|
32
33
|
tasks/deployment.rake
|
33
34
|
TODO
|
34
35
|
USAGE
|
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.
|
5
|
+
Echoe.new('static-generators', '0.2.0') 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"
|
@@ -5,7 +5,7 @@ class <%=class_name%>GenSpecs < GeneratorSpecs
|
|
5
5
|
:plural_label, :singular_label, :plural_title, :singular_title,
|
6
6
|
:authentication_method, :authorization_method,
|
7
7
|
:order_preference_columns, :order_preference,
|
8
|
-
:
|
8
|
+
:paperclip_public_root_path, :paperclip_private_root_path, :paperclip_custom_root_path_code, :will_paginate
|
9
9
|
|
10
10
|
def initialize()
|
11
11
|
@model_name = <%=model_name.inspect%>
|
@@ -20,15 +20,16 @@ class <%=class_name%>GenSpecs < GeneratorSpecs
|
|
20
20
|
|
21
21
|
# Security
|
22
22
|
@authentication_method = :AuthLogic # :none
|
23
|
-
@authorization_method = :static_authorization # :
|
23
|
+
@authorization_method = :static_authorization # :none
|
24
24
|
|
25
25
|
# Order
|
26
26
|
@order_preference_columns = <%=guess_ordered_columns.inspect%>
|
27
27
|
@order_preference = "ASC"
|
28
28
|
|
29
|
-
#
|
30
|
-
@
|
31
|
-
@
|
29
|
+
# Paperclip configuration
|
30
|
+
@paperclip_public_root_path = ':rails_root/public/system/'
|
31
|
+
@paperclip_private_root_path = ':rails_root/private/'
|
32
|
+
@paperclip_custom_root_path_code = nil # "self.project.project_number" or "self.album_id"
|
32
33
|
|
33
34
|
# Pagination
|
34
35
|
@will_paginate = true # false
|
@@ -76,6 +77,7 @@ class <%=class_name%>GenSpecs < GeneratorSpecs
|
|
76
77
|
end
|
77
78
|
|
78
79
|
def belongs_to
|
80
|
+
# {:name=>"foo", :model=>"Foo", :key=>"foo_id"}
|
79
81
|
[
|
80
82
|
<%justifier = CodeJustifier.new(belongs_to_columns) -%>
|
81
83
|
<%justifier.add_parameter {|o| ":name=>#{o.name.slice(0,o.name.length-3).inspect}, "} -%>
|
@@ -88,6 +90,7 @@ class <%=class_name%>GenSpecs < GeneratorSpecs
|
|
88
90
|
end
|
89
91
|
|
90
92
|
def ascendant
|
93
|
+
# {:name=>"foo", :model=>"Foo", :key=>"foo_id"}
|
91
94
|
<%justifier = CodeJustifier.new(belongs_to_columns) -%>
|
92
95
|
<%justifier.add_parameter {|o| ":name=>#{o.name.slice(0,o.name.length-3).inspect}, "} -%>
|
93
96
|
<%justifier.add_parameter {|o| ":model=>#{o.name.slice(0,o.name.length-3).camelize.inspect}, "} -%>
|
@@ -98,6 +101,7 @@ class <%=class_name%>GenSpecs < GeneratorSpecs
|
|
98
101
|
end
|
99
102
|
|
100
103
|
def has_many
|
104
|
+
# {:name=>"foo", :model=>"Foo", :key=>"foo_id"}
|
101
105
|
[
|
102
106
|
<%justifier = CodeJustifier.new(has_many_columns) -%>
|
103
107
|
<%justifier.add_parameter {|o| ":name=>#{o[:table].pluralize.inspect}, "} -%>
|
@@ -110,6 +114,7 @@ class <%=class_name%>GenSpecs < GeneratorSpecs
|
|
110
114
|
end
|
111
115
|
|
112
116
|
def desendants
|
117
|
+
# {:name=>"foo", :model=>"Foo", :key=>"foo_id"}
|
113
118
|
[
|
114
119
|
<%justifier = CodeJustifier.new(has_many_columns) -%>
|
115
120
|
<%justifier.add_parameter {|o| ":name=>#{o[:table].pluralize.inspect}, "} -%>
|
@@ -61,6 +61,11 @@ class StaticScaffoldGenerator < Rails::Generator::NamedBase
|
|
61
61
|
m.directory(File.join('test/unit', class_path))
|
62
62
|
m.directory(File.join('test/unit/helpers', class_path))
|
63
63
|
m.directory(File.join('public/stylesheets', class_path))
|
64
|
+
|
65
|
+
# Paperclip tokens initializer
|
66
|
+
# http://blog.eizesus.com/2009/4/paperclip-custom-storage-path
|
67
|
+
m.template("paperclip_tokens.rb",
|
68
|
+
File.join("config","initializers","paperclip_tokens.rb"))
|
64
69
|
|
65
70
|
# Model
|
66
71
|
m.template(
|
@@ -1,11 +1,22 @@
|
|
1
1
|
class <%= class_name %> < ActiveRecord::Base
|
2
2
|
|
3
|
-
PUBLIC_ROOT_PATH = <%=gen_spec.public_root_path%>
|
4
|
-
PRIVATE_ROOT_PATH = <%=gen_spec.private_root_path%>
|
5
|
-
|
6
3
|
<%if gen_spec.file_columns.length>0 -%>
|
7
4
|
<%for column,options in gen_spec.file_columns -%>
|
8
|
-
|
5
|
+
<%if options[:access]==:private -%>
|
6
|
+
has_attached_file <%=column.inspect%>,
|
7
|
+
:url => "/<%=gen_spec.plural_name%>/attachment/:attachment/:id/:style/:basename.:extension",
|
8
|
+
:path => "<%=gen_spec.paperclip_private_root_path%><%=":custom_root_path/" if gen_spec.paperclip_custom_root_path_code%>:attachment/:id/:style/:basename.:extension"
|
9
|
+
<%else -%>
|
10
|
+
has_attached_file <%=column.inspect%>,
|
11
|
+
:url => "/system/:attachment/:id/:style/:basename.:extension",
|
12
|
+
:path => "<%=gen_spec.paperclip_public_root_path%><%=":custom_root_path/" if gen_spec.paperclip_custom_root_path_code%>:attachment/:id/:style/:basename.:extension"
|
13
|
+
<%end -%>
|
14
|
+
|
15
|
+
<%end -%>
|
16
|
+
<%if gen_spec.paperclip_custom_root_path_code -%>
|
17
|
+
def paperclip_custom_root_path
|
18
|
+
<%=gen_spec.paperclip_custom_root_path_code%>
|
19
|
+
end
|
9
20
|
<%end -%>
|
10
21
|
|
11
22
|
<%end -%>
|
@@ -47,43 +58,8 @@ class <%= class_name %> < ActiveRecord::Base
|
|
47
58
|
<%=gen_spec.ascendant[:name]%>
|
48
59
|
end
|
49
60
|
|
50
|
-
<%end -%>
|
51
|
-
<%if gen_spec.file_columns -%>
|
52
|
-
# File Columns Directory
|
53
|
-
|
54
|
-
def refactored_store_dir
|
55
|
-
<%=gen_spec.singular_name.pluralize.inspect%>
|
56
|
-
end
|
57
|
-
<%for column,options in gen_spec.file_columns -%>
|
58
|
-
def <%=column%>_store_dir
|
59
|
-
File.join(refactored_store_dir, <%=column.to_s.pluralize.inspect%>)
|
60
|
-
end
|
61
|
-
|
62
|
-
def <%=column%>_icon
|
63
|
-
<%if options["type"]==:photo%>
|
64
|
-
return "photo.gif"
|
65
|
-
<%else -%>
|
66
|
-
return "attachment.gif"
|
67
|
-
<%end -%>
|
68
|
-
end
|
69
|
-
|
70
|
-
def <%=column%>_basename
|
71
|
-
File.basename(@<%=column%>)
|
72
|
-
end
|
73
|
-
|
74
|
-
def <%=column%>_shortname
|
75
|
-
b=<%=column%>_basename
|
76
|
-
if b and b.length>13
|
77
|
-
"#{b.slice(0,8)}~#{b.slice(-4,4)}"
|
78
|
-
else
|
79
|
-
b
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
|
84
61
|
<%end -%>
|
85
62
|
|
86
|
-
<%end -%>
|
87
63
|
# Security / Authorization
|
88
64
|
|
89
65
|
<%if gen_spec.authorization_method.to_s == 'static_authorization' -%>
|
data/static-generators.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{static-generators}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.2.0"
|
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", "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/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"]
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeffrey Hicks
|
@@ -58,11 +58,11 @@ files:
|
|
58
58
|
- rails_generators/static_scaffold/USAGE
|
59
59
|
- Rakefile
|
60
60
|
- README.md
|
61
|
+
- static-generators.gemspec
|
61
62
|
- tasks/deployment.rake
|
62
63
|
- TODO
|
63
64
|
- USAGE
|
64
65
|
- Manifest
|
65
|
-
- static-generators.gemspec
|
66
66
|
has_rdoc: true
|
67
67
|
homepage: http://github.com/jrhicks/static-scaffolds
|
68
68
|
post_install_message:
|