viewaide 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -1,3 +1,100 @@
1
1
  h1. Viewaide
2
2
 
3
+ Viewaide contains a set of view helpers made to standardize basic HTML structures and provide simple Blueprint CSS integration.
4
+
5
+ h2. Installation
6
+
7
+ Viewaide is a gem and should be declared in your @config/environment.rb@.
8
+
9
+ <pre><code>config.gem "viewaide"</code></pre>
10
+
11
+ h2. Usage
12
+
13
+ Viewaide has a handful of helpers for things like recordsets and zebra rows (@<table>@s and @<tr>@s), columns (@<div class="span-#">@), fieldsets, sets (for input elements), and more.
14
+
15
+ For a full overview of what the library does, head to "the documentation":http://yardoc.org/docs/frames/joshuaclayton-viewaide. Here's a brief overview.
16
+
17
+ <pre><code># layouts/admin.html.erb
18
+ <!DOCTYPE html>
19
+ <html lang="en">
20
+ <head>
21
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
22
+ <title><%= application_name %></title>
23
+ <%= stylesheet_link_tag *%w(screen my-screen) %>
24
+ <!--[if lt IE 8]>
25
+ <%= stylesheet_link_tag "ie" %>
26
+ <![endif]-->
27
+ <%= yield :head %>
28
+ </head>
29
+ <% body :admin do %>
30
+ <% container do %>
31
+ <% column :header do %>
32
+ <h1><%= link_to "#{application_name} - Admin", admin_root_path %></h1>
33
+ <%= render :partial => "layouts/admin_navigation" %>
34
+ <% end %>
35
+ <% column do %>
36
+ <%= messages(flash) %>
37
+ <h2><%= yield :page_title %></h2>
38
+ <%= yield %>
39
+ <% end %>
40
+ <%= render :partial => "layouts/footer" %>
41
+ <% end %>
42
+ <%= yield :footer %>
43
+ </body>
44
+ </html>
45
+
46
+ # admin/users/index.html.erb
47
+ <% body :additional_class %>
48
+ <% column :three_fourths, :content do %>
49
+ <% recordset do %>
50
+ <thead>
51
+ <tr>
52
+ <th>Name</th>
53
+ <th>Email Address</th>
54
+ <th>Confirmed At</th>
55
+ </tr>
56
+ </thead>
57
+ <tbody>
58
+ <% @users.each do |user| %>
59
+ <% zebra_row do %>
60
+ <td><%= user.name %></td>
61
+ <td><%= link_to_email user.email %></td>
62
+ <td><%= datetime user.confirmed_at, "Unconfirmed" %></td>
63
+ <% end %>
64
+ <% end %>
65
+ </tbody>
66
+ <% end %>
67
+ <% end %>
68
+ <% column :one_fourth, :last do %>
69
+ <%= link_button "Create New User", new_admin_user_path %>
70
+ <% form_for :user, :url => admin_users_path, :action => :get do |form| %>
71
+ <% fieldset "Search" do %>
72
+ <% set do %>
73
+ <%= form.label :search %>
74
+ <%= form.text_field :search %>
75
+ <% end %>
76
+ <% end %>
77
+ <% fieldset "Filter" do %>
78
+ <% set :select do %>
79
+ <%= form.label :filter %>
80
+ <%= form.select :filter, filter_options_for_users %>
81
+ <% end %>
82
+ <% end %>
83
+ <%= submit_button "Filter" %>
84
+ <% end %>
85
+ <% end %></pre></code>
86
+
87
+ h2. Conventions
88
+
89
+ Most of the helpers (@body@, @container@, @column@, @fieldset@, @set@, @submit_button@, and @recordset@) support some sort of splat arguments and a hash; that is, they take a handful of classes and a hash of additional attributes.
90
+
91
+ <pre><code># at the top of a view
92
+ <% body :admin, "another-class", :id => "body-id" %></code></pre>
93
+
94
+ This helper would attach the admin and another-class classes, as well as an id of 'body-id', to the @<body>@ element (if the @body@ helper is used in the layout). This convention allows developers to quickly and easily assign multiple classes without worry of duplication to the HTML structures generated.
95
+
96
+ h2. Patches, Tweaks, or Fixes?
97
+
98
+ Fork the project, write (failing) tests, write code to get the tests to pass, rake to ensure the entire suite passes, and commit. Send me a pull request once everything is working. Do not touch Rakefile or version of the project. If you write code without tests, I'm not going to accept it.
99
+
3
100
  Copyright (c) 2009 Josh Clayton, released under the MIT license
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
@@ -9,7 +9,7 @@ module Viewaide
9
9
  # <% zebra_row do %>no class<% end %><% zebra_row do %>alt class<% end %>
10
10
  # generates
11
11
  # <tr>no class</tr>
12
- # <tr class="alt">alt class</tr>
12
+ # <tr class="even">alt class</tr>
13
13
  #
14
14
  # @example
15
15
  # <% (colors = %w(red white blue)).each do |color| %>
@@ -20,7 +20,7 @@ module Viewaide
20
20
  # <tr class="white">the color white</tr>
21
21
  # <tr class="blue">the color blue</tr>
22
22
  def zebra_row(options = {}, &block)
23
- cycle_list = options.delete(:cycle_list) || [nil, "alt"]
23
+ cycle_list = options.delete(:cycle_list) || [nil, "even"]
24
24
  css_classes = [cycle(*cycle_list)] << options.delete(:class)
25
25
  css_classes = clean_css_classes(css_classes)
26
26
 
@@ -7,7 +7,7 @@ class TableHelperTest < Viewaide::ViewTestCase
7
7
  should "default with the correct structure" do
8
8
  show_view "<table><% zebra_row do %>no class<% end %><% zebra_row do %>alt class<% end %></table>" do
9
9
  assert_select "tr:first-child", "no class"
10
- assert_select "tr.alt:last-child", "alt class"
10
+ assert_select "tr.even:last-child", "alt class"
11
11
  end
12
12
  end
13
13
 
@@ -54,10 +54,12 @@ class TableHelperTest < Viewaide::ViewTestCase
54
54
  <% end %>
55
55
  <% recordset do %>
56
56
  <% zebra_row do %>text<% end %>
57
+ <% zebra_row do %>text<% end %>
57
58
  <% end %>
58
59
  ) do
59
60
  assert_select "table.recordset" do
60
- assert_select "tr.alt", 0
61
+ assert_select "tr", 3
62
+ assert_select "tr.even", 1
61
63
  end
62
64
  end
63
65
 
data/viewaide.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{viewaide}
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Joshua Clayton"]
12
- s.date = %q{2010-01-31}
12
+ s.date = %q{2010-02-08}
13
13
  s.description = %q{Making your views easier}
14
14
  s.email = %q{joshua.clayton@gmail.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: viewaide
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Clayton
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-31 00:00:00 -05:00
12
+ date: 2010-02-08 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency