uberkit 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (6) hide show
  1. data/README.rdoc +145 -0
  2. data/Rakefile +1 -0
  3. data/VERSION.yml +2 -2
  4. data/lib/uberkit/menu.rb +10 -3
  5. metadata +4 -4
  6. data/README +0 -149
data/README.rdoc ADDED
@@ -0,0 +1,145 @@
1
+ = Uberkit
2
+
3
+ The Uberkit is a set of helpers to ease the development of common UI
4
+ practices.
5
+
6
+ == Installation
7
+
8
+ Uberkit is available both as a gem and as a traditional plugin. To use
9
+ it as a gem, add this to your environment.rb:
10
+
11
+ config.gem 'uberkit'
12
+
13
+ To install it as a plugin (Rails 2.1 or later):
14
+
15
+ script/plugin install git://github.com/mbleigh/uberkit.git
16
+
17
+ == UberForms
18
+
19
+ UberForms provide a simple context for building forms in a DRYer
20
+ manner by abstracting the markup into a simple, CSS-styleable
21
+ format. It is available as a form builder as Uberkit::Forms::Builder,
22
+ but is likely more useful when used in one of the helper forms:
23
+ uberform_for or remote_uberform_for.
24
+
25
+ === Basic Example
26
+
27
+ <% uberform_for :user do |f| %>
28
+ <%= f.text_field :login %>
29
+ <%= f.password_field :password %>
30
+ <%= f.submit "Submit"%>
31
+ <% end %>
32
+
33
+ Becomes...
34
+
35
+ <form method="post" class="uberform" action="/users">
36
+ <div class="field_row">
37
+ <label for="user_login">Login:</label>
38
+ <input type="text" size="30" name="user[login]" id="user_login" class="text_field"/>
39
+ <br/>
40
+ </div>
41
+ <div class="field_row">
42
+ <label for="user_password">Password:</label>
43
+ <input type="password" size="30" name="user[password]" id="user_password" class="password_field"/>
44
+ <br/>
45
+ </div>
46
+ <button type="submit">Submit</button>
47
+ </form>
48
+
49
+ === Labels, Help, and Descriptions
50
+
51
+ You can pass options into a given field to set a custom label,
52
+ some help text, or a description of the field.
53
+
54
+ <%= f.text_field :login, :label => "Username",
55
+ :help => "Only a-z and underscores.",
56
+ :description => "The name you will use to log in." %>
57
+
58
+ Becomes...
59
+
60
+ <div class="field_row">
61
+ <label for="user_login">Username:</label>
62
+ <input type="text" size="30" name="user[login]" label="Username" id="user_login" help="Only a-z and underscores." description="The name you will use to log in." class="text_field"/>
63
+ <span class="help">Only a-z and underscores.</span>
64
+ <span class="description">The name you will use to log in.</span>
65
+ <br/>
66
+ </div>
67
+
68
+ === Custom Fields
69
+
70
+ Maybe the built-in form helpers won't do it for you. In that case, you
71
+ can use the custom helper to insert arbitrary HTML that still plays
72
+ nice with the rest of UberForms:
73
+
74
+ <% f.custom :label => "State", :for => "user_state" do |f| %>
75
+ <%= state_select :user, :state %>
76
+ <% end %>
77
+
78
+ Becomes...
79
+
80
+ <div class="field_row">
81
+ <label for="user_state">State:</label>
82
+ <div class="pseudo_field">
83
+ <select id="user_state">...</select>
84
+ </div>
85
+ <br/>
86
+ </div>
87
+
88
+ == UberMenu
89
+
90
+ UberMenu is the simplest way to generate the markup for CSS menus,
91
+ including state representation and special hooks for cross-browser
92
+ advanced CSS needs.
93
+
94
+ === Basic Example
95
+
96
+ <% ubermenu do |m| %>
97
+ <% m.action 'Home', '/' %>
98
+ <% m.action 'Users', users_path %>
99
+ <% m.action 'Log Out', logout_path, :class => "special" %>
100
+ <% end %>
101
+
102
+ Becomes...
103
+
104
+ <ul>
105
+ <li class="first current first_current"><a href="/">Home</a></li>
106
+ <li><a href="/users">Users</a></li>
107
+ <li class="special last"><a href="/logout">Log Out</a></li>
108
+ </ul>
109
+
110
+ === Submenus
111
+
112
+ You can nest ubermenus for subnavigation using the 'submenu' method.
113
+ If you pass :delegate instead of a url to the submenu option, it will
114
+ automatically pick up the url of the first action in the submenu instead.
115
+
116
+ <% ubermenu 'nav' do |m| %>
117
+ <% m.action 'Home', home_path %>
118
+ <% m.submenu 'Services', services_home_path do |s| %>
119
+ <% s.action 'Service A', service_path('a') %>
120
+ <% s.action 'Service B', service_path('b') %>
121
+ <% end %>
122
+ <% end %>
123
+
124
+ === State
125
+
126
+ UberMenus automatically retain state using the current_page? helper.
127
+ You can specify further by passing a :current boolean expression to
128
+ evaluate whether or not the menu item is selected:
129
+
130
+ <% ubermenu 'nav' do |m| %>
131
+ <% m.action 'Users', users_path, :current => controller.controller_name == 'users' %>
132
+ <% end %>
133
+
134
+ === Method Listing
135
+
136
+ * <tt>action</tt> - like link_to with additional options (see below)
137
+ :current - a boolean expression to determine whether this menu option is selected,
138
+ works with current_page? (if current_page? is true this will be true regardless)
139
+ :force_current - boolean expression that ignores the current_page?
140
+ :disabled - adds 'disabled' to class and forces non-current
141
+ * <tt>remote_action</tt> - like link_to_remote
142
+ * <tt>custom_action</tt> - only builds the outer <li>, accepts block for contents
143
+ * <tt>submenu</tt> - accepts a block yielding a new menu object
144
+
145
+ Copyright (c) 2010 Michael Bleigh and Intridea, Inc., released under the MIT license
data/Rakefile CHANGED
@@ -9,6 +9,7 @@ begin
9
9
  s.authors = ["Michael Bleigh"]
10
10
  s.files = FileList["[A-Z]*", "{lib,rails}/**/*"]
11
11
  end
12
+ Jeweler::GemcutterTasks.new
12
13
  rescue LoadError
13
14
  puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
14
15
  end
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :build:
3
- :minor: 0
4
- :patch: 7
3
+ :patch: 8
5
4
  :major: 0
5
+ :minor: 0
data/lib/uberkit/menu.rb CHANGED
@@ -3,7 +3,7 @@ module Uberkit
3
3
  def ubermenu(options = {}, &block)
4
4
  nav = NavigationMenu.new(self,options)
5
5
  yield nav
6
- concat(nav.to_html, block.binding) if nav.actions.any?
6
+ concat(nav.to_html) if nav.actions.any?
7
7
  end
8
8
 
9
9
  class NavigationMenu < Uberkit::Displayer
@@ -22,7 +22,8 @@ module Uberkit
22
22
  classes << "current" if merits_current?(contents,options,url_for_options)
23
23
  classes << "disabled" if options.delete(:disabled)
24
24
  classes << classes.join("_") if classes.size > 1
25
- content_tag(:li, contents, :class => classes.join(" "))
25
+ classes << options[:html].delete(:class)
26
+ content_tag(:li, contents, options[:html].merge(:class => classes.join(" ")))
26
27
  end
27
28
 
28
29
  def merits_current?(contents,options={},url_for_options={})
@@ -35,7 +36,13 @@ module Uberkit
35
36
  end
36
37
 
37
38
  def action(name, options = {}, html_options = {})
38
- wrapper_options = { :current => html_options.delete(:current), :disabled => html_options.delete(:disabled), :force_current => html_options.delete(:force_current), :url => options }
39
+ wrapper_options = {
40
+ :current => html_options.delete(:current),
41
+ :disabled => html_options.delete(:disabled),
42
+ :force_current => html_options.delete(:force_current),
43
+ :url => options,
44
+ :html => html_options.delete(:html)
45
+ }
39
46
  @actions << [@template.link_to(name,options,html_options), wrapper_options, options]
40
47
  end
41
48
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uberkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-15 00:00:00 -05:00
12
+ date: 2010-01-14 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -20,10 +20,10 @@ executables: []
20
20
  extensions: []
21
21
 
22
22
  extra_rdoc_files:
23
- - README
23
+ - README.rdoc
24
24
  files:
25
25
  - MIT-LICENSE
26
- - README
26
+ - README.rdoc
27
27
  - Rakefile
28
28
  - VERSION.yml
29
29
  - lib/uberkit.rb
data/README DELETED
@@ -1,149 +0,0 @@
1
- Uberkit
2
- =======
3
-
4
- The Uberkit is a set of helpers to ease the development of common UI
5
- practices.
6
-
7
- Installation
8
- ------------
9
-
10
- Uberkit is available both as a gem and as a traditional plugin. To use
11
- it as a gem, add this to your environment.rb:
12
-
13
- config.gem 'mbleigh-uberkit', :lib => 'uberkit', :source => 'http://gems.github.com/'
14
-
15
- To install it as a plugin (Rails 2.1 or later):
16
-
17
- script/plugin install git://github.com/mbleigh/uberkit.git
18
-
19
- UberForms
20
- ---------
21
-
22
- UberForms provide a simple context for building forms in a DRYer
23
- manner by abstracting the markup into a simple, CSS-styleable
24
- format. It is available as a form builder as Uberkit::Forms::Builder,
25
- but is likely more useful when used in one of the helper forms:
26
- uberform_for or remote_uberform_for.
27
-
28
- === Basic Example
29
-
30
- <% uberform_for :user do |f| %>
31
- <%= f.text_field :login %>
32
- <%= f.password_field :password %>
33
- <%= f.submit "Submit"%>
34
- <% end %>
35
-
36
- Becomes...
37
-
38
- <form method="post" class="uberform" action="/users">
39
- <div class="field_row">
40
- <label for="user_login">Login:</label>
41
- <input type="text" size="30" name="user[login]" id="user_login" class="text_field"/>
42
- <br/>
43
- </div>
44
- <div class="field_row">
45
- <label for="user_password">Password:</label>
46
- <input type="password" size="30" name="user[password]" id="user_password" class="password_field"/>
47
- <br/>
48
- </div>
49
- <button type="submit">Submit</button>
50
- </form>
51
-
52
- === Labels, Help, and Descriptions
53
-
54
- You can pass options into a given field to set a custom label,
55
- some help text, or a description of the field.
56
-
57
- <%= f.text_field :login, :label => "Username",
58
- :help => "Only a-z and underscores.",
59
- :description => "The name you will use to log in." %>
60
-
61
- Becomes...
62
-
63
- <div class="field_row">
64
- <label for="user_login">Username:</label>
65
- <input type="text" size="30" name="user[login]" label="Username" id="user_login" help="Only a-z and underscores." description="The name you will use to log in." class="text_field"/>
66
- <span class="help">Only a-z and underscores.</span>
67
- <span class="description">The name you will use to log in.</span>
68
- <br/>
69
- </div>
70
-
71
- === Custom Fields
72
-
73
- Maybe the built-in form helpers won't do it for you. In that case, you
74
- can use the custom helper to insert arbitrary HTML that still plays
75
- nice with the rest of UberForms:
76
-
77
- <% f.custom :label => "State", :for => "user_state" do |f| %>
78
- <%= state_select :user, :state %>
79
- <% end %>
80
-
81
- Becomes...
82
-
83
- <div class="field_row">
84
- <label for="user_state">State:</label>
85
- <div class="pseudo_field">
86
- <select id="user_state">...</select>
87
- </div>
88
- <br/>
89
- </div>
90
-
91
- UberMenu
92
- --------
93
-
94
- UberMenu is the simplest way to generate the markup for CSS menus,
95
- including state representation and special hooks for cross-browser
96
- advanced CSS needs.
97
-
98
- === Basic Example
99
-
100
- <% ubermenu do |m| %>
101
- <% m.action 'Home', '/' %>
102
- <% m.action 'Users', users_path %>
103
- <% m.action 'Log Out', logout_path, :class => "special" %>
104
- <% end %>
105
-
106
- Becomes...
107
-
108
- <ul>
109
- <li class="first current first_current"><a href="/">Home</a></li>
110
- <li><a href="/users">Users</a></li>
111
- <li class="special last"><a href="/logout">Log Out</a></li>
112
- </ul>
113
-
114
- === Submenus
115
-
116
- You can nest ubermenus for subnavigation using the 'submenu' method.
117
- If you pass :delegate instead of a url to the submenu option, it will
118
- automatically pick up the url of the first action in the submenu instead.
119
-
120
- <% ubermenu 'nav' do |m| %>
121
- <% m.action 'Home', home_path %>
122
- <% m.submenu 'Services', services_home_path do |s| %>
123
- <% s.action 'Service A', service_path('a') %>
124
- <% s.action 'Service B', service_path('b') %>
125
- <% end %>
126
- <% end %>
127
-
128
- === State
129
-
130
- UberMenus automatically retain state using the current_page? helper.
131
- You can specify further by passing a :current boolean expression to
132
- evaluate whether or not the menu item is selected:
133
-
134
- <% ubermenu 'nav' do |m| %>
135
- <% m.action 'Users', users_path, :current => controller.controller_name == 'users' %>
136
- <% end %>
137
-
138
- === Method Listing
139
-
140
- * action - like link_to with additional options (see below)
141
- :current - a boolean expression to determine whether this menu option is selected,
142
- works with current_page? (if current_page? is true this will be true regardless)
143
- :force_current - boolean expression that ignores the current_page?
144
- :disabled - adds 'disabled' to class and forces non-current
145
- * remote_action - like link_to_remote
146
- * custom_action - only builds the outer <li>, accepts block for contents
147
- * submenu - accepts a block yielding a new menu object
148
-
149
- Copyright (c) 2008 Michael Bleigh and Intridea, Inc., released under the MIT license