Skip to content

Commit

Permalink
First import
Browse files Browse the repository at this point in the history
  • Loading branch information
topfunky committed Dec 22, 2008
0 parents commit 471865e
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
.DS_Store
6 changes: 6 additions & 0 deletions History.txt
@@ -0,0 +1,6 @@
=== 1.0.0 / 2008-12-22

* 1 major enhancement

* Birthday!

7 changes: 7 additions & 0 deletions Manifest.txt
@@ -0,0 +1,7 @@
History.txt
Manifest.txt
README.txt
Rakefile
bin/good_form
lib/good_form.rb
test/test_good_form.rb
52 changes: 52 additions & 0 deletions README.txt
@@ -0,0 +1,52 @@
= GoodForm

* FIX (url)

== AUTHOR

Geoffrey Grosenbach

== DESCRIPTION:

Rails form builder that implements a Good Form as demonstrated by Khoi Vinh.

== FEATURES/PROBLEMS:

* FIX (list of features or problems)

== SYNOPSIS:

FIX (code sample of usage)

== REQUIREMENTS:

* Uses Sass for stylesheets, as shipped with Haml.

== INSTALL:

* FIX (sudo gem install, anything else)

== LICENSE:

(The MIT License)

Copyright (c) 2008 Topfunky Corporation

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 changes: 12 additions & 0 deletions Rakefile
@@ -0,0 +1,12 @@
# -*- ruby -*-

require 'rubygems'
require 'hoe'
require './lib/good_form.rb'

Hoe.new('GoodForm', GoodForm::VERSION) do |p|
# p.rubyforge_name = 'GoodFormx' # if different than lowercase project name
# p.developer('FIX', 'FIX@example.com')
end

# vim: syntax=Ruby
20 changes: 20 additions & 0 deletions lib/form_helper_fieldset.rb
@@ -0,0 +1,20 @@
##
# From http://github.com/zachinglis/rails-plugins/raw/master/form_helper_fieldset/lib/form_helper_fieldset.rb

module ActionView
module Helpers
module FormHelper
# Displays a fieldset and if specified a legend with it.
def fieldset(legend=nil, &block)
raise ArgumentError, "Missing block" unless block_given?

inner = capture(&block)
inner = content_tag("legend", legend) + inner unless legend.nil?
concat "
#{content_tag "fieldset" do
inner
end}", block.binding
end
end
end
end
3 changes: 3 additions & 0 deletions lib/good_form.rb
@@ -0,0 +1,3 @@
class GoodForm
VERSION = '1.0.0'
end
47 changes: 47 additions & 0 deletions lib/topfunky_form_builder.rb
@@ -0,0 +1,47 @@
##
# Custom form builder.
#
# For use with CSS from http://examples.webtypes.com/goodform/

class TopfunkyFormBuilder < ActionView::Helpers::FormBuilder
# helpers = field_helpers +
# %w{date_select datetime_select time_select} +
# %w{collection_select select country_select time_zone_select} -
# %w{hidden_field label fields_for} # Don't decorate these

def text_field(field, *args)
options = args.last.is_a?(Hash) ? args.pop : {}

label_class = (options.delete(:class) || 'field')
@template.content_tag("label",
(options.delete(:label) || field.to_s.titleize) + super,
:class => label_class,
:for => [@object_name, field].join('_'))
end

def radio_button(field, tag_value, options={})
label_title = options.delete(:label)
options[:class] = "radiobutton"
super(field, tag_value, options) +
label([field, tag_value].join('_'), label_title, :class => options[:class])
end

def check_box(field, options={}, checked_value='1', unchecked_value='0')
label_title = options.delete(:label)
options[:class] = "checkbox"
super(field, options, checked_value, unchecked_value) +
label(field, label_title, :class => options[:class])
end

def collection_select(field, collection, value_method, text_method, options={}, html_options={})
label_class = (html_options.delete(:class) || 'field')
@template.content_tag("label",
(html_options.delete(:label) || field.to_s.titleize) + super,
:class => label_class,
:for => [@object_name, field].join('_'))
end

end



Empty file added spec/good_form_spec.rb
Empty file.

0 comments on commit 471865e

Please sign in to comment.