some example Code, how supertemplates can be used.

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2304 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
allo 19 years ago
parent 5214f571cd
commit 67c486a023

@ -1,12 +1,3 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>YaCy '#[clientname]#': Lab</title>
#%env/templates/metas.template%#
</head>
<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0">
#%env/templates/header.template%#
<br><br>
<h2>The YACY Lab</h2> <h2>The YACY Lab</h2>
<p> <p>
@ -18,7 +9,3 @@ You may try out these things but please do not care about bugs.</p>
<li>The <a href="Wiki.html">Wiki</a></li> <li>The <a href="Wiki.html">Wiki</a></li>
<li>Advanced <a href="/Config_p.html">Configuration</a></li> <li>Advanced <a href="/Config_p.html">Configuration</a></li>
</ul> </ul>
#%env/templates/footer.template%#
</body>
</html>

@ -1,3 +1,18 @@
#[test1]# <!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>
<!-- 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 -->
#%env/templates/metas.template%#
</head>
<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0">
#%env/templates/header.template%#
<br><br>
#[page]# #[page]#
#(test2)#zero::one::two#(/test2)#
#%env/templates/footer.template%#
</body>
</html>

@ -33,8 +33,9 @@ public class page {
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) { public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
//plasmaSwitchboard switchboard = (plasmaSwitchboard) env; //plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
serverObjects prop = new serverObjects(); serverObjects prop = new serverObjects();
prop.put("test1", "testit!"); //prop.put("test1", "testit!");
prop.put("test2", 1); //prop.put("test2", 1);
return prop; return prop;
} }

@ -693,10 +693,17 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
} }
//use the page template //use the page template
if(sb.getConfig("usePageTemplate", "false").equals("true")){ String supertemplate="";
if(tp.containsKey("SUPERTEMPLATE")){
supertemplate=(String) tp.get("SUPERTEMPLATE");
}
//if(sb.getConfig("usePageTemplate", "false").equals("true")){
if(!supertemplate.equals("")){
o = new serverByteBuffer(); o = new serverByteBuffer();
File pageFile=getOverlayedFile("/env/page.html"); /*File pageFile=getOverlayedFile("/env/page.html");
File pageClass=getOverlayedClass("/env/page.html"); File pageClass=getOverlayedClass("/env/page.html");*/
File pageFile=getOverlayedFile(supertemplate);
File pageClass=getOverlayedClass(supertemplate);
if(pageFile != null && pageFile.exists()){ if(pageFile != null && pageFile.exists()){
//warning: o,tp and fis are reused //warning: o,tp and fis are reused
httpTemplate.writeTemplate(fis, o, tp, "-UNRESOLVED_PATTERN-".getBytes()); httpTemplate.writeTemplate(fis, o, tp, "-UNRESOLVED_PATTERN-".getBytes());

Loading…
Cancel
Save