jrhicks-static-generators 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/LICENSE +21 -0
- data/Manifest +32 -0
- data/README.md +27 -0
- data/Rakefile +15 -0
- data/TODO +4 -0
- data/USAGE +17 -0
- data/lib/static_generators.rb +3 -0
- data/rails_generators/static_app/USAGE +0 -0
- data/rails_generators/static_app/static_app_generator.rb +26 -0
- data/rails_generators/static_app/templates/application_helper.rb +11 -0
- data/rails_generators/static_app/templates/layout.html.erb +0 -0
- data/rails_generators/static_app/templates/layout_helper.rb +9 -0
- data/rails_generators/static_app/templates/sorttable.js +568 -0
- data/rails_generators/static_app/templates/static_style.css +90 -0
- data/rails_generators/static_gen_specs/USAGE +0 -0
- data/rails_generators/static_gen_specs/static_gen_specs_generator.rb +343 -0
- data/rails_generators/static_gen_specs/templates/generator_specs.rb +60 -0
- data/rails_generators/static_gen_specs/templates/model_gen_specs.rb +145 -0
- data/rails_generators/static_scaffold/USAGE +29 -0
- data/rails_generators/static_scaffold/static_scaffold_generator.rb +150 -0
- data/rails_generators/static_scaffold/templates/controller.rb +85 -0
- data/rails_generators/static_scaffold/templates/functional_test.rb +45 -0
- data/rails_generators/static_scaffold/templates/helper.rb +2 -0
- data/rails_generators/static_scaffold/templates/helper_test.rb +4 -0
- data/rails_generators/static_scaffold/templates/layout.html.erb +18 -0
- data/rails_generators/static_scaffold/templates/model.rb +109 -0
- data/rails_generators/static_scaffold/templates/view_edit.html.erb +19 -0
- data/rails_generators/static_scaffold/templates/view_index.html.erb +26 -0
- data/rails_generators/static_scaffold/templates/view_new.html.erb +18 -0
- data/rails_generators/static_scaffold/templates/view_show.html.erb +13 -0
- data/static-generators.gemspec +31 -0
- data/tasks/deployment.rake +9 -0
- metadata +95 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
|
7
|
+
<title><<%%= h yield(:title) || <%=File.basename(RAILS_ROOT).titleize.inspect%> %></title>
|
8
|
+
<%%= stylesheet_link_tag 'static_style' %>
|
9
|
+
<%%= javascript_include_tag 'sorttable' %>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
|
13
|
+
<p style="color: green"><%%= flash[:notice] %></p>
|
14
|
+
|
15
|
+
<%%= yield %>
|
16
|
+
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,109 @@
|
|
1
|
+
class <%= class_name %> < ActiveRecord::Base
|
2
|
+
|
3
|
+
PUBLIC_ROOT_PATH = <%=gen_spec.public_root_path%>
|
4
|
+
PRIVATE_ROOT_PATH = <%=gen_spec.private_root_path%>
|
5
|
+
|
6
|
+
<%if gen_spec.file_columns.length>0 -%>
|
7
|
+
<%for column,options in gen_spec.file_columns -%>
|
8
|
+
file_column <%=column.inspect%>, :store_dir=><%="#{column}_store_dir".inspect%>, :root_path=><%if options["access"]%>PUBLIC_ROOT_PATH><%else%>PRIVATE_ROOT_PATH<%end%>
|
9
|
+
<%end -%>
|
10
|
+
|
11
|
+
<%end -%>
|
12
|
+
<%if gen_spec.belongs_to.length>0 -%>
|
13
|
+
<%for bt in gen_spec.belongs_to.sort {|a,b|a["name"]<=>b["name"]} -%>
|
14
|
+
belongs_to <%=bt[:name].inspect%>, :class_name=><%=bt[:model].inspect%>, :foreign_key=><%=bt[:key].inspect%>
|
15
|
+
<%end -%>
|
16
|
+
|
17
|
+
<%end -%>
|
18
|
+
<%if gen_spec.has_many.length>0 -%>
|
19
|
+
<%for hm in gen_spec.has_many.sort {|a,b|a["name"]<=>b["name"]} -%>
|
20
|
+
has_many <%=hm[:name].inspect%>, :class_name=><%=hm[:model].inspect%>, :foreign_key=><%=hm[:key].inspect%>
|
21
|
+
<%end -%>
|
22
|
+
|
23
|
+
<%end -%>
|
24
|
+
def self.table_name()
|
25
|
+
"<%=gen_spec.table_name%>"
|
26
|
+
end
|
27
|
+
|
28
|
+
def icon
|
29
|
+
"<%=gen_spec.singular_name%>.gif"
|
30
|
+
end
|
31
|
+
|
32
|
+
def short_name
|
33
|
+
name = "<%=gen_spec.short_name_columns.map{|c| "\#{@#{c}}"}.join(" ")%>"
|
34
|
+
if name==""
|
35
|
+
return "Untitled"
|
36
|
+
else
|
37
|
+
return name
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def order_preference
|
42
|
+
"<%=gen_spec.order_preference_columns.join(", ")%> <%=gen_spec.order_preference%>"
|
43
|
+
end
|
44
|
+
|
45
|
+
<%if gen_spec.ascendant -%>
|
46
|
+
def ascendant
|
47
|
+
<%=gen_spec.ascendant[:name]%>
|
48
|
+
end
|
49
|
+
|
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
|
+
<%end -%>
|
85
|
+
|
86
|
+
<%end -%>
|
87
|
+
# Security / Authorization
|
88
|
+
|
89
|
+
<%if gen_spec.authorization_method.to_s == 'static_authorization' -%>
|
90
|
+
def permits?(user)
|
91
|
+
if user.has_global_permit_for(<%=gen_spec.plural_name.inspect%>)
|
92
|
+
return true
|
93
|
+
else
|
94
|
+
<%if gen_spec.ascendant -%>
|
95
|
+
return (permitted_include?(user) and ascendant.permits?(user))
|
96
|
+
<%else -%>
|
97
|
+
return permitted_include?(user)
|
98
|
+
<%end -%>
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def permitted_include?(user)
|
103
|
+
# Asside from ascendant constraints, is this user permitted to access this <%=gen_spec.singular_name%>
|
104
|
+
return true
|
105
|
+
end
|
106
|
+
|
107
|
+
<%end -%>
|
108
|
+
end
|
109
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%% title "Edit <%= gen_spec.singular_title %>: "+@<%=gen_spec.singular_name%>.short_name %>
|
2
|
+
<h1>Editing <%= gen_spec.singular_name %>: <%%=@<%=gen_spec.singular_name%>.short_name%></h1>
|
3
|
+
|
4
|
+
<%% form_for(@<%= singular_name %>) do |f| %>
|
5
|
+
<%%= f.error_messages %>
|
6
|
+
|
7
|
+
<% for attribute in attributes -%>
|
8
|
+
<p>
|
9
|
+
<%%= f.label :<%= attribute.name %> %><br />
|
10
|
+
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
|
11
|
+
</p>
|
12
|
+
<% end -%>
|
13
|
+
<p>
|
14
|
+
<%%= f.submit 'Update' %>
|
15
|
+
</p>
|
16
|
+
<%% end %>
|
17
|
+
|
18
|
+
<%%= link_to 'Show', @<%= singular_name %> %> |
|
19
|
+
<%%= link_to 'Back', <%= plural_name %>_path %>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<%% title "Listing <%= gen_spec.plural_title %>" %>
|
2
|
+
<h1>Listing <%= gen_spec.plural_title %></h1>
|
3
|
+
|
4
|
+
<%%=data_table_start <%="#{gen_spec.plural_name}_#{next_count}".inspect%>%>
|
5
|
+
<tr>
|
6
|
+
<th> </th>
|
7
|
+
<% for cname in gen_spec.table_view_columns -%>
|
8
|
+
<% specs = gen_spec.column_specs[cname] -%>
|
9
|
+
<th><%= specs[:label]%><%= " (#{specs[:units]})" if specs[:units]%></th>
|
10
|
+
<% end -%>
|
11
|
+
</tr>
|
12
|
+
|
13
|
+
<%% @<%= gen_spec.plural_name %>.each do |<%= gen_spec.singular_name %>| %>
|
14
|
+
<tr>
|
15
|
+
<td><%%= link_to <%=gen_spec.singular_name%>.short_name, <%= gen_spec.singular_name %> %> </td>
|
16
|
+
<% for cname in gen_spec.table_view_columns -%>
|
17
|
+
<% specs = gen_spec.column_specs[cname] -%>
|
18
|
+
<td align="<%=specs["align"]%>"><%%=h <%= gen_spec.singular_name %>.<%= cname %> %></td>
|
19
|
+
<% end -%>
|
20
|
+
</tr>
|
21
|
+
<%% end %>
|
22
|
+
<%%=data_table_end <%="#{gen_spec.plural_name}_#{count}".inspect%>%>
|
23
|
+
|
24
|
+
<br />
|
25
|
+
|
26
|
+
<%%= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<%% title "New <%= gen_spec.singular_title %>" %>
|
2
|
+
<h1>New <%= gen_spec.singular_name %></h1>
|
3
|
+
|
4
|
+
<%% form_for(@<%= singular_name %>) do |f| %>
|
5
|
+
<%%= f.error_messages %>
|
6
|
+
|
7
|
+
<% for attribute in attributes -%>
|
8
|
+
<p>
|
9
|
+
<%%= f.label :<%= attribute.name %> %><br />
|
10
|
+
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
|
11
|
+
</p>
|
12
|
+
<% end -%>
|
13
|
+
<p>
|
14
|
+
<%%= f.submit 'Create' %>
|
15
|
+
</p>
|
16
|
+
<%% end %>
|
17
|
+
|
18
|
+
<%%= link_to 'Back', <%= plural_name %>_path %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<%% title @<%=gen_spec.singular_name%>.short_name%> %>
|
2
|
+
<h1><%%=@<%=gen_spec.singular_name%>.short_name%></h1>
|
3
|
+
|
4
|
+
<% for attribute in attributes -%>
|
5
|
+
<p>
|
6
|
+
<b><%= attribute.column.human_name %>:</b>
|
7
|
+
<%%=h @<%= singular_name %>.<%= attribute.name %> %>
|
8
|
+
</p>
|
9
|
+
|
10
|
+
<% end -%>
|
11
|
+
|
12
|
+
<%%= link_to 'Edit', edit_<%= singular_name %>_path(@<%= singular_name %>) %> |
|
13
|
+
<%%= link_to 'Back', <%= plural_name %>_path %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{static-generators}
|
5
|
+
s.version = "0.1.6"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Jeffrey Hicks"]
|
9
|
+
s.date = %q{2009-06-28}
|
10
|
+
s.description = %q{Generate attractive interfaces that are easy to edit.}
|
11
|
+
s.email = %q{jrhicks (at) gmail (dot) com}
|
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_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", "static-generators.gemspec"]
|
14
|
+
s.has_rdoc = true
|
15
|
+
s.homepage = %q{http://github.com/jrhicks/static-scaffolds}
|
16
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Static-generators", "--main", "README.md"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = %q{staticgenerators}
|
19
|
+
s.rubygems_version = %q{1.3.1}
|
20
|
+
s.summary = %q{Generate attractive interfaces that are easy to edit.}
|
21
|
+
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
|
+
s.specification_version = 2
|
25
|
+
|
26
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
+
else
|
28
|
+
end
|
29
|
+
else
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
desc "Build the manifest and gemspec files."
|
2
|
+
task :build => [:build_manifest, :build_gemspec]
|
3
|
+
|
4
|
+
desc "Move gemspec to root for github"
|
5
|
+
task :publish => :build_gemspec do
|
6
|
+
sh "git add static-generators.gemspec"
|
7
|
+
sh 'git commit -m "publish gem"'
|
8
|
+
sh 'git push'
|
9
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jrhicks-static-generators
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeffrey Hicks
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-06-28 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Generate attractive interfaces that are easy to edit.
|
17
|
+
email: jrhicks (at) gmail (dot) com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- CHANGELOG
|
24
|
+
- lib/static_generators.rb
|
25
|
+
- LICENSE
|
26
|
+
- README.md
|
27
|
+
- tasks/deployment.rake
|
28
|
+
- TODO
|
29
|
+
files:
|
30
|
+
- CHANGELOG
|
31
|
+
- lib/static_generators.rb
|
32
|
+
- LICENSE
|
33
|
+
- rails_generators/static_app/static_app_generator.rb
|
34
|
+
- rails_generators/static_app/templates/application_helper.rb
|
35
|
+
- rails_generators/static_app/templates/layout.html.erb
|
36
|
+
- rails_generators/static_app/templates/layout_helper.rb
|
37
|
+
- rails_generators/static_app/templates/sorttable.js
|
38
|
+
- rails_generators/static_app/templates/static_style.css
|
39
|
+
- rails_generators/static_app/USAGE
|
40
|
+
- rails_generators/static_gen_specs/static_gen_specs_generator.rb
|
41
|
+
- rails_generators/static_gen_specs/templates/generator_specs.rb
|
42
|
+
- rails_generators/static_gen_specs/templates/model_gen_specs.rb
|
43
|
+
- rails_generators/static_gen_specs/USAGE
|
44
|
+
- rails_generators/static_scaffold/static_scaffold_generator.rb
|
45
|
+
- rails_generators/static_scaffold/templates/controller.rb
|
46
|
+
- rails_generators/static_scaffold/templates/functional_test.rb
|
47
|
+
- rails_generators/static_scaffold/templates/helper.rb
|
48
|
+
- rails_generators/static_scaffold/templates/helper_test.rb
|
49
|
+
- rails_generators/static_scaffold/templates/layout.html.erb
|
50
|
+
- rails_generators/static_scaffold/templates/model.rb
|
51
|
+
- rails_generators/static_scaffold/templates/view_edit.html.erb
|
52
|
+
- rails_generators/static_scaffold/templates/view_index.html.erb
|
53
|
+
- rails_generators/static_scaffold/templates/view_new.html.erb
|
54
|
+
- rails_generators/static_scaffold/templates/view_show.html.erb
|
55
|
+
- rails_generators/static_scaffold/USAGE
|
56
|
+
- Rakefile
|
57
|
+
- README.md
|
58
|
+
- tasks/deployment.rake
|
59
|
+
- TODO
|
60
|
+
- USAGE
|
61
|
+
- Manifest
|
62
|
+
- static-generators.gemspec
|
63
|
+
has_rdoc: true
|
64
|
+
homepage: http://github.com/jrhicks/static-scaffolds
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options:
|
67
|
+
- --line-numbers
|
68
|
+
- --inline-source
|
69
|
+
- --title
|
70
|
+
- Static-generators
|
71
|
+
- --main
|
72
|
+
- README.md
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: "0"
|
80
|
+
version:
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: "1.2"
|
86
|
+
version:
|
87
|
+
requirements: []
|
88
|
+
|
89
|
+
rubyforge_project: staticgenerators
|
90
|
+
rubygems_version: 1.2.0
|
91
|
+
signing_key:
|
92
|
+
specification_version: 2
|
93
|
+
summary: Generate attractive interfaces that are easy to edit.
|
94
|
+
test_files: []
|
95
|
+
|