form_factor 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest ADDED
@@ -0,0 +1,10 @@
1
+ Rakefile
2
+ app/helpers/form_factor_helper.rb
3
+ lib/form_factor/form_factor.rb
4
+ lib/form_factor/scaffold_template.rb
5
+ lib/templates/erb/scaffold/_form.html.erb
6
+ lib/templates/erb/scaffold/edit.html.erb
7
+ lib/templates/erb/scaffold/index.html.erb
8
+ lib/templates/erb/scaffold/new.html.erb
9
+ lib/templates/erb/scaffold/show.html.erb
10
+ Manifest
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('form_factor', '0.0.2') do |g|
6
+ g.summary = "Abstract builder of form structure with pluggable templates"
7
+ g.description = <<-EOF
8
+ Form Factor is a miniature abstraction layer for view generation.
9
+ Form Factor breaks the coupling between a view element and the structural
10
+ markup generated, in order to make the generation more flexible.
11
+
12
+ Instead of directly specifying the literal view to generate, Form Factor
13
+ defers that to a template, which decides: (1) Structural markup to generate
14
+ (2) stylesheets to include and (3) javascripts to include.
15
+
16
+ Plugging in a different Form Factor template can be done with a single line
17
+ of controller code, giving your site a different look and feel.
18
+ EOF
19
+ g.url = "http://www.ociweb.com/products/formfactor"
20
+ g.author = "Jeff Schmitz @iamtheschmitzer"
21
+ g.email = "jeffrey.j.schmitz@nospam.gmail.com"
22
+ g.ignore_pattern = ["tmp/*", "script/*"]
23
+ g.development_dependencies = []
24
+ end
@@ -0,0 +1,23 @@
1
+ module FormFactorHelper
2
+
3
+ def ff_stylesheet_links
4
+ ff_included_ss.map {|ss| stylesheet_link_tag(ss) }.join.html_safe
5
+ end
6
+
7
+ def ff_javascript_includes
8
+ ff_included_js.map {|js| javascript_include_tag(js) }.join.html_safe
9
+ end
10
+
11
+ def form_factor options
12
+ t = ff_template(options)
13
+ results = "".html_safe
14
+ if t.respond_to? :render_head
15
+ results << t.render_head
16
+ end
17
+ results << with_output_buffer { yield(t) if block_given? }
18
+ if t.respond_to? :render_tail
19
+ results << t.render_tail
20
+ end
21
+ results
22
+ end
23
+ end
@@ -0,0 +1,42 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{form_factor}
5
+ s.version = "0.0.3"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Jeff Schmitz @iamtheschmitzer"]
9
+ s.cert_chain = ["/export/home/jeff/.ssh/gem-public_cert.pem"]
10
+ s.date = %q{2010-09-27}
11
+ s.description = %q{ Form Factor is a miniature abstraction layer for view generation.
12
+ Form Factor breaks the coupling between a view element and the structural
13
+ markup generated, in order to make the generation more flexible.
14
+
15
+ Instead of directly specifying the literal view to generate, Form Factor
16
+ defers that to a template, which decides: (1) Structural markup to generate
17
+ (2) stylesheets to include and (3) javascripts to include.
18
+
19
+ Plugging in a different Form Factor template can be done with a single line
20
+ of controller code, giving your site a different look and feel.
21
+ }
22
+ s.email = %q{jeffrey.j.schmitz@nospam.gmail.com}
23
+ s.extra_rdoc_files = ["lib/form_factor/form_factor.rb", "lib/form_factor/scaffold_template.rb", "lib/templates/erb/scaffold/_form.html.erb", "lib/templates/erb/scaffold/edit.html.erb", "lib/templates/erb/scaffold/index.html.erb", "lib/templates/erb/scaffold/new.html.erb", "lib/templates/erb/scaffold/show.html.erb"]
24
+ s.files = ["Rakefile", "app/helpers/form_factor_helper.rb", "lib/form_factor/form_factor.rb", "lib/form_factor/scaffold_template.rb", "lib/templates/erb/scaffold/_form.html.erb", "lib/templates/erb/scaffold/edit.html.erb", "lib/templates/erb/scaffold/index.html.erb", "lib/templates/erb/scaffold/new.html.erb", "lib/templates/erb/scaffold/show.html.erb", "Manifest", "form_factor.gemspec"]
25
+ s.homepage = %q{http://www.ociweb.com/products/formfactor}
26
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Form_factor"]
27
+ s.require_paths = ["lib"]
28
+ s.rubyforge_project = %q{form_factor}
29
+ s.rubygems_version = %q{1.3.7}
30
+ s.signing_key = %q{/export/home/jeff/.ssh/gem-private_key.pem}
31
+ s.summary = %q{Abstract builder of form structure with pluggable templates}
32
+
33
+ if s.respond_to? :specification_version then
34
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
35
+ s.specification_version = 3
36
+
37
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
38
+ else
39
+ end
40
+ else
41
+ end
42
+ end
@@ -0,0 +1,59 @@
1
+ module FormFactor
2
+ def self.included(mod)
3
+ mod.helper :form_factor
4
+ mod.helper_method :ff_template, :ff_included_ss, :ff_included_js
5
+
6
+ def ff_template options
7
+ t = instantiate_template options
8
+ ff_include_ss t.stylesheets
9
+ ff_include_js t.javascripts
10
+ t
11
+ end
12
+
13
+ def ff_include_ss files
14
+ [files].flatten.compact.each {|f| (@included_stylesheets ||= []) << f }
15
+ end
16
+
17
+ def ff_include_js files
18
+ [files].flatten.compact.each {|f| (@included_javascripts ||= []) << f }
19
+ end
20
+
21
+ def ff_included_ss
22
+ (@included_stylesheets || []).uniq
23
+ end
24
+
25
+ def ff_included_js
26
+ (@included_javascripts || []).uniq
27
+ end
28
+
29
+ def instantiate_template options
30
+ name = options[:template] || FormFactor.default_template[options[:format]]
31
+ template_name = name.to_s + "_template"
32
+ template_name.camelize.constantize.new(options)
33
+ end
34
+ end
35
+
36
+ def FormFactor.default_template
37
+ @default_template ||= Hash.new(:scaffold)
38
+ end
39
+
40
+ class Base
41
+ attr_reader :options
42
+ def initialize(options)
43
+ @options = options.clone
44
+ @options[:index] = 0
45
+ end
46
+
47
+ def stylesheets
48
+ end
49
+
50
+ def javascripts
51
+ end
52
+
53
+ def render *parts
54
+ result = do_render *parts
55
+ @options[:index] += 1
56
+ result
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,13 @@
1
+ class ScaffoldTemplate < FormFactor::Base
2
+ def stylesheets
3
+ 'scaffold'
4
+ end
5
+
6
+ def render(*parts)
7
+ label,input = parts
8
+ result = "<p>".html_safe + label +
9
+ "<br/>".html_safe + input +
10
+ "</p>".html_safe
11
+ result
12
+ end
13
+ end
@@ -0,0 +1,20 @@
1
+ <%%= form_for(@<%= singular_table_name %>) do |f| %>
2
+ <%% if @<%= singular_table_name %>.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
5
+
6
+ <ul>
7
+ <%% @<%= singular_table_name %>.errors.full_messages.each do |msg| %>
8
+ <li><%%= msg %></li>
9
+ <%% end %>
10
+ </ul>
11
+ </div>
12
+ <%% end %>
13
+
14
+ <% for attribute in attributes -%>
15
+ <%%= ff.render(f.label(:<%= attribute.name %>), f.<%= attribute.field_type %>(:<%= attribute.name %>))%>
16
+ <% end -%>
17
+ <div class="actions">
18
+ <%%= f.submit %>
19
+ </div>
20
+ <%% end %>
@@ -0,0 +1,8 @@
1
+ <h1>Editing <%= singular_table_name %></h1>
2
+
3
+ <%%= form_factor :format => :form do |ff| %>
4
+ <%%= render 'form', :ff => ff %>
5
+ <%% end %>
6
+
7
+ <%%= link_to 'Show', @<%= singular_table_name %> %> |
8
+ <%%= link_to 'Back', <%= index_helper %>_path %>
@@ -0,0 +1,27 @@
1
+ <h1>Listing <%= plural_table_name %></h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <% for attribute in attributes -%>
6
+ <th><%= attribute.human_name %></th>
7
+ <% end -%>
8
+ <th></th>
9
+ <th></th>
10
+ <th></th>
11
+ </tr>
12
+
13
+ <%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
14
+ <tr>
15
+ <% for attribute in attributes -%>
16
+ <td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
17
+ <% end -%>
18
+ <td><%%= link_to 'Show', <%= singular_table_name %> %></td>
19
+ <td><%%= link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>) %></td>
20
+ <td><%%= link_to 'Destroy', <%= singular_table_name %>, :confirm => 'Are you sure?', :method => :delete %></td>
21
+ </tr>
22
+ <%% end %>
23
+ </table>
24
+
25
+ <br />
26
+
27
+ <%%= link_to 'New <%= human_name %>', new_<%= singular_table_name %>_path %>
@@ -0,0 +1,7 @@
1
+ <h1>New <%= singular_table_name %></h1>
2
+
3
+ <%%= form_factor :format => :form do |ff| %>
4
+ <%%= render 'form', :ff => ff %>
5
+ <%% end %>
6
+
7
+ <%%= link_to 'Back', <%= index_helper %>_path %>
@@ -0,0 +1,12 @@
1
+ <p id="notice"><%%= notice %></p>
2
+
3
+ <% for attribute in attributes -%>
4
+ <p>
5
+ <b><%= attribute.human_name %>:</b>
6
+ <%%= @<%= singular_table_name %>.<%= attribute.name %> %>
7
+ </p>
8
+
9
+ <% end -%>
10
+
11
+ <%%= link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>) %> |
12
+ <%%= link_to 'Back', <%= index_helper %>_path %>
data.tar.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ o�mR��]K�����k��%���<��xR�bWz��@��")�
2
+ �e��l����j�-X[d�� O�!�DE0@ ����(�*<#L� n� 蘊�>H�h�0�N��� �W�_��2|$7K�/}�}S�����H�؂�+<���w'���쒽~l��Ӂ��wvUц�\M�x~Ki&s��ݥ;8�|��B�v(s�N5s�MQa��]���WRe[۴]��
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: form_factor
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 3
10
+ version: 0.0.3
11
+ platform: ruby
12
+ authors:
13
+ - Jeff Schmitz @iamtheschmitzer
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain:
17
+ - |
18
+ -----BEGIN CERTIFICATE-----
19
+ MIIDRDCCAiygAwIBAgIBADANBgkqhkiG9w0BAQUFADBIMRowGAYDVQQDDBFqZWZm
20
+ c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ryRICCcx
36
+ 10tIJEmcBVwFuldQmoNCwpfCheLz8tPA
37
+ -----END CERTIFICATE-----
38
+
39
+ date: 2010-09-27 00:00:00 -05:00
40
+ default_executable:
41
+ dependencies: []
42
+
43
+ description: " Form Factor is a miniature abstraction layer for view generation. \n Form Factor breaks the coupling between a view element and the structural \n markup generated, in order to make the generation more flexible.\n\n Instead of directly specifying the literal view to generate, Form Factor \n defers that to a template, which decides: (1) Structural markup to generate \n (2) stylesheets to include and (3) javascripts to include.\n\n Plugging in a different Form Factor template can be done with a single line\n of controller code, giving your site a different look and feel.\n"
44
+ email: jeffrey.j.schmitz@nospam.gmail.com
45
+ executables: []
46
+
47
+ extensions: []
48
+
49
+ extra_rdoc_files:
50
+ - lib/form_factor/form_factor.rb
51
+ - lib/form_factor/scaffold_template.rb
52
+ - lib/templates/erb/scaffold/_form.html.erb
53
+ - lib/templates/erb/scaffold/edit.html.erb
54
+ - lib/templates/erb/scaffold/index.html.erb
55
+ - lib/templates/erb/scaffold/new.html.erb
56
+ - lib/templates/erb/scaffold/show.html.erb
57
+ files:
58
+ - Rakefile
59
+ - app/helpers/form_factor_helper.rb
60
+ - lib/form_factor/form_factor.rb
61
+ - lib/form_factor/scaffold_template.rb
62
+ - lib/templates/erb/scaffold/_form.html.erb
63
+ - lib/templates/erb/scaffold/edit.html.erb
64
+ - lib/templates/erb/scaffold/index.html.erb
65
+ - lib/templates/erb/scaffold/new.html.erb
66
+ - lib/templates/erb/scaffold/show.html.erb
67
+ - Manifest
68
+ - form_factor.gemspec
69
+ has_rdoc: true
70
+ homepage: http://www.ociweb.com/products/formfactor
71
+ licenses: []
72
+
73
+ post_install_message:
74
+ rdoc_options:
75
+ - --line-numbers
76
+ - --inline-source
77
+ - --title
78
+ - Form_factor
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ hash: 3
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ hash: 11
96
+ segments:
97
+ - 1
98
+ - 2
99
+ version: "1.2"
100
+ requirements: []
101
+
102
+ rubyforge_project: form_factor
103
+ rubygems_version: 1.3.7
104
+ signing_key:
105
+ specification_version: 3
106
+ summary: Abstract builder of form structure with pluggable templates
107
+ test_files: []
108
+
metadata.gz.sig ADDED
Binary file