Commit 60f50df74f43ce91202200e9f3a4fd00993f3853

Authored by Dan Croak
1 parent 391a7b8b

added SemiFormal

vendor/plugins/semi_formal/MIT-LICENSE 0 → 100644
... ... @@ -0,0 +1,20 @@
  1 +Copyright (c) 2009 [name of plugin creator]
  2 +
  3 +Permission is hereby granted, free of charge, to any person obtaining
  4 +a copy of this software and associated documentation files (the
  5 +"Software"), to deal in the Software without restriction, including
  6 +without limitation the rights to use, copy, modify, merge, publish,
  7 +distribute, sublicense, and/or sell copies of the Software, and to
  8 +permit persons to whom the Software is furnished to do so, subject to
  9 +the following conditions:
  10 +
  11 +The above copyright notice and this permission notice shall be
  12 +included in all copies or substantial portions of the Software.
  13 +
  14 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  18 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  19 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  20 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
... ...
vendor/plugins/semi_formal/README.markdown 0 → 100644
... ... @@ -0,0 +1,57 @@
  1 +SemiFormal
  2 +==========
  3 +
  4 +A FormBuilder meant to play well with [Coulda](http://github.com/dancroak/coulda) and [Evergreen](http://github.com/dancroak/evergreen).
  5 +
  6 +Examples
  7 +--------
  8 +
  9 +I had been writing this:
  10 +
  11 + <% form_for :session, :url => session_path do |form| %>
  12 + <fieldset class="inputs">
  13 + <div class="string">
  14 + <%= form.label :email %>
  15 + <%= form.text_field :email %>
  16 + </div>
  17 + <div class="password">
  18 + <%= form.label :password %>
  19 + <%= form.password_field :password %>
  20 + </div>
  21 + <div class="boolean">
  22 + <%= form.check_box :remember_me %>
  23 + <%= form.label :remember_me %>
  24 + </div>
  25 + </fieldset>
  26 + <fieldset class="buttons">
  27 + <%= form.submit "Sign in", :disable_with => "Please wait..." %>
  28 + </fieldset>
  29 + <% end %>
  30 +
  31 +With SemiFormal, I write this:
  32 +
  33 + <% form_for :session, :url => session_path do |form| %>
  34 + <fieldset class="inputs">
  35 + <%= form.string :email %>
  36 + <%= form.password :password %>
  37 + <%= form.boolean :remember_me %>
  38 + </fieldset>
  39 + <fieldset class="buttons">
  40 + <%= form.submit "Sign in", :disable_with => "Please wait..." %>
  41 + </fieldset>
  42 + <% end %>
  43 +
  44 +Hey, slightly better.
  45 +
  46 +Also available:
  47 +
  48 + form.text
  49 + form.numeric
  50 +
  51 +numeric is also aliased as integer, decimal, and float to feel migration-like.
  52 +
  53 +Installation
  54 +------------
  55 +
  56 + script/plugin install git://github.com/dancroak/semi_formal.git
  57 +
... ...
vendor/plugins/semi_formal/Rakefile 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 +require 'rake'
  2 +require 'rake/testtask'
  3 +require 'rake/rdoctask'
  4 +
  5 +desc 'Default: run unit tests.'
  6 +task :default => :test
  7 +
  8 +desc 'Test the semi_formal plugin.'
  9 +Rake::TestTask.new(:test) do |t|
  10 + t.libs << 'lib'
  11 + t.libs << 'test'
  12 + t.pattern = 'test/**/*_test.rb'
  13 + t.verbose = true
  14 +end
  15 +
  16 +desc 'Generate documentation for the semi_formal plugin.'
  17 +Rake::RDocTask.new(:rdoc) do |rdoc|
  18 + rdoc.rdoc_dir = 'rdoc'
  19 + rdoc.title = 'SemiFormal'
  20 + rdoc.options << '--line-numbers' << '--inline-source'
  21 + rdoc.rdoc_files.include('README')
  22 + rdoc.rdoc_files.include('lib/**/*.rb')
  23 +end
... ...
vendor/plugins/semi_formal/init.rb 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +require File.join(File.dirname(__FILE__), 'lib', 'semi_formal')
  2 +
... ...
vendor/plugins/semi_formal/install.rb 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +puts IO.read(File.join(File.dirname(__FILE__), 'README.textile'))
  2 +
... ...
vendor/plugins/semi_formal/lib/semi_formal.rb 0 → 100644
... ... @@ -0,0 +1,47 @@
  1 +class SemiFormal < ActionView::Helpers::FormBuilder
  2 + def string(field, *args)
  3 + options = args.extract_options!
  4 + "<div class=\"string\">" +
  5 + label(field, options[:label] || {}) +
  6 + text_field(field, options[:text_field] || {}) +
  7 + "<div>"
  8 + end
  9 +
  10 + def password(field, *args)
  11 + options = args.extract_options!
  12 + "<div class=\"password\">" +
  13 + label(field, options[:label] || {}) +
  14 + password_field(field, options[:password_field] || {}) +
  15 + "<div>"
  16 + end
  17 +
  18 + def boolean(field, *args)
  19 + options = args.extract_options!
  20 + "<div class=\"boolean\">" +
  21 + check_box(field, options[:check_box] || {}) +
  22 + label(field, options[:label] || {}) +
  23 + "<div>"
  24 + end
  25 +
  26 + def numeric(field, *args)
  27 + options = args.extract_options!
  28 + "<div class=\"numeric\">" +
  29 + label(field, options[:label] || {}) +
  30 + text_field(field, options[:text_field] || {}) +
  31 + "<div>"
  32 + end
  33 + alias :integer :numeric
  34 + alias :float :numeric
  35 + alias :decimal :numeric
  36 +
  37 + def text(field, *args)
  38 + options = args.extract_options!
  39 + "<div class=\"text\">" +
  40 + label(field, options[:label] || {}) +
  41 + text_area(field, options[:text_area] || {}) +
  42 + "<div>"
  43 + end
  44 +end
  45 +
  46 +ActionView::Base.default_form_builder = SemiFormal
  47 +
... ...
vendor/plugins/semi_formal/tasks/semi_formal_tasks.rake 0 → 100644
... ... @@ -0,0 +1,4 @@
  1 +# desc "Explaining what the task does"
  2 +# task :semi_formal do
  3 +# # Task goes here
  4 +# end
... ...
vendor/plugins/semi_formal/test/semi_formal_test.rb 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +require 'test_helper'
  2 +
  3 +class SemiFormalTest < ActiveSupport::TestCase
  4 + # Replace this with your real tests.
  5 + test "the truth" do
  6 + assert true
  7 + end
  8 +end
... ...
vendor/plugins/semi_formal/test/test_helper.rb 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +require 'rubygems'
  2 +require 'active_support'
  3 +require 'active_support/test_case'
0 4 \ No newline at end of file
... ...