bivouac 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README +15 -0
- data/bin/bivouac +45 -8
- data/doc/rdoc/classes/BivouacHelpers/FormView.html +157 -122
- data/doc/rdoc/classes/BivouacHelpers/JavaScriptView.html +1 -1
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/README.html +41 -1
- data/doc/rdoc/files/lib/bivouac/helpers/view/goh/form_rb.html +1 -1
- data/doc/rdoc/files/lib/bivouac/helpers/view/goh/javascript_rb.html +1 -1
- data/examples/bivouac_sample/Rakefile +20 -0
- data/examples/bivouac_sample/app/bivouac_sample.rb +12 -4
- data/examples/bivouac_sample/app/controllers/edit_in_place.rb +17 -0
- data/examples/bivouac_sample/app/controllers/index.rb +11 -1
- data/examples/bivouac_sample/app/controllers/not_found.rb +16 -0
- data/examples/bivouac_sample/app/helpers/_helpers.rb +5 -3
- data/examples/bivouac_sample/app/views/edit_in_place.rb +52 -0
- data/examples/bivouac_sample/app/views/index.rb +21 -11
- data/examples/bivouac_sample/app/views/not_found.rb +13 -0
- data/examples/bivouac_sample/config/database.yml +3 -0
- data/examples/bivouac_sample/config/environment.rb +3 -2
- data/examples/bivouac_sample/config/postamble.rb +104 -44
- data/examples/bivouac_sample/script/generate +6 -0
- data/examples/bivouac_sample/test/test_edit_in_place.rb +22 -0
- data/examples/bivouac_sample/test/test_index.rb +22 -0
- data/lib/bivouac/commands/generate.rb +34 -13
- data/lib/bivouac/commands/generate.rb_OLD +342 -0
- data/lib/bivouac/helpers/view/goh/form.rb +33 -9
- data/lib/bivouac/helpers/view/goh/javascript.rb +1 -1
- data/lib/bivouac/template/application/postamble.rb +3 -3
- data/lib/bivouac/template/application_goh.rb +21 -3
- data/lib/bivouac/template/environment.rb +7 -2
- data/lib/bivouac/template/generate/create.rb +3 -5
- data/lib/bivouac/template/generate/migrate.rb +1 -2
- data/lib/bivouac/template/generate/migrate_begin.rb +11 -0
- data/lib/bivouac/template/generate/migrate_column.rb +1 -0
- data/lib/bivouac/template/generate/migrate_end.rb +8 -0
- data/lib/bivouac/template/generate/migration_add.rb +1 -0
- data/lib/bivouac/template/generate/migration_begin.rb +10 -0
- data/lib/bivouac/template/generate/migration_end.rb +3 -0
- data/lib/bivouac/template/generate/migration_middle.rb +3 -0
- data/lib/bivouac/template/generate/migration_remove.rb +1 -0
- data/lib/bivouac/template/static/default_layout_view.rb +33 -0
- data/lib/bivouac/template/static/not_found_controller.rb +16 -0
- data/lib/bivouac/template/static/not_found_view.rb +13 -0
- data/lib/cookies_sessions.rb +39 -0
- metadata +23 -3
data/README
CHANGED
@@ -20,6 +20,21 @@ Bivouac is a simple generator for camping[http://code.whytheluckystiff.net/campi
|
|
20
20
|
|
21
21
|
== FEATURES/PROBLEMS:
|
22
22
|
|
23
|
+
=== 0.2.3:
|
24
|
+
|
25
|
+
* Ruby 1.9... not yet !
|
26
|
+
* Database configuration use YAML
|
27
|
+
* Add not_found controller and view
|
28
|
+
* Remove :id column definition in migrate.rb
|
29
|
+
* Add helper FormView#editable_content from
|
30
|
+
http://blog.codahale.com/2006/01/14/a-rails-howto-simplify-in-place-editing-with-scriptaculous/
|
31
|
+
Example at http://bivouac.rubyforge.org/svn/trunk/bivouac/examples/bivouac_sample/
|
32
|
+
* model generator now work with column name and type. Example :
|
33
|
+
ruby script/generate model user name:string mail:string
|
34
|
+
* Add Multiple Layouts support (see http://rubyforge.org/pipermail/camping-list/2008-May/000729.html)
|
35
|
+
* Thin is not more the default server (because layouts don't work with Thin :()
|
36
|
+
* Add Cookie session support. Use -S to specify session type (db or cookie - default).
|
37
|
+
|
23
38
|
=== 0.2.2:
|
24
39
|
* Postamble has been completely rewritten. So :
|
25
40
|
|
data/bin/bivouac
CHANGED
@@ -9,6 +9,7 @@ require 'optparse'
|
|
9
9
|
require 'ostruct'
|
10
10
|
require 'active_support'
|
11
11
|
require 'fileutils'
|
12
|
+
require 'yaml'
|
12
13
|
|
13
14
|
require 'bivouac/template'
|
14
15
|
include Bivouac::Template
|
@@ -17,7 +18,13 @@ include Bivouac::Template
|
|
17
18
|
database_configuration = {
|
18
19
|
:adapter => "sqlite3"
|
19
20
|
}
|
20
|
-
@conf = OpenStruct.new(
|
21
|
+
@conf = OpenStruct.new(
|
22
|
+
:db => { :adapter => 'sqlite3', :database => 'db/bivouac.db' },
|
23
|
+
:orgtype => "GOH",
|
24
|
+
:port => 3301,
|
25
|
+
:address => "0.0.0.0",
|
26
|
+
:session => :cookie
|
27
|
+
)
|
21
28
|
|
22
29
|
opts = OptionParser.new do |opts|
|
23
30
|
opts.banner = "Usage: bivouac [options] app"
|
@@ -50,12 +57,24 @@ opts = OptionParser.new do |opts|
|
|
50
57
|
exit
|
51
58
|
end
|
52
59
|
|
53
|
-
@conf.db =
|
60
|
+
@conf.db = {:adapter => dbtype, :database => 'db/bivouac.db'}
|
54
61
|
}
|
55
62
|
|
56
|
-
opts.on("-P", "--port PORT", "Which port to bind to (3301)") {
|
63
|
+
opts.on("-P", "--port PORT", "Which port to bind to (3301)") { |port|
|
64
|
+
@conf.port = port
|
65
|
+
}
|
57
66
|
|
58
|
-
opts.on("-a", "--address ADDR", "Address to bind to (0.0.0.0)") {
|
67
|
+
opts.on("-a", "--address ADDR", "Address to bind to (0.0.0.0)") { |address|
|
68
|
+
@conf.address = address
|
69
|
+
}
|
70
|
+
|
71
|
+
opts.on("-S", "--session TYPE", "Session type (db|cookie). Default : cookie") { |session|
|
72
|
+
@conf.session = session.to_sym
|
73
|
+
unless [:db, :cookie].include?( @conf.session )
|
74
|
+
puts opts
|
75
|
+
exit
|
76
|
+
end
|
77
|
+
}
|
59
78
|
|
60
79
|
opts.separator ""
|
61
80
|
opts.separator "Common options:"
|
@@ -96,12 +115,10 @@ if database_configuration[:adapter] =~ /sqlite/
|
|
96
115
|
else
|
97
116
|
database_configuration[:database] = @conf.appdir
|
98
117
|
end
|
99
|
-
@conf.db = database_configuration
|
100
|
-
|
101
|
-
## REMOVE ME ## ---------------- @appname = @conf.appname
|
118
|
+
@conf.db = database_configuration
|
102
119
|
|
103
120
|
# Create Application Directories
|
104
|
-
createDir( @conf.appdir )
|
121
|
+
createDir( @conf.appdir ) ## TODO: Replace by createDir( name ) to keep the given name
|
105
122
|
createDir( "#{@conf.appdir}/config" )
|
106
123
|
createDir( "#{@conf.appdir}/app" )
|
107
124
|
createDir( "#{@conf.appdir}/app/controllers" )
|
@@ -125,6 +142,11 @@ createFile( "#{@conf.appdir}/config/environment.rb" ) { |io|
|
|
125
142
|
io.puts template( "environment" )
|
126
143
|
}
|
127
144
|
|
145
|
+
# Create Database configuration file
|
146
|
+
createFile( "#{@conf.appdir}/config/database.yml" ) { |io|
|
147
|
+
io.puts YAML.dump( @conf.db )
|
148
|
+
}
|
149
|
+
|
128
150
|
# Create Application Postamble file
|
129
151
|
createFile( "#{@conf.appdir}/config/postamble.rb" ) { |io|
|
130
152
|
io.puts template( "application/postamble" )
|
@@ -177,3 +199,18 @@ copyTemplate( "static/autocomplete.css", "#{@conf.appdir}/public/stylesheets" )
|
|
177
199
|
createFile( "#{@conf.appdir}/app/controllers/index.rb" ) { |io|
|
178
200
|
io.puts template( "static/index" )
|
179
201
|
}
|
202
|
+
|
203
|
+
# Create not_found controller
|
204
|
+
createFile( "#{@conf.appdir}/app/controllers/not_found.rb" ) { |io|
|
205
|
+
io.puts template( "static/not_found_controller" )
|
206
|
+
}
|
207
|
+
|
208
|
+
# Create not_found view
|
209
|
+
createFile( "#{@conf.appdir}/app/views/not_found.rb" ) { |io|
|
210
|
+
io.puts template( "static/not_found_view" )
|
211
|
+
}
|
212
|
+
|
213
|
+
# Create default_layout view
|
214
|
+
createFile( "#{@conf.appdir}/app/views/default_layout.rb" ) { |io|
|
215
|
+
io.puts template( "static/default_layout_view" )
|
216
|
+
}
|
@@ -131,7 +131,7 @@ ID specified by <tt>field_id</tt>.
|
|
131
131
|
</div>
|
132
132
|
</div>
|
133
133
|
<h4 class="ruled">Public Instance method:
|
134
|
-
<strong><a name="
|
134
|
+
<strong><a name="M000048">button_to_function(name, *args, &block)</a></strong> <a href="#M000048"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: button_to_function" /></a></h4>
|
135
135
|
|
136
136
|
<p>
|
137
137
|
Returns a button that‘ll trigger a JavaScript function using the
|
@@ -144,26 +144,63 @@ making an Ajax request first).
|
|
144
144
|
</p>
|
145
145
|
|
146
146
|
<div class="sourcecode">
|
147
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
148
|
-
<div id="
|
147
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000048_source')" id="l_M000048_source">show source</a> ]</p>
|
148
|
+
<div id="M000048_source" class="dyn-source">
|
149
149
|
<pre>
|
150
|
-
<span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/form.rb, line
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
150
|
+
<span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/form.rb, line 87</span>
|
151
|
+
87: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">button_to_function</span>(<span class="ruby-identifier">name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
152
|
+
88: <span class="ruby-identifier">html_options</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> {}
|
153
|
+
89: <span class="ruby-identifier">function</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">''</span>
|
154
|
+
90:
|
155
|
+
91: <span class="ruby-identifier">function</span> = <span class="ruby-identifier">update_page</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
156
|
+
92:
|
157
|
+
93: <span class="ruby-identifier">input</span>( <span class="ruby-identifier">html_options</span>.<span class="ruby-identifier">merge</span>({
|
158
|
+
94: <span class="ruby-identifier">:type</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"button"</span>, <span class="ruby-identifier">:value</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">name</span>,
|
159
|
+
95: <span class="ruby-identifier">:onclick</span> =<span class="ruby-operator">></span> (<span class="ruby-identifier">html_options</span>[<span class="ruby-identifier">:onclick</span>] <span class="ruby-operator">?</span> <span class="ruby-node">"#{html_options[:onclick]}; "</span> <span class="ruby-operator">:</span> <span class="ruby-value str">""</span>) <span class="ruby-operator">+</span> <span class="ruby-node">"#{function};"</span>
|
160
|
+
96: }))
|
161
|
+
97: <span class="ruby-keyword kw">end</span>
|
162
162
|
</pre>
|
163
163
|
</div>
|
164
164
|
</div>
|
165
165
|
<h4 class="ruled">Public Instance method:
|
166
|
-
<strong><a name="
|
166
|
+
<strong><a name="M000046">editable_content(options)</a></strong> <a href="#M000046"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: editable_content" /></a></h4>
|
167
|
+
|
168
|
+
<p>
|
169
|
+
<a
|
170
|
+
href="http://blog.codahale.com/2006/01/14/a-rails-howto-simplify-in-place-editing-with-scriptaculous">blog.codahale.com/2006/01/14/a-rails-howto-simplify-in-place-editing-with-scriptaculous</a>/
|
171
|
+
</p>
|
172
|
+
|
173
|
+
<div class="sourcecode">
|
174
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000046_source')" id="l_M000046_source">show source</a> ]</p>
|
175
|
+
<div id="M000046_source" class="dyn-source">
|
176
|
+
<pre>
|
177
|
+
<span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/form.rb, line 20</span>
|
178
|
+
20: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">editable_content</span>(<span class="ruby-identifier">options</span>)
|
179
|
+
21: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:content</span>] = { <span class="ruby-identifier">:element</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'span'</span> }.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:content</span>])
|
180
|
+
22: <span class="ruby-comment cmt"># options[:url] = {}.merge(options[:url])</span>
|
181
|
+
23: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:ajax</span>] = { <span class="ruby-identifier">:okText</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"'Save'"</span>, <span class="ruby-identifier">:cancelText</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"'Cancel'"</span>}.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:ajax</span>] <span class="ruby-operator">||</span> {})
|
182
|
+
24: <span class="ruby-identifier">script</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
|
183
|
+
25: <span class="ruby-identifier">script</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"new Ajax.InPlaceEditor("</span>
|
184
|
+
26: <span class="ruby-identifier">script</span> <span class="ruby-operator"><<</span> <span class="ruby-node">" '#{options[:content][:options][:id]}',"</span>
|
185
|
+
27: <span class="ruby-identifier">script</span> <span class="ruby-operator"><<</span> <span class="ruby-node">" '#{options[:url]}',"</span>
|
186
|
+
28: <span class="ruby-identifier">script</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" {"</span>
|
187
|
+
29: <span class="ruby-identifier">script</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:ajax</span>].<span class="ruby-identifier">map</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-node">"#{key.to_s}: #{value}"</span> }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">", "</span>)
|
188
|
+
30: <span class="ruby-identifier">script</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" }"</span>
|
189
|
+
31: <span class="ruby-identifier">script</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">")"</span>
|
190
|
+
32:
|
191
|
+
33: <span class="ruby-identifier">send</span>(
|
192
|
+
34: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:content</span>][<span class="ruby-identifier">:element</span>],
|
193
|
+
35: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:content</span>][<span class="ruby-identifier">:text</span>],
|
194
|
+
36: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:content</span>][<span class="ruby-identifier">:options</span>]
|
195
|
+
37: )
|
196
|
+
38:
|
197
|
+
39: <span class="ruby-identifier">javascript_tag</span>( <span class="ruby-identifier">script</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"\n"</span>) )
|
198
|
+
40: <span class="ruby-keyword kw">end</span>
|
199
|
+
</pre>
|
200
|
+
</div>
|
201
|
+
</div>
|
202
|
+
<h4 class="ruled">Public Instance method:
|
203
|
+
<strong><a name="M000051">form_remote_tag(options = {}, &block)</a></strong> <a href="#M000051"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: form_remote_tag" /></a></h4>
|
167
204
|
|
168
205
|
<p>
|
169
206
|
Returns a form tag that will submit using XMLHttpRequest in the background
|
@@ -185,15 +222,15 @@ Example:
|
|
185
222
|
</pre>
|
186
223
|
<p>
|
187
224
|
The Hash passed to the :html key is equivalent to the options (2nd)
|
188
|
-
argument in the <a href="FormView.html#
|
225
|
+
argument in the <a href="FormView.html#M000050">form_tag</a> method.
|
189
226
|
</p>
|
190
227
|
<p>
|
191
228
|
By default the fall-through action is the same as the one specified in the
|
192
229
|
:url (and the default method is :post).
|
193
230
|
</p>
|
194
231
|
<p>
|
195
|
-
<a href="FormView.html#
|
196
|
-
href="FormView.html#
|
232
|
+
<a href="FormView.html#M000051">form_remote_tag</a> takes a block, like <a
|
233
|
+
href="FormView.html#M000050">form_tag</a>:
|
197
234
|
</p>
|
198
235
|
<pre>
|
199
236
|
form_remote_tag :url => '/posts' do
|
@@ -202,25 +239,25 @@ href="FormView.html#M000049">form_tag</a>:
|
|
202
239
|
</pre>
|
203
240
|
|
204
241
|
<div class="sourcecode">
|
205
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
206
|
-
<div id="
|
242
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000051_source')" id="l_M000051_source">show source</a> ]</p>
|
243
|
+
<div id="M000051_source" class="dyn-source">
|
207
244
|
<pre>
|
208
|
-
<span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/form.rb, line
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
245
|
+
<span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/form.rb, line 183</span>
|
246
|
+
183: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">form_remote_tag</span>(<span class="ruby-identifier">options</span> = {}, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
247
|
+
184: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:form</span>] = <span class="ruby-keyword kw">true</span>
|
248
|
+
185:
|
249
|
+
186: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>] <span class="ruby-operator">||=</span> {}
|
250
|
+
187: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>][<span class="ruby-identifier">:onsubmit</span>] =
|
251
|
+
188: (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>][<span class="ruby-identifier">:onsubmit</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>][<span class="ruby-identifier">:onsubmit</span>] <span class="ruby-operator">+</span> <span class="ruby-value str">"; "</span> <span class="ruby-operator">:</span> <span class="ruby-value str">""</span>) <span class="ruby-operator">+</span>
|
252
|
+
189: <span class="ruby-node">"#{remote_function(options)}; return false;"</span>
|
253
|
+
190:
|
254
|
+
191: <span class="ruby-identifier">form_tag</span>( <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>].<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:url</span>), <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>], <span class="ruby-operator">&</span><span class="ruby-identifier">block</span> )
|
255
|
+
192: <span class="ruby-keyword kw">end</span>
|
219
256
|
</pre>
|
220
257
|
</div>
|
221
258
|
</div>
|
222
259
|
<h4 class="ruled">Public Instance method:
|
223
|
-
<strong><a name="
|
260
|
+
<strong><a name="M000050">form_tag(url, options = {}) {|| ...}</a></strong> <a href="#M000050"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: form_tag" /></a></h4>
|
224
261
|
|
225
262
|
<p>
|
226
263
|
Starts a form tag that points the action to an url. The method for the form
|
@@ -230,11 +267,11 @@ defaults to POST.
|
|
230
267
|
Examples:
|
231
268
|
</p>
|
232
269
|
<ul>
|
233
|
-
<li><tt><a href="FormView.html#
|
270
|
+
<li><tt><a href="FormView.html#M000050">form_tag</a>(’/posts’)
|
234
271
|
=> <form action="/posts" method="post"></tt>
|
235
272
|
|
236
273
|
</li>
|
237
|
-
<li><tt><a href="FormView.html#
|
274
|
+
<li><tt><a href="FormView.html#M000050">form_tag</a>(’/upload’,
|
238
275
|
:multipart => true) => <form action="/upload"
|
239
276
|
method="post" enctype="multipart/form-data"></tt>
|
240
277
|
|
@@ -273,118 +310,116 @@ either "get" or "post".
|
|
273
310
|
</ul>
|
274
311
|
|
275
312
|
<div class="sourcecode">
|
276
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
277
|
-
<div id="
|
313
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000050_source')" id="l_M000050_source">show source</a> ]</p>
|
314
|
+
<div id="M000050_source" class="dyn-source">
|
278
315
|
<pre>
|
279
|
-
<span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/form.rb, line
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
316
|
+
<span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/form.rb, line 133</span>
|
317
|
+
133: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">form_tag</span>(<span class="ruby-identifier">url</span>, <span class="ruby-identifier">options</span> = {}, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
318
|
+
134: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:enctype</span>] = <span class="ruby-value str">"multipart/form-data"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:multipart</span>)
|
319
|
+
135: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:action</span>] = <span class="ruby-identifier">url</span>
|
320
|
+
136:
|
321
|
+
137: <span class="ruby-identifier">method_tag</span> = <span class="ruby-keyword kw">false</span>
|
322
|
+
138:
|
323
|
+
139: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">method</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:method</span>).<span class="ruby-identifier">to_s</span>
|
324
|
+
140: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^get$/i</span> <span class="ruby-comment cmt"># must be case-insentive, but can't use downcase as might be nil</span>
|
325
|
+
141: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:method</span>] = <span class="ruby-value str">"get"</span>
|
326
|
+
142: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^post$/i</span>, <span class="ruby-value str">""</span>, <span class="ruby-keyword kw">nil</span>
|
327
|
+
143: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:method</span>] = <span class="ruby-value str">"post"</span>
|
328
|
+
144: <span class="ruby-keyword kw">else</span>
|
329
|
+
145: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:method</span>] = <span class="ruby-value str">"post"</span>
|
330
|
+
146: <span class="ruby-identifier">method_tag</span> = <span class="ruby-keyword kw">true</span>
|
331
|
+
147: <span class="ruby-keyword kw">end</span>
|
332
|
+
148:
|
333
|
+
149: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
334
|
+
150: <span class="ruby-identifier">form</span>( <span class="ruby-identifier">options</span> ) <span class="ruby-keyword kw">do</span>
|
335
|
+
151: <span class="ruby-keyword kw">yield</span>( )
|
336
|
+
152: <span class="ruby-identifier">input</span>( <span class="ruby-identifier">:type</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"hidden"</span>, <span class="ruby-identifier">:name</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"_method"</span>, <span class="ruby-identifier">:value</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">method</span> ) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">method_tag</span>
|
337
|
+
153: <span class="ruby-keyword kw">end</span>
|
338
|
+
154: <span class="ruby-keyword kw">else</span>
|
339
|
+
155: <span class="ruby-identifier">form</span>( <span class="ruby-identifier">options</span> ) <span class="ruby-keyword kw">do</span>; <span class="ruby-keyword kw">end</span>
|
340
|
+
156: <span class="ruby-keyword kw">end</span>
|
341
|
+
157: <span class="ruby-keyword kw">end</span>
|
305
342
|
</pre>
|
306
343
|
</div>
|
307
344
|
</div>
|
308
345
|
<h4 class="ruled">Public Instance method:
|
309
|
-
<strong><a name="
|
346
|
+
<strong><a name="M000049">submit_to_remote(name, value, options = {})</a></strong> <a href="#M000049"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: submit_to_remote" /></a></h4>
|
310
347
|
|
311
348
|
<p>
|
312
349
|
Returns a button input tag that will submit form using XMLHttpRequest in
|
313
350
|
the background instead of regular reloading POST arrangement.
|
314
351
|
<tt>options</tt> argument is the same as in <tt><a
|
315
|
-
href="FormView.html#
|
352
|
+
href="FormView.html#M000051">form_remote_tag</a></tt>.
|
316
353
|
</p>
|
317
354
|
|
318
355
|
<div class="sourcecode">
|
319
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
320
|
-
<div id="
|
356
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000049_source')" id="l_M000049_source">show source</a> ]</p>
|
357
|
+
<div id="M000049_source" class="dyn-source">
|
321
358
|
<pre>
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
359
|
+
<span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/form.rb, line 102</span>
|
360
|
+
102: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">submit_to_remote</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">options</span> = {})
|
361
|
+
103: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:with</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">'Form.serialize(this.form)'</span>
|
362
|
+
104:
|
363
|
+
105: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>] <span class="ruby-operator">||=</span> {}
|
364
|
+
106: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>][<span class="ruby-identifier">:type</span>] = <span class="ruby-value str">'button'</span>
|
365
|
+
107: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>][<span class="ruby-identifier">:onclick</span>] = <span class="ruby-node">"#{remote_function(options)}; return false;"</span>
|
366
|
+
108: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>][<span class="ruby-identifier">:name</span>] = <span class="ruby-identifier">name</span>
|
367
|
+
109: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>][<span class="ruby-identifier">:value</span>] = <span class="ruby-identifier">value</span>
|
368
|
+
110:
|
369
|
+
111: <span class="ruby-identifier">input</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>]
|
370
|
+
112: <span class="ruby-keyword kw">end</span>
|
334
371
|
</pre>
|
335
372
|
</div>
|
336
373
|
</div>
|
337
374
|
<h4 class="ruled">Public Instance method:
|
338
|
-
<strong><a name="
|
375
|
+
<strong><a name="M000047">text_field(field_name, value = "", options = {})</a></strong> <a href="#M000047"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: text_field" /></a></h4>
|
339
376
|
|
340
377
|
<p>
|
341
378
|
Autocomplete options :
|
342
379
|
</p>
|
343
|
-
<
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
has been updated (i.e. when the user has selected an entry).
|
350
|
-
|
351
|
-
you to modify the querystring that is sent to the server.
|
352
|
-
you need to send any additional parameters through your search form, add
|
353
|
-
|
354
|
-
‘value’} or ‘field=value&another=value’ manner.
|
355
|
-
</p>
|
380
|
+
<pre>
|
381
|
+
:url : URL to call for autocompletion results
|
382
|
+
:tokens:
|
383
|
+
:frequency :
|
384
|
+
:minChars :
|
385
|
+
:indicator : When sending the Ajax request Autocompleter shows this
|
386
|
+
:updateElement : Hook for a custom function called after the element has been updated (i.e. when the user has selected an entry).
|
387
|
+
:afterUpdateElement : Hook for a custom function called after the element has been updated (i.e. when the user has selected an entry).
|
388
|
+
:callback : This function is called just before the Request is actually made, allowing you to modify the querystring that is sent to the server.
|
389
|
+
:parameters : If you need to send any additional parameters through your search form, add them here, in the usual {field: 'value',another: 'value'} or 'field=value&another=value' manner.
|
390
|
+
</pre>
|
356
391
|
|
357
392
|
<div class="sourcecode">
|
358
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
359
|
-
<div id="
|
393
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000047_source')" id="l_M000047_source">show source</a> ]</p>
|
394
|
+
<div id="M000047_source" class="dyn-source">
|
360
395
|
<pre>
|
361
|
-
<span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/form.rb, line
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
396
|
+
<span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/form.rb, line 54</span>
|
397
|
+
54: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">text_field</span>(<span class="ruby-identifier">field_name</span>, <span class="ruby-identifier">value</span> = <span class="ruby-value str">""</span>, <span class="ruby-identifier">options</span> = {})
|
398
|
+
55: <span class="ruby-identifier">autocomplete_options</span> = <span class="ruby-keyword kw">nil</span>
|
399
|
+
56:
|
400
|
+
57: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">has_key?</span>( <span class="ruby-identifier">:autocomplete</span> )
|
401
|
+
58: <span class="ruby-keyword kw">unless</span> [<span class="ruby-value str">"on"</span>, <span class="ruby-value str">"off"</span>].<span class="ruby-identifier">include?</span>( <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:autocomplete</span>] )
|
402
|
+
59: <span class="ruby-identifier">autocomplete_options</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>( )
|
403
|
+
60: <span class="ruby-identifier">autocomplete_options</span>[<span class="ruby-identifier">:url</span>] = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>( <span class="ruby-identifier">:autocomplete</span> )
|
404
|
+
61: <span class="ruby-comment cmt"># options[:autocomplete] = "off"</span>
|
405
|
+
62: <span class="ruby-keyword kw">end</span>
|
406
|
+
63: <span class="ruby-keyword kw">end</span>
|
407
|
+
64:
|
408
|
+
65:
|
409
|
+
66: [<span class="ruby-identifier">:tokens</span>, <span class="ruby-identifier">:frequency</span>, <span class="ruby-identifier">:minChars</span>, <span class="ruby-identifier">:indicator</span>, <span class="ruby-identifier">:updateElement</span>, <span class="ruby-identifier">:afterUpdateElement</span>, <span class="ruby-identifier">:callback</span>, <span class="ruby-identifier">:parameters</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">op</span><span class="ruby-operator">|</span>
|
410
|
+
67: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">has_key?</span>( <span class="ruby-identifier">op</span> )
|
411
|
+
68: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">autocomplete_options</span>.<span class="ruby-identifier">nil?</span>
|
412
|
+
69: <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>( <span class="ruby-identifier">op</span> )
|
413
|
+
70: <span class="ruby-keyword kw">else</span>
|
414
|
+
71: <span class="ruby-identifier">autocomplete_options</span>[<span class="ruby-identifier">op</span>] = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>( <span class="ruby-identifier">op</span> )
|
415
|
+
72: <span class="ruby-keyword kw">end</span>
|
416
|
+
73: <span class="ruby-keyword kw">end</span>
|
417
|
+
74: <span class="ruby-keyword kw">end</span>
|
418
|
+
75:
|
419
|
+
76: <span class="ruby-identifier">options</span> = { <span class="ruby-identifier">:id</span> =<span class="ruby-operator">></span> <span class="ruby-node">"default_#{Time.now.to_i}"</span>, <span class="ruby-identifier">:type</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"text"</span>, <span class="ruby-identifier">:name</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">field_name</span>, <span class="ruby-identifier">:value</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">value</span> }.<span class="ruby-identifier">merge</span>( <span class="ruby-identifier">options</span> )
|
420
|
+
77: <span class="ruby-identifier">input</span>( <span class="ruby-identifier">options</span> )
|
421
|
+
78: <span class="ruby-identifier">auto_complete_field</span>( <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:id</span>], <span class="ruby-identifier">autocomplete_options</span> ) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">autocomplete_options</span>.<span class="ruby-identifier">nil?</span>
|
422
|
+
79: <span class="ruby-keyword kw">end</span>
|
388
423
|
</pre>
|
389
424
|
</div>
|
390
425
|
</div>
|
@@ -149,7 +149,7 @@ Returns:
|
|
149
149
|
218: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">javascript_tag</span>( <span class="ruby-identifier">content</span>, <span class="ruby-identifier">options</span> = {} )
|
150
150
|
219: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:type</span>] = <span class="ruby-value str">"text/javascript"</span>
|
151
151
|
220: <span class="ruby-identifier">script</span>( <span class="ruby-identifier">options</span> ) <span class="ruby-keyword kw">do</span>
|
152
|
-
221: <span class="ruby-value str">"//<![CDATA[\n"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">content</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"\n//]]>
|
152
|
+
221: <span class="ruby-value str">"//<![CDATA[\n"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">content</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"\n//]]>\n"</span>
|
153
153
|
222: <span class="ruby-keyword kw">end</span>
|
154
154
|
223: <span class="ruby-keyword kw">end</span>
|
155
155
|
</pre>
|
data/doc/rdoc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Tue, 03 Jun 2008 16:18:13 +0200
|