Webforms

Hi!

I’m just curious, if anyone developed a library.
For a web page developer, it is a repetitive task to give a form to the
user, and next time check, wheter the data are correct, and do something
with them, another is a wizard, when the user just click the next button
10 times :slight_smile: (and (s)he of course fill out little forms…)

Gergo

±[Kontra, Gergely @ Budapest University of Technology and Economics]-+

    Email: kgergely@mcl.hu,  kgergely@turul.eet.bme.hu          |

URL: turul.eet.bme.hu/~kgergely Mobile: (+36 20) 356 9656 |
±------“Olyan langesz vagyok, hogy poroltoval kellene jarnom!”-------+
.
Magyar php mirror es magyar php dokumentacio: http://hu.php.net

“Kontra, Gergely” wrote:

I’m just curious, if anyone developed a library.
For a web page developer, it is a repetitive task to give a form to the
user, and next time check, wheter the data are correct, and do something
with them, another is a wizard, when the user just click the next button
10 times :slight_smile: (and (s)he of course fill out little forms…)

I am not sure exactly what you wish for, but I recommend a look at IOWA:
beta4.com
iOWA Objects for Web Applications download | SourceForge.net

···


([ Kent Dahl ]/)_ ~ [ http://www.stud.ntnu.no/~kentda/ ]/~
))_student
/(( _d L b_/ NTNU - graduate engineering - 5. year )
( __õ|õ// ) )Industrial economics and technological management(
_
/ö____/ (_engineering.discipline=Computer::Technology)

I downloaded and tried it but fails to create a session (?).
(That redirecting message appears, but that’s all. I don’t
have the energy to debug it out now, sorry. I have session
cookies enabled (not that it should be required), but well,
I could never get Ruby (1.6.7) cgi/sessions working here
yet for some reason, with reasonable effort. PHP sessions
work just fine on the same setup.)

BTW, this iowa stuff looks very interesting. Anyone used
it with success?

Cheers,
Sab

···

----- Original Message -----
From: “Kent Dahl” kentda@stud.ntnu.no
Newsgroups: comp.lang.ruby
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Monday, October 07, 2002 12:12 PM
Subject: Re: webforms

“Kontra, Gergely” wrote:

I’m just curious, if anyone developed a library.
For a web page developer, it is a repetitive task to give a form to the
user, and next time check, wheter the data are correct, and do something
with them, another is a wizard, when the user just click the next button
10 times :slight_smile: (and (s)he of course fill out little forms…)

I am not sure exactly what you wish for, but I recommend a look at IOWA:
beta4.com
iOWA Objects for Web Applications download | SourceForge.net

Szabolcs Szasz wrote:

BTW, this iowa stuff looks very interesting. Anyone used
it with success?

I used it to implement a prototype simulating some portal functionality.
Basically just a lot of HTML pages and some logic flying back and forth,
nothing too substantial, like storing state to database or such.

I didn’t look into sessions explicitly. I usually just created new pages
in IOWA which I’d extended to include some attribute (mostly the current
user) and assigned that explicitly. That probably is unnecessarily
cumbersome, but the simplest thing I could think of that worked. :slight_smile:

Once I found out that I needed to set the number of pages to cache up a
bit, so that the back button wasn’t totally useless, I didn’t run into
anything that a little reading of the examples didn’t clear up. (Except
some wierd problem with tags when I tried some CSS stuff.)

Hopefully someone has used it for something more serious :slight_smile:

···


([ Kent Dahl ]/)_ ~ [ http://www.stud.ntnu.no/~kentda/ ]/~
))_student
/(( _d L b_/ NTNU - graduate engineering - 5. year )
( __õ|õ// ) )Industrial economics and technological management(
_
/ö____/ (_engineering.discipline=Computer::Technology)

“Szabolcs Szasz” sz@szasz.hu writes:

BTW, this iowa stuff looks very interesting. Anyone used
it with success?

I’m using it to implement the new online Ruby FAQ: so far no
problems. Or at least no problems with Iowa. I do have a problem
with the database stuff. I thought I’d use Mysql’s freetext query to
permit searches of the database, but that turns out to be way too
limited (if for no other reason that I can’t search for operators such
as ‘||’).

So, I’m either going to have to drop back to plain text, or I need a
new approach.

Does anyone know any decent freetext search things that work on small
files that aren’t in HTML. Or does anyone know any different way to
allow boolean text searches of faq articles that can return an article
number?

Cheers

Dave

“Szabolcs Szasz” sz@szasz.hu writes:

I downloaded and tried it but fails to create a session (?).
(That redirecting message appears, but that’s all. I don’t
have the energy to debug it out now, sorry. I have session
cookies enabled (not that it should be required), but well,
I could never get Ruby (1.6.7) cgi/sessions working here
yet for some reason, with reasonable effort. PHP sessions
work just fine on the same setup.)

BTW, this iowa stuff looks very interesting. Anyone used
it with success?

Cheers,
Sab

I got iowa working under ruby 1.7.3, but I had to make some small
changes. Two changes were minor and only served to remove warnings, but
one of the changes (the one in Context.rb) was essential for
oid-generated links to work.

Here are my patches:

*** Application.rb.orig Sat Oct 19 17:43:54 2002
— Application.rb Sat Oct 19 13:47:33 2002

···

*** 88,94 ****
data = file.read

	begin

! codefile = File.new(file.path.sub(“.html”, “.iwa”))

puts "reloading " + codefile.path

		codedata = codefile.read
	rescue Exception

— 88,94 ----
data = file.read

	begin

! codefile = File.new(file.path.sub(/.html/, “.iwa”))

puts "reloading " + codefile.path

		codedata = codefile.read
	rescue Exception

*** BindingsParser.rb.orig Sat Oct 19 17:44:06 2002
— BindingsParser.rb Sat Oct 19 13:45:32 2002


*** 23,29 ****
while data.sub!(BodyPattern, “”)
key, value = $1, $2
if value =~ /[1]/
! bindingHash[key] = LiteralAssociation.new(eval value)
else
bindingHash[key] = PathAssociation.new(value)
end
— 23,29 ----
while data.sub!(BodyPattern, “”)
key, value = $1, $2
if value =~ /[2]/
! bindingHash[key] = LiteralAssociation.new(eval(value))
else
bindingHash[key] = PathAssociation.new(value)
end
*** Context.rb.orig Sat Oct 19 17:44:18 2002
— Context.rb Sat Oct 19 14:15:24 2002


*** 8,14 ****
attr_accessor :session

def initialize(url, params, out)

! url =~ “(.?/iowa/[^/])(/.*)?”
@urlRoot = $1
remainder = $2? $2 : “”

— 8,14 ----
attr_accessor :session

def initialize(url, params, out)

! url =~ /(.?/iowa/[^/])(/.*)?/
@urlRoot = $1
remainder = $2? $2 : “”


Lloyd Zusman
ljz@asfast.com


  1. \d"': ↩︎

  2. \d"': ↩︎

I've been told by someone who's just recently started using it, that
Webglimpse might do the trick:

    http://webglimpse.org/

I've never used it, so I can't be sure it'll do what you want, but
it'll let you index files in the local filesystem (rather than spidering
through the webserver) and will let you index any files you want
(regardless of HTML content or not).

-- Dossy

···

On 2002.10.08, Dave Thomas <Dave@PragmaticProgrammer.com> wrote:

Does anyone know any decent freetext search things that work on small
files that aren't in HTML. Or does anyone know any different way to
allow boolean text searches of faq articles that can return an article
number?

--
Dossy Shiobara mail: dossy@panoptic.com
Panoptic Computer Network web: http://www.panoptic.com/
  "He realized the fastest way to change is to laugh at your own
    folly -- then you can let go and quickly move on." (p. 70)

Does anyone know any decent freetext search things that work on small
files that aren’t in HTML. Or does anyone know any different way to
allow boolean text searches of faq articles that can return an article
number?

How about namazu which is what powers ruby-talk searching:
http://www.namazu.org/

regards,
-joe

Why are you using MySQL? If it’s just to index articles by article
numbers, then you might be better off storing the FAQ in plaintext files
named by article number. If lookup performance is too slow, use a
filesystem that is designed to lookup filenames in huge directories very
fast, such as ReiserFS. You can then use normal file system tools to
search the text, or map the text files into memory, etc. etc.

Cheers,
Nat.

···

On Mon, 2002-10-07 at 18:06, Dave Thomas wrote:

I do have a problem
with the database stuff. I thought I’d use Mysql’s freetext query to
permit searches of the database, but that turns out to be way too
limited (if for no other reason that I can’t search for operators such
as ‘||’).

So, I’m either going to have to drop back to plain text, or I need a
new approach.

Does anyone know any decent freetext search things that work on small
files that aren’t in HTML. Or does anyone know any different way to
allow boolean text searches of faq articles that can return an article
number?


Dr. Nathaniel Pryce, Technical Director, B13media Ltd.
Studio 3a, 22-24 Highbury Grove, London N5 2EA, UK
http://www.b13media.com

“Dave Thomas” Dave@PragmaticProgrammer.com wrote in message
news:m2lm5afaav.fsf_-_@zip.local.thomases.com

with the database stuff. I thought I’d use Mysql’s freetext query to
permit searches of the database, but that turns out to be way too
limited (if for no other reason that I can’t search for operators such
as ‘||’).

So, I’m either going to have to drop back to plain text, or I need a
new approach.

I guess you are not on a Windows box, but actually the MS Access database
has a pretty good free text search facility using the Like operator.
I’m running ASP wiki for my personal notes - it stores pages in Access. ASP
Wiki is by far the most primitive Wiki, except it is also the only Wiki that
can search on two independent keywords, except for a Lisp Wiki that cannot
run Windows. The Lisp Wiki (CLiki creates Google style weighted indexing and
stores pages in plain text. I found the link to CLiki using AspWiki’s search
“Lisp Wiki”, as I didn’t recall it’s name :slight_smile:

CLiki is a Lisp based Wiki running on a Lips based web server. The (small)
site looks fast enough. Formatting rules are different, more Lisp’ish - but
this is not necessarily bad. Most importantly… It supports multikeyword
search with an advanced ranking scheme!!

http://ww.telent.net/cliki/index
http://ww.telent.net/cliki/Text%20Formatting

ASP Wiki
http://c2.com/cgi/wiki?AspWiki
Mikkel

Lloyd Zusman said:

I got iowa working under ruby 1.7.3, but I had to make some small
changes. Two changes were minor and only served to remove warnings,
but one of the changes (the one in Context.rb) was essential for
oid-generated links to work.

Here are my patches:

Thank you. I will do a little testing of these patches and then apply
them to the CVS.

Kirk Haines

Nat Pryce nat.pryce@b13media.com writes:

Why are you using MySQL? If it’s just to index articles by article
numbers, then you might be better off storing the FAQ in plaintext files
named by article number. If lookup performance is too slow, use a
filesystem that is designed to lookup filenames in huge directories very
fast, such as ReiserFS. You can then use normal file system tools to
search the text, or map the text files into memory, etc. etc.

Something I’d like is queries such as

article contains: +matz +irb -python

I know I can do this using egrep n times and combining the results,
but I’d really rather not.

I’ve tried Glimpse, but I currently can’t get ‘and’ searches to
work. I’ve also tried Swish, but it’s currently segfaulting on me if I
just index a single file…

Cheers

Dave

“Kirk Haines” khaines@enigo.com writes:

Lloyd Zusman said:

I got iowa working under ruby 1.7.3, but I had to make some small
changes. Two changes were minor and only served to remove warnings,
but one of the changes (the one in Context.rb) was essential for
oid-generated links to work.

Here are my patches:

Thank you. I will do a little testing of these patches and then apply
them to the CVS.

Kirk Haines

Thanks for considering my patch.

Also, I want to let you know that I’m happy with what you have done in
iowa, and I want to congratulate you on a very nice piece of software.

···


Lloyd Zusman
ljz@asfast.com

Good evening,

···

On Tue, Oct 08, 2002, Dave Thomas wrote:

Nat Pryce nat.pryce@b13media.com writes:

Why are you using MySQL? If it’s just to index articles by article
numbers, then you might be better off storing the FAQ in plaintext files
named by article number. If lookup performance is too slow, use a
filesystem that is designed to lookup filenames in huge directories very
fast, such as ReiserFS. You can then use normal file system tools to
search the text, or map the text files into memory, etc. etc.

Something I’d like is queries such as

article contains: +matz +irb -python

I can do this on my namazu install which indexes all my mail:

./namazu +from:dave matz python head ~/namazu/

to get all your mails which talk about matz and python.

namazu is pretty straightforward to install and allows one step of url
rewriting to link to a custom document from the search result page.

hth,

Pierre Baillet
Support the Debian GNU/Linux Project (http://www.debian.org)

Dave,

I’ve recently written an indexer in Ruby that I’m currently using with my
home-rolled Wiki for full-text searches. It’s got a touch of drb code in it
to have it run as a server. c

However, it only handles simple searches (single keyword or literal phrase)
at the moment – but could probably be easily expanded to handle fancier
searches (of course said work would have to be done by ‘other open source
contributors’ :slight_smile:

No release, but you can wade through it here:

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/scrapware/scrapware/ruby/cl/i
ndex/

The main storage is a hash – key is the term and the value is an array of
references to that term.

Chris

At work we used Swish-e for that task, but one of our developers had to modify
the spider to get it to work as we wanted it to (something to do with
controlling the depth of site that gets indexed). This is running on a
win2000 machine. Unfortunately, I can’t give you the details of what was
modified in the spider because I wasn’t a part of this project. The spider
was written in perl.


Signed,
Holden Glova

···

On Tue, 08 Oct 2002 07:15, Dave Thomas wrote:

Nat Pryce nat.pryce@b13media.com writes:

Why are you using MySQL? If it’s just to index articles by article
numbers, then you might be better off storing the FAQ in plaintext files
named by article number. If lookup performance is too slow, use a
filesystem that is designed to lookup filenames in huge directories very
fast, such as ReiserFS. You can then use normal file system tools to
search the text, or map the text files into memory, etc. etc.

Something I’d like is queries such as

article contains: +matz +irb -python

I know I can do this using egrep n times and combining the results,
but I’d really rather not.

I’ve tried Glimpse, but I currently can’t get ‘and’ searches to
work. I’ve also tried Swish, but it’s currently segfaulting on me if I
just index a single file…

[…]

Something I’d like is queries such as

article contains: +matz +irb -python

I know I can do this using egrep n times and combining the results,
but I’d really rather not.

Given that you’re working with a small set of files, why don’t you use a
simple cross reference database and set operations? See below for a
quick and dirty implementation of one (it uses Dan Bernstein’s cdb
database for a good compromise between size and speed, but should be
adaptable to Berkeley DB or GDBM). Note that the size of the cross
reference index will be on the order of magnitude of the original data,
so it won’t work too well for large sets of files. On the other hand, if
you don’t mind wasting some more space, phrase searching can be
implemented at essentially no additional CPU cost.

		Reimer Behrends

#!/usr/bin/env ruby

See end of file for license.

require “cdb” # Dan Bernstein’s constant database
require “find”

Regular expression for words. Should be case-insensitive.

WORDPAT = /\ba-z0-9\b/i

Key in the DB where the file list is stored.

INDEX_FILES = “files

gather_index: list of files → cross reference index

optional block argument to filter file content before scanning

for words. Example:

gather_index(Dir[SOURCE+“//*.html"]+Dir[SOURCE+"//*.txt”]) do

| filename, data |

if filename =~ /.html$/ then

extern_filter(“html2text -nobs”, data)

else

data

end

end

···

Dave Thomas (Dave@PragmaticProgrammer.com) wrote:

The resulting index uses numbers instead of file names to reference

files.

def gather_index(files)
result = {}
index = 0
files.each do
> file |
contents = File.open(file){|fp| fp.read}
contents = yield file, contents if block_given?
contents.scan(WORDPAT) do
> word |
word.downcase!
result[word] ||=
list = result[word]
if list[-1] != index then
list << index
end
end
index += 1
end

The following code will remove common words from the database if

that is desired (“a”, “the”, “you”, …).

#limit = [files.size*2/3,20].max
#result.keys.each do

| word |

result.delete word if result[word].size >= limit

#end

result[INDEX_FILES] = files
result
end

search: Arguments are: the cross reference index (or any object with

the same basic semantics as the hash and the same contents), lists of

words that must occur, must not occur, and may occur. Result is an

array of file names that satisfy these criteria.

def search(index, words=, exclude=, oneof=)
files = index[INDEX_FILES]
if words.size == 0 and oneof.size == 0 then
return
end
result_and = nil

intersection of all sets of files that contain words in ‘words’

if words.size > 0 then
set = index[words[0]]
if set then
result_and = set
else
puts “Not found: "#{words[0]}"”
end
words[1…-1].each do
> word |
set = index[word]
if not set then
puts “Not found: "#{word}"”
next
end
if result_and then
result_and &= set
else
result_and = set
end
end
end

union of all sets of files that occur in ‘oneof’

In addition, calculate weights depending on how many and which terms

are matched. Files that contain more search terms have a higher

weight. If files match the same number of search terms, terms that

occur earlier are given priority.

result_or =
weights = Hash.new(0)
weight = oneof.size**2 + oneof.size
oneof.each do
> word |
set = index[word]
if not set then
puts “Not found: "#{word}"”
next
end
result_or |= set
set.each do | file | weights[file] += weight end
weight -= 1
end

remove all files that contain words in the ‘exclude’ list.

result = result_and || result_or
exclude.each do
> word |
set = index[word]
if not set then
puts “Not found: "#{word}"”
next
end
result -= set
end

sort according to weighting criteria and replace indices with

file names.

result.sort! {|i1, i2| [-weights[i1], i1] <=> [-weights[i2], i2] }
result.map {|i| files[i]}
end

marshalled_access adds a method that automatically unmarshals the

result.

def marshalled_access(index)
class <<index
def
result = super(key)
result and Marshal.load(result)
end
end
end

all_files expands path names on the list and replaces directories

by a list of files that can be found under them.

def all_files(list)
result =
list = list.map{|path| File.expand_path path}
list.each do
> path |
if File.file? path then
result << path
else
Find.find(path) do
> path2 |
result << path2 if File.file? path2
end
end
end
result
end

main program

op = ARGV.shift
indexfile = ARGV.shift

case op
when “make” then
if File.exists? indexfile then
$stderr.puts “Index file "#{indexfile}" exists – aborting.”
exit 1
end
files = all_files(ARGV)
index = gather_index(files)

We write the index as a database

CDB.create(indexfile, indexfile+“.tmp”) do
> db |
index.each_pair do
> key, value |
db[key] = Marshal.dump(value)
end
end
when “search” then

We open the database and disguise it as a hash, rather than a

string → string mapping with marshalled data.

index = CDB.new(indexfile)
marshalled_access(index)
words =
oneof =
exclude =
ARGV.each do
> word |
word = word.downcase
case word
when /^+/ then
oneof << word[1…-1]
when /^-/ then
exclude << word[1…-1]
else
words << word
end
end
search(index, words, exclude, oneof).each do
> file |
puts file
end
else
puts “Usage:”
puts “#{$0} make <file…>”
puts “#{$0} search <term…> <+term…> <-term…>”
puts " Prefix + denotes a word that may occur."
puts " Prefix - denotes a word that must not occur."
puts " All other words must occur."
exit 1
end

Copyright (c) 2002 Reimer Behrends

Permission is hereby granted, free of charge, to any person obtaining

a copy of this software and associated documentation files (the

“Software”), to deal in the Software without restriction, including

without limitation the rights to use, copy, modify, merge, publish,

distribute, sublicense, and/or sell copies of the Software, and to

permit persons to whom the Software is furnished to do so, subject to

the following conditions:

The above copyright notice and this permission notice shall be

included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,

EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF

MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.

IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY

CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,

TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE

SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Thanks for considering my patch.

Also, I want to let you know that I’m happy with what you have done in
iowa, and I want to congratulate you on a very nice piece of software.

Congratulate Avi Bryant. He created it. I’ve been using it for about 8
months, now, and I adore it for the kind of work I find myself doing
regularly. I started with some fairly minor changes to make it work
better for my initial uses of it, and since then have done some fairly
significant work on a private version of it that I have running across
several production web sites in varying capacities.
I’ve been working on bringing a lot of my changes back into the CVS for
Iowa, as they are fixes or are generally beneficial feature enhancements
for production use, but it’s taking a while. I’ve also been trying to
improve both the in-code comments and the documentation.
I have plans to put up a set of online documents for Iowa that I have been
working on as well as making available a bunch of live examples of various
features of Iowa.
In short, I’m working hard to try to expand the feature set to more
broadly support a variety of production uses and to make the whole product
more accessible, but going has been slow the last few months.
For anyone reading this who runs into issues with Iowa, feel free to email
me directly for help if you need it.

Kirk Haines
khaines@enigo.com

However, it only handles simple searches (single keyword or literal
phrase)
at the moment –

Also, it doesn’t do any parsing of the data to build the index – it’s just
the storage and retrieval. It’s supposed to be multi-user ready, however,
for handling multiple requests. For example, a search request can be refused
or held if the index is being edited or written to disk – I haven’t stress
tested it, but I know it works on a small scale.

Unit tests for all this, too.

Chris