Can I ask for a vote on including my select list builder patch in 3.2.0b1?
It's a pretty simple addition, but right now it lacks documentation.  I
don't know if my notes in the patch file are clear enough to use as the
documentation for it, but I'm open to suggestions.  I've had no feedback
either way so far.  However, it does seem to address a request that comes
up rather often.

Here's my
+1

--- begin forwarded message, from bugs database ---
From: Gilles Detillieux <[EMAIL PROTECTED]>
Subject: Re: New feature to add (PR#745)
To: [EMAIL PROTECTED]
Date: Thu, 20 Jan 2000 11:51:43 -0600 (CST)
Cc: [EMAIL PROTECTED], [EMAIL PROTECTED]

According to [EMAIL PROTECTED]:
> I use ht://dig V3.1.4, and i think there would a feature to add :
> the search_algorithm attribut, that permit to choose if you whant exact
> search, fuzzy search, or a combination of several is a good thing, but it
> would be good if this option was reported in results files, to show (and
> modify) in full (comprehensive) text them like you have $(FORMAT),
> $(METHOD), ...
> 
> a $(SEARCH_ALGORITHM) , or something like that whould then be good...

You can already do this by adding "allow_in_form: search_algorithm"
to your config file, which can turn any config attribute into an input
parameter with a corresponding template variable.  This will define the
SEARCH_ALGORITHM template variable, for use in search forms.  It will be
defined simply as the value of the config attribute or input parameter,
not as a select list.

If you want to make a select list out of it, you could apply this patch

        ftp://sol.ccsf.cc.ca.us/htdig-patches/3.1.4/select.list

and then define how you want the select list put together, following the
example in that file.  It lets you define select lists for any input
parameter.  This patch should eventually become part of the htsearch
source, as it's an often requested feature.

--- begin select.list patch, with minor revisions ---
This patch implements a generalized <select> list builder for htsearch.
Its usage is a bit complicated, but it's extremely flexible, allowing
you do define any htsearch input parameter as a select list for use in
templates, provided you also define the corresponding name list attribute
which enumerates all the choices to put in the list.

Each octuple specified in build_select_lists has these values:
<tempvar> <inparm> <namelistattr> <ntuple> <ivalue> <ilabel> <defattr> <deflabel>
where <tempvar> is the template variable to be defined as a list, <inpar>
is the input parameter name that the select list will set, <namelistattr>
is the user-defined list of values and labels for the select list items,
<ntuple> is the tuple size used in <namelistattr>, <ivalue> is the index
into a <namelistattr> tuple for the value, <ilabel> is the index for the
corresponding label to be used on the selector, <defattr> is the config
attribute where the default value for this input parameter is defined,
and <deflabel> (if not an empty string) will be used as the label for an
additional list item for the current input parameter value if it doesn't
match any value in the given list.

The patch is designed for 3.1.4, but can probably easily be adapted to
3.2.0b1.

Here are a couple examples of its usage:

build_select_lists:     MATCH_LIST matchesperpage matches_per_page_list \
                                1 1 1 matches_per_page "Previous Amount" \
                RESTRICT_LIST restrict restrict_names 2 1 2 restrict "" \
                FORMAT_LIST format template_map 3 2 1 template_name ""
matches_per_page_list:  1 5 10 20 100 500
restrict_names: "http://www.scrc.umanitoba.ca/SCRC/" "SCRC Web Pages" \
                "http://www.scrc.umanitoba.ca/Physiology/" "Physiology Web Pages" \
                "http://www.scrc.umanitoba.ca/wcsn/" "WCSN Web Pages" \
                "" "Whole Web Site"

The FORMAT_LIST example should give something equivalent to the FORMAT
template variable, which is already set by htsearch.  It is included as
an additional example of how to specify the tuple size and indices of
values and labels in a tuple.

Here's the patch, with apologies for lack of documentation...

--- htcommon/defaults.cc.orig   Mon Dec  6 16:14:04 1999
+++ htcommon/defaults.cc        Wed Dec  8 13:53:37 1999
@@ -36,6 +36,7 @@ ConfigDefaults        defaults[] =
     {"bad_extensions",                 ".wav .gz .z .sit .au .zip .tar .hqx .exe .com 
.gif .jpg .jpeg .aiff .class .map .ram .tgz .bin .rpm .mpg .mov .avi"},
     {"bad_querystr",                    ""},
     {"bad_word_list",                  "${common_dir}/bad_words"},
+    {"build_select_lists",             ""},
     {"case_sensitive",                  "true"},
     {"common_url_parts",                "http:// http://www. ftp:// ftp://ftp. /pub/ 
.html .htm .gif .jpg .jpeg /index.html /index.htm .com/ .com mailto:"},
     {"create_image_list",              "false"},
--- htsearch/Display.cc.orig    Tue Dec  7 10:32:21 1999
+++ htsearch/Display.cc Wed Dec  8 13:41:34 1999
@@ -478,6 +478,47 @@ Display::setVariables(int pageNumber, Li
     *str << "</select>\n";
     vars.Add("SORT", str);
     vars.Add("SELECTED_SORT", new String(st));
+
+    // Handle user-defined select lists.
+    // Uses octuples containing these values:
+    // <tempvar> <inparm> <namelistattr> <ntuple> <ivalue> <ilabel> 
+    //                                 <defattr> <deflabel>
+    // e.g.:
+    // METHOD_LIST method method_names 2 1 2 match_method ""
+    // FORMAT_LIST format template_map 3 2 1 template_name ""
+    // EXCLUDE_LIST exclude exclude_names 2 1 2 exclude ""
+    // MATCH_LIST matchesperpage matches_per_page_list 1 1 1 \
+    //                                 matches_per_page "Previous Amount"
+    QuotedStringList   builds(config["build_select_lists"], " \t\r\n");
+    for (int b = 0; b <= builds.Count()-8; b += 8)
+    {
+       int     ntuple = atoi(builds[b+3]);
+       int     ivalue = atoi(builds[b+4]);
+       int     ilabel = atoi(builds[b+5]);
+       int     nsel = 0;
+       QuotedStringList        namelist(config[builds[b+2]], " \t\r\n");
+       if (ntuple > 0 && ivalue > 0 && ivalue <= ntuple
+         && ilabel > 0 && ilabel <= ntuple && namelist.Count() % ntuple == 0)
+       {
+           str = new String();
+           *str << "<select name="<<builds[b+1]<<">\n";
+           for (i = 0; i < namelist.Count(); i += ntuple)
+           {
+               *str << "<option value=\"" << namelist[i+ivalue-1] << '"';
+               if (mystrcasecmp(namelist[i+ivalue-1],config[builds[b+6]]) == 0)
+               {
+                   *str << " selected";
+                   ++nsel;
+               }
+               *str << '>' << namelist[i+ilabel-1] << '\n';
+           }
+           if (!nsel && builds[b+7][0] && input->exists(builds[b+1]))
+               *str << "<option value=\"" << input->get(builds[b+1])
+                    << "\" selected>" << builds[b+7] << '\n';
+           *str << "</select>\n";
+           vars.Add(builds[b], str);
+       }
+    }
        
     //
     // If a paged output is required, set the appropriate variables



-- 
Gilles R. Detillieux              E-mail: <[EMAIL PROTECTED]>
Spinal Cord Research Centre       WWW:    http://www.scrc.umanitoba.ca/~grdetil
Dept. Physiology, U. of Manitoba  Phone:  (204)789-3766
Winnipeg, MB  R3E 3J7  (Canada)   Fax:    (204)789-3930

------------------------------------
To unsubscribe from the htdig3-dev mailing list, send a message to
[EMAIL PROTECTED] 
You will receive a message to confirm this. 

Reply via email to