According to mike grommet:
> I've been browsing through the htsearch.cc code to sort of get a feel
> for where the changes need to be made to implement this properly.
> I want to make sure the changes I introduce fit with the overall
> consistencey of the htdig project code. I certainly want to keep this from
> looking like a cheap hack :)
That's always a worthy goal! :)
> I figure that it would be appropriate to set the start an end date
> variables by putting them in the config paramaters
> with something like
> config.Add("start_month", input["startmonth"]);
> ..
> for instance. This would happen near line 153 or so.
Yup. You should only do this if the input exists, just like the other
variables handled there. When I added the sort option, I followed
existing examples in htsearch.cc & Display.cc, so I recommend you do
likewise.
The general idea is when an input parameter exists, it's added to config
in htsearch.cc, and it's added to the URL string in Display::createURL(),
so it gets passed along when you use the page buttons at the bottom of
the results form. The rest of the processing of the parameter is done
from the config object, rather than the input object, which allows you
to set a default for the parameter in you htdig.conf file, for cases
where the search form doesn't define it. Any of the input parameters
that get placed in the config object also get placed in the vars
object, with an upper-case name, for use in templates and header.html,
for follow-up searches. This is done in Display::setVariables().
While not all variable names are consistent among the input, config,
and vars objects, it's generally a good idea to do so, to avoid confusion!
There are some inconsistencies in the current set of parameters,
so you should take them with a grain of salt when you add new ones.
For instance, the exclude & restrict parameters get put into the config
object, like most other input parameters, but the StringMatch patterns
are set from the input object, rather than the config object, so you can't
set a default for these in htdig.conf (that inconsistency probably ought
to be fixed). On the other hand, some input parameters, like words &
page, don't even get put into the config object, nor should they.
If you want to put select boxes in the follow-up forms, used in
header.html, wrapper.html, nomatch.html & syntax.html, they are generated
in Display::setVariables() as well. Follow the examples of format,
method & sort.
> the config object has to be accessible by the htsearch (or maybe the parse
> methods, see below)
> function because it will contain this information. Where is this
> information declared?
> I've searched for it, but it has eluded me at this point
htcommon/default.h, included in htsearch/htsearch.h
> Hmm this brings up another question... the actuall function htsearch is
> pretty tiny,
> but makes calles to the parser for result compilation...
> should I actually be making these modifications inside the parse code?
I think a better place would be Display::buildMatchList(), because the
DocTime() field is in the DocumentRef object, fetched from docDB in this
function. No point fetching the record from the database more than once
per match.
By the way, as Geoff pointed out, DocTime is a time_t. This is usally a
32-bit signed integer, representing seconds since the "Epoch" (January 1,
1970, 0:00:00 UTC), so a 0 represents the epoch, and the maximum value
(2^32-1) is Jan. 19, 2038, 03:14:07 UTC. This field will no doubt become
a 64-bit integer before then.
When setting defaults for the start and end of the date range you want,
I'd use (time_t) 0 for the start, and (time_t) ~(1<<(sizeof(time_t)*8-1))
for the end. This latter value will be the maximum signed value for a
time_t, regardless of how many bytes it's eventually defined to be.
--
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] containing the single word "unsubscribe" in
the SUBJECT of the message.