Merge branch 'master' into diffbot-testing

This commit is contained in:
mwells
2014-04-10 15:09:22 -07:00
7 changed files with 205 additions and 124 deletions

@ -52,7 +52,7 @@ bool sendPageInject ( TcpSocket *s , HttpRequest *r ) {
msg7->m_crawlbotAPI = crawlbotAPI;
strncpy(msg7->m_coll,coll,MAX_COLL_LEN);
strncpy(msg7->m_coll,cr->m_coll,MAX_COLL_LEN);
// for diffbot
//if ( crawlbotAPI )

@ -995,6 +995,62 @@ bool printSearchResultsHeader ( State0 *st ) {
printLogoAndSearchBox ( sb , &st->m_hr , -1 ); // catId = -1
}
// the calling function checked this so it should be non-null
CollectionRec *cr = si->m_cr;
char *coll = cr->m_coll;
long collLen = gbstrlen(coll);
if ( si->m_format == FORMAT_WIDGET ) {
sb->safePrintf("<img onclick=\""
"var e=document.getElementById('sbox');"
"if(e.style.display == 'none') {"
"e.style.display = '';"
"} else {"
"e.style.display = 'none';"
"}"
"\" " // end function
" "
"width=25 "
"height=25 "
"style=\""
"position:absolute;"
"z-index:10;"
"right:10px;"
"\" "
"src=\"http://etc-mysitemyway.s3.amazonaws.com/icons/legacy-previews/icons/simple-black-square-icons-business/126715-simple-black-square-icon-business-magnifying-glass-ps.png\">"
);
long widgetwidth = hr->getLong("widgetwidth",250);
long refresh = hr->getLong("refresh",15);
char *oq = hr->getString("q",NULL);
if ( ! oq ) oq = "";
char *prepend = hr->getString("prepend");
if ( ! prepend ) prepend = "";
char *displayStr = "none";
if ( prepend && prepend[0] ) displayStr = "";
sb->safePrintf("<form method=get action=/search>"
"<div align=left id=sbox style=display:%s;>"
"<input type=text name=prepend size=%li "
"value=\"%s\" style=z-index:10;>"
// hidden parms like collection
"<input name=c type=hidden value=\"%s\">"
"<input name=format type=hidden value=widget>"
"<input name=widgetwidth type=hidden value=%li>"
"<input name=refresh type=hidden value=%li>"
"<input name=q type=hidden value=\"%s\">"
"</form>"
"</div>\n"
, displayStr
, widgetwidth / 12
, prepend
, coll
, widgetwidth
, refresh
, oq
);
}
// xml
if ( si->m_format == FORMAT_XML )
sb->safePrintf("<?xml version=\"1.0\" "
@ -1247,11 +1303,6 @@ bool printSearchResultsHeader ( State0 *st ) {
bool isAdmin = si->m_isAdmin;
if ( si->m_format != FORMAT_HTML ) isAdmin = false;
// the calling function checked this so it should be non-null
CollectionRec *cr = si->m_cr;
char *coll = cr->m_coll;
long collLen = gbstrlen(coll);
// otherwise, we had no error
if ( numResults == 0 && si->m_format == FORMAT_HTML ) {
sb->safePrintf ( "No results found in <b>%s</b> collection.",
@ -1320,13 +1371,12 @@ bool printSearchResultsHeader ( State0 *st ) {
}
// is it the main collection?
bool isMain = false;
if ( collLen == 4 && strncmp ( coll, "main", 4) == 0 ) isMain = true;
// print "in collection ***" if we had a collection
if ( collLen > 0 && ! isMain && si->m_format == FORMAT_HTML )
if (collLen>0 && numResults>0 && !isMain && si->m_format==FORMAT_HTML )
sb->safePrintf (" in collection <b>%s</b>",coll);
@ -1364,12 +1414,14 @@ bool printSearchResultsHeader ( State0 *st ) {
// print reindex link
// get the filename directly
char *langStr = getLangAbbr ( si->m_queryLang );
sb->safePrintf (" &nbsp; "
"<font color=red><b>"
"<a href=\"/admin/reindex?c=%s&"
"qlang=%s&q=%s\">"
"[reindex or delete these results]</a></b>"
"</font> ", coll , langStr , st->m_qe );
if ( numResults>0 )
sb->safePrintf (" &nbsp; "
"<font color=red><b>"
"<a href=\"/admin/reindex?c=%s&"
"qlang=%s&q=%s\">"
"[reindex or delete these results]"
"</a></b>"
"</font> ",coll, langStr , st->m_qe );
sb->safePrintf (" &nbsp; "
"<font color=red><b>"
"<a href=\"/inject?c=%s&qts=%s\">"

@ -170,6 +170,16 @@ bool printWebHomePage ( SafeBuf &sb , HttpRequest *r ) {
sb.safePrintf("<br>\n");
sb.safePrintf("\n");
if ( cr && cr->m_coll && strcmp(cr->m_coll,"main") ) {
sb.safePrintf("<center>"
"Searching the <b>%s</b> collection."
"</center>",
cr->m_coll);
sb.safePrintf("<br>\n");
sb.safePrintf("\n");
}
// print any red boxes we might need to
if ( printRedBox2 ( &sb , true ) )
sb.safePrintf("<br>\n");
@ -190,7 +200,7 @@ bool printWebHomePage ( SafeBuf &sb , HttpRequest *r ) {
sb.safePrintf("<td><font size=+1><b>Open Source!</b>"
"</font><br>\n");
sb.brify2("Gigablast is now available as an <a href=https://github.com/gigablast/open-source-search-engine>open source search engine</a> on github.com. Download it today. Finally a robust, scalable search solution in C/C++ that has been in development and used commercially since 2000. <a href=/admin.html#features>Features.</a> Limited support available for free."
sb.brify2("Gigablast is now available as an <a href=https://github.com/gigablast/open-source-search-engine>open source search engine</a> on github.com. Download it today. Finally a robust, scalable search solution in C/C++ that has been in development and used commercially since 2000. <a href=/admin.html#features>Features</a>. Limited support available for free."
,80);
sb.safePrintf("<br><br>");
sb.safePrintf("</td></tr>\n");

@ -837,11 +837,13 @@ m if (! cr->hasSearchPermission ( sock, encapIp ) ) {
char *prepend = r->getString("prepend",NULL,NULL);
// . the query to use for highlighting... can be overriden with "hq"
// . we need the language id for doing synonyms
if ( m_highlightQuery && m_highlightQuery[0] )
if ( prepend && prepend[0] )
m_hqq.set2 ( prepend , m_queryLang , true );
else if ( m_highlightQuery && m_highlightQuery[0] )
m_hqq.set2 ( m_highlightQuery , m_queryLang , true );
else if ( m_query && m_query[0] )
m_hqq.set2 ( m_query , m_queryLang , true );

@ -12399,8 +12399,9 @@ bool getSpiderStatusMsg ( CollectionRec *cx , SafeBuf *msg , long *status ) {
*status = SP_ROUNDDONE;
return msg->safePrintf ( "Nothing currently "
"available to spider. "
"Change your url filters or try "
"adding new urls.");
"Change your url filters, try "
"adding new urls, or wait for "
"existing urls to be respidered.");
}

File diff suppressed because one or more lines are too long

@ -406,11 +406,14 @@ int main2 ( int argc , char *argv[] ) {
printHelp:
SafeBuf sb;
sb.safePrintf(
"Usage: gb [-d workingDir] <CMD>\n");
"\n"
"Usage: gb [-d workingDir] <CMD>\n");
sb.safePrintf(
"\n"
"\tItems in []'s are optional, and items "
"in <>'s are "
"required.");
/*
sb.safePrintf(
"\n\t"
"[hostsConf] is the hosts.conf config file as "
@ -420,21 +423,27 @@ int main2 ( int argc , char *argv[] ) {
"used instead of ./hosts.conf. That is "
"convenient to use since it will not be "
"overwritten from git pulls.\n\n" );
*/
sb.safePrintf(
"<CMD> can have the following values:\n\n"
"-h\tprint this help.\n\n"
"-v\tprint version and exit.\n\n"
"-d\tdebug mode. do not run as daemon. "
"<hostId>\n"
"\tstart the gb process for this <hostId> locally."
" <hostId> is 0 to run as host #0, for instance."
"\n\n"
"<hostId> -g\n\tdebug mode. do not run as daemon. "
"log to stderr.\n\n"
//"-o\tprint the overview documentation in HTML. "
//"Contains the format of hosts.conf.\n\n"
"-r\tindicates recovery mode, "
"<hostId> -r\n\tindicates recovery mode, "
"sends email to addresses "
"specified in Conf.h upon startup.\n\n"
"<hostId>\n"
"\tstart the gb process for this <hostId> locally.\n\n"
"start [hostId]\n"
"\tstart the gb process on all hosts or just on "
@ -1006,7 +1015,7 @@ int main2 ( int argc , char *argv[] ) {
if ( strcmp ( cmd , "-r" ) == 0 ) g_recoveryMode = true;
// debug on gdb? then do not fork
if ( strcmp ( cmd , "-d" ) == 0 ) g_conf.m_runAsDaemon = false;
if ( strcmp ( cmd , "-g" ) == 0 ) g_conf.m_runAsDaemon = false;
bool testMandrill = false;
if ( strcmp ( cmd , "emailmandrill" ) == 0 ) {