htdig: Don't consider my previous mail: "Editing CONFIG for make"


U.O. Telematica Municipale - Comune di Prato (tlm@www2.comune.prato.it)
Thu, 24 Dec 1998 13:48:02 +0100


I was wrong. The error was another one. In fact I was trying to personalize
the "try server" search engine output with template map. I only specified
the template_map with the following syntax:

template_map: /usr1/htdig_tmp/common/template.txt

And the error was over there. But why the htsearch didn't tell me anything?
And so I have tried to make it skip this error. If you have any suggestions
please correct me.

I've modified the TemplateList member method createFromString this way:

    int createFromString(char *);

and the definitions so:

//////////

int
TemplateList::createFromString(char *str)
{
    StringList sl(str, "\t \r\n");
    String display, internal, file;
    Template *t;

    if (sl.Count()%3) return 0; // Check for the triad

    for (int i = 0; i < sl.Count(); i += 3)
    {
        display = sl[i];
        decodeURL(display);
        internal = sl[i + 1];
        file = sl[i + 2];
        displayNames.Add(new String(display));
        internalNames.Add(new String(internal));

        t = new Template();
                
        if (mystrcasecmp(internal, "builtin-long") == 0)
        {
            String s;
            s << "<dl><dt><strong><a href=\"$(URL)\">$(TITLE)</a></strong>";
            s << "$(STARSLEFT)\n";
            s << "</dt><dd>$(EXCERPT)<br>\n";
            s << "<i><a href=\"$(URL)\">$(URL)</a></i>\n";
            s << " <font size=-1>$(MODIFIED), $(SIZE) bytes</font>\n";
            s << "</dd></dl>\n";
            t->setMatchTemplate(s);
        }
        else if (mystrcasecmp(internal, "builtin-short") == 0)
        {
            t->setMatchTemplate("$(STARSRIGHT) <strong><a
href=\"$(URL)\">$(TITLE)</a></strong><br>\n");
        }
        else
        {
            t->createFromFile(file);
        }
        templates.Add(t);
    }

    return 1;
}

//////////

I modified the Display constructor this way:

//////////

Display::Display(char *indexFile, char *docFile)
{
    docIndex = Database::getDatabaseInstance();
    docIndex->OpenRead(indexFile);
    docDB.Read(docFile);

    limitTo = 0;
    excludeFrom = 0;
    needExcerpt = 0;
    templateError = 0;

    maxStars = config.Value("max_stars");
    maxScore = 100;
    setupImages();

    if(!templates.createFromString(config["template_map"]))
    {
        // Error in createFromString.
        // Set default template

#define DEFAULT_TEMPLATE_STRING "Long builtin-long - Short builtin-short -"

        if(!templates.createFromString(DEFAULT_TEMPLATE_STRING))
        {
                // Unrecoverable Error

                templateError = 1;

        }
    }

    currentTemplate = templates.get(config["template_name"]);

    if (!currentTemplate)
    {
        //
        // Must have been some error. Resort to the builtin-long (slot 0)
        //

        currentTemplate = (Template *) templates.templates[0];

    }

    if (!currentTemplate)
      {
        //
        // Another error!? Time to bail out...
        //
        templateError = 1;
      }
    else if (mystrcasestr(currentTemplate->getMatchTemplate(), "excerpt"))
        needExcerpt = 1;
}

//////////

And so, if I don't specify a triad option for template_map it takes the
default one.

Please tell me if I did the good choice (cos I'm a beginner C++ programmer).

Another question.

Can you tell me what .start and .end files mean?

Ciao and Happy Xmas
Gabriele Bartolini

----------------------------------------------------------

 U.O. Rete Civica - Comune di Prato
 Via Ricasoli, 4 - 59100 Prato PO Italia
 Tel. +39 0574616342 Fax +39 0574616003

 http://www.comune.prato.it
 E-Mail: tlm@mbox.comune.prato.it

----------------------------------------------------------
----------------------------------------------------------------------
To unsubscribe from the htdig mailing list, send a message to
htdig-request@sdsu.edu containing the single word "unsubscribe" in
the body of the message.



This archive was generated by hypermail 2.0b3 on Sat Jan 02 1999 - 16:29:56 PST