mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
Merge branch 'master' of https://github.com/yacy/yacy_search_server
This commit is contained in:
commit
07437986e7
10
htroot/proxymsg/urlproxyheader.html
Normal file
10
htroot/proxymsg/urlproxyheader.html
Normal file
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body style="background:white">
|
||||
<div align="center" style="width:98%; padding:5px; background:white; border-bottom: medium solid lightgrey;">
|
||||
<form method="get" target="_parent" action="#[proxyurl]#">
|
||||
<input type="submit" value="YaCy stop proxy"> #(httpsAlertMsg)#:: - <span style='color:red'>(Warning: secure target viewed over normal http)</span>#(/httpsAlertMsg)#
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
49
htroot/proxymsg/urlproxyheader.java
Normal file
49
htroot/proxymsg/urlproxyheader.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
|
||||
import net.yacy.cora.protocol.RequestHeader;
|
||||
import net.yacy.search.Switchboard;
|
||||
import net.yacy.server.serverObjects;
|
||||
import net.yacy.server.serverSwitch;
|
||||
|
||||
|
||||
/**
|
||||
* Servlet to be included as header (via iframe) on top of a page viewed via urlproxyservlet
|
||||
*/
|
||||
public class urlproxyheader {
|
||||
|
||||
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader requestHeader, @SuppressWarnings("unused") final serverObjects post, @SuppressWarnings("unused") final serverSwitch env) {
|
||||
final serverObjects prop = new serverObjects();
|
||||
final Switchboard sb = (Switchboard) env;
|
||||
|
||||
final String proxyurlstr = post.get("url",""); // the url of remote page currently viewed
|
||||
prop.put("proxyurl", proxyurlstr);
|
||||
|
||||
if (proxyurlstr.startsWith("https")) {
|
||||
prop.put("httpsAlertMsg", "1");
|
||||
} else {
|
||||
prop.put("httpsAlertMsg", "0");
|
||||
}
|
||||
|
||||
// TODO: get some index data to display
|
||||
/*
|
||||
if (post.containsKey("hash")) {
|
||||
try {
|
||||
String hashstr = post.get("hash");
|
||||
final SolrDocument idxdoc = sb.index.fulltext().getDefaultEmbeddedConnector().getDocumentById(hashstr);
|
||||
if (idxdoc != null) {
|
||||
String keywords = (String) idxdoc.getFieldValue(CollectionSchema.keywords.getSolrFieldName());
|
||||
if (keywords != null && !keywords.isEmpty()) {
|
||||
keytxt += keywords;
|
||||
}
|
||||
Collection cols = idxdoc.getFieldValues(CollectionSchema.collection_sxt.getSolrFieldName());
|
||||
if (cols != null && !cols.isEmpty()) {
|
||||
for (Object sx : cols) {
|
||||
coltxt += sx.toString();
|
||||
}
|
||||
}
|
||||
}catch (IOException ex) { }
|
||||
}
|
||||
*/
|
||||
return prop;
|
||||
}
|
||||
|
||||
}
|
|
@ -15,7 +15,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<div align="center">
|
||||
<img src="env/grafics/kaskelix.png"/><br/>
|
||||
<img src="/env/grafics/kaskelix.png"/><br/>
|
||||
<h1><xsl:value-of select='channel/title' /></h1>
|
||||
</div>
|
||||
<p>
|
||||
|
|
|
@ -252,13 +252,20 @@ public class UrlProxyServlet extends ProxyServlet implements Servlet {
|
|||
}
|
||||
|
||||
// 8 - add interaction elements (e.g. proxy exit button to switch back to original url)
|
||||
// TODO: use a template file for
|
||||
if (_stopProxyText != null) {
|
||||
String httpsAllertMsg = "";
|
||||
if (proxyurl.getProtocol().equalsIgnoreCase("https") && !request.getScheme().equalsIgnoreCase("https")) httpsAllertMsg = " - <span style='color:red'>(Warning: secure target viewed over normal http)</span>";
|
||||
bde.prepend("<div width='100%' style='padding:5px; background:white; border-bottom: medium solid lightgrey;'>"
|
||||
+ "<div align='center' style='font-size:11px; color:darkgrey;'><a href='" + proxyurl + "'>" + _stopProxyText + "</a> "
|
||||
+ httpsAllertMsg + "</div></div>");
|
||||
|
||||
String httpsAlertMsg = "";
|
||||
if (proxyurl.getProtocol().equalsIgnoreCase("https") && !request.getScheme().equalsIgnoreCase("https")) httpsAlertMsg = " - <span style='color:red'>(Warning: secure target viewed over normal http)</span>";
|
||||
|
||||
// use a template file, to allow full servlet functionallity header as iframe included
|
||||
String hdrtemplate = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/proxymsg/urlproxyheader.html?url=" + proxyurl.toString();
|
||||
hdrtemplate = "<iframe src='" + hdrtemplate +"' width='98%' height='50px' >"
|
||||
// alternative for no-frame supporting browser
|
||||
+ "<div width='100%' style='padding:5px; background:white; border-bottom: medium solid lightgrey;'>"
|
||||
+ "<div align='center' style='font-size:11px;'><a style='font-size:11px; color:black;' href='" + proxyurl + "'>" + _stopProxyText + "</a> "
|
||||
+ httpsAlertMsg + "</div></div>"
|
||||
+ "</iframe>";
|
||||
bde.prepend(hdrtemplate); // put as 1st element in body
|
||||
}
|
||||
|
||||
// 9 - deliver to client
|
||||
|
|
Loading…
Reference in New Issue
Block a user