diff --git a/htroot/js/yacyinteractive.js b/htroot/js/yacyinteractive.js index 7c0e889c2..63575a25d 100644 --- a/htroot/js/yacyinteractive.js +++ b/htroot/js/yacyinteractive.js @@ -11,6 +11,8 @@ var totalResults = 0; var filetypes; var topics; var script = ""; +var modifier = ""; +var modifiertype = ""; function search(search) { query = search; @@ -49,14 +51,23 @@ function preparepage(str) { topics = navget(firstChannel.navigation, "topics"); filetypes = {}; script = ""; - - document.getElementById("searchresults").innerHTML = resultList(); + if (query.length >= 13 && query.substring(query.length - 13, query.length - 3) == " filetype:") { + modifier = query.substring(query.length - 12); + } + if (modifier != "") modifiertype = modifier.substring(modifier.length - 3) + + + if (modifiertype == "png" || modifiertype == "gif" || modifiertype == "jpg") { + document.getElementById("searchresults").innerHTML = resultImages(); + } else { + document.getElementById("searchresults").innerHTML = resultList(); + } document.getElementById("searchnavigation").innerHTML = resultStart(); hideDownloadScript(); } function makeDownloadScript() { - document.getElementById("downloadscript").innerHTML = "
" + script + "
"; + document.getElementById("downloadscript").innerHTML = "
" + script + "

"; document.getElementById("downloadbutton").innerHTML = ""; } @@ -91,8 +102,8 @@ function resultStart() { html += "apply a filter by filetype:    " + extnav + ""; } else { // check if there is a filetype constraint and offer a removal - if (query.length >= 13 && query.substring(query.length - 13, query.length - 3) == " filetype:") { - html += "remote the filter '" + query.substring(query.length - 12) + "'"; + if (modifier != "") { + html += "remove the filter '" + modifier + "'"; } } @@ -113,27 +124,22 @@ function resultStart() { function resultList() { var html = ""; if (searchresult.length > 0) { - var item; html += ""; - html += ""; - html += ""; - html += ""; - html += ""; - html += ""; - html += ""; - //html += ""; - html += ""; - for (var i = 0; i < searchresult.length; i++) { - var item = searchresult[i]; - html += resultLine(item); - } + html += ""; + for (var i = 0; i < searchresult.length; i++) { html += resultLine("row", searchresult[i]); } html += "
ProtocolHostPathNameSizeDescriptionDate
ProtocolHostPathNameSizeDate
"; } return html; } -function resultLine(item) { +function resultImages() { var html = ""; + for (var i = 0; i < searchresult.length; i++) { html += resultLine("image", searchresult[i]); } + return html; +} + +function resultLine(type, item) { + // evaluate item p = item.link.indexOf("//"); protocol = ""; host = ""; @@ -145,23 +151,14 @@ function resultLine(item) { path = item.link.substring(q + 1); } if (path.length >= 40) path = path.substring(0, 18) + "..." + path.substring(path.length - 19); - html += ""; - html += "" + protocol + ""; - html += "" + host + ""; - html += "" + path + ""; title = item.title; if (title == "") title = path; if (title.length >= 60) title = title.substring(0, 28) + "..." + title.substring(title.length - 29); - html += "" + title + ""; - html += "" + item.sizename + ""; - //html += "" + item.description + ""; pd = item.pubDate; if (pd.substring(pd.length - 6) == " +0000") pd = pd.substring(0, pd.length - 6); if (pd.substring(pd.length - 9) == " 00:00:00") pd = pd.substring(0, pd.length - 9); if (pd.substring(pd.length - 5) == " 2010") pd = pd.substring(0, pd.length - 5); - html += "" + pd + ""; - html += ""; - + // update navigation if (item.link && item.link.length > 4) { ext = item.link.substring(item.link.length - 4); @@ -178,6 +175,30 @@ function resultLine(item) { // update download script script += "curl -OL \"" + item.link + "\"\n"; - // return table row + // make table row + var html = ""; + if (type == "row") { + html += ""; + html += "" + protocol + ""; + html += "" + host + ""; + html += "" + path + ""; + html += "" + title + ""; + html += "" + item.sizename + ""; + //html += "" + item.description + ""; + html += "" + pd + ""; + html += ""; + } + if (type == "image") { + html += "
"; + html += ""; + html += "\"""; + html += ""; + var name = title; + while ((p = name.indexOf("/")) >= 0) { name = name.substring(p + 1); } + html += "
" + name + "
" + host + "
"; + html += "
"; + } + + // return entry return html; } diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java index 825e69dc4..33d34106a 100644 --- a/htroot/yacysearch.java +++ b/htroot/yacysearch.java @@ -318,7 +318,7 @@ public class yacysearch { String ft = querystring.substring(filetype + 9, ftb); querystring = querystring.replace("filetype:" + ft, ""); while (ft.length() > 0 && ft.charAt(0) == '.') ft = ft.substring(1); - if(ft.length() > 0) { + if (ft.length() > 0) { if (urlmask == null) { urlmask = ".*\\." + ft; } else { diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.java index 8639f2d18..c255ba291 100644 --- a/htroot/yacysearchitem.java +++ b/htroot/yacysearchitem.java @@ -104,18 +104,17 @@ public class yacysearchitem { final ResultEntry result = theSearch.oneResult(item, theQuery.isLocal() ? 1000 : 5000); if (result == null) return prop; // no content - - final int port=result.url().getPort(); + DigestURI resultURL = result.url(); + final int port = resultURL.getPort(); DigestURI faviconURL = null; - if (isHtml && !sb.isIntranetMode() && !result.url().isLocal()) try { - faviconURL = new DigestURI(result.url().getProtocol() + "://" + result.url().getHost() + ((port != -1) ? (":" + port) : "") + "/favicon.ico"); + if (isHtml && !sb.isIntranetMode() && !resultURL.isLocal()) try { + faviconURL = new DigestURI(resultURL.getProtocol() + "://" + resultURL.getHost() + ((port != -1) ? (":" + port) : "") + "/favicon.ico"); } catch (final MalformedURLException e1) { Log.logException(e1); faviconURL = null; } prop.put("content", 1); // switch on specific content - prop.put("content_authorized", authenticated ? "1" : "0"); prop.put("content_authorized_recommend", (sb.peers.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, yacyNewsPool.CATEGORY_SURFTIPP_ADD, "url", result.urlstring()) == null) ? "1" : "0"); prop.putHTML("content_authorized_recommend_deletelink", "/yacysearch.html?query=" + theQuery.queryString.replace(' ', '+') + "&Enter=Search&count=" + theQuery.displayResults() + "&offset=" + (theQuery.neededResults() - theQuery.displayResults()) + "&order=" + crypt.simpleEncode(theQuery.ranking.toExternalString()) + "&resource=local&time=3&deleteref=" + new String(result.hash()) + "&urlmaskfilter=.*"); @@ -138,9 +137,9 @@ public class yacysearchitem { //prop.put("content_ybr", RankingProcess.ybr(result.hash())); prop.putHTML("content_size", Integer.toString(result.filesize())); // we don't use putNUM here because that number shall be usable as sorting key. To print the size, use 'sizename' prop.putHTML("content_sizename", sizename(result.filesize())); - prop.putHTML("content_host", result.url().getHost() == null ? "" : result.url().getHost()); - prop.putHTML("content_file", result.url().getFile()); - prop.putHTML("content_path", result.url().getPath()); + prop.putHTML("content_host", resultURL.getHost() == null ? "" : resultURL.getHost()); + prop.putHTML("content_file", resultURL.getFile()); + prop.putHTML("content_path", resultURL.getPath()); prop.put("content_nl", (item == 0) ? 0 : 1); prop.putHTML("content_publisher", result.publisher()); prop.putHTML("content_creator", result.creator());// author @@ -167,10 +166,18 @@ public class yacysearchitem { prop.put("content_heuristic_name", heuristic.heuristicName); } EventTracker.update(EventTracker.EClass.SEARCH, new ProfilingGraph.searchEvent(theQuery.id(true), SearchEvent.Type.FINALIZATION, "" + item, 0, 0), false); + String ext = resultURL.getFileExtension().toLowerCase(); + if (ext.equals("png") || ext.equals("jpg") || ext.equals("gif")) { + String license = sb.licensedURLs.aquireLicense(resultURL); + prop.put("content_code", license); + } else { + prop.put("content_code", ""); + } return prop; } + if (theQuery.contentdom == ContentDomain.IMAGE) { // image search; shows thumbnails @@ -179,10 +186,11 @@ public class yacysearchitem { if (ms == null) { prop.put("content_item", "0"); } else { + String license = sb.licensedURLs.aquireLicense(ms.href); sb.loader.loadIfNotExistBackground(ms.href.toNormalform(true, false), 1024 * 1024 * 10); prop.putHTML("content_item_hrefCache", (auth) ? "/ViewImage.png?url=" + ms.href.toNormalform(true, false) : ms.href.toNormalform(true, false)); prop.putHTML("content_item_href", ms.href.toNormalform(true, false)); - prop.put("content_item_code", sb.licensedURLs.aquireLicense(ms.href)); + prop.put("content_item_code", license); prop.putHTML("content_item_name", shorten(ms.name, namelength)); prop.put("content_item_mimetype", ms.mime); prop.put("content_item_fileSize", ms.fileSize); diff --git a/htroot/yacysearchitem.json b/htroot/yacysearchitem.json index 61a663bbb..e597469dd 100644 --- a/htroot/yacysearchitem.json +++ b/htroot/yacysearchitem.json @@ -2,6 +2,7 @@ { "title": "#[title-json]#", "link": "#[link]#", + "code": "#[code]#", "description": "#[description-json]#", "pubDate": "#[date822]#", "size": "#[size]#", diff --git a/source/de/anomic/search/QueryParams.java b/source/de/anomic/search/QueryParams.java index 857d35c2a..c17b98b35 100644 --- a/source/de/anomic/search/QueryParams.java +++ b/source/de/anomic/search/QueryParams.java @@ -185,7 +185,7 @@ public final class QueryParams { this.contentdom = contentdom; this.itemsPerPage = Math.min((specialRights) ? 1000 : 100, itemsPerPage); this.offset = Math.min((specialRights) ? 10000 : 1000, offset); - this.urlMask = Pattern.compile(urlMask); + this.urlMask = Pattern.compile(urlMask.toLowerCase()); this.urlMask_isCatchall = this.urlMask.toString().equals(catchall_pattern.toString()); this.prefer = Pattern.compile(prefer); this.prefer_isMatchnothing = this.prefer.toString().equals(matchnothing_pattern.toString()); diff --git a/source/net/yacy/document/Condenser.java b/source/net/yacy/document/Condenser.java index cbd2dfe0d..446907af0 100644 --- a/source/net/yacy/document/Condenser.java +++ b/source/net/yacy/document/Condenser.java @@ -287,6 +287,7 @@ public final class Condenser { } private void createCondensement(final InputStream is, final DidYouMeanLibrary meaningLib) throws UnsupportedEncodingException { + assert is != null; final Set currsentwords = new HashSet(); StringBuilder sentence = new StringBuilder(100); String word = ""; @@ -513,6 +514,7 @@ public final class Condenser { private DidYouMeanLibrary meaningLib; public sievedWordsEnum(final InputStream is, final DidYouMeanLibrary meaningLib) throws UnsupportedEncodingException { + assert is != null; this.e = new unsievedWordsEnum(is); this.buffer = nextElement0(); this.meaningLib = meaningLib; @@ -557,6 +559,7 @@ public final class Condenser { private int sIndex; public unsievedWordsEnum(final InputStream is) throws UnsupportedEncodingException { + assert is != null; e = new sentencesFromInputStreamEnum(is); s = new ArrayList(); sIndex = 0; @@ -634,6 +637,7 @@ public final class Condenser { } public static sentencesFromInputStreamEnum sentencesFromInputStream(final InputStream is) { + assert is != null; try { return new sentencesFromInputStreamEnum(is); } catch (final UnsupportedEncodingException e) { @@ -651,6 +655,7 @@ public final class Condenser { private boolean pre = false; public sentencesFromInputStreamEnum(final InputStream is) throws UnsupportedEncodingException { + assert is != null; raf = new BufferedReader(new InputStreamReader(is, "UTF-8")); buffer = nextElement0(); counter = 0; diff --git a/source/net/yacy/document/Document.java b/source/net/yacy/document/Document.java index 081d4e94d..572cf0ecb 100644 --- a/source/net/yacy/document/Document.java +++ b/source/net/yacy/document/Document.java @@ -112,12 +112,7 @@ public class Document { this.outboundLinks = -1; this.languages = languages; this.indexingDenied = indexingDenied; - - if (text == null) - this.text = new ByteArrayOutputStream(); - else { - this.text = text; - } + this.text = text == null ? new ByteArrayOutputStream() : text; } public void setInboundLinks(int il) { diff --git a/source/net/yacy/kelondro/data/meta/URIMetadataRow.java b/source/net/yacy/kelondro/data/meta/URIMetadataRow.java index d185e2988..5951ad9c4 100644 --- a/source/net/yacy/kelondro/data/meta/URIMetadataRow.java +++ b/source/net/yacy/kelondro/data/meta/URIMetadataRow.java @@ -555,8 +555,8 @@ public class URIMetadataRow implements URIMetadata { this.dc_publisher = publisher; } public boolean matches(Pattern matcher) { - if (this.urlRaw != null) return matcher.matcher(this.urlRaw).matches(); - if (this.url != null) return matcher.matcher(this.url.toNormalform(true, true)).matches(); + if (this.urlRaw != null) return matcher.matcher(this.urlRaw.toLowerCase()).matches(); + if (this.url != null) return matcher.matcher(this.url.toNormalform(true, true).toLowerCase()).matches(); return false; } public DigestURI url() {