Overview (from SLING-1438)
This is a Google Summer of Code 2010, Federico Paparoni has been accepted as a student to work on it, mentored by Bertrand Delacretaz
The goal is to create a mini-CMS with Sling, that demonstrates Sling best practices.
Apache Sling is an opensource project with a lot of technologies and features. The goal of this project is to create a mini-CMS, that developers can use to understand how to develop a simple application with Sling.
So it is necessary to know a little about two main topics: OSGi and JCR. The following links are useful resources to read something about these technologies.
The repository for this project can be found at http://code.google.com/p/davidgsoc2010/.
First steps into Sling
Firstly you must setup the environment for Sling, so you can follow the guide at http://sling.apache.org/site/getting-and-building-sling.html.
Now that you created your environment, you can setup some other tools that can be useful during the development:
- cURL : Command line tool to send HTTP request
- JCR Explorer : Extension that create a useful explorer for the JCR repository you are working in
- BitKinex : FTP/SFTP/HTTP/WebDAV Client that can be used to manage the files you uploaded in Sling
It's time to make our "Hello world" in Apache Sling.
Open a console and simply launch the next command:
curl -F"sling:resourceType=foo/bar" -F"title=Hello world" http://admin:admin@localhost:8080/content/myfirstnode
This is a simple HTTP request, where you pass some parameters and values. Using it you have created a first resource under Sling.
The resource is a JCR node, as every resource in Sling, put under folder /content. This node has two parameters, title and sling:resourceType.
Node creation is a simple task, but you must understand how you can render the information stored in the nodes using Sling.
The first document you can read is the next one: http://dev.day.com/content/ddc/blog/2008/07/cheatsheet/_jcr_content/par/download/file.res/cheatsheet.pdf
It simply describes how content resolution works in Sling.
Another important information to better understand Sling, is that a resource is rendered by a script.
Script files are stored under the folders /apps or /libs and there is a wide choice of possible scripting engine:
- Java Servlet
To select a script, Sling uses the node's sling:resourceType property. So if we say that sling:resourceType is foo/bar, Sling will search under the /apps/foo/bar/ folder.
The following links describes how the scripts work and what type of variables we have during the script execution: