Author: fred
Date: 2007-07-08 17:46:47 +0000 (Sun, 08 Jul 2007)
New Revision: 13995
Added:
trunk/plugins/Echo/build.xml
trunk/plugins/Echo/images/
trunk/plugins/Echo/images/echo-logo-small-0.1.png
trunk/plugins/Echo/src/
trunk/plugins/Echo/src/Echo.java
trunk/plugins/Echo/src/Node.java
trunk/plugins/Echo/src/NodesManager.java
trunk/plugins/Echo/src/Page.java
trunk/plugins/Echo/src/Test.java
trunk/plugins/Echo/src/TextRender.java
trunk/plugins/Echo/src/resources/
trunk/plugins/Echo/src/resources/edit.css
trunk/plugins/Echo/src/test/
trunk/plugins/Echo/src/test/0001.xml
trunk/plugins/Echo/src/test/0002.xml
trunk/plugins/Echo/src/test/0003.xml
trunk/plugins/Echo/src/test/blocks.xml
trunk/plugins/Echo/src/test/menu.001.xml
trunk/plugins/Echo/src/test/menu.002.xml
trunk/plugins/Echo/src/test/recent-posts.001.xml
trunk/plugins/Echo/src/test/style.css
trunk/plugins/Echo/src/xml/
trunk/plugins/Echo/src/xml/edit.xsl
trunk/plugins/Echo/src/xml/test.xsl
Log:
Putting initial directory structure
Added: trunk/plugins/Echo/build.xml
===================================================================
--- trunk/plugins/Echo/build.xml (rev 0)
+++ trunk/plugins/Echo/build.xml 2007-07-08 17:46:47 UTC (rev 13995)
@@ -0,0 +1,71 @@
+<?xml version="1.0"?>
+
+<project name="Echo" default="dist">
+
+ <property name="src.dir" location="src/" />
+ <property name="images.dir" location="images/" />
+ <property name="lib.dir" location="lib/" />
+ <property name="build.dir" location="build/" />
+ <property name="dist.dir" location="dist/" />
+ <property name="freenet-cvs-snapshot.location"
location="/home/svn-build/freenet-alpha.jar" />
+
+ <property name="xom.location" value="${lib.dir}/xom-1.2b2.jar" />
+ <available file="${xom.location}" property="xom_available" />
+ <fail unless="xom_available" status="1"
+ message="You need to download xom-1.2b2.jar from
http://www.xom.nu/unstable.html and to put it in lib/" />
+
+ <property name="radeox.location" value="${lib.dir}/radeox.jar" />
+ <available file="${radeox.location}" property="radeox_available" />
+ <fail unless="radeox_available" status="1"
+ message="You need to download radeox.jar from
http://fred.rec.free.fr/lib/ and to put it in lib/" />
+
+ <property name="commons-logging.location"
value="${lib.dir}/commons-logging.jar" />
+ <available file="${commons-logging.location}"
property="commons-logging_available" />
+ <fail unless="commons-logging_available" status="1"
+ message="You need to download commons-logging.jar from
http://fred.rec.free.fr/lib/ and to put it in lib/" />
+
+ <target name="init">
+ <tstamp/>
+ <mkdir dir="${build.dir}"/>
+ <mkdir dir="${build.dir}/xml" />
+ <mkdir dir="${dist.dir}"/>
+ </target>
+
+
+ <target name="compile" depends="init">
+
+ <javac srcdir="${src.dir}" destdir="${build.dir}" debug="true"
optimize="true">
+ <classpath>
+ <pathelement
location="${freenet-cvs-snapshot.location}"/>
+ <fileset dir="${lib.dir}">
+ <include name="**/*.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+
+ <copy todir="${build.dir}/xml/">
+ <fileset dir="${src.dir}/xml/" />
+ </copy>
+ <copy todir="${build.dir}">
+ <fileset dir="${src.dir}/resources/" />
+ <fileset dir="${images.dir}" />
+ </copy>
+ </target>
+
+ <target name="dist" depends="compile" description="generate the
distribution" >
+ <jar jarfile="${dist.dir}/Echo.jar" basedir="${build.dir}">
+ <manifest>
+ <attribute name="Plugin-Main-Class"
value="plugins.echo.Echo"/>
+ </manifest>
+
+ <ZipFileSet src="${xom.location}"/>
+ <ZipFileSet src="${radeox.location}"/>
+ <ZipFileSet src="${commons-logging.location}"/>
+ </jar>
+ </target>
+
+ <target name="clean" description="clean up">
+ <delete dir="${build.dir}"/>
+ <delete dir="${dist.dir}"/>
+ </target>
+</project>
Added: trunk/plugins/Echo/images/echo-logo-small-0.1.png
===================================================================
(Binary files differ)
Property changes on: trunk/plugins/Echo/images/echo-logo-small-0.1.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/plugins/Echo/src/Echo.java
===================================================================
--- trunk/plugins/Echo/src/Echo.java (rev 0)
+++ trunk/plugins/Echo/src/Echo.java 2007-07-08 17:46:47 UTC (rev 13995)
@@ -0,0 +1,268 @@
+package plugins.echo;
+
+import freenet.pluginmanager.FredPlugin;
+import freenet.pluginmanager.FredPluginHTTP;
+import freenet.pluginmanager.FredPluginHTTPAdvanced;
+import freenet.pluginmanager.FredPluginThreadless;
+import freenet.pluginmanager.PluginRespirator;
+import freenet.pluginmanager.PluginHTTPException;
+
+import freenet.pluginmanager.DownloadPluginHTTPException;
+
+import freenet.support.api.HTTPRequest;
+import freenet.support.HTMLNode;
+
+import nu.xom.Builder;
+import nu.xom.Document;
+import nu.xom.Element;
+import nu.xom.Attribute;
+import nu.xom.Serializer;
+import nu.xom.xslt.XSLTransform;
+
+import nu.xom.ParsingException;
+import nu.xom.xslt.XSLException;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.ByteArrayOutputStream;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+// TODO
+// * Exceptions !
+
+
+public class Echo implements FredPlugin, FredPluginHTTP,
FredPluginHTTPAdvanced, FredPluginThreadless {
+
+ private static final int MAX_TITLE_LENGTH = 200;
+ private static final int MAX_BODY_LENGTH = 100000;
+ private static final int MAX_ID_LENGTH = 4;
+
+ private static final String PATH_PREFIX = "plugins/Echo/";
+ private static final File NODES_DIR = new File(PATH_PREFIX + "nodes");
+
+ private PluginRespirator respirator;
+ private Builder parser;
+ private XSLTransform transform;
+ private Page page;
+ private NodesManager nodesManager;
+ private Node node;
+
+ public Echo() throws PluginHTTPException
+ {
+ try {
+ // suxx
+ NODES_DIR.mkdirs();
+
+ parser = new Builder();
+ Document styleSheet =
parser.build(getClass().getResourceAsStream("/xml/edit.xsl"));
+// Document styleSheet =
parser.build("/home/fred/prog/soc/trunk/plugins/Echo/src/xml/edit.xsl");
+ transform = new XSLTransform(styleSheet);
+ transform.setParameter("contextprefix",
NODES_DIR.getAbsolutePath() + "/");
+
+ nodesManager = new NodesManager(NODES_DIR);
+
+ } catch (IOException ioe) {
//
+ throw new PluginHTTPException("Cannot open the style
sheet", ""); //
+ } catch (ParsingException pe) {
// Useless ?
+ throw new PluginHTTPException("Cannot parse the style
sheet", ""); //
+ } catch (XSLException xe) {
//
+ throw new PluginHTTPException("Cannot build the XSL
transformer", ""); //
+ }
+
+ }
+
+ public void runPlugin(PluginRespirator p) {
+ this.respirator = p;
+ }
+
+ public void terminate() {
+ // TODO
+ // Bleh
+ }
+
+ private String transform(Page page) {
+ try {
+ ByteArrayOutputStream baos = new
ByteArrayOutputStream();
+ Serializer serializer = new Serializer(baos);
+ serializer.setIndent(4);
+ serializer.setMaxLength(128);
+ serializer.write(new Document((Element)
transform.transform(page.getDoc()).get(0)));
+
+ return baos.toString();
+ } catch (Exception e) {
+ return e.getMessage();
+ }
+ }
+
+ public String handleHTTPGet(HTTPRequest request) throws
PluginHTTPException {
+
+ String fileName = (new File(request.getPath())).getName();
+ String nodeId = request.getParam("node");
+
+ if ("edit.css".equals(fileName) ||
"echo-logo-small-0.1.png".equals(fileName)) {
+
+ try {
+ InputStream in =
getClass().getResourceAsStream("/" + fileName);
+// InputStream in = new
FileInputStream("/home/fred/prog/soc/trunk/plugins/Echo/src/test/" + fileName);
+
+ int read;
+ int off = 0;
+ byte[] buffer = new byte[in.available()];
+ while((read = in.read(buffer, off,
in.available())) != 0) {
+ off+=read;
+ }
+
+ throw new DownloadPluginHTTPException(buffer,
fileName, ("edit.css".equals(fileName)) ? "text/css" : "image/png");
+ } catch (IOException ioe) {
+ return ioe.getMessage();
+ }
+
+ } else if ("new".equals(fileName) || ("edit".equals(fileName)
&& ! "".equals(nodeId))) {
+
+ page = new Page();
+
+ Element formPassword = new Element("formpassword");
+ formPassword.addAttribute(new Attribute("value",
respirator.getNode().clientCore.formPassword));
+ page.appendData(formPassword);
+
+ if("edit".equals(fileName)) {
+
+ page.setTitle("Edit");
+ try {
+
+ node = nodesManager.getNodeById(nodeId);
+ page.appendData(node.getRoot());
+
+ } catch (NullPointerException npe) {
+ page.appendError("The node " + nodeId +
"does not exist");
+ } catch (IOException ioe) {
+ page.appendError(ioe.getMessage());
+ } catch (ParsingException pe) {
+ page.appendError("The node " + nodeId
+ " is damaged : " + pe.getMessage());
+ }
+
+ } else {
+ page.setTitle("New node");
+ node = nodesManager.newNode();
+ page.appendData(node.getRoot());
+ }
+
+ } else if ("del".equals(fileName) && ! "".equals(nodeId)) {
+
+ page = new Page();
+ page.setTitle("Delete");
+
+ Element del = new Element("delete");
+ del.addAttribute(new Attribute("id", nodeId));
+ page.appendData(del);
+
+ Element formPassword = new Element("formpassword");
+ formPassword.addAttribute(new Attribute("value",
respirator.getNode().clientCore.formPassword));
+ page.appendData(formPassword);
+ } else if ("generate".equals(fileName)) {
+
+ page = new Page();
+ page.setTitle("Generated");
+
+ try {
+ Test test = new Test();
+ test.generate();
+
+ Element gen = new Element("generated");
+ gen.addAttribute(new Attribute("outputdir",(new
File(PATH_PREFIX + "out/")).getAbsolutePath() + "/"));
+ page.appendData(gen);
+
+ } catch (Exception e) {
+ page.appendError(e.getMessage());
+ }
+
+ } else {
+ setDefaultPage();
+ }
+
+ return transform(page);
+
+ }
+
+ public String handleHTTPPut(HTTPRequest request) throws
PluginHTTPException {
+ return "Put";
+ }
+
+ public String handleHTTPPost(HTTPRequest request) throws
PluginHTTPException {
+ try {
+ String passwd = request.getPartAsString("formPassword",
32);
+ if((passwd == null) ||
!passwd.equals(respirator.getNode().clientCore.formPassword))
+ return "Wrong Password !!";
+
+ page = new Page();
+
+ if(request.isPartSet("confirmdelete") ||
request.isPartSet("cancel")) {
+ try {
+ if(request.isPartSet("confirmdelete"))
+
nodesManager.deleteNode(request.getPartAsString("node-id", MAX_ID_LENGTH));
+
+ } catch (NullPointerException npe) {
+ // Va foutre
+ }
+
+ setDefaultPage();
+
+ } else {
+
+ String title = request.getPartAsString("title",
MAX_TITLE_LENGTH).trim();
+ String body = request.getPartAsString("body",
MAX_BODY_LENGTH).trim();
+
+ if("".equals(title))
+ page.appendError("Field \"title\" is
empty");
+
+ if("".equals(body))
+ page.appendError("Field \"body\" is
empty");
+
+ node.setTitle(title);
+ node.setBody(body);
+
+ if(page.countErrors() == 0) {
+ page = new Page();
+ page.setTitle("My nodes");
+
+ try {
+
+ nodesManager.writeNode(node);
+
page.appendData(nodesManager.getXMLNodesList());
+
+ } catch (FileNotFoundException fnfe) {
+ page.appendError("fnfe" +
fnfe.getMessage());
+ } catch (IOException ioe) {
+ page.appendError("Cannot write
node " + node.getId() + " : " + ioe.getMessage());
+ } catch (Exception e) {
+
page.appendError(e.getMessage());
+ }
+ } else {
+
+ page.setTitle("Edit");
+
+ Element formPassword = new
Element("formpassword");
+ formPassword.addAttribute(new
Attribute("value", respirator.getNode().clientCore.formPassword));
+ page.appendData(formPassword);
+ page.appendData(node.getRoot());
+ }
+ }
+ } catch (Exception e) {
+ return e.getMessage();
+ }
+
+ return transform(page);
+
+ }
+
+
+ private void setDefaultPage() {
+ page = new Page();
+ page.setTitle("My nodes");
+ page.appendData(nodesManager.getXMLNodesList());
+ }
+
+}
\ No newline at end of file
Added: trunk/plugins/Echo/src/Node.java
===================================================================
--- trunk/plugins/Echo/src/Node.java (rev 0)
+++ trunk/plugins/Echo/src/Node.java 2007-07-08 17:46:47 UTC (rev 13995)
@@ -0,0 +1,104 @@
+package plugins.echo;
+
+import nu.xom.Document;
+import nu.xom.Element;
+import nu.xom.Attribute;
+import nu.xom.Serializer;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
+public class Node {
+
+ private String id;
+ private Document doc = null;
+ private Element nodeElement = null;
+ private Element titleElement = null;
+ private Element contentElement = null;
+
+ public Node (String nodeId) {
+
+ this.id = nodeId;
+
+ nodeElement = new Element("node");
+ nodeElement.addAttribute(new Attribute("id", id));
+
+ titleElement = new Element("title");
+ nodeElement.appendChild(titleElement);
+
+ contentElement = new Element("content");
+ nodeElement.appendChild(contentElement);
+
+ doc = new Document(nodeElement);
+
+ }
+
+ protected Node (Document document) {
+
+ this.doc = document;
+
+ }
+
+ private Element getTitleElement() {
+ if(titleElement == null)
+ titleElement = (Element)
doc.query("/node/title").get(0);
+
+ return titleElement;
+ }
+
+ public String getTitle() {
+
+ return getTitleElement().getValue();
+ }
+
+ public void setTitle(String str){
+ Element title = getTitleElement();
+ title.removeChildren();
+ title.appendChild(str);
+ }
+
+ private Element getContentElement() {
+ if(contentElement == null)
+ contentElement = (Element)
doc.query("/node/content").get(0);
+
+ return contentElement;
+ }
+
+ public String getBody() {
+ return getContentElement().getValue();
+ }
+
+ public void setBody(String str) {
+ Element content = getContentElement();
+ content.removeChildren();
+ content.appendChild(str);
+ }
+
+ public String getId() {
+ if(id == null)
+ id = ((Attribute)
doc.query("/node/@id").get(0)).getValue();
+ return id;
+ }
+
+ // FIXME: delete
+ public void write(OutputStream out) throws IOException{
+
+ Serializer serializer = new Serializer(out);
+ serializer.setIndent(4);
+ serializer.setMaxLength(128);
+
+ serializer.write(doc);
+ }
+
+ protected Document getDoc() {
+ return doc;
+ }
+
+ public Element getRoot() {
+
+ return (Element) getDoc().getRootElement().copy();
+
+ }
+
+}
Added: trunk/plugins/Echo/src/NodesManager.java
===================================================================
--- trunk/plugins/Echo/src/NodesManager.java (rev 0)
+++ trunk/plugins/Echo/src/NodesManager.java 2007-07-08 17:46:47 UTC (rev
13995)
@@ -0,0 +1,113 @@
+package plugins.echo;
+
+import nu.xom.Builder;
+import nu.xom.Element;
+import nu.xom.Attribute;
+import nu.xom.Serializer;
+import nu.xom.ParsingException;
+
+import java.util.HashMap;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.FileNotFoundException;
+
+
+public class NodesManager {
+
+ private File nodesDir;
+ private HashMap<String, File> nodes;
+ private Builder parser;
+
+ public NodesManager(File nodesDirectory) {
+
+ nodesDir = nodesDirectory;
+ nodes = new HashMap<String, File> ();
+ parser = new Builder();
+
+ File[] files = nodesDirectory.listFiles();
+ for(File f : files) {
+ if(f.getName().matches("[0-9]{4}.xml"))
+ nodes.put(f.getName().substring(0,4), f);
+ }
+ }
+
+ public Node getNodeById(String nodeId) throws IOException,
ParsingException {
+
+ File file = nodes.get(nodeId);
+ return new Node(parser.build(file));
+
+ }
+
+ // TODO
+ public Node newNode() {
+
+ String id = "";
+ for(int i=1; i < 10000; i++) {
+ id = String.valueOf(i);
+ while(id.length() < 4)
+ id = "0" + id;
+
+ if(!nodes.containsKey(id))
+ break;
+ }
+
+ return new Node(id);
+
+ }
+
+
+ public boolean nodeExists(String nodeId) {
+
+ return nodes.containsKey(nodeId);
+
+ }
+
+ public void deleteNode(String nodeId) throws IOException {
+
+ File file = nodes.get(nodeId);
+ if(!file.delete()) {
+ throw new IOException(file.getPath() + " cannot be
deleted");
+ }
+
+ nodes.remove(nodeId);
+ }
+
+ public void writeNode(Node node) throws FileNotFoundException,
IOException{
+
+ File file;
+ String nodeId = node.getId();
+
+ if(!nodeExists(nodeId)) {
+ file = new File (nodesDir.getPath() + File.separator +
nodeId + ".xml");
+ nodes.put(nodeId, file);
+ } else {
+ file = nodes.get(nodeId);
+ }
+
+ Serializer serializer = new Serializer(new
FileOutputStream(file));
+ serializer.setIndent(4);
+ serializer.setMaxLength(128);
+ serializer.write(node.getDoc());
+
+ }
+
+ public String[] getIds() {
+
+ return nodes.keySet().toArray(new String[]{});
+
+ }
+
+ public Element getXMLNodesList() {
+
+ String[] ids = this.getIds();
+ Element nodesElement = new Element("nodes");
+
+ for(String id : ids) {
+ Element node = new Element("node");
+ node.addAttribute(new Attribute("id", id));
+ nodesElement.appendChild(node);
+ }
+ return nodesElement;
+ }
+}
Added: trunk/plugins/Echo/src/Page.java
===================================================================
--- trunk/plugins/Echo/src/Page.java (rev 0)
+++ trunk/plugins/Echo/src/Page.java 2007-07-08 17:46:47 UTC (rev 13995)
@@ -0,0 +1,68 @@
+package plugins.echo;
+
+import nu.xom.Document;
+import nu.xom.Node;
+import nu.xom.Nodes;
+import nu.xom.Element;
+
+import java.util.Vector;
+
+public class Page {
+
+ private String title = null;
+ private nu.xom.Nodes data;
+ private Vector<String> errors;
+
+ public Page() {
+ data = new nu.xom.Nodes();
+ errors = new Vector<String> ();
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public void setData(nu.xom.Nodes data) {
+ this.data = data;
+ }
+
+ public void appendData(nu.xom.Node data) {
+ this.data.append(data);
+ }
+
+ public void appendError(String desc) {
+ errors.add(desc);
+ }
+
+ public Document getDoc() {
+ Element page = new Element("page");
+
+ Element titleElement = new Element("title");
+ titleElement.appendChild(title);
+ page.appendChild(titleElement);
+
+ if(errors.size() != 0) {
+ Element errorsElement = new Element("errors");
+ for(String e : errors) {
+ Element error = new Element("error");
+ error.appendChild(e);
+ errorsElement.appendChild(error);
+ }
+
+ page.appendChild(errorsElement);
+ }
+
+ Element dataElement = new Element("data");
+ for(int i=0; i < data.size(); i++)
+ dataElement.appendChild(data.get(i));
+
+ page.appendChild(dataElement);
+
+ return new Document(page);
+
+ }
+
+ public int countErrors() {
+ return errors.size();
+ }
+}
Added: trunk/plugins/Echo/src/Test.java
===================================================================
--- trunk/plugins/Echo/src/Test.java (rev 0)
+++ trunk/plugins/Echo/src/Test.java 2007-07-08 17:46:47 UTC (rev 13995)
@@ -0,0 +1,60 @@
+package plugins.echo;
+
+import nu.xom.*;
+import nu.xom.xslt.*;
+
+import java.io.*;
+
+public class Test{
+
+ private static final String PATH_PREFIX = "plugins/Echo/";
+
+ public void generate() throws Exception{
+
+ File nodeDir = new File(PATH_PREFIX + "nodes" + File.separator);
+ File outDir = new File(PATH_PREFIX + "out" + File.separator);
+ outDir.mkdirs();
+
+ NodesManager nodesManager = new NodesManager(nodeDir);
+
+ 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");
+ XSLTransform transform = new XSLTransform(styleSheet);
+ transform.setParameter("contextprefix", (new
File(PATH_PREFIX)).getAbsolutePath() + "/");
+
+ Serializer serializer = new Serializer(System.out);
+ serializer.setIndent(4);
+ serializer.setMaxLength(128);
+
+ TextRender render = new TextRender();
+
+ String[] ids = nodesManager.getIds();
+ for(String id : ids) {
+
+ System.out.println(id);
+
+ Element root = nodesManager.getNodeById(id).getRoot();
+ Element content = (Element)
root.query("./content").get(0);
+ Text contentText = (Text) content.getChild(0);
+
+ Nodes result = render.render(contentText.toXML());
+
+ contentText.detach();
+ for (int i=0; i < result.size(); i++) {
+ content.appendChild(result.get(i));
+ }
+
+ Nodes t = transform.transform(new Document(root));
+ serializer.setOutputStream(new
FileOutputStream(outDir.getPath() + File.separator + id + ".html"));
+ serializer.write(new Document((Element) t.get(0)));
+
+ }
+
+
+ }
+// public static void main(String args[]){
+// Test test = new Test();
+// test.generate();
+// }
+}
\ No newline at end of file
Added: trunk/plugins/Echo/src/TextRender.java
===================================================================
--- trunk/plugins/Echo/src/TextRender.java (rev 0)
+++ trunk/plugins/Echo/src/TextRender.java 2007-07-08 17:46:47 UTC (rev
13995)
@@ -0,0 +1,43 @@
+package plugins.echo;
+
+import org.radeox.api.engine.context.RenderContext;
+import org.radeox.engine.context.BaseRenderContext;
+import org.radeox.api.engine.RenderEngine;
+import org.radeox.engine.BaseRenderEngine;
+
+import nu.xom.Builder;
+import nu.xom.Element;
+import nu.xom.Node;
+import nu.xom.Nodes;
+import nu.xom.ParsingException;
+
+import java.io.IOException;
+
+public class TextRender {
+
+ private RenderContext renderContext;
+ private RenderEngine engine;
+
+ public TextRender() {
+ renderContext = new BaseRenderContext();
+ engine = new BaseRenderEngine();
+ }
+
+ public Nodes render(String text) throws ParsingException, IOException {
+
+ String result = engine.render(text, renderContext);
+ Builder parser = new Builder();
+ // FIXME : bug ?
+ Element renderedContent = parser.build("<rendered>" + result +
"</rendered>", null).getRootElement();
+
+ Nodes nodes = new Nodes();
+ while (renderedContent.getChildCount() != 0) {
+ Node node = renderedContent.getChild(0);
+ node.detach();
+ nodes.append(node);
+ }
+
+ return nodes;
+ }
+
+}
\ No newline at end of file
Added: trunk/plugins/Echo/src/resources/edit.css
===================================================================
--- trunk/plugins/Echo/src/resources/edit.css (rev 0)
+++ trunk/plugins/Echo/src/resources/edit.css 2007-07-08 17:46:47 UTC (rev
13995)
@@ -0,0 +1,134 @@
+
+html {
+font-size : 75%;
+font-family : "Lucida sans unicode", Lucida, Tahoma, Arial, sans-serif;
+/* color : #808080; */
+color:black;
+margin : 0; padding : 0;
+}
+
+body {
+background-color : #777;
+margin : 0 auto; padding : 0;
+}
+
+h1 {font-size : 1.6em; color : orange;}
+
+h2 {
+ color : #E29A00;
+ font-size : 1.5em;
+ font-weight : normal;
+ margin : 0; padding : 3px 0 0 0;
+ margin-left:15px;
+ font-family : Georgia;
+ font-style : italic;
+}
+
+h3 {font-size : 1.1em; padding : 5px 0; margin : 0;}
+p {margin : 0; padding : 3px 0;}
+
+a {
+ color : #696969;
+ font-size:0.9em;
+ font-weight:bold;
+ text-decoration: none;
+}
+
+a:hover {
+/* color : #696969; */
+ text-decoration: underline;
+}
+
+hr {clear : both; visibility : hidden; margin : 0; padding : 0;}
+p {margin: 0 0 10px 30px;}
+
+
+
+#container {
+ width: 90%;
+ margin-top:20px;
+ margin-bottom:10px;
+ margin-left: auto;
+ margin-right: auto;
+ border: 1px solid black;
+ background-color:#fff;
+}
+
+#header {
+ font-size:45px;
+ font-weight:bold;
+ padding: 5px 5px 10px 5px;
+ background-color: #ddd;
+ color : #C3C3C3;
+ border-bottom: 1px dotted #bbb;
+}
+
+#main {
+ margin-left: 130px;
+ padding: 5px 15px 15px 15px;
+ border-left: 1px dotted gray;
+}
+
+#left {
+ float:left;
+ width: 130px;
+}
+
+/***** Menu *****/
+
+#left ul {
+ list-style-type: none;
+ padding: 0 0 0 10px;
+ font-weight: bold;
+
+
+}
+
+#left a {
+ color:#696969;
+ font-size : 1.1em;
+}
+
+/***** Forms *****/
+
+label {
+ display:block;
+ margin-bottom:0px;
+}
+
+input {
+ display:block;
+ margin-bottom:5px;
+}
+
+input.inline {
+ display:inline;
+}
+
+/***** Tables *****/
+
+th {
+ background-color:#ccc;
+}
+
+td {
+ background-color:#ddd;
+ padding: 2px 5px 2px 5px;
+}
+
+tr.alternate td {
+ background-color:#eee;
+}
+
+/***** Errors *****/
+
+div.edit-error {
+ color:black;
+ border:1px dotted red;
+ background-color:#ffcccc;
+ margin-bottom: 20px;
+}
+
+ul.edit-error {
+ list-style-type:square;
+}
Added: trunk/plugins/Echo/src/test/0001.xml
===================================================================
--- trunk/plugins/Echo/src/test/0001.xml (rev 0)
+++ trunk/plugins/Echo/src/test/0001.xml 2007-07-08 17:46:47 UTC (rev
13995)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<node id="0001">
+ <title>Title of the node #0001</title>
+ <created>date</created>
+ <modified>date</modified>
+ <categories>
+ <category id="001" />
+ <category id="003" />
+ </categories>
+ <content><![CDATA[1 Heading level 1
+ ~~text in italic~~
+
+ __bold__
+ ]]>
+ </content>
+</node>
\ No newline at end of file
Added: trunk/plugins/Echo/src/test/0002.xml
===================================================================
--- trunk/plugins/Echo/src/test/0002.xml (rev 0)
+++ trunk/plugins/Echo/src/test/0002.xml 2007-07-08 17:46:47 UTC (rev
13995)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<node id="0002">
+ <title>Title</title>
+ <created>date</created>
+ <modified>date</modified>
+ <categories>
+ <category id="002" />
+ </categories>
+ <content>
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Vivamus faucibus arcu vel massa. Maecenas in massa quis
+libero vulputate semper. Fusce egestas sodales ipsum. Cras libero. Phasellus
blandit dui at lacus. Nullam metus neque, pharetra
+porta, consectetuer et, ultrices quis, enim. Suspendisse ut lorem. Nullam
nisi. Class aptent taciti sociosqu ad litora torquent
+per conubia nostra, per inceptos hymenaeos. Fusce tristique. Cras dignissim
magna nec ante. Aenean nonummy, lorem at cursus
+varius, neque risus nonummy sapien, vel mattis tellus tortor quis purus.
Pellentesque eu dolor. Cras nunc neque, elementum id,
+lacinia eu, ultrices tincidunt, orci. Fusce eget ipsum vel massa placerat
scelerisque. Mauris metus nisi, mollis sit amet, sodales
+sit amet, malesuada quis, nulla. Maecenas laoreet.
+
+Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac
turpis egestas. Nunc sagittis, dui vestibulum
+dignissim accumsan, sem risus vulputate pede, rhoncus lobortis odio orci at
libero. Phasellus laoreet nisi at eros vestibulum
+ornare. Integer eget nunc non metus scelerisque faucibus. Etiam consectetuer
sapien at mauris. Pellentesque risus turpis, auctor
+sed, malesuada et, convallis non, est. Praesent pharetra ipsum non dolor.
Mauris non magna at ipsum suscipit feugiat. Aliquam arcu
+mauris, cursus non, sagittis sit amet, ornare ut, odio. Pellentesque habitant
morbi tristique senectus et netus et malesuada fames
+ac turpis egestas. Suspendisse pulvinar neque sed tellus semper tincidunt. Sed
eu mi. Integer auctor lacinia metus. Nunc nibh leo,
+nonummy ut, tempus sed, volutpat quis, lorem.
+
+Vivamus nec enim at enim molestie blandit. Phasellus aliquam, quam quis
dapibus gravida, ipsum tellus blandit ante, id dapibus
+lacus ante vitae turpis. Integer aliquet odio ac orci. Aenean nec est et massa
nonummy mollis. Vivamus pretium, augue at pretium
+dapibus, augue erat dignissim pede, tempor venenatis lectus magna quis leo.
Morbi venenatis tortor a purus. Quisque ullamcorper
+lorem eu ligula. Aliquam erat volutpat. Aliquam eros. Etiam gravida, libero a
cursus eleifend, nisi pede tempus lorem, vel rutrum
+est leo nec sem. Donec pede ipsum, faucibus non, vestibulum in, ornare
ultrices, lacus. Cras congue magna. Etiam ac mauris eu quam
+consectetuer congue. Integer euismod porttitor tellus. Cras consequat rutrum
ipsum.
+
+Integer sapien. Ut sem. Aenean ut tellus a mi auctor tempus. Etiam vel tellus
semper odio pretium mattis. Quisque adipiscing
+pulvinar orci. Nam in ligula volutpat urna elementum tristique. Fusce risus
nisl, ultrices et, commodo nec, pharetra a, tortor. Ut
+in elit. Mauris congue ante. Nam dapibus eros et tellus. Nulla vestibulum pede
vel lectus. Proin faucibus rutrum leo.
+
+Donec felis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices
posuere cubilia Curae; Nulla gravida, metus id
+rhoncus aliquet, libero enim eleifend velit, quis malesuada sapien turpis eu
nibh. Aliquam erat volutpat. Duis quam. Proin
+malesuada purus auctor elit. Quisque tristique commodo diam. Phasellus
imperdiet dolor non pede. Aenean sit amet enim. Vivamus eu
+nulla. Vivamus venenatis congue velit. Duis vel arcu. Suspendisse metus.
Integer vitae urna tempus purus ultricies hendrerit.
+ </content>
+</node>
\ No newline at end of file
Added: trunk/plugins/Echo/src/test/0003.xml
===================================================================
--- trunk/plugins/Echo/src/test/0003.xml (rev 0)
+++ trunk/plugins/Echo/src/test/0003.xml 2007-07-08 17:46:47 UTC (rev
13995)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<node id="0003">
+ <title>Freenet</title>
+ <created>date</created>
+ <modified>date</modified>
+ <content>
+1 What is Freenet?
+
+Freenet is free software which lets you publish and obtain information on the
Internet without fear of censorship. To achieve this freedom, the network is
entirely decentralized and publishers and consumers of information are
anonymous. Without anonymity there can never be true freedom of speech, and
without decentralization the network will be vulnerable to attack.
+
+Communications by Freenet nodes are encrypted and are "routed-through" other
nodes to make it extremely difficult to determine who is requesting the
information and what its content is.
+
+Users contribute to the network by giving bandwidth and a portion of their
hard drive (called the "data store") for storing files. Unlike other
peer-to-peer file sharing networks, Freenet does not let the user control what
is stored in the data store. Instead, files are kept or deleted depending on
how popular they are, with the least popular being discarded to make way for
newer or more popular content. Files in the data store are encrypted to reduce
the likelihood of prosecution by persons wishing to censor Freenet content.
+
+The network can be used in a number of different ways and isn't restricted to
just sharing files like other peer-to-peer networks. It acts more like an
Internet within an Internet. For example Freenet can be used for:
+
+ * Publishing websites or 'freesites'
+ * Communicating via message boards
+ * Content distribution
+ * Sending email messages
+ </content>
+</node>
\ No newline at end of file
Added: trunk/plugins/Echo/src/test/blocks.xml
===================================================================
--- trunk/plugins/Echo/src/test/blocks.xml (rev 0)
+++ trunk/plugins/Echo/src/test/blocks.xml 2007-07-08 17:46:47 UTC (rev
13995)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<blocks>
+ <block id="menu.002" align="left" order="2" />
+ <block id="menu.001" align="left" order="1" />
+ <block id="recent-posts.001" align="right" order="1" />
+</blocks>
+
Added: trunk/plugins/Echo/src/test/menu.001.xml
===================================================================
--- trunk/plugins/Echo/src/test/menu.001.xml (rev 0)
+++ trunk/plugins/Echo/src/test/menu.001.xml 2007-07-08 17:46:47 UTC (rev
13995)
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<block id="menu.001" type="menu">
+ menu
+</block>
Added: trunk/plugins/Echo/src/test/menu.002.xml
===================================================================
--- trunk/plugins/Echo/src/test/menu.002.xml (rev 0)
+++ trunk/plugins/Echo/src/test/menu.002.xml 2007-07-08 17:46:47 UTC (rev
13995)
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<block id="menu.002" type="menu">
+ menu 2
+</block>
Added: trunk/plugins/Echo/src/test/recent-posts.001.xml
===================================================================
--- trunk/plugins/Echo/src/test/recent-posts.001.xml
(rev 0)
+++ trunk/plugins/Echo/src/test/recent-posts.001.xml 2007-07-08 17:46:47 UTC
(rev 13995)
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<block id="recent-posts.001" type="recent-posts">
+ <param name="max-number">5</param>
+</block>
\ No newline at end of file
Added: trunk/plugins/Echo/src/test/style.css
===================================================================
--- trunk/plugins/Echo/src/test/style.css (rev 0)
+++ trunk/plugins/Echo/src/test/style.css 2007-07-08 17:46:47 UTC (rev
13995)
@@ -0,0 +1,62 @@
+
+html {
+font-size : 75%;
+font-family : "Lucida sans unicode", Lucida, Tahoma, Arial, sans-serif;
+color : #808080;
+margin : 0; padding : 0;
+}
+
+body {
+background-color : #eee;
+margin : 0 auto; padding : 0;
+}
+
+h1 {font-size : 1.6em;}
+h2 {
+color : #E29A00;
+font-size : 1.5em;
+font-weight : normal;
+margin : 0; padding : 3px 0 0 0;
+margin-left:15px;
+font-family : Georgia;
+font-style : italic;
+}
+
+h3 {font-size : 1.1em; padding : 5px 0; margin : 0;}
+p {margin : 0; padding : 3px 0;}
+a {color : #696969;}
+a:hover {color : #E4C600;}
+hr {clear : both; visibility : hidden; margin : 0; padding : 0;}
+
+#header {
+font-size:45px;
+padding:20px;
+background-color: #777;
+color : #C3C3C3;
+}
+
+#container {
+margin-top:20px;
+width: 90%;
+margin-left: auto;
+margin-right: auto;
+border: 1px solid black;
+background-color:#fff;
+}
+
+#main {
+margin-left: 150px;
+padding-left: 10px;
+border-left: dotted 1px gray;
+}
+
+#left {
+width: 150px;
+}
+
+#footer {
+height: 30px;
+background-color: #99CC99;
+}
+
+p {margin: 0 0 10px 30px;}
Added: trunk/plugins/Echo/src/xml/edit.xsl
===================================================================
--- trunk/plugins/Echo/src/xml/edit.xsl (rev 0)
+++ trunk/plugins/Echo/src/xml/edit.xsl 2007-07-08 17:46:47 UTC (rev 13995)
@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+<xsl:output
+ method="xml"
+ encoding="ISO-8859-1"
+ media-type="text/html"
+ omit-xml-declaration="yes"
+ doctype-public= "-//W3C//DTD XHTML 1.0 Strict//EN"
+ doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
+ indent="yes" />
+
+ <xsl:preserve-space elements="content" />
+
+ <xsl:param name="contextprefix" />
+
+ <xsl:template match="/page">
+ <html>
+ <head>
+ <link rel="stylesheet" href="./edit.css"
type="text/css" media="screen" />
+ <title>Echo - Editor</title>
+ </head>
+ <body>
+ <div id="container">
+ <div id="header">
+ <img
src="./echo-logo-small-0.1.png" />
+ </div>
+
+ <div id="left">
+ <ul id="menu">
+ <li><a
href="./nodes">My nodes</a></li>
+ <li><a href="./new">New
node</a></li>
+ <li><a
href="./generate">Generate</a></li>
+ </ul>
+ </div>
+
+ <div id="main">
+ <h1><xsl:value-of
select="title/text()" /></h1>
+ <xsl:apply-templates
select="errors" />
+ <xsl:apply-templates
select="data" />
+<!-- <div><xsl:copy-of
select="/node()" /></div> -->
+
+ </div>
+ </div>
+ </body>
+ </html>
+ </xsl:template>
+
+ <xsl:template match="data">
+ <!-- otherwise nodes list ? (document(..)) -->
+ <xsl:choose>
+ <xsl:when test="./nodes">
+ <xsl:choose>
+ <xsl:when test="count(./nodes/node) > 0">
+ <table>
+ <tr>
+ <th>Id</th>
+ <th>Title</th>
+ <th colspan="2">Action</th>
+ </tr>
+ <xsl:for-each select="nodes/node">
+ <xsl:sort select="@id" />
+ <tr>
+ <xsl:if test="(position() mod 2) = 0">
+ <xsl:attribute
name="class">alternate</xsl:attribute>
+ </xsl:if>
+
+ <td><xsl:value-of select="@id" /></td>
+ <td>
+ <xsl:value-of
select="document(concat($contextprefix, @id, '.xml'))/node/title/text()" />
+ </td>
+ <td><a
href="./edit?node={@id}">Edit</a></td>
+ <td><a
href="./del?node={@id}">Delete</a></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </xsl:when>
+ <xsl:otherwise>
+ You don't have any node, <a
href="./new">create a new one</a>.
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="./node">
+ <form name="edit" method="POST" action="">
+ <label for="edit-title">Title</label>
+ <input type="text" id="edit-title" name="title"
value="{node/title/text()}"/>
+ <label for="edit-body">Body</label>
+ <textarea id="edit-body" name="body" cols="60"
rows="20">
+ <xsl:choose>
+ <xsl:when
test="node/content/text()">
+ <xsl:text>
+ <xsl:value-of
select="node/content" />
+ </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text> </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </textarea>
+ <!--del ?--> <input type="hidden" name="node-id"
value="{node/@id}" />
+ <input type="hidden" name="formPassword"
value="{formpassword/@value}" />
+ <input type="submit" />
+ </form>
+ </xsl:when>
+ <xsl:when test="./delete">
+ Are you sure you want to delete the node <xsl:value-of
select="./delete/@id" /> ?
+ <form name="del" method="POST" action="">
+ <input type="hidden" name="node-id"
value="{delete/@id}" />
+ <input type="hidden" name="formPassword"
value="{formpassword/@value}" />
+ <input type="submit" name="confirmdelete"
value="Delete" class="inline" />
+ <input type="submit" name="cancel"
value="Cancel" class="inline" />
+ </form>
+ </xsl:when>
+ <xsl:when test="./generated">
+ <a href="file://{generated/@outputdir}">Output
dir</a>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="errors">
+ <div class="edit-error">
+<!-- <h3 class="edit-error">Error :</h3> -->
+ <xsl:choose>
+ <xsl:when test="1 = 1">
+ <ul class="edit-error">
+ <xsl:for-each select="error">
+ <li><xsl:value-of select="text()"
/></li>
+ </xsl:for-each>
+ </ul>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="error/text()" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </div>
+ </xsl:template>
+</xsl:stylesheet>
+
Added: trunk/plugins/Echo/src/xml/test.xsl
===================================================================
--- trunk/plugins/Echo/src/xml/test.xsl (rev 0)
+++ trunk/plugins/Echo/src/xml/test.xsl 2007-07-08 17:46:47 UTC (rev 13995)
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+<xsl:output
+ method="xml"
+ encoding="ISO-8859-1"
+ media-type="text/html"
+ omit-xml-declaration="yes"
+ doctype-public= "-//W3C//DTD XHTML 1.0 Strict//EN"
+ doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
+ indent="yes" />
+
+ <xsl:param name="contextprefix" />
+
+ <xsl:template match="/">
+ <html>
+ <head>
+ <link rel="stylesheet" href="style.css" type="text/css"
media="screen" />
+ <title>Blog - <xsl:call-template name="title"
/></title>
+ </head>
+ <body>
+ <div id="container">
+ <div id="header">My Flog</div>
+
+ <div id="left">
+ <xsl:call-template name="blocks">
+ <xsl:with-param
name="align">left</xsl:with-param>
+ </xsl:call-template>
+ </div>
+
+ <div id="main">
+ <h2><xsl:call-template
name="title" /></h2>
+ <xsl:call-template
name="content" />
+ </div>
+
+ <!--<div id="right">
+ <xsl:call-template name="blocks">
+ <xsl:with-param
name="align">right</xsl:with-param>
+ </xsl:call-template>
+ </div>-->
+
+ <div id="footer">
+<!-- <xsl:call-template name="blocks">
+ <xsl:with-param
name="align">bottom</xsl:with-param>
+ </xsl:call-template>
+--> </div>
+ </div>
+ </body>
+ </html>
+ </xsl:template>
+
+ <xsl:template name="blocks">
+ No block
+ <!-- <xsl:param name="align" />
+
+ <xsl:for-each
select="document(concat($contextprefix,'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:template>
+
+ <xsl:template match="block">
+<!-- <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">
+ <li><a
href="{@id}.html"><xsl:value-of select="document(concat(@id,
'.xml'))//title/text()" /></a></li>
+ </xsl:for-each>
+ </ul>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="." />
+ </xsl:otherwise>
+ </xsl:choose>-->
+ </xsl:template>
+
+ <xsl:template name="content">
+ <xsl:copy-of select="/node/content/node()" />
+ </xsl:template>
+
+ <xsl:template name="title">
+ <xsl:value-of select="/node/title/text()" />
+ </xsl:template>
+</xsl:stylesheet>