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
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”
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
cq5: welcome
cq5: content tree
cq5: page editing
cq5: visual workflow
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.
cq5: zero-install IDE
content
                structures
     no database? No SQL?    everything is content


            JCR repository
CQ5 and Sling
overview
geometrixx page content
              /content
               /geometrixx
                /en
                 /company
                   /jcr:content
                     /par
                      /title
blog design content




    /etc/designs/blog/kubrick/jcr:content
code content!


                /libs
                  /cq
                    /code
                     /install
                       /xyz.jar
dynamic java modules (OSGi)
Apache
       Sling
Apache Software Foundation       open source
     script == servlet           open development
Applications layer for JCR repositories   OSGi-based
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..
                                                                 Apache Sling framework

                                   OSGi framework
                                    (Apache Felix)
                                       JSR-170 API

                                          JCR
                                        content
CQ5/Sling                              repository
                                                           storage
                                                         components
architecture
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!
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
Sling blog
46 lines of code
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
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
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
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
we’ve got a blog!
html form + Sling wizard() + Sling.getContent()
more info?
www.day.com/cq5
www.day.com/crx (free download)
sling.apache.org
jackrabbit.apache.org
felix.apache.org
slideshare.net/bdelacretaz
CQ5 and Sling
overview                   Bertrand Delacrétaz
This slide deck is licensed under the
Creative Commons Attribution-Noncommercial-Share Alike 3 license.
            Copyright (C) 2010, Bertrand Delacretaz

CQ5 and Sling overview

  • 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
  • 4.
  • 5.
  • 6.
  • 7.
  • 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.
  • 9.
  • 10.
    content structures no database? No SQL? everything is content JCR repository CQ5 and Sling overview
  • 11.
    geometrixx page content /content /geometrixx /en /company /jcr:content /par /title
  • 12.
    blog design content /etc/designs/blog/kubrick/jcr:content
  • 13.
    code content! /libs /cq /code /install /xyz.jar
  • 14.
  • 15.
    Apache Sling Apache Software Foundation open source script == servlet open development Applications layer for JCR repositories OSGi-based
  • 16.
    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.. Apache Sling framework OSGi framework (Apache Felix) JSR-170 API JCR content CQ5/Sling repository storage components architecture
  • 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? OSGiis 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
  • 19.
  • 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 ablog! html form + Sling wizard() + Sling.getContent()
  • 25.
    more info? www.day.com/cq5 www.day.com/crx (freedownload) sling.apache.org jackrabbit.apache.org felix.apache.org slideshare.net/bdelacretaz CQ5 and Sling overview Bertrand Delacrétaz
  • 26.
    This slide deckis licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3 license. Copyright (C) 2010, Bertrand Delacretaz