small corrections to image loading methods in result presentation

especially loading of favicons in search results. This is a fix that
affects only searches in intranet/repository configurations.

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5670 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 16 years ago
parent 98f36a801a
commit f1b712c29a

@ -43,6 +43,13 @@ public class ViewImage {
private static HashMap<String, Image> iconcache = new HashMap<String, Image>(); private static HashMap<String, Image> iconcache = new HashMap<String, Image>();
private static String defaulticon = "htroot/env/grafics/dfltfvcn.ico"; private static String defaulticon = "htroot/env/grafics/dfltfvcn.ico";
private static byte[] defaulticonb;
static {
try {
defaulticonb = FileUtils.read(new File(defaulticon));
} catch (final IOException e) {
}
}
public static Image respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) { public static Image respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
@ -68,9 +75,6 @@ public class ViewImage {
urlString = (url == null) ? null : url.toNormalform(true, true); urlString = (url == null) ? null : url.toNormalform(true, true);
} }
if (url == null) return null;
System.out.println("loading image from " + url.toString());
int width = post.getInt("width", 0); int width = post.getInt("width", 0);
int height = post.getInt("height", 0); int height = post.getInt("height", 0);
int maxwidth = post.getInt("maxwidth", 0); int maxwidth = post.getInt("maxwidth", 0);
@ -81,7 +85,7 @@ public class ViewImage {
Image scaled = iconcache.get(urlString); Image scaled = iconcache.get(urlString);
if (scaled == null) { if (scaled == null) {
Object[] resource = null; Object[] resource = null;
try { if (url != null) try {
resource = plasmaSnippetCache.getResource(url, true, timeout, false, true); resource = plasmaSnippetCache.getResource(url, true, timeout, false, true);
} catch (IOException e) { } catch (IOException e) {
Log.logWarning("ViewImage", "cannot load: " + e.getMessage()); Log.logWarning("ViewImage", "cannot load: " + e.getMessage());
@ -90,10 +94,12 @@ public class ViewImage {
if (resource == null) { if (resource == null) {
if (urlString.endsWith(".ico")) { if (urlString.endsWith(".ico")) {
// load default favicon dfltfvcn.ico // load default favicon dfltfvcn.ico
try { if (defaulticonb == null) try {
imgb = FileUtils.read(new File(sb.getRootPath(), defaulticon)); imgb = FileUtils.read(new File(sb.getRootPath(), defaulticon));
} catch (final IOException e) { } catch (final IOException e) {
return null; return null;
} else {
imgb = defaulticonb;
} }
} else { } else {
return null; return null;

@ -1,7 +1,7 @@
#(content)#:: #(content)#::
<div class="searchresults"> <div class="searchresults">
<h4 class="linktitle"> <h4 class="linktitle">
<img src="ViewImage.png?width=16&amp;height=16&amp;code=#[faviconCode]#" id="f#[urlhash]#" class="favicon" style="width:16px; height:16px;" alt="favicon" /> <img src="ViewImage.png?width=16&amp;height=16&amp;code=#[faviconCode]#" id="f#[urlhash]#" class="favicon" style="width:16px; height:16px;" alt="" />
<a href="#[link]#">#[title]#</a></h4> <a href="#[link]#">#[title]#</a></h4>
#(authorized)#:: #(authorized)#::
<div class="urlactions"> <div class="urlactions">

@ -98,8 +98,8 @@ public class yacysearchitem {
final int port=result.url().getPort(); final int port=result.url().getPort();
yacyURL faviconURL; yacyURL faviconURL = null;
try { if (!result.url().isLocal()) try {
faviconURL = new yacyURL(result.url().getProtocol() + "://" + result.url().getHost() + ((port != -1) ? (":" + String.valueOf(port)) : "") + "/favicon.ico", null); faviconURL = new yacyURL(result.url().getProtocol() + "://" + result.url().getHost() + ((port != -1) ? (":" + String.valueOf(port)) : "") + "/favicon.ico", null);
} catch (final MalformedURLException e1) { } catch (final MalformedURLException e1) {
faviconURL = null; faviconURL = null;

@ -10,6 +10,7 @@ au = audio/basic
avi = video/x-msvideo avi = video/x-msvideo
bat = text/plain bat = text/plain
bin = application/octet-stream bin = application/octet-stream
bmp = image/bmp
bz2 = application/x-bzip2 bz2 = application/x-bzip2
class = application/octet-stream class = application/octet-stream
c = text/plain c = text/plain
@ -29,6 +30,7 @@ gz = application/gzip
hqx = application/mac-binhex40 hqx = application/mac-binhex40
htm = text/html htm = text/html
html = text/html html = text/html
ico = image/bmp
jar = application/java-archive jar = application/java-archive
java = text/plain java = text/plain
jpe = image/jpeg jpe = image/jpeg

@ -56,6 +56,7 @@ public class URLLicense {
public String aquireLicense(final yacyURL url) { public String aquireLicense(final yacyURL url) {
// generate license key // generate license key
String license = ""; String license = "";
if (url == null) return license;
while (license.length() < keylen) license += Integer.toHexString(random.nextInt()); while (license.length() < keylen) license += Integer.toHexString(random.nextInt());
license = license.substring(0, keylen); license = license.substring(0, keylen);
// store reference to url with license key // store reference to url with license key

Loading…
Cancel
Save