content for the masses

Marketing technologist, content management strategist, digital platform architect, technology evangelist.

Accessing the Content Repository

The content repository is not file system. It is not a database. It’s somewhere in-between. Some would argue its the best of both worlds. Others would not. Either way, when you run Sling, you are running on top of a Java Content Repository (JCR) and you need to know how to access its contents.

The Sling Content Repository

When you run the Sling application using all the defaults, http://localhost:8080/ you are presented with the welcome. Go ahead and read that and be sure to catch upon the Sling in 15 minutes tutorial linked to from there. Done that, good!

Now, how do you change that index.html file that is served up on http://localhost:8080/? Well the first thing to realise is that index.html is content and that all content is stored in the content repository. However, everyone links dealing with files. Recognising this, the Sling folks have bundled WebDAV support in with Sling. To expose the Sling content repository has a bunch of files on your desktop do the following:

  • Go into your favourite WebDAV client. IE for some, Finder for others (Cmd-K).
  • Enter the url for the content root, e.g. http://localhost:8080/
  • Voila! The content repository is available as files

For me, and other mac users, drag the localhost mounted directory into TextMate and you’re away. For windows folks, chose whatever text editor you’re happy with to achieve a similar effect.

Above you can see what’s in the Sling content repository. In fact, we can see that index.html file. Change something in there, save it and go back to http://localhost:8080 in your browser. Simple!

We also added a file called cleve.html and that can be displayed in the browser by traversing to http://localhost:8080/cleve.html. What we’re seeing here is Sling acting as a web server where all the pages are stored within the content repository.

Next Steps

After the novelty of adding static pages to Sling has worn off, its time to move on:

  • What happens when I try to access content and its not there?