re-designed response format for navigation:

- changed json and rss response templates


git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6019 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 16 years ago
parent 15fad767c0
commit 1c77db670f

@ -457,49 +457,32 @@ public class yacysearch {
final StringBuilder resnav = new StringBuilder();
final int thispage = offset / theQuery.displayResults();
if (thispage == 0) {
//resnav.append("< ");
resnav.append("<img src=\"env/grafics/navdl.gif\" width=\"16\" height=\"16\">&nbsp;");
} else {
/*
resnav.append(navurla(thispage - 1, display, theQuery, originalUrlMask));
resnav.append("<strong>&lt;</strong></a>&nbsp;");
*/
resnav.append(plasmaSearchQuery.navurla(thispage - 1, display, theQuery, originalUrlMask, null));
resnav.append("<img src=\"env/grafics/navdl.gif\" width=\"16\" height=\"16\"></a>&nbsp;");
resnav.append("<a href=\"");
resnav.append(plasmaSearchQuery.navurl("html", thispage - 1, display, theQuery, originalUrlMask, null));
resnav.append("\"><img src=\"env/grafics/navdl.gif\" width=\"16\" height=\"16\"></a>&nbsp;");
}
final int numberofpages = Math.min(10, Math.max(thispage + 2, totalcount / theQuery.displayResults()));
for (int i = 0; i < numberofpages; i++) {
if (i == thispage) {
/*
resnav.append("<strong>");
resnav.append(i + 1);
resnav.append("</strong>&nbsp;");
*/
resnav.append("<img src=\"env/grafics/navs");
resnav.append(i + 1);
resnav.append(".gif\" width=\"16\" height=\"16\">&nbsp;");
} else {
/*
resnav.append(navurla(i, display, theQuery, originalUrlMask));
resnav.append(i + 1);
resnav.append("</a>&nbsp;");
*/
resnav.append(plasmaSearchQuery.navurla(i, display, theQuery, originalUrlMask, null));
resnav.append("<img src=\"env/grafics/navd");
resnav.append("<a href=\"");
resnav.append(plasmaSearchQuery.navurl("html", i, display, theQuery, originalUrlMask, null));
resnav.append("\"><img src=\"env/grafics/navd");
resnav.append(i + 1);
resnav.append(".gif\" width=\"16\" height=\"16\"></a>&nbsp;");
}
}
if (thispage >= numberofpages) {
//resnav.append("&gt;");
resnav.append("<img src=\"env/grafics/navdr.gif\" width=\"16\" height=\"16\">");
} else {
/*
resnav.append(navurla(thispage + 1, display, theQuery, originalUrlMask));
resnav.append("<strong>&gt;</strong></a>");
*/
resnav.append(plasmaSearchQuery.navurla(thispage + 1, display, theQuery, originalUrlMask, null));
resnav.append("<img src=\"env/grafics/navdr.gif\" width=\"16\" height=\"16\"></a>");
resnav.append("<a href=\"");
resnav.append(plasmaSearchQuery.navurl("html", thispage + 1, display, theQuery, originalUrlMask, null));
resnav.append("\"><img src=\"env/grafics/navdr.gif\" width=\"16\" height=\"16\"></a>");
}
prop.put("num-results_resnav", resnav.toString());

@ -1,17 +1,19 @@
#(navigation)#
#(nav-domains)#
::
<h3 style="padding-left:25px;">Domains</h3>
<div>
<ul style="padding-left: 0px;">
#{domains}#
<li>#[domain]#</li>
#{/domains}#
<ul style="padding-left: 0px;">#{element}#
<li>#[url]#</li>
#{/element}#
</ul></div>
#(/navigation)#
#(/nav-domains)#
#(nav-topics)#::
<h3 style="padding-left:25px;">Topics</h3>
<div><ul style="padding-left: 0px;">#{words}#
<li><a href="yacysearch.html?search=#[newsearch]#&amp;Enter=Search&amp;count=#[count]#&amp;offset=#[offset]#&amp;resource=#[resource]#&amp;contentdom=#[contentdom]#&amp;display=#[display]#">#[word]#</a></li>
#{/words}#</ul></div>
<div><ul style="padding-left: 0px;">#{element}#
<li>#[url]#</li>
#{/element}#</ul></div>
#(/nav-topics)#
<h3 style="padding-left:25px;">Timeline</h3>
<div>
<p>

@ -47,9 +47,6 @@ public class yacysearchtrailer {
final String eventID = post.get("eventID", "");
final int display = post.getInt("display", 0);
// default settings for blank item
prop.put("words", "0");
// find search event
final plasmaSearchEvent theSearch = plasmaSearchEvent.getEvent(eventID);
if (theSearch == null) {
@ -62,46 +59,55 @@ public class yacysearchtrailer {
// compose search navigation
ArrayList<NavigatorEntry> hostNavigator = theSearch.getHostNavigator(10);
if (hostNavigator == null) {
prop.put("navigation", 0);
prop.put("nav-domains", 0);
} else {
prop.put("navigation", 1);
prop.put("nav-domains", 1);
NavigatorEntry entry;
int i;
for (i = 0; i < hostNavigator.size(); i++) {
entry = hostNavigator.get(i);
prop.put("navigation_domains_" + i + "_domain", plasmaSearchQuery.navurla(0, display, theQuery, theQuery.urlMask, "site:" + entry.name) + entry.name + " (" + entry.count + ")</a>");
prop.putJSON("navigation_domains_" + i + "_domain-json", plasmaSearchQuery.navurla(0, display, theQuery, theQuery.urlMask, "site:" + entry.name) + entry.name + " (" + entry.count + ")</a>");
prop.put("navigation_domains_" + i + "_nl", 1);
prop.put("nav-domains_element_" + i + "_url", "<a href=\"" + plasmaSearchQuery.navurl("html", 0, display, theQuery, theQuery.urlMask, "site:" + entry.name) + "\">" + entry.name + " (" + entry.count + ")</a>");
prop.putJSON("nav_domains_element_" + i + "_url-json", plasmaSearchQuery.navurl("json", 0, display, theQuery, theQuery.urlMask, "site:" + entry.name));
prop.put("nav-domains_element_" + i + "_name", entry.name);
prop.put("nav-domains_element_" + i + "_count", entry.count);
prop.put("nav-domains_element_" + i + "_modifier", "site:" + entry.name);
prop.put("nav-domains_element_" + i + "_nl", 1);
}
i--;
prop.put("navigation_domains_" + i + "_nl", 0);
prop.put("navigation_domains", hostNavigator.size());
prop.put("nav_domains_element_" + i + "_nl", 0);
prop.put("nav_domains_element", hostNavigator.size());
}
// attach the bottom line with search references (topwords)
final ArrayList<NavigatorEntry> references = theSearch.getTopicNavigator(10);
// default settings for no topics
prop.put("nav-topics", "0");
if (references.size() > 0) {
int hintcount = 0;
int i = 0;
NavigatorEntry e;
Iterator<NavigatorEntry> iter = references.iterator();
while (iter.hasNext()) {
e = iter.next();
if (/*(theQuery == null) ||*/ (theQuery.queryString == null)) break;
if (e.name != null) {
prop.putHTML("words_" + hintcount + "_word", e.name);
prop.putHTML("words_" + hintcount + "_newsearch", theQuery.queryString.replace(' ', '+') + "+" + e.name);
prop.put("words_" + hintcount + "_count", theQuery.displayResults());
prop.put("words_" + hintcount + "_offset", "0");
prop.put("words_" + hintcount + "_display", display);
prop.put("words_" + hintcount + "_contentdom", theQuery.contentdom());
prop.put("words_" + hintcount + "_resource", ((theQuery.isLocal()) ? "local" : "global"));
prop.put("words_" + hintcount + "_nl", (iter.hasNext() && hintcount < MAX_TOPWORDS) ? 1 : 0);
if (/*(theQuery == null) ||*/ (theQuery.queryString == null)) break;
if (e != null && e.name != null) {
prop.putHTML("nav-topics_element_" + i + "_name", e.name);
prop.put("nav-topics_element_" + i + "_url", "<a href=\"" + plasmaSearchQuery.navurl("html", 0, display, theQuery, theQuery.urlMask, e.name) + "\">" + e.name + " (" + e.count + ")</a>");
prop.putJSON("nav-topics_element_" + i + "_url-json", plasmaSearchQuery.navurl("json", 0, display, theQuery, theQuery.urlMask, e.name));
prop.put("nav-topics_element_" + i + "_count", e.count);
prop.put("nav-topics_element_" + i + "_offset", "0");
prop.put("nav-topics_element_" + i + "_display", display);
prop.put("nav-topics_element_" + i + "_modifier", e.name);
prop.put("nav-topics_element_" + i + "_contentdom", theQuery.contentdom());
prop.put("nav-topics_element_" + i + "_resource", ((theQuery.isLocal()) ? "local" : "global"));
prop.put("nav-topics_element_" + i + "_nl", (iter.hasNext() && i < MAX_TOPWORDS) ? 1 : 0);
}
if (hintcount++ > MAX_TOPWORDS) {
if (i++ > MAX_TOPWORDS) {
break;
}
}
prop.put("words", hintcount);
prop.put("nav-topics_element", i);
prop.put("nav-topics", "1");
}
serverProfiling.update("SEARCH", new plasmaProfiling.searchEvent(theQuery.id(true), plasmaSearchEvent.FINALIZATION + "-" + "bottomline", 0, 0), false);

@ -1,13 +1,28 @@
"topwords": [
#{words}#
{ "word": "#[word]#" }#(nl)#::,#(/nl)#
#{/words}#
],
#(navigation)#
::
"domains": [
#{domains}#
{ "domain": "#[domain-json]#" }#(nl)#::,#(/nl)#
#{/domains}#
]
#(/navigation)#
"navigation": [#(nav-domains)#::
{
"facetname": "domains",
"displayname": "Domains",
"type": "String",
"min": "0",
"max": "0",
"mean": "0",
"elements": [
#{element}#
{"name": "#[name]#", "count": "#[count]#", "modifier": "#[modifier]#", "url": "#[url-json]#"}#(nl)#::,#(/nl)#
#{/element}#
]
},#(/nav-domains)##(nav-topics)#::
{
"facetname": "topwords",
"displayname": "Topics",
"type": "String",
"min": "0",
"max": "0",
"mean": "0",
"elements": [
#{element}#
{"name": "#[name]#", "count": "#[count]#", "modifier": "#[modifier]#", "url": "#[url-json]#"}#(nl)#::,#(/nl)#
#{/element}#
]
}#(/nav-topics)#
]

@ -1,5 +1,17 @@
<yacy:topwords>
#{words}#
<yacy:item>#[word]#</yacy:item>
#{/words}#
</yacy:topwords>
<yacy:navigation>
#(nav-domains)#::
<yacy:facet name="domains" displayname="Domains" type="String" min="0" max="0" mean="0">
#{element}#
<yacy:element name="#[name]#" count="#[count]#" modifier="#[modifier]#" />
#{/element}#
</yacy:facet>
#(/nav-domains)#
#(nav-topics)#::
<yacy:facet name="topwords" displayname="Topics" type="String" min="0" max="0" mean="0">
#{element}#
<yacy:element name="#[name]#" count="#[count]#" modifier="#[modifier]#" />
#{/element}#
</yacy:facet>
#(/nav-topics)#
</yacy:navigation>

@ -339,18 +339,18 @@ public final class plasmaSearchQuery {
* @param addToQuery
* @return
*/
public static String navurla(final int page, final int display, final plasmaSearchQuery theQuery, final String originalUrlMask, String addToQuery) {
public static String navurl(String ext, final int page, final int display, final plasmaSearchQuery theQuery, final String originalUrlMask, String addToQuery) {
return
"<a href=\"yacysearch.html?display=" + display +
"&amp;search=" + theQuery.queryString(true) + ((addToQuery == null) ? "" : "+" + addToQuery) +
"&amp;maximumRecords="+ theQuery.displayResults() +
"&amp;startRecord=" + (page * theQuery.displayResults()) +
"&amp;resource=" + ((theQuery.isLocal()) ? "local" : "global") +
"&amp;verify=" + ((theQuery.onlineSnippetFetch) ? "true" : "false") +
"&amp;urlmaskfilter=" + originalUrlMask +
"&amp;prefermaskfilter=" + theQuery.prefer +
"&amp;cat=href&amp;constraint=" + ((theQuery.constraint == null) ? "" : theQuery.constraint.exportB64()) +
"&amp;contentdom=" + theQuery.contentdom() +
"&amp;former=" + theQuery.queryString(true) + "\">";
"/yacysearch." + ext + "?display=" + display +
"&search=" + theQuery.queryString(true) + ((addToQuery == null) ? "" : "+" + addToQuery) +
"&maximumRecords="+ theQuery.displayResults() +
"&startRecord=" + (page * theQuery.displayResults()) +
"&resource=" + ((theQuery.isLocal()) ? "local" : "global") +
"&verify=" + ((theQuery.onlineSnippetFetch) ? "true" : "false") +
"&urlmaskfilter=" + originalUrlMask +
"&prefermaskfilter=" + theQuery.prefer +
"&cat=href&amp;constraint=" + ((theQuery.constraint == null) ? "" : theQuery.constraint.exportB64()) +
"&contentdom=" + theQuery.contentdom() +
"&former=" + theQuery.queryString(true);
}
}

@ -153,7 +153,7 @@ public class serverObjects extends HashMap<String, String> implements Cloneable
* @return the modified String that was added to the map.
*/
public String putJSON(final String key, String value) {
value = value.replaceAll("\"", ""); // temporary fix until right quotation is known
value = value.replaceAll("\"", "\\\"");
value = value.replaceAll("/", "\\/");
// value = value.replaceAll("\\", "\\\\");
value = value.replaceAll("\b", "\\b");

Loading…
Cancel
Save