added link to Snapshots in search results if the snapshot exists and

option is set in ConfigSearchPage_p
(this is a stub: we also need a visualization of pdf files!)
pull/8/head
Michael Peter Christen 10 years ago
parent 72f6a0b0b2
commit 9c12555be5

@ -831,6 +831,7 @@ search.result.show.proxy = false
search.result.show.hostbrowser = true search.result.show.hostbrowser = true
search.result.show.vocabulary = false search.result.show.vocabulary = false
search.result.show.vocabulary.omit = search.result.show.vocabulary.omit =
search.result.show.snapshots = false
# search navigators: comma-separated list of default values for search navigation. # search navigators: comma-separated list of default values for search navigation.

@ -245,6 +245,7 @@ var solr= $.getJSON("/solr/collection1/select?q=*:*&defType=edismax&start=0&rows
<td>&nbsp;|&nbsp;<a href="CacheResource_p.html" target="LayouTest">Cache</a></td> <td>&nbsp;|&nbsp;<a href="CacheResource_p.html" target="LayouTest">Cache</a></td>
<td>&nbsp;|&nbsp;<a href="proxy.html" target="LayouTest">Augmented Browsing</a></td> <td>&nbsp;|&nbsp;<a href="proxy.html" target="LayouTest">Augmented Browsing</a></td>
<td>&nbsp;|&nbsp;<a href="HostBrowser.html" target="LayouTest"><img src="env/grafics/minitree.png" width="15" height="8" /></a></td> <td>&nbsp;|&nbsp;<a href="HostBrowser.html" target="LayouTest"><img src="env/grafics/minitree.png" width="15" height="8" /></a></td>
<td>&nbsp;|&nbsp;<a href="yacysearch.html" target="LayouTest">Snapshots</a></td>
</tr> </tr>
<tr> <tr>
<td></td> <td></td>
@ -263,6 +264,7 @@ var solr= $.getJSON("/solr/collection1/select?q=*:*&defType=edismax&start=0&rows
</span></span> </span></span>
</td> </td>
<td align="center"><input type="checkbox" name="search.result.show.hostbrowser" value="true" #(search.result.show.hostbrowser)#::checked="checked" #(/search.result.show.hostbrowser)# /></td> <td align="center"><input type="checkbox" name="search.result.show.hostbrowser" value="true" #(search.result.show.hostbrowser)#::checked="checked" #(/search.result.show.hostbrowser)# /></td>
<td align="center"><input type="checkbox" name="search.result.show.snapshots" value="true" #(search.result.show.snapshots)#::checked="checked" #(/search.result.show.snapshots)# /></td>
</tr> </tr>
</table> </table>
</p> </p>

@ -35,7 +35,6 @@ import net.yacy.cora.date.GenericFormatter;
import net.yacy.cora.protocol.RequestHeader; import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.util.ConcurrentLog; import net.yacy.cora.util.ConcurrentLog;
import net.yacy.data.WorkTables; import net.yacy.data.WorkTables;
import net.yacy.document.LibraryProvider;
import net.yacy.search.Switchboard; import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants; import net.yacy.search.SwitchboardConstants;
import net.yacy.server.serverObjects; import net.yacy.server.serverObjects;
@ -78,6 +77,7 @@ public class ConfigSearchPage_p {
sb.setConfig("search.result.show.cache", post.getBoolean("search.result.show.cache")); sb.setConfig("search.result.show.cache", post.getBoolean("search.result.show.cache"));
sb.setConfig("search.result.show.proxy", post.getBoolean("search.result.show.proxy")); sb.setConfig("search.result.show.proxy", post.getBoolean("search.result.show.proxy"));
sb.setConfig("search.result.show.hostbrowser", post.getBoolean("search.result.show.hostbrowser")); sb.setConfig("search.result.show.hostbrowser", post.getBoolean("search.result.show.hostbrowser"));
sb.setConfig("search.result.show.snapshots", post.getBoolean("search.result.show.snapshots"));
// construct navigation String // construct navigation String
String nav = ""; String nav = "";
@ -134,6 +134,7 @@ public class ConfigSearchPage_p {
sb.setConfig("search.result.show.cache", config.getProperty("search.result.show.cache","true")); sb.setConfig("search.result.show.cache", config.getProperty("search.result.show.cache","true"));
sb.setConfig("search.result.show.proxy", config.getProperty("search.result.show.proxy","false")); sb.setConfig("search.result.show.proxy", config.getProperty("search.result.show.proxy","false"));
sb.setConfig("search.result.show.hostbrowser", config.getProperty("search.result.show.hostbrowser","true")); sb.setConfig("search.result.show.hostbrowser", config.getProperty("search.result.show.hostbrowser","true"));
sb.setConfig("search.result.show.snapshots", config.getProperty("search.result.show.snapshots","true"));
} }
} }
@ -160,6 +161,7 @@ public class ConfigSearchPage_p {
prop.put("search.result.show.cache", sb.getConfigBool("search.result.show.cache", false) ? 1 : 0); prop.put("search.result.show.cache", sb.getConfigBool("search.result.show.cache", false) ? 1 : 0);
prop.put("search.result.show.proxy", sb.getConfigBool("search.result.show.proxy", false) ? 1 : 0); prop.put("search.result.show.proxy", sb.getConfigBool("search.result.show.proxy", false) ? 1 : 0);
prop.put("search.result.show.hostbrowser", sb.getConfigBool("search.result.show.hostbrowser", false) ? 1 : 0); prop.put("search.result.show.hostbrowser", sb.getConfigBool("search.result.show.hostbrowser", false) ? 1 : 0);
prop.put("search.result.show.snapshots", sb.getConfigBool("search.result.show.snapshots", false) ? 1 : 0);
prop.put("search.navigation.location", sb.getConfig("search.navigation", "").indexOf("location",0) >= 0 ? 1 : 0); prop.put("search.navigation.location", sb.getConfig("search.navigation", "").indexOf("location",0) >= 0 ? 1 : 0);
prop.put("search.navigation.filetype", sb.getConfig("search.navigation", "").indexOf("filetype",0) >= 0 ? 1 : 0); prop.put("search.navigation.filetype", sb.getConfig("search.navigation", "").indexOf("filetype",0) >= 0 ? 1 : 0);

@ -35,6 +35,7 @@
#(showProxy)#::&nbsp;|&nbsp;<a href="proxy.html?url=#[link]#" target="_blank">Augmented Browsing</a>#(/showProxy)# #(showProxy)#::&nbsp;|&nbsp;<a href="proxy.html?url=#[link]#" target="_blank">Augmented Browsing</a>#(/showProxy)#
#(showHostBrowser)#::&nbsp;|&nbsp;<a href="HostBrowser.html?path=#[link]#"><img src="env/grafics/minitree.png" width="15" height="8"/></a>#(/showHostBrowser)# #(showHostBrowser)#::&nbsp;|&nbsp;<a href="HostBrowser.html?path=#[link]#"><img src="env/grafics/minitree.png" width="15" height="8"/></a>#(/showHostBrowser)#
#(showVocabulary)#::<br/>#{vocabulary}##[name]#:#[terms]# #{/vocabulary}##(/showVocabulary)# #(showVocabulary)#::<br/>#{vocabulary}##[name]#:#[terms]# #{/vocabulary}##(/showVocabulary)#
#(showSnapshots)#::<a href="#[link]#">Snapshots</a>#(/showSnapshots)#
</p> </p>
</div> </div>
:: ::

@ -24,6 +24,7 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import java.io.File;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
@ -43,6 +44,8 @@ import net.yacy.cora.protocol.RequestHeader.FileType;
import net.yacy.cora.util.ConcurrentLog; import net.yacy.cora.util.ConcurrentLog;
import net.yacy.cora.util.Memory; import net.yacy.cora.util.Memory;
import net.yacy.crawler.data.Cache; import net.yacy.crawler.data.Cache;
import net.yacy.crawler.data.Transactions;
import net.yacy.crawler.data.Transactions.State;
import net.yacy.crawler.retrieval.Response; import net.yacy.crawler.retrieval.Response;
import net.yacy.data.URLLicense; import net.yacy.data.URLLicense;
import net.yacy.kelondro.data.meta.URIMetadataNode; import net.yacy.kelondro.data.meta.URIMetadataNode;
@ -194,6 +197,7 @@ public class yacysearchitem {
Date[] events = result.events(); Date[] events = result.events();
boolean showEvent = events != null && events.length > 0 && sb.getConfig("search.navigation", "").indexOf("date",0) >= 0; boolean showEvent = events != null && events.length > 0 && sb.getConfig("search.navigation", "").indexOf("date",0) >= 0;
prop.put("content_showEvent", showEvent ? 1 : 0); prop.put("content_showEvent", showEvent ? 1 : 0);
Collection<File> snapshotPaths = sb.getConfigBool("search.result.show.snapshots", true) ? Transactions.findPaths(result.url(), null, State.ANY) : null;
if (fileType == FileType.HTML) { // html template specific settings if (fileType == FileType.HTML) { // html template specific settings
prop.put("content_showDate", sb.getConfigBool("search.result.show.date", true) && !showEvent ? 1 : 0); prop.put("content_showDate", sb.getConfigBool("search.result.show.date", true) && !showEvent ? 1 : 0);
prop.put("content_showSize", sb.getConfigBool("search.result.show.size", true) ? 1 : 0); prop.put("content_showSize", sb.getConfigBool("search.result.show.size", true) ? 1 : 0);
@ -204,6 +208,7 @@ public class yacysearchitem {
prop.put("content_showCache", sb.getConfigBool("search.result.show.cache", true) && Cache.has(resultURL.hash()) ? 1 : 0); prop.put("content_showCache", sb.getConfigBool("search.result.show.cache", true) && Cache.has(resultURL.hash()) ? 1 : 0);
prop.put("content_showProxy", sb.getConfigBool("search.result.show.proxy", true) && sb.getConfigBool("proxyURL", false) ? 1 : 0); prop.put("content_showProxy", sb.getConfigBool("search.result.show.proxy", true) && sb.getConfigBool("proxyURL", false) ? 1 : 0);
prop.put("content_showHostBrowser", sb.getConfigBool("search.result.show.hostbrowser", true) ? 1 : 0); prop.put("content_showHostBrowser", sb.getConfigBool("search.result.show.hostbrowser", true) ? 1 : 0);
prop.put("content_showSnapshots", snapshotPaths != null && snapshotPaths.size() > 0 && sb.getConfigBool("search.result.show.snapshots", true) ? 1 : 0);
prop.put("content_showVocabulary", sb.getConfigBool("search.result.show.vocabulary", true) ? 1 : 0); prop.put("content_showVocabulary", sb.getConfigBool("search.result.show.vocabulary", true) ? 1 : 0);
if (showEvent) prop.put("content_showEvent_date", GenericFormatter.RFC1123_SHORT_FORMATTER.format(events[0])); if (showEvent) prop.put("content_showEvent_date", GenericFormatter.RFC1123_SHORT_FORMATTER.format(events[0]));
@ -220,7 +225,6 @@ public class yacysearchitem {
int c = 0; int c = 0;
for (String key: result.getFieldNames()) { for (String key: result.getFieldNames()) {
if (key.startsWith("vocabulary_") && key.endsWith("_sxt")) { if (key.startsWith("vocabulary_") && key.endsWith("_sxt")) {
@SuppressWarnings("unchecked")
Collection<Object> terms = result.getFieldValues(key); Collection<Object> terms = result.getFieldValues(key);
prop.putHTML("content_showVocabulary_vocabulary_" + c + "_name", key.substring(11, key.length() - 4)); prop.putHTML("content_showVocabulary_vocabulary_" + c + "_name", key.substring(11, key.length() - 4));
prop.putHTML("content_showVocabulary_vocabulary_" + c + "_terms", terms.toString()); prop.putHTML("content_showVocabulary_vocabulary_" + c + "_terms", terms.toString());
@ -233,6 +237,9 @@ public class yacysearchitem {
prop.put("content_showVocabulary_vocabulary", 0); prop.put("content_showVocabulary_vocabulary", 0);
prop.put("content_showVocabulary", 0); prop.put("content_showVocabulary", 0);
} }
if (snapshotPaths != null && snapshotPaths.size() > 0) {
prop.put("content_showSnapshots_link", snapshotPaths.iterator().next().getAbsolutePath());
}
} }
prop.put("content_urlhexhash", Seed.b64Hash2hexHash(urlhash)); prop.put("content_urlhexhash", Seed.b64Hash2hexHash(urlhash));
prop.putHTML("content_urlname", nxTools.shortenURLString(result.urlname(), MAX_URL_LENGTH)); prop.putHTML("content_urlname", nxTools.shortenURLString(result.urlname(), MAX_URL_LENGTH));

@ -57,8 +57,8 @@ public class Transactions {
private final static String XML_PREFIX = "<response>\n<!--\n"; private final static String XML_PREFIX = "<response>\n<!--\n";
private final static char[] WHITESPACE = new char[132]; private final static char[] WHITESPACE = new char[132];
private final static int WHITESPACE_START = XML_PREFIX.length(); //private final static int WHITESPACE_START = XML_PREFIX.length();
private final static int WHITESPACE_LENGTH = WHITESPACE.length; //private final static int WHITESPACE_LENGTH = WHITESPACE.length;
private static File transactionDir = null, inventoryDir = null, archiveDir = null; private static File transactionDir = null, inventoryDir = null, archiveDir = null;
private static Snapshots inventory = null, archive = null; private static Snapshots inventory = null, archive = null;
private static ExecutorService executor = Executors.newCachedThreadPool(); private static ExecutorService executor = Executors.newCachedThreadPool();
@ -348,7 +348,7 @@ public class Transactions {
* This method is inefficient because it tests all different depths, it would be better to use * This method is inefficient because it tests all different depths, it would be better to use
* findPaths/3 with a given depth. * findPaths/3 with a given depth.
* @param url * @param url
* @param ext * @param ext required extension or null if the extension must not be checked
* @param state the wanted transaction state, State.INVENTORY, State.ARCHIVE or State.ANY * @param state the wanted transaction state, State.INVENTORY, State.ARCHIVE or State.ANY
* @return a set of files for snapshots of the url * @return a set of files for snapshots of the url
*/ */

Loading…
Cancel
Save