configure documentation
why the lucky stiff
why at hobix.com
Wed Sep 7 14:37:09 EDT 2005
Christopher T. Osborn wrote:
> Is there a chance that someone who knows can write some more
> documentation for the configure method? I can make it (based on one
> of _why's examples) show checkboxes on my script's configuration page,
> but how to use a mountpoint to save information completely escapes me.
Well, there's a couple ways to do this.
1) Ajax + mount. MouseHole has the simple sendReq function you can use
to communicate setting alterations. If your script mounts a directory,
pass information to the mount. (You'll probably want to clearly mark
that these are updated without submission.)
2) The HTTPRequest#query object. If you have form fields in your
configure block, the submitted contents will be stored in the
WEBrick::HTTPRequest#query object. (The second parameter coming into
the object.)
configure do |req, res|
if req.request_method == "POST"
self['username'] = req.query['username']
end
%{<input type="text" name="username" value="#{ self['username'] }" />}
end
Your script has its own object database (using YAML::DBM). You can
stuff anything you like in the database by using self[]=. Read it back
out with self[].
_why
More information about the Mousehole-scripters
mailing list