This is a multi-part message in MIME format.

------=_NextPart_000_000A_01BE7F81.667672E0
Content-Type: text/plain;
        charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Here are the attached patches of my work for the past few days.

At least they are attached if Outlook + Our lovely exchange server actually
works.  Its random at times.  Let me know if the attachments didn't make it.

I'm sure the code will need some work :)
All suggestions are most welcome, and needed.  I need someone else to look
at the code anyway...

I've made slight modifications to htsearch.cc and fairly chunky
changes to Display.cc

date input comes in via web form
(see an example at http://omega.insolwwb.net/htsearch)

right now, the only search section that works is NEWS.  just to play around
you can search for deer show or something like that... they are all copies
of the same
document, just with different dates...

I don't have date search capabilities beyond the first screen.  I'm not sure
how to
accomplish this just yet... one thing at a time.  Any clues here would be
great.


------=_NextPart_000_000A_01BE7F81.667672E0
Content-Type: application/octet-stream;
        name="Display.cc.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
        filename="Display.cc.patch"

*** Display.cc.orig     Mon Apr  5 16:10:01 1999
--- Display.cc  Mon Apr  5 16:13:58 1999
*************** Display::buildMatchList()
*** 854,860 ****
--- 854,1007 ----
      double      backlink_factor =3D config.Double("backlink_factor");
      double      date_factor =3D config.Double("date_factor");
      SortType  typ =3D sortType();
+=20
+=20
+     // Additions made here by Mike Grommet 4-1-99
+     =20
+     tm startdate;     // structure to hold the startdate specified by =
the user
+     tm enddate;       // structure to hold the enddate specified by =
the user
+=20
+     time_t eternity =3D ~(1<<(sizeof(time_t)*8-1));  // will be the =
largest value holdable by a time_t
+     tm *endoftime;     // the time_t eternity will be converted into a =
tm, held by this variable
+=20
+     time_t timet_startdate;
+     time_t timet_enddate;
+     int monthdays[] =3D {31,28,31,30,31,30,31,31,30,31,30,31};
+   =20
+   // boolean to test to see if we need to build date information or =
not
+     int dategiven =3D (=20
+                      (config.Value("startmonth")) ||
+                      (config.Value("startday"))   ||
+                      (config.Value("startyear"))  ||
+                      (config.Value("endmonth"))  ||
+                      (config.Value("endday"))  ||
+                      (config.Value("endyear"))=20
+                     );
+=20
+     // find the end of time
+     endoftime =3D gmtime(&eternity);
+=20
+=20
+     if(dategiven)   // user specified some sort of date information
+       {
+          // set up the startdate structure
+          // see man mktime for details on the tm structure
+          startdate.tm_sec =3D 0;
+          startdate.tm_min =3D 0;
+          startdate.tm_hour =3D 0;
+=20
+          // The concept here is that if a user did not specify a part =
of a date, then we will
+          // make assumtions...=20
+          // For instance, suppose the user specified Feb, 1999 as the =
start range
+          // we take steps to make sure that the search range date =
starts at Feb 1, 1999
+          // along these same lines:  (these are in MM-DD-YYYY format)
+          // Startdates:      Date          Becomes
+          //                  01-01          01-01-1970
+          //                  01-1970       01-01-1970
+          //                  04-1970       04-01-1970
+          //                  1970          Becomes 01-01-1970
+          // These things seem to work fine  for start dates, as all =
months have the same first day
+          // however the ending date can't work this way.
+       =20
+          if(config.Value("startmonth"))                          // =
form input specified a start month
+            {
+              startdate.tm_mon =3D config.Value("startmonth") - 1;      =
// tm months are zero based.  They are passed in as 1 based    =20
+            }
+          else startdate.tm_mon =3D 0;                                  =
// otherwise, no start month, default to 0
+=20
+=20
+          if(config.Value("startday"))                            // =
form input specified a start day
+            {
+              startdate.tm_mday =3D config.Value("startday");           =
// tm days are 1 based, they are passed in as 1 based
+            }
+          else startdate.tm_mday =3D 1;                                 =
// otherwise, no start day, default to 1
+=20
+=20
+          // year is handled a little differently... the tm_year =
structure=20
+          // wants the tm_year in a format of year - 1900. =20
+          // since we are going to convert these dates to a time_t,=20
+          // a time_t value of zero, the earliest possible date
+          // occurs jan 1, 1970.  If we allow dates < 1970, then we
+          // could get negative time_t values right???
+       =20
+          if(config.Value("startyear"))                         // form =
input specified a start year
+            {
+              startdate.tm_year =3D config.Value("startyear") - 1900;   =
    =20
+            }
+          else startdate.tm_year =3D 1970-1900;                        =
// otherwise, no start day, specify start at 1970
+=20
+=20
+          // set up the enddate structure
+=20
+          enddate.tm_sec =3D 0;
+          enddate.tm_min =3D 0;
+          enddate.tm_hour =3D 0;
+       =20
+          if(config.Value("endmonth"))                          // form =
input specified an end month
+            {
+              enddate.tm_mon =3D config.Value("endmonth") - 1;        =
// tm months are zero based.  They are passed in as 1 based    =20
+            }
+          else enddate.tm_mon =3D 11;                                  =
// otherwise, no end month, default to 11=20
+=20
+          if(config.Value("endyear"))                         // form =
input specified a end year
+            {
+             enddate.tm_year =3D config.Value("endyear") - 1900;        =

+            }
+          else enddate.tm_year =3D endoftime->tm_year;               // =
otherwise, no end year, specify end at the end of time allowable
+=20
+=20
+        // Months have different number of days, and this makes things =
more complicated than the startdate range.
+        // Following the example above, here is what we want to happen:
+        // Enddates:        Date          Becomes
+        //                  04-31         04-31-endoftime->tm_year
+        //                  05-1999       05-31-1999, may has 31 =
days... we want to search until the end of may so...
+        //                  1999          12-31-1999, search until the =
end of the year
+=20
+=20
+        if(config.Value("endday"))                             // form =
input specified an end day
+          {
+            enddate.tm_mday =3D config.Value("endday");              // =
tm days are 1 based, they are passed in as 1 based
+          }
+        else enddate.tm_mday =3D monthdays[enddate.tm_mon];          // =
otherwise, no end day, default to the end of the month
+=20
+=20
+        // convert the tm values into time_t values;
+        // Web servers specify modification times in GMT.  I am =
assuming that
+        // the user is specifying a date in GMT.  Most of the time this =
won't
+        // cause too many problems but could cause some unexpected =
results for the user.
+        // maybe I should convert it.  I'm open certainly to thoughts =
on this.
+=20
+        timet_startdate=3Dtimegm(&startdate);
+        timet_enddate=3Dtimegm(&enddate);
+=20
+=20
+        // I'm not quite sure what behavior I want to happen if
+        // someone reverses the start and end dates, and one of them is =
invalid.
+        // for now, if there is a completely invalid date on the start =
or end date, I will force
+        // the start date to time_t 0, and the end date to the maximum =
that can behandled by a time_t
+=20
+        if(timet_startdate < 0)
+           timet_startdate =3D 0;
  =09
+        if(timet_enddate < 0)
+           timet_enddate =3D ~(1<<(sizeof(time_t)*8-1));
+=20
+=20
+        // what if the user did something really goofy like choose an =
end date thats before the start date
+ =20
+      if(timet_enddate < timet_startdate)  // if so, then swap them so =
they are in order
+          {
+            time_t timet_temp =3D timet_enddate;
+            timet_enddate =3D timet_startdate;
+            timet_startdate =3D timet_enddate;
+          }
+     }
+     else   // no date was specifed, so plug in some defaults
+      {
+           timet_startdate =3D 0;
+           timet_enddate =3D ~(1<<(sizeof(time_t)*8-1));
+      }
+=20
      results->Start_Get();
      while ((id =3D results->Get_Next()))
      {
*************** Display::buildMatchList()
*** 901,909 ****
        // We want older docs to have smaller values and the
        // ultimate values to be a reasonable size (max about 100)
 =20
!       if (date_factor !=3D 0.0 || backlink_factor !=3D 0.0 || typ !=3D =
SortByScore)
          {
            DocumentRef *thisRef =3D docDB[thisMatch->getURL()];
            if (thisRef)   // We better hope it's not null!
              {
                score +=3D date_factor *=20
--- 1048,1070 ----
        // We want older docs to have smaller values and the
        // ultimate values to be a reasonable size (max about 100)
 =20
!         // New check added on whether or not we need to check date =
ranges
!=20
!       if (date_factor !=3D 0.0 || backlink_factor !=3D 0.0 || typ !=3D =
SortByScore || timet_startdate > 0 ||=20
!             enddate.tm_year < endoftime->tm_year)
          {
+=20
+=20
            DocumentRef *thisRef =3D docDB[thisMatch->getURL()];
+           =20
+              // check for valid date range.  toss it out if it isnt =
relevant  =20
+              if(thisRef->DocTime() < timet_startdate || =
thisRef->DocTime() > timet_enddate)
+                 {
+                   delete thisMatch;
+                   delete thisRef;
+                   continue;
+                 }
+=20
            if (thisRef)   // We better hope it's not null!
              {
                score +=3D date_factor *=20
*************** Display::buildMatchList()
*** 923,928 ****
--- 1084,1092 ----
                        sortRef->DocTitle(thisRef->DocTitle());
                    thisMatch->setRef(sortRef);
                  }
+=20
+                // code added by Mike Grommet for date search ranges
+               =20
              }
            // Get rid of it to free the memory!
            delete thisRef;
*************** Display::buildMatchList()
*** 934,940 ****
        //
        // Append this match to our list of matches.
        //
!       matches->Add(thisMatch);
      }
 =20
      //
--- 1098,1105 ----
        //
        // Append this match to our list of matches.
        //
!=20
!       matches->Add(thisMatch);
      }
 =20
      //

------=_NextPart_000_000A_01BE7F81.667672E0
Content-Type: application/octet-stream;
        name="htsearch.cc.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
        filename="htsearch.cc.patch"

*** htsearch.cc.orig    Mon Apr  5 16:10:16 1999
--- htsearch.cc Wed Mar 31 14:48:40 1999
*************** main(int ac, char **av)
*** 169,174 ****
--- 169,195 ----
      if (input.exists("sort"))
        config.Add("sort", input["sort"]);
 =20
+     // Changes added 3-31-99, by Mike Grommet
+     // Check form entries for starting date, and ending date
+     // Each date consists of a month, day, and year
+=20
+     if (input.exists("startmonth"))
+       config.Add("startmonth", input["startmonth"]);
+     if (input.exists("startday"))
+       config.Add("startday", input["startday"]);
+     if (input.exists("startyear"))
+       config.Add("startyear", input["startyear"]);
+=20
+     if (input.exists("endmonth"))
+       config.Add("endmonth", input["endmonth"]);
+     if (input.exists("endday"))
+       config.Add("endday", input["endday"]);
+     if (input.exists("endyear"))
+       config.Add("endyear", input["endyear"]);
+=20
+     // END OF CHANGES BY MIKE GROMMET   =20
+=20
+=20
      minimum_word_length =3D config.Value("minimum_word_length", =
minimum_word_length);
 =20
      StringList form_vars(config["allow_in_form"], " \t\r\n");

------=_NextPart_000_000A_01BE7F81.667672E0--

------------------------------------
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.

-------

Reply via email to