Author: fred
Date: 2007-07-27 13:26:14 +0000 (Fri, 27 Jul 2007)
New Revision: 14376
Modified:
trunk/plugins/Echo/src/plugins/echo/Echo.java
trunk/plugins/Echo/src/plugins/echo/Node.java
trunk/plugins/Echo/src/plugins/echo/Page.java
trunk/plugins/Echo/src/plugins/echo/Test.java
trunk/plugins/Echo/src/plugins/echo/i18n/I18n.java
trunk/plugins/Echo/src/xml/test.xsl
Log:
i18n + various fix
Modified: trunk/plugins/Echo/src/plugins/echo/Echo.java
===================================================================
--- trunk/plugins/Echo/src/plugins/echo/Echo.java 2007-07-27 12:47:46 UTC
(rev 14375)
+++ trunk/plugins/Echo/src/plugins/echo/Echo.java 2007-07-27 13:26:14 UTC
(rev 14376)
@@ -99,11 +99,11 @@
private String transform(Page page) {
try {
-// return
transform.transform(page.getDoc()).get(0).toXML();
+ return
transform.transform(page.getDoc()).get(0).toXML();
/*
Nice but input white space are not respected
- */
+
ByteArrayOutputStream baos = new
ByteArrayOutputStream();
Serializer serializer = new Serializer(baos);
serializer.setIndent(4);
@@ -111,9 +111,9 @@
serializer.write(new Document((Element)
transform.transform(page.getDoc()).get(0)));
return baos.toString();
+ */
-
} catch (Exception e) {
return e.getMessage();
}
@@ -122,7 +122,7 @@
public String handleHTTPGet(HTTPRequest request) throws
PluginHTTPException {
- if ("/plugins/plugins.echo.Echo".equals(request.getPath()))
// FIXME
+ if ("/plugins/plugins.echo.Echo".equals(request.getPath()))
throw new RedirectPluginHTTPException("",
"/plugins/plugins.echo.Echo", "/plugins/plugins.echo.Echo/");
@@ -180,7 +180,7 @@
} else if ("renameCategory".equals(fileName) && !
"".equals(catId)) {
page = new Page();
- page.setTitle("Rename");
+ page.setTitle(i18n.getString("echo.common.rename"));
Element rename = new Element("rename");
Element category = new Element("category");
@@ -194,7 +194,7 @@
} else if ("del".equals(fileName) && (! "".equals(nodeId) || !
"".equals(catId))) {
page = new Page();
- page.setTitle("Delete");
+ page.setTitle(i18n.getString("echo.common.delete"));
Element object;
if(!"".equals(nodeId)) {
@@ -212,12 +212,16 @@
} else if ("write".equals(fileName) ||
"manage".equals(fileName)) {
- page = new Page(new Element(fileName));
+ page = new Page();
+ page.setTitle(i18n.getString("echo.action." +
fileName));
+ page.appendData(new Element(fileName));
+
} else if ("publish".equals(fileName)) {
Element pub = new Element("publish");
page = new Page(pub);
+ page.setTitle(i18n.getString("echo.action.publish"));
try {
Test test = new Test();
@@ -363,6 +367,7 @@
private void setCategoriesPage() {
page = new Page(new Element("categories"));
+ page.setTitle(i18n.getString("echo.common.categories"));
page.appendData(getFormPassword());
}
Modified: trunk/plugins/Echo/src/plugins/echo/Node.java
===================================================================
--- trunk/plugins/Echo/src/plugins/echo/Node.java 2007-07-27 12:47:46 UTC
(rev 14375)
+++ trunk/plugins/Echo/src/plugins/echo/Node.java 2007-07-27 13:26:14 UTC
(rev 14376)
@@ -3,6 +3,7 @@
import nu.xom.Document;
import nu.xom.Element;
import nu.xom.Attribute;
+import nu.xom.Text;
import nu.xom.Serializer;
import java.util.Date;
@@ -136,13 +137,13 @@
}
public String getBody() {
- return getContentElement().getValue();
+ return getContentElement().getValue().trim();
}
public void setBody(String str) {
Element content = getContentElement();
content.removeChildren();
- content.appendChild(str);
+ content.appendChild(new Text(str));
}
public String getId() {
Modified: trunk/plugins/Echo/src/plugins/echo/Page.java
===================================================================
--- trunk/plugins/Echo/src/plugins/echo/Page.java 2007-07-27 12:47:46 UTC
(rev 14375)
+++ trunk/plugins/Echo/src/plugins/echo/Page.java 2007-07-27 13:26:14 UTC
(rev 14376)
@@ -21,9 +21,7 @@
public Page(Element content) {
data = new nu.xom.Nodes();
errors = new Vector<String> ();
- this.setTitle(content.getLocalName()); // TODO : upperFirst ?
this.appendData(content);
-
}
public void setTitle(String title) {
Modified: trunk/plugins/Echo/src/plugins/echo/Test.java
===================================================================
--- trunk/plugins/Echo/src/plugins/echo/Test.java 2007-07-27 12:47:46 UTC
(rev 14375)
+++ trunk/plugins/Echo/src/plugins/echo/Test.java 2007-07-27 13:26:14 UTC
(rev 14376)
@@ -7,18 +7,20 @@
public class Test{
+ private static final File BASE_DIR = new
File("/home/fred/Freenet/plugins/Echo");
+
public void generate() throws Exception{
- File outDir = new File(Echo.BASE_DIR.getPath() +
File.separator + "out");
+ File outDir = new File(BASE_DIR.getAbsolutePath() +
File.separator + "out");
outDir.mkdirs();
- NodesManager nodesManager = new NodesManager(Echo.BASE_DIR);
+ NodesManager nodesManager = new NodesManager(BASE_DIR);
Builder parser = new Builder();
- Document styleSheet =
parser.build(getClass().getResourceAsStream("/xml/test.xsl"));
-// Document styleSheet =
parser.build("/home/fred/prog/soc/trunk/plugins/Echo/src/xml/test.xsl");
+// Document styleSheet =
parser.build(getClass().getResourceAsStream("/xml/test.xsl"));
+ Document styleSheet =
parser.build("/home/fred/prog/soc/trunk/plugins/Echo/src/xml/test.xsl");
XSLTransform transform = new XSLTransform(styleSheet);
- transform.setParameter("contextprefix",
Echo.BASE_DIR.getAbsolutePath() + "/");
+ transform.setParameter("basedir", BASE_DIR.getAbsolutePath() +
"/");
Serializer serializer = new Serializer(System.out);
serializer.setIndent(4);
Modified: trunk/plugins/Echo/src/plugins/echo/i18n/I18n.java
===================================================================
--- trunk/plugins/Echo/src/plugins/echo/i18n/I18n.java 2007-07-27 12:47:46 UTC
(rev 14375)
+++ trunk/plugins/Echo/src/plugins/echo/i18n/I18n.java 2007-07-27 13:26:14 UTC
(rev 14376)
@@ -76,6 +76,8 @@
if(str != null)
return str;
else {
+ Logger.normal("I18n", "The translation for " + key + "
hasn't been found (" + selectedLanguage + ")! please tell the maintainer.");
+
if(selectedLanguage.equals(DEFAULT_LANGUAGE))
return key;
Modified: trunk/plugins/Echo/src/xml/test.xsl
===================================================================
--- trunk/plugins/Echo/src/xml/test.xsl 2007-07-27 12:47:46 UTC (rev 14375)
+++ trunk/plugins/Echo/src/xml/test.xsl 2007-07-27 13:26:14 UTC (rev 14376)
@@ -12,17 +12,19 @@
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
indent="yes" />
- <xsl:param name="contextprefix" />
+ <xsl:param name="basedir" />
+ <xsl:variable name="blocksdir"><xsl:value-of select="$basedir"
/>/blocks/</xsl:variable>
+
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css"
media="screen" />
- <title>Blog - <xsl:call-template name="title"
/></title>
+ <title>Blog - <xsl:call-template
name="page-title" /></title>
</head>
<body>
<div id="container">
- <div id="header">My Flog</div>
+ <div id="header"><h1 id="blog-title">My
Flog</h1></div>
<div id="left">
<xsl:call-template name="blocks">
@@ -35,35 +37,35 @@
<xsl:call-template
name="content" />
</div>
- <!--<div id="right">
+ <div id="right">
<xsl:call-template name="blocks">
<xsl:with-param
name="align">right</xsl:with-param>
</xsl:call-template>
- </div>-->
+ </div>
<div id="footer">
<!-- <xsl:call-template name="blocks">
<xsl:with-param
name="align">bottom</xsl:with-param>
</xsl:call-template>
---> </div>
+--> Powered by Echo
+ </div>
</div>
</body>
</html>
</xsl:template>
<xsl:template name="blocks">
- No block
- <!-- <xsl:param name="align" />
+ <xsl:param name="align" />
- <xsl:for-each
select="document(concat($contextprefix,'blocks.xml'))//block[@align=$align]">
+ <xsl:for-each
select="document(concat($blocksdir,'blocks.xml'))//block[@align=$align]">
<xsl:sort order="ascending" select ="@order" />
- <xsl:apply-templates
select="document(concat($contextprefix, @id, '.xml'))/block" />
- </xsl:for-each>-->
+ <xsl:apply-templates
select="document(concat($blocksdir, @id, '.xml'))/block" />
+ </xsl:for-each>
</xsl:template>
<xsl:template match="block">
-<!-- <xsl:choose>
- <xsl:when test="@type='recent-posts'">
+ <xsl:choose>
+ <!--<xsl:when test="@type='recent-posts'">
<h3 class="block">Recent posts</h3>
<ul class="block,recent-posts">
<xsl:for-each
select="document('nodes.xml')//node">
@@ -71,17 +73,50 @@
</xsl:for-each>
</ul>
</xsl:when>
+-->
+ <xsl:when test="@type='categories'">
+ <h3 class="block">Categories</h3>
+ <ul class="block categories">
+ <xsl:for-each select="document(concat($basedir,
'categories.xml'))//category">
+ <li>
+ <a
href="category/{text()}.html"><xsl:value-of select="text()"/></a>
+ </li>
+ </xsl:for-each>
+ </ul>
+ </xsl:when>
+
+ <xsl:when test="@type='blogroll'">
+ <h3 class="block">Blogroll</h3>
+ <ul class="block blogroll">
+ <xsl:for-each select="blog">
+ <li>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:if test="@url">
+ <xsl:value-of
select="@url" />
+ </xsl:if>
+ <xsl:if test="@key">
+ <xsl:value-of
select="concat('/', @key)" />
+ </xsl:if>
+ </xsl:attribute>
+ <xsl:value-of select="text()" />
+ </a>
+ </li>
+ </xsl:for-each>
+ </ul>
+ </xsl:when>
+
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
- </xsl:choose>-->
+ </xsl:choose>
</xsl:template>
<xsl:template name="content">
<xsl:copy-of select="/node/content/node()" />
</xsl:template>
- <xsl:template name="title">
+ <xsl:template name="page-title">
<xsl:value-of select="/node/title/text()" />
</xsl:template>
</xsl:stylesheet>