From 14d6e476c9f9b3ccdb6253ab7302de5f645c27d6 Mon Sep 17 00:00:00 2001 From: orbiter Date: Mon, 10 Apr 2006 22:34:47 +0000 Subject: [PATCH] tried to solve some problems with new picture viewer git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2019 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/ViewImage.java | 11 ++-- htroot/yacysearch.html | 4 +- htroot/yacysearch.java | 54 ++++++++++--------- source/de/anomic/http/httpdFileHandler.java | 6 ++- .../de/anomic/plasma/plasmaSwitchboard.java | 3 +- 5 files changed, 45 insertions(+), 33 deletions(-) diff --git a/htroot/ViewImage.java b/htroot/ViewImage.java index d88feb630..553064535 100644 --- a/htroot/ViewImage.java +++ b/htroot/ViewImage.java @@ -76,9 +76,10 @@ public class ViewImage { // create image MediaTracker mediaTracker = new MediaTracker(new Container()); - Image original = Toolkit.getDefaultToolkit().createImage(imgb); - mediaTracker.addImage(original, 0); - try {mediaTracker.waitForID(0);} catch (InterruptedException e) {} + Image original = Toolkit.getDefaultToolkit().createImage(imgb); + int handle = original.hashCode(); + mediaTracker.addImage(original, handle); + try {mediaTracker.waitForID(handle);} catch (InterruptedException e) {} boolean auth = ((String) header.get("CLIENTIP", "")).equals("localhost") || sb.verifyAuthentication(header, false); // handle access rights if ((auth) && ((width == 0) || (height == 0)) && (maxwidth == 0) && (maxheight == 0)) return original; @@ -106,6 +107,10 @@ public class ViewImage { } } + // check for minimum values + width = Math.max(width, 1); + height = Math.max(height, 1); + // scale image Image scaled = original.getScaledInstance(width, height, Image.SCALE_AREA_AVERAGING); mediaTracker.addImage(scaled, 0); diff --git a/htroot/yacysearch.html b/htroot/yacysearch.html index a867f7a78..1f6e171a4 100644 --- a/htroot/yacysearch.html +++ b/htroot/yacysearch.html @@ -111,7 +111,7 @@ available for everyone. Then stay online to support crawls from other peers. Tha #{results}#

- + bookmark #[description]#
@@ -119,7 +119,7 @@ available for everyone. Then stay online to support crawls from other peers. Tha #(snippet)#loading snippet ...::#[text]##(/snippet)#
 
#[urlname]#
 #[date]# | -YBR-#[ybr]# | Info | Pictures +YBR-#[ybr]# | Info | Pictures

diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java index 58bac30fa..63f93de65 100644 --- a/htroot/yacysearch.java +++ b/htroot/yacysearch.java @@ -78,11 +78,7 @@ public class yacysearch { boolean authenticated = sb.adminAuthenticated(header) >= 2; int display = ((post == null) || (!authenticated)) ? 0 : post.getInt("display", 0); - boolean global = (post == null) ? true : post.get("resource", "global").equals("global"); - final boolean indexDistributeGranted = sb.getConfig("allowDistributeIndex", "true").equals("true"); - final boolean indexReceiveGranted = sb.getConfig("allowReceiveIndex", "true").equals("true"); - if (!indexDistributeGranted || !indexReceiveGranted) { global = false; } - + // case if no values are requested final String referer = (String) header.get("Referer"); if (post == null || env == null) { @@ -134,6 +130,21 @@ public class yacysearch { serverObjects prop = new serverObjects(); + final int count = Integer.parseInt(post.get("count", "10")); + final String order = post.get("order", plasmaSearchPreOrder.canUseYBR() ? "YBR-Date-Quality" : "Date-Quality-YBR"); + boolean global = (post == null) ? true : post.get("resource", "global").equals("global"); + final boolean indexDistributeGranted = sb.getConfig("allowDistributeIndex", "true").equals("true"); + final boolean indexReceiveGranted = sb.getConfig("allowReceiveIndex", "true").equals("true"); + if (!indexDistributeGranted || !indexReceiveGranted) { global = false; } + final long searchtime = 1000 * Long.parseLong(post.get("time", "10")); + String urlmask = ""; + if (post.containsKey("urlmask") && post.get("urlmask").equals("no")) { + urlmask = ".*"; + } else { + urlmask = (post.containsKey("urlmaskfilter")) ? (String) post.get("urlmaskfilter") : ".*"; + } + String prefer = post.get("prefer", ".*"); + if (post.get("cat", "href").equals("href")) { prop.put("type", 0); // set type of result: normal link list @@ -156,9 +167,7 @@ public class yacysearch { } // prepare search order - final String order = post.get("order", plasmaSearchPreOrder.canUseYBR() ? "YBR-Date-Quality" : "Date-Quality-YBR"); - final int count = Integer.parseInt(post.get("count", "10")); - final long searchtime = 1000 * Long.parseLong(post.get("time", "10")); + final boolean yacyonline = ((yacyCore.seedDB != null) && (yacyCore.seedDB.mySeed != null) && (yacyCore.seedDB.mySeed.getAddress() != null)); String order1 = plasmaSearchRankingProfile.ORDER_DATE; @@ -173,13 +182,7 @@ public class yacysearch { if (order.endsWith("YBR")) order3 = plasmaSearchRankingProfile.ORDER_YBR; if (order.endsWith("Date")) order3 = plasmaSearchRankingProfile.ORDER_DATE; if (order.endsWith("Quality")) order3 = plasmaSearchRankingProfile.ORDER_QUALITY; - String urlmask = ""; - if (post.containsKey("urlmask") && post.get("urlmask").equals("no")) { - urlmask = ".*"; - } else { - urlmask = (post.containsKey("urlmaskfilter")) ? (String) post.get("urlmaskfilter") : ".*"; - } - + // do the search plasmaSearchQuery thisSearch = new plasmaSearchQuery( query, @@ -296,16 +299,9 @@ public class yacysearch { } } - prop.put("former", post.get("search", "")); - prop.put("count", count); - prop.put("order", order); - prop.put("resource", (global) ? "global" : "local"); - prop.put("time", searchtime / 1000); - prop.put("urlmaskfilter", urlmask); prop.put("type", "0"); prop.put("cat", "href"); prop.put("depth", "0"); - // adding some additional properties needed for the rss feed String hostName = (String) header.get("Host", "localhost"); @@ -340,13 +336,21 @@ public class yacysearch { line++; } prop.put("type_results", line); - - prop.put("cat", "image"); + prop.put("type", 1); // set type of result: image list - prop.put("former", post.get("search", "")); + prop.put("cat", "href"); prop.put("depth", depth); } + + prop.put("former", post.get("search", "")); + prop.put("count", count); + prop.put("order", order); + prop.put("resource", (global) ? "global" : "local"); + prop.put("time", searchtime / 1000); + prop.put("urlmaskfilter", urlmask); + prop.put("prefer", prefer); prop.put("display", display); + // return rewrite properties return prop; } diff --git a/source/de/anomic/http/httpdFileHandler.java b/source/de/anomic/http/httpdFileHandler.java index 4abb7b065..4ca17621d 100644 --- a/source/de/anomic/http/httpdFileHandler.java +++ b/source/de/anomic/http/httpdFileHandler.java @@ -515,9 +515,11 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http String mimeType = mimeTable.getProperty(targetExt, "text/html"); // generate an byte array from the generated image + int width = i.getWidth(null); + int height = i.getHeight(null); + BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + bi.createGraphics().drawImage(i, 0, 0, width, height, null); serverByteBuffer baos = new serverByteBuffer(); - BufferedImage bi = new BufferedImage(i.getWidth(null), i.getHeight(null), BufferedImage.TYPE_INT_RGB); - bi.createGraphics().drawImage(i, 0, 0, i.getWidth(null), i.getHeight(null), null); ImageIO.write(bi, targetExt, baos); byte[] result = baos.toByteArray(); diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java index 1a409a743..3afa54b77 100644 --- a/source/de/anomic/plasma/plasmaSwitchboard.java +++ b/source/de/anomic/plasma/plasmaSwitchboard.java @@ -1878,7 +1878,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser prop.put("type_results_" + i + "_date", dateString(urlentry.moddate())); prop.put("type_results_" + i + "_ybr", plasmaSearchPreOrder.ybr(urlentry.hash())); prop.put("type_results_" + i + "_size", Long.toString(urlentry.size())); - prop.put("type_results_" + i + "_words",URLEncoder.encode(query.queryWords.toString(),"UTF-8")); + prop.put("type_results_" + i + "_words", URLEncoder.encode(query.queryWords.toString(),"UTF-8")); + prop.put("type_results_" + i + "_former", formerSearch); // adding snippet if available if (snippet.exists()) { prop.put("type_results_" + i + "_snippet", 1);