Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
extended Supertemplates for Headerincludes.
alloa29b4d4fb52b
diff --git a/htroot/Lab.html b/htroot/Lab.htmlindex f651be891..5836015e8 100644--- a/htroot/Lab.html+++ b/htroot/Lab.html@@ -1,3 +1,6 @@+<!--HEADER for Lab.html+<title>#[clientname]#'s Lab</title>+end of HEADER--><h2>The YaCy Lab</h2><p>diff --git a/htroot/env/page.html b/htroot/env/page.htmlindex 9586e35df..364ea18f6 100644--- a/htroot/env/page.html+++ b/htroot/env/page.html@@ -1,7 +1,8 @@<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html><head>-<title>YaCy '#[clientname]#': #[title]#</title>+#[header]#+<!--<title>YaCy '#[clientname]#': #[title]#</title>--><!-- TODO: title cannot be set, yet. --><!-- clientname needs to be set in page.java (this will remove the code in httpdFileHandler,if we use supertemplates for everything -->diff --git a/source/de/anomic/http/httpdFileHandler.java b/source/de/anomic/http/httpdFileHandler.javaindex dd88024cf..9452919cc 100644--- a/source/de/anomic/http/httpdFileHandler.java+++ b/source/de/anomic/http/httpdFileHandler.java@@ -77,11 +77,13 @@ package de.anomic.http;import java.awt.Image;import java.awt.image.BufferedImage;import java.io.BufferedInputStream;+import java.io.BufferedReader;import java.io.ByteArrayInputStream;import java.io.File;import java.io.FileInputStream;import java.io.IOException;import java.io.InputStream;+import java.io.InputStreamReader;import java.io.OutputStream;import java.io.PushbackInputStream;import java.io.UnsupportedEncodingException;@@ -89,6 +91,7 @@ import java.lang.ref.SoftReference;import java.lang.reflect.InvocationTargetException;import java.lang.reflect.Method;import java.net.URLDecoder;+import java.nio.Buffer;import java.security.MessageDigest;import java.security.NoSuchAlgorithmException;import java.util.Date;@@ -707,20 +710,55 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http}//if(sb.getConfig("usePageTemplate", "false").equals("true")){if(!supertemplate.equals("")){- o = new serverByteBuffer();- /*File pageFile=getOverlayedFile("/env/page.html");- File pageClass=getOverlayedClass("/env/page.html");*/- File pageFile=getOverlayedFile(supertemplate);+ File pageFile=getOverlayedFile(supertemplate); //typically /env/page.htmlFile pageClass=getOverlayedClass(supertemplate);if(pageFile != null && pageFile.exists()){//warning: o,tp and fis are reused+ //this replaces the normal template function (below), and the+ //normal function is used for supertemplates.++ //search for header Data+ //XXX: This part may be slow :-(+ BufferedReader br=new BufferedReader(new InputStreamReader(fis));+ String line;+ boolean inheader=false;+ StringBuffer header=new StringBuffer();+ StringBuffer content=new StringBuffer();+ String content_s,header_s;+ while((line=br.readLine())!=null){+ if(!inheader){+ if(line.startsWith("<!--HEADER")){+ inheader=true;+ }else{+ content.append(line);+ }+ }else{+ if(line.endsWith("HEADER-->")){+ inheader=false;+ }else{+ header.append(line);+ }+ }+ }++ //tp is from the servlet, fis is the content-only from the servlet+ //this resolvs templates in both header and content+ o = new serverByteBuffer();+ fis=new ByteArrayInputStream(content.toString().getBytes());+ httpTemplate.writeTemplate(fis, o, tp, "-UNRESOLVED_PATTERN-".getBytes());+ content_s=o.toString();+ o = new serverByteBuffer();+ fis=new ByteArrayInputStream(header.toString().getBytes());httpTemplate.writeTemplate(fis, o, tp, "-UNRESOLVED_PATTERN-".getBytes());+ header_s=o.toString();+ //further processing of page.html (via page.class)?if (pageClass != null && pageClass.exists())tp = (serverObjects) invokeServlet(pageClass, requestHeader, args);elsetp = new serverObjects();- tp.put("page", o.toString());+ tp.put("header", header_s);+ tp.put("page", content_s);fis=new BufferedInputStream(new FileInputStream(pageFile));}