cziegeler 2004/02/12 01:32:00
Modified: src/blocks/portal/samples/profiles/copletbasedata portal.xml
Added: src/blocks/portal/samples/coplets/samples page2html.xsl
sitemap.xmap form-sample.js
src/blocks/portal/samples/coplets/html sitemap.xmap
cleanhtml.xsl
src/blocks/portal/samples/coplets/samples/screens
received.xml content.xml form.xml
Log:
New samples
Revision Changes Path
1.1
cocoon-2.1/src/blocks/portal/samples/coplets/samples/page2html.xsl
Index: page2html.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="page">
<html>
<head>
<title><xsl:value-of select="title"/></title>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="title">
<h2>
<xsl:apply-templates/>
</h2>
</xsl:template>
<xsl:template match="content">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="para">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="link">
<a href="[EMAIL PROTECTED]">
<xsl:apply-templates/>
</a>
</xsl:template>
<xsl:template match="@*|node()"
priority="-2"><xsl:copy><xsl:apply-templates
select="@*|node()"/></xsl:copy></xsl:template>
<xsl:template match="text()" priority="-1"><xsl:value-of
select="."/></xsl:template>
</xsl:stylesheet>
1.1
cocoon-2.1/src/blocks/portal/samples/coplets/samples/sitemap.xmap
Index: sitemap.xmap
===================================================================
<?xml version="1.0"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<!-- indicates what flowscript to attach to this sitemap -->
<map:flow language="javascript">
<map:script src="form-sample.js"/>
</map:flow>
<map:pipelines>
<map:pipeline>
<!--+
| produces the screens called by the flowscript
+-->
<map:match pattern="page/*">
<map:generate type="jx" src="screens/{1}.xml"/>
<map:transform src="page2html.xsl"/>
<map:serialize/>
</map:match>
</map:pipeline>
<map:pipeline>
<!--+
| matches the page with the continuation ID and calls the flowscript
| associated to this sitemap with the given continuation ID. The
flow
| engine will then look into the continuation store, retrieve
| the correct continuation and resume execution of the flowscript
| with that continuation. This guarantees transparent state
| resumption between requests without the need for anything else
| (cookies or URL-encoded session IDs)
+-->
<map:match pattern="continue.*">
<map:call continuation="{1}">
<map:parameter name="copletId" value="{request-param:copletid}"/>
</map:call>
</map:match>
<!--+
| matches the call to the beginning of the flow and calls the flow
| from its entry point which, in this case is the 'form()'
| javascript function.
+-->
<map:match pattern="form">
<map:call function="form">
<map:parameter name="copletId" value="{request-param:copletid}"/>
</map:call>
</map:match>
<map:match pattern="clearform">
<map:call function="clear">
<map:parameter name="copletId" value="{request-param:copletid}"/>
</map:call>
</map:match>
</map:pipeline>
</map:pipelines>
</map:sitemap>
1.1
cocoon-2.1/src/blocks/portal/samples/coplets/samples/form-sample.js
Index: form-sample.js
===================================================================
// This is a simple flow script
// that can be used as an example for building forms
//
// The script gets the coplet id as a parameter. This id can be used
// as a unique key for the coplet.
//
// The script below doesn't use any continuations. It just checks:
// - if the user already has given some input (which is stored in
// a session attribute)
// - if the user has just submitted some input
// - if a form should be displayed
// - The function clear() clears the user input
//
function form() {
// get the coplet id
var cid = cocoon.parameters["copletId"];
var pname = cid + "/myform";
if ( cocoon.session.getAttribute(pname) == null ) {
var name = cocoon.request.getParameter("name");
if ( name == null ) {
cocoon.sendPage("page/form", {});
} else {
cocoon.session.setAttribute(pname, name);
cocoon.sendPage("page/received", {"name" : name});
}
} else {
var name = cocoon.session.getAttribute(pname);
cocoon.sendPage("page/content", {"name" : name});
}
}
function clear() {
// get the coplet id
var cid = cocoon.parameters["copletId"];
var pname = cid + "/myform";
cocoon.session.removeAttribute(pname);
form();
}
1.1
cocoon-2.1/src/blocks/portal/samples/coplets/html/sitemap.xmap
Index: sitemap.xmap
===================================================================
<?xml version="1.0"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:pipelines>
<map:pipeline>
<map:match pattern="application">
<map:generate
src="{coplet:temporaryAttributes/application-uri}?copletid={coplet:#}"/>
<map:transform type="xslt" src="cleanhtml.xsl"/>
<map:transform type="portal-html-eventlink">
<map:parameter name="attribute-name" value="application-uri"/>
</map:transform>
<map:serialize type="xml"/>
</map:match>
<!--
<map:match pattern="live.html">
<map:generate type="html" src="{request-param:feed}"/>
<map:transform type="xslt" src="cleanhtml.xsl"/>
<map:serialize type="xml"/>
</map:match>
-->
</map:pipeline>
</map:pipelines>
</map:sitemap>
1.1
cocoon-2.1/src/blocks/portal/samples/coplets/html/cleanhtml.xsl
Index: cleanhtml.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--
This stylesheet simply removes the surrounding html and body tag
$Id: cleanhtml.xsl,v 1.1 2004/02/12 09:32:00 cziegeler Exp $
-->
<xsl:template match="/" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xsl:apply-templates select="xhtml:html/xhtml:body"/>
<xsl:apply-templates select="html/body"/>
</xsl:template>
<xsl:template match="xhtml:body" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<div>
<xsl:copy-of select="*"/>
</div>
</xsl:template>
<xsl:template match="body">
<div>
<xsl:copy-of select="*"/>
</div>
</xsl:template>
</xsl:stylesheet>
1.1
cocoon-2.1/src/blocks/portal/samples/coplets/samples/screens/received.xml
Index: received.xml
===================================================================
<?xml version="1.0"?>
<!--+
| CVS: $Id: received.xml,v 1.1 2004/02/12 09:32:00 cziegeler Exp $
| Author: Carsten Ziegeler ([EMAIL PROTECTED])
+-->
<page>
<title>Received</title>
<content>
<para>Thanks for your input.</para>
<para>Please continue <link href="form">here</link></para>
</content>
</page>
1.1
cocoon-2.1/src/blocks/portal/samples/coplets/samples/screens/content.xml
Index: content.xml
===================================================================
<?xml version="1.0"?>
<!--+
| CVS: $Id: content.xml,v 1.1 2004/02/12 09:32:00 cziegeler Exp $
| Author: Carsten Ziegeler ([EMAIL PROTECTED])
+-->
<page>
<title>Your current input</title>
<content>
<para>Hello <strong>#{name}</strong>!</para>
<para>If you want to reenter your name, click <link
href="clearform">here</link>.</para>
</content>
</page>
1.1
cocoon-2.1/src/blocks/portal/samples/coplets/samples/screens/form.xml
Index: form.xml
===================================================================
<?xml version="1.0"?>
<!--+
| CVS: $Id: form.xml,v 1.1 2004/02/12 09:32:00 cziegeler Exp $
| Author: Carsten Ziegeler ([EMAIL PROTECTED])
+-->
<page>
<title>Form</title>
<content>
<form method="post" action="form">
<para>Please enter your <strong>name</strong>: <input type="text"
name="name"/></para>
<input type="submit" name="submit" value="Enter"/>
</form>
</content>
</page>
1.5 +6 -0
cocoon-2.1/src/blocks/portal/samples/profiles/copletbasedata/portal.xml
Index: portal.xml
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/samples/profiles/copletbasedata/portal.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- portal.xml 22 Jan 2004 14:12:49 -0000 1.4
+++ portal.xml 12 Feb 2004 09:32:00 -0000 1.5
@@ -3,8 +3,14 @@
<coplet-base-data id="URICoplet">
<coplet-adapter>uri</coplet-adapter>
</coplet-base-data>
+ <coplet-base-data id="CachingURICoplet">
+ <coplet-adapter>caching-uri</coplet-adapter>
+ </coplet-base-data>
<coplet-base-data id="Portlet">
<coplet-adapter>portlet</coplet-adapter>
+ </coplet-base-data>
+ <coplet-base-data id="Application">
+ <coplet-adapter>application</coplet-adapter>
</coplet-base-data>
</coplets>