From 820b896146ad7196a443161c440b47a8e237d948 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Tue, 15 Oct 2013 16:46:06 +0200 Subject: [PATCH] Replaced the inframe loading from yacy.net for donations with the loading of this iframe from the local host. To make this more flexible, this iframe is loaded once after startup from yacy.net. --- defaults/yacy.init | 5 ++++- source/net/yacy/yacy.java | 28 ++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/defaults/yacy.init b/defaults/yacy.init index 1398c0697..7a51c6ced 100644 --- a/defaults/yacy.init +++ b/defaults/yacy.init @@ -1045,7 +1045,10 @@ content.phpbb3.dumpfile = # search engine teaser: an about box in search results # this is only shown, if the about.body is filled about.headline=Please support YaCy! -about.body=
If you run a YaCy server, feel free to replace our donation plea with your own support message, use the Portal Configuration servlet.
+about.body=
If you run a YaCy server, feel free to replace our donation plea with your own support message, use the Portal Configuration servlet.
+ +donation.iframesource=http://yacy.net/include/donate.html +donation.iframetarget=env/donate.html # search heuristics heuristic.site = false diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.java index 900fe5534..ea3e53f14 100644 --- a/source/net/yacy/yacy.java +++ b/source/net/yacy/yacy.java @@ -42,6 +42,8 @@ import java.util.concurrent.Semaphore; import java.util.concurrent.ExecutionException; import net.yacy.cora.date.GenericFormatter; +import net.yacy.cora.document.id.DigestURL; +import net.yacy.cora.federate.yacy.CacheStrategy; import net.yacy.cora.lod.JenaTripleStore; import net.yacy.cora.protocol.ClientIdentification; import net.yacy.cora.protocol.RequestHeader; @@ -49,6 +51,7 @@ import net.yacy.cora.protocol.TimeoutRequest; import net.yacy.cora.protocol.http.HTTPClient; import net.yacy.cora.sorting.Array; import net.yacy.cora.util.ConcurrentLog; +import net.yacy.crawler.retrieval.Response; import net.yacy.data.Translator; import net.yacy.gui.YaCyApp; import net.yacy.gui.framework.Browser; @@ -263,12 +266,26 @@ public final class yacy { mkdirIfNeseccary(htDocsPath); //final File htTemplatePath = new File(homePath, sb.getConfig("htTemplatePath","htdocs")); + // copy the donate iframe (better to copy this once here instead of doing this in an actual iframe in the search result) + final File wwwEnvPath = new File(htDocsPath, "env"); + mkdirIfNeseccary(wwwEnvPath); + final String iframesource = sb.getConfig("donation.iframesource", ""); + final String iframetarget = sb.getConfig("donation.iframetarget", ""); + final File iframefile = new File(htDocsPath, iframetarget); + if (!iframefile.exists()) new Thread() { + public void run() { + final ClientIdentification.Agent agent = ClientIdentification.getAgent(ClientIdentification.yacyInternetCrawlerAgentName); + Response response; + try { + response = sb.loader == null ? null : sb.loader.load(sb.loader.request(new DigestURL(iframesource), false, true), CacheStrategy.NOCACHE, Integer.MAX_VALUE, null, agent); + if (response != null) FileUtils.copy(response.getContent(), iframefile); + } catch (Throwable e) {} + } + }.start(); + // create default notifier picture - //TODO: Use templates instead of copying images ... - if (!((new File(htDocsPath, "notifier.gif")).exists())) try { - Files.copy(new File(htRootPath, "env/grafics/empty.gif"), - new File(htDocsPath, "notifier.gif")); - } catch (final IOException e) {} + File notifierFile = new File(htDocsPath, "notifier.gif"); + if (!notifierFile.exists()) try {Files.copy(new File(htRootPath, "env/grafics/empty.gif"), notifierFile);} catch (final IOException e) {} final File htdocsReadme = new File(htDocsPath, "readme.txt"); if (!(htdocsReadme.exists())) try {FileUtils.copy(( @@ -290,7 +307,6 @@ public final class yacy { final File wwwDefaultPath = new File(htDocsPath, "www"); mkdirIfNeseccary(wwwDefaultPath); - final File shareDefaultPath = new File(htDocsPath, "share"); mkdirIfNeseccary(shareDefaultPath);