Web 2.0 with Cocoon 2 - The Apache Software...

64
Web 2.0 with Cocoon 2.2 ApacheCon EU 2007

Transcript of Web 2.0 with Cocoon 2 - The Apache Software...

Page 1: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

Web 2.0 with Cocoon 2.2ApacheCon EU 2007

Page 2: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

What isWeb 2.0?

Page 3: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

http://en.wikipedia.org/wiki/Image:Web20buzz.png

Page 4: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •
Page 5: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •
Page 6: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •
Page 7: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •
Page 8: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •
Page 9: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

What isCocoon?

Page 10: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •
Page 11: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •
Page 12: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

On Pipelines...

• Task: find the total number of unique hosts visiting the home page of your website

Page 13: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

On Pipelines...

Windows solution:#include <stdlib.h>...

Page 14: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

On Pipelines...

Windows solution:#include <stdlib.h>...

Unix solution:grep index.html access.log | awk ‘{print $2 }’ | sort | uniq | wc -l

Page 15: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

On Pipelines...

Pipelines: specialised components glued together

Page 16: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •
Page 17: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

Web 2.0 since 2001tm

Page 18: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

Cocoon 2.2..?

Page 19: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

maven 2

Page 20: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •
Page 21: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

Cocoon 2.2 Web 2.0

Page 22: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

A Web 2.0 application

• Use of other resources via REST

• Cocoon as a web service

• Rich client interface

Page 23: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

Building aCocoon 2.2application

Page 24: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

Cocoon archetypes

Page 25: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

archetype |ˈärk(i)ˌtīp| |ˌɑrk(ə)ˈtaɪp| |ˌɑːkɪtʌɪp|nouna very typical example of a certain person or thing : the book is a perfect archetype of the genre. See note at model .

Page 26: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

mvn archetype:create-DarchetypeGroupId=org.apache.cocoon-DarchetypeArtifactId=cocoon-22-archetype-block-DarchetypeVersion=1.0.0-RC1-SNAPSHOT-DgroupId=com.mycompany-DartifactId=myBlock1

Page 27: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

archetype video

Page 28: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

mvn cocoon:rcl

Page 29: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

cocoon:rcl video

Page 30: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

mvn jetty:run

Page 31: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

jetty:run video

Page 32: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •
Page 33: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

REST

Page 34: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

The REST example

• Use Flickr API to display content through Cocoon

• http://www.flickr.com/services/api/request.rest.html

• http://www.flickr.com/services/rest/?method=flickr.method.name&name=value

Page 35: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

<map:match pattern="flickr"> <map:generate src="......"/><map:serialize type="xml"/>

</map:match>

Page 36: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

<map:match pattern="flickr"> <map:generate src="......"/><map:serialize type="xml"/>

</map:match>

http://www.flickr.com/services/rest/?method=flickr.people.getPublicPhotos&api_key=1234&user_id=abcd

Page 37: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •
Page 38: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

Taking it further ...

<map:match pattern="flickr"> <map:generate src="......"/> <map:transform src="flickr2html.xsl"/><map:serialize type="html"/>

</map:match>

Page 39: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

<xsl:template match="/"> <html> <head> <link rel="stylesheet" href="styles/site.css" type="text/css" /> </head> <body> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="rsp"><xsl:apply-templates/></xsl:template> <xsl:template match="photos"> <h1><xsl:value-of select="@total"/> photos</h1> <table> <xsl:apply-templates/> </table> </xsl:template>

<xsl:template match="photo"> <tr> <td><img src="http://farm{@farm}.static.flickr.com/{@server}/{@id}_{@secret}_s.jpg"/></td> <td><xsl:value-of select="@title"/></td> </tr> </xsl:template>

Page 40: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •
Page 41: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

http://www.flickr.com/services/rest/?method=flickr.photos.geo.getLocation&api_key=1234&photo_id=5678

Adding location...

Page 42: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •
Page 43: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

Pipelines...

Unix solution:grep index.html access.log | awk ‘{print $2 }’ | sort | uniq | wc -l

Pipelines: specialised components glued together

Page 44: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •
Page 45: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

<xsl:template match="photo"> <xsl:copy><!--copy node being visited--> <xsl:copy-of select="@*"/><!--copy of all attributes--> <ci:include src="http://www.flickr.com/services/rest/?method=flickr.photos.geo.getLocation&#38;api_key=1234&#38;photo_id={@id}" select="rsp/photo/location" parse="xml"/> </xsl:copy> </xsl:template>

Page 46: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

<map:match pattern="flickr"> <map:generate src="......"/> <map:transform src="getLocation.xsl"/> <map:transform type="cinclude"/> <map:transform src="flickr2html.xsl"/><map:serialize type="html"/>

</map:match>

Page 47: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

And presenting it... <xsl:template match="photo"> <tr> <td><img src="http://farm{@farm}.static.flickr.com/{@server}/{@id}_{@secret}_s.jpg"/></td> <td><xsl:value-of select="@title"/></td> <xsl:if test="location"> <td> <xsl:apply-templates select="location"/> </td> </xsl:if> </tr> </xsl:template>

<xsl:template match="location"> <xsl:value-of select="locality"/><br/><xsl:value-of select="country"/> </xsl:template>

Page 48: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •
Page 49: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •
Page 50: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

Building pipelines<map:match pattern="flickr"> <map:generate src="......"/> <map:transform src="getLocation.xsl"/> <map:transform type="cinclude"/> <map:transform src="yahoomaps.xsl"/> <map:transform type="cinclude"/> <map:transform src="flickr2html.xsl"/><map:serialize type="html"/>

</map:match>

Page 51: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •
Page 52: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

http://cocoon.zones.apache.org/demos/release/samples/aggregation/

TMTOWTDI/tim toh' dee/, abbrev.

Page 53: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

Web Services

Page 54: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

What flavour?

• SOAP, WS-*, ...

• http://cocoon.zones.apache.org/demos/release/samples/blocks/axis/status.xsp

• http://ws.apache.org/

Page 55: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

The SOAP example

Page 56: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

<map:match pattern="news"> <map:generate src="......"/><map:transform src="photosearch.xsl"/><map:transform type="cinclude"/><map:transform src="photoinsert.xsl"/><map:serialize type="xml"/>

</map:match>

RSS serving example

Page 57: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

News/Flickr Mashup

Page 58: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

The Rich GUI

Page 59: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

Rich GUIs in Cocoon

• Power of CForms’ widget-based framework

• DOJO

Page 60: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

The GUI example

Page 61: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

pom.xml<dependency> <groupId>org.apache.cocoon</groupId> <artifactId>cocoon-forms-impl</artifactId> <version>1.0.0-RC1-SNAPSHOT</version></dependency>

<dependency> <groupId>org.apache.cocoon</groupId> <artifactId>cocoon-ajax-impl</artifactId> <version>1.0.0-RC1-SNAPSHOT</version></dependency>

Page 62: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

But there’s more...

• Authentication

• Blogs

• Microformats

• Semantic

Page 63: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

Thank you

Page 64: Web 2.0 with Cocoon 2 - The Apache Software Foundationpeople.apache.org/~asavory/apacheconeu2007/web2cocoon22.pdf · A Web 2.0 application • Use of other resources via REST •

Latest version

• http://people.apache.org/~asavory/