1. cq5 and Sling
overview
Bertrand Delacrétaz
Senior Developer, R&D, Day Software, www.day.com
Apache Software Foundation Member
http://grep.codeconsult.ch - twitter: @bdelacretaz - bdelacretaz@apache.org
Logica Geneva monthly developer meeting, February 2010
slides revision: 2010-02-25
CQ5 and Sling 1
overview Bertrand Delacrétaz
2. Basel, Switzerland headquarters
(~80 people, ~150 worldwide)
Munich “Day allows us to quickly
London
and reliably deliver content
to our entire McFamily, content-centric
helping us to be flexible and
drive new opportunities.” products
Newport
Beach, CA Steve Wilson, Senior
Director of Web
Toronto
Communications,
McDonald’s (everything is content)
www.day.com
Swiss open source
award / business / 2008
note the 3-letter domain name:
we’ve been doing this for a while...
Strong ties to the Apache Software Foundation
2001
2001
2009
Roy T. Fielding and David Nuescheler,
Survived tough times (SWX:DAYN) “Mr. REST” and “Mr. JCR”
3. What is cq5?
content management system
no database? No SQL? everything is content
fun to use
digital assets OSGi applications framework
JCR repository
Marketing dept. loves IT dept.?
CQ5 and Sling
overview
8. cq5: multivariate testing
User provides 3 (N) possible
banner designs (drag & drop)
cq5 provides statistics on
impressions and click-
through rates -> helps
selecting the best banner.
17. HTTP debugger filesystem browser
content administration UI
standard custom servlets WebDAV Sling OSGi
servlets and components server console
javascript
JSP
resource servlet/script JSR 223 Ruby
resolution resolution scripting Velocity
etc..
OSGi framework
(Apache Felix)
JSR-170 API
JCR
open source?
repository storage
components
you bet!
18. OSGi?
OSGi is great for modularity
Fosters better structured code
Dynamic services and plugins
Tooling needs to improve, but usable
OSGi skills? - OSGi way of thinking is new...
Asynchronous startup can be problematic if
using declarative services
CQ5 and Sling
overview Bertrand Delacrétaz
20. Sling POST servlet
# POST to Sling
curl -F title=hi http://localhost:8888/foo
-> 200 OK
# GET created node in json format
curl http://localhost:8888/foo.tidy.json
{
"jcr:primaryType": "nt:unstructured",
"title": "hi"
}
POST ters se t
e
param operties
node pr
CQ5 and Sling 20
overview Bertrand Delacrétaz
21. blog step 1: create content
<form method="POST">
Title:
<input type="text" name="title"/>
Text:
<textarea name="text"></textarea>
<input type="submit" value="save"/>
<input type="hidden"
name=":redirect" value="*"/>
</form>
Form e fields
dri ve th model
CQ5 and Sling
ontent
21
overview c Bertrand Delacrétaz
22. blog step 2: retrieve content
<script src="/system/sling.js"></script>
<form method="POST">
...(as in step 1)...
</form>
<!-- set form fields to current node values -->
<script>Sling.wizard();</script>
t CRU(D)
Instan
CQ5 and Sling 22
overview Bertrand Delacrétaz
23. blog step 3: navigation
<ul>
<li>
<a href="/content/blog/*">[Create post]</a>
</li>
<script>
var posts = Sling.getContent("/content/blog", 2);
for(var post in posts) {
document.write(
"<li><a href=’” + post + "'>"
+ posts[post].title + "</a></li>");
}
</script>
</ul>
CQ5 and Sling 23
overview Bertrand Delacrétaz
24. we’ve got a blog!
html form + Sling wizard() + Sling.getContent()