Creating a Resource Type with Apache Lenya 2.0
Upcoming SlideShare
Loading in...5
×
 

Creating a Resource Type with Apache Lenya 2.0

on

  • 3,048 views

 

Statistics

Views

Total Views
3,048
Views on SlideShare
3,038
Embed Views
10

Actions

Likes
0
Downloads
37
Comments
0

1 Embed 10

http://www.slideshare.net 10

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Creating a Resource Type with Apache Lenya 2.0 Creating a Resource Type with Apache Lenya 2.0 Presentation Transcript

  • Creating
a Resource
Type 
Andreas
Hartmann BeCompany
GmbH 1
  • Agenda Declaring
the
Resource
Type Creating
Documents Presentation
(Pipelines,
XSLT) Editing
with
the
One-Form
Editor Editing
with
the
BXE
Editor 2
  • Resource
Type
„Person“ • FOAF:
Friend
of
a
Friend
(www.foaf-project.org) • Machine-readable
information
about
people (Semantic
Web) • Based
on
RDF
schema • Analyzation
and
visualization
of
social
networks 3
  • Directory
Layout $HOME/ apache/ lenya-1.4/ $LENYA_HOME src/ lenya/ Lenya-related sources modules/ Modules person/ quot;personquot; resource type module 4
  • Module
Directory
Layout person/ config/ menu.xsp module.xml cocoon-xconf/ resourcetype-person.xconf resources/ icons/ person.gif samples/ foaf.xml xslt/ foaf2xhtml.xml menus.xmap 5
  • Module
Descriptor modules/person/config/module.xml <?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?> <module xmlns=quot;http://apache.org/lenya/module/1.0quot;> <id>org.yourproject.lenya.modules.person</id> <package>org.yourproject.lenya.modules</package> <version>0.1-dev</version> <name>person</name> <lenya-version>@lenya.version@</lenya-version> <description> Resource type to store person details </description> </module> 6
  • Declaring
the
Resource
Type modules/person/config/cocoon-xconf/resourcetype-person.xconf <xconf xpath=quot;/cocoon/resource-typesquot; unless=quot;/cocoon/resource-types/component-instance[@name = 'person']quot;> <component-instance name=quot;personquot; logger=quot;lenya.resourcetypesquot; class=quot;org.apache.lenya.cms.publication.ResourceTypeImplquot;> <schema language=quot;http://relaxng.org/ns/structure/0.9quot; src=quot;fallback://lenya/modules/person/resources/schemas/foaf.rngquot;/> <expires seconds=quot;3600quot; /> <sample-name>fallback://lenya/modules/person/samples/foaf.xml</sample-name> <format name=quot;xhtmlquot; uri=quot;cocoon://modules/person/xhtml.xmlquot;/> <format name=quot;xhtml-includequot; uri=quot;cocoon://modules/person/xhtml-include.xmlquot;/> <format name=quot;iconquot; uri=quot;cocoon://modules/person/iconquot;/> </component-instance> </xconf> 7
  • Register
Module
+
Resource
Type local.build.properties: modules.root.dirs=... publication.xml: <module name=quot;personquot;/> <resource-type name=quot;personquot; workflow=quot;...quot;/> 8
  • Menu
Sitemap modules/person/menus.xmap <map:sitemap xmlns:map=quot;http://apache.org/cocoon/sitemap/1.0quot;> <map:pipelines> <map:pipeline> <map:match pattern=quot;**quot;> <map:generate type=quot;serverpagesquot; src=quot;fallback://lenya/modules/person/config/menu.xspquot;/> <map:serialize type=quot;xmlquot;/> </map:match> </map:pipeline> </map:pipelines> </map:sitemap> 9
  • Menu
XSP modules/person/config/menu.xsp <xsp:page language=quot;javaquot; xmlns:xsp=... > <menu> <menus> <menu i18n:attr=quot;namequot; name=quot;Filequot;> <block areas=quot;site authoringquot;> <item uc:usecase=quot;sitemanagement.createquot; href=quot;?doctype=personquot;> <i18n:translate> <i18n:text>New ... Document</i18n:text> <i18n:param>Person</i18n:param> </i18n:translate> </item> </block> </menu> </menus> </menu> </xsp:page> 10
  • Providing
the
Sample modules/person/samples/foaf.xml <rdf:RDF xmlns:rdf=quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#quot; xmlns:foaf=quot;http://xmlns.com/foaf/0.1/quot;> <foaf:Person rdf:ID=quot;mequot;> <foaf:title>Mr</foaf:title> <foaf:givenname>Homer</foaf:givenname> <foaf:family_name>Simpson</foaf:family_name> <foaf:mbox rdf:resource=quot;mailto:chunkylover53@aol.comquot;/> <foaf:phone rdf:resource=quot;tel:555-555-555quot;/> <foaf:workplaceHomepage rdf:resource=quot;http://powerplantspringfield.comquot;/> </foaf:Person> </rdf:RDF> 11
  • Presentation
Pipeline modules/person/sitemap.xmap <!-- {format}.xml --> <map:match pattern=quot;*.xmlquot;> <map:generate src=quot;cocoon:/{1}.xml/{page-envelope:publication-id}/ {page-envelope:area}/{page-envelope:document-uuid}/ {page-envelope:document-language}quot;/> <map:serialize type=quot;xmlquot;/> </map:match> <!-- {format}.xml/{pubId}/{area}/{uuid}/{language} --> <map:match pattern=quot;*.xml/*/*/*/*quot;> <map:generate src=quot;lenya-document:{4},lang={5}{link:rev}quot;/> <map:transform src=quot;fallback://lenya/modules/person/xslt/foaf2xhtml.xslquot;/> <map:serialize type=quot;xmlquot;/> </map:match> 12
  • Presentation
XSLT
(1) modules/person/xslt/foaf2xhtml.xsl <xsl:template match=quot;rdf:RDFquot;> <html> <body> <div id=quot;bodyquot;> <xsl:apply-templates select=quot;foaf:Personquot;/> </div> </body> </html> </xsl:template> 13
  • Presentation
XSLT
(2) modules/person/xslt/foaf2xhtml.xsl <xsl:template match=quot;foaf:Personquot;> <h2>Person Details</h2> <table class=quot;personquot;> <tr> <th>Title:</th> <td><xsl:value-of select=quot;foaf:titlequot;/></td> </tr> ... <tr> <th>E-Mail:</th> <td> <xsl:variable name=quot;mboxquot; select=quot;foaf:mbox/@rdf:resourcequot;/> <a href=quot;{$mbox}quot;> <xsl:value-of select=quot;substring-after($mbox, 'mailto:')quot;/> </a> </td> </tr> ... 14
  • CSS pubs/default/resources/shared/css/person.css table.person { font-size: small; } table.person th { font-weight: normal; color: #999999; text-align: left; padding-right: 1em; } 15
  • Presentation 16
  • Relax
NG
Schema <grammar xmlns=quot;http://relaxng.org/ns/structure/1.0quot; ...> <start> <element name=quot;rdf:RDFquot;> <element name=quot;foaf:Personquot;> <attribute name=quot;rdf:IDquot;><data type=quot;NCNamequot;/></attribute> <element name=quot;foaf:titlequot;><text/></element> <element name=quot;foaf:givennamequot;><text/></element> <element name=quot;foaf:family_namequot;><text/></element> <element name=quot;foaf:mboxquot;> <attribute name=quot;rdf:resourcequot;><data type=quot;anyURIquot;/></attribute> </element> <element name=quot;foaf:phonequot;> <attribute name=quot;rdf:resourcequot;><data type=quot;NMTOKENquot;/></attribute> </element> <element name=quot;foaf:workplaceHomepagequot;> <attribute name=quot;rdf:resourcequot;><data type=quot;anyURIquot;/></attribute> </element> </element> </element> </start> </grammar> 17
  • One-Form
Editor
Menu
Item <menu i18n:attr=quot;namequot; name=quot;Editquot;> <xsp:logic> try { Object doc = <input:get-attribute module=quot;page-envelopequot; as=quot;objectquot; name=quot;documentquot;/>; if (doc instanceof Document &amp;&amp; ((Document) doc).exists()) { String doctype = <input:get-attribute module=quot;page-envelopequot; as=quot;stringquot; name=quot;document-typequot;/>; if (quot;personquot;.equals(doctype)) { <block areas=quot;authoringquot;> <item uc:usecase=quot;editors.oneformquot; href=quot;?quot;> <i18n:text>With one Form</i18n:text> </item> </block> } } } catch (Exception e) { throw new ProcessingException(quot;Error during menu generation: quot;, e); } </xsp:logic> </menu> 18
  • BXE
Menu
Item <block areas=quot;authoringquot;> <item uc:usecase=quot;bxe.editquot; href=quot;?quot;> <i18n:text>With BXE</i18n:text> </item> <item uc:usecase=quot;editors.oneformquot; href=quot;?quot;> <i18n:text>With one Form</i18n:text> </item> </block> 19
  • webdavGET
Format modules/person/config/cocoon-xconf/resourcetype-person.xconf <format name=quot;webdavGETquot; uri=quot;cocoon://modules/person/davget.xmlquot;/> modules/person/sitemap.xmap <map:match pattern=quot;davget.xmlquot;> <map:act type=quot;set-headerquot;> <map:parameter name=quot;Last-Modifiedquot; value=quot;{date-iso8601-rfc822: {page-envelope:document-lastmodified}}quot; /> <map:generate src=quot;lenya-document:{page-envelope:document-uuid}quot;/> <map:transform type=quot;uuid2urlquot;> <map:parameter name=quot;urlsquot; value=quot;absolutequot;/> </map:transform> <map:serialize type=quot;xmlquot;/> </map:act> </map:match> 20
  • BXE
Attributes
in
XSLT modules/person/xslt/foaf2xhtml.xsl <xsl:template name=quot;bxeAttributequot;> <xsl:param name=quot;elementquot;/> <xsl:if test=quot;$rendertype = 'edit'quot;> <xsl:attribute name=quot;bxe_xpathquot;> /rdf:RDF/foaf:Person/foaf:<xsl:value-of select=quot;$elementquot;/> </xsl:attribute> </xsl:if> </xsl:template> <tr> <th>Title:</th> <td> <xsl:call-template name=quot;bxeAttributequot;> <xsl:with-param name=quot;elementquot;>title</xsl:with-param> </xsl:call-template> <xsl:value-of select=quot;foaf:titlequot;/> </td> </tr> 21
  • Editing
in
BXE 22
  • Next
Steps • Extend
schema • Form-based
editing • Add
content
fields
to
„Create“
screen • Image
upload
(portrait
photo
/
avatar) • Additional
presentation
pipelines • FOAF
XML
file • XSL-FO
for
PDF
business
card
generation • vCard
format
(.vcf) • ... 23