With all the options out there to create a personal website: WordPress, Drupal or Joomla to name a few why would anyone create a site from scratch anymore?
Naturally creating something from scratch takes a lot more work than simply taking something Out of the Box (OOTB).
A number of open source projects allow users to template out pages and do WYSIWYG editing of content but very few give you complete control over how content goes into those templates. Also the concept of making the content modular and reusable is a bit foreign to many platforms. I wanted to be able to create a site that allowed me to build out content quickly and reuse it anywhere.
Sling makes it very simple to implement simple applications, while providing an enterprise-level framework for more complex applications, which comes with a free data model to store content since it’s built on top of the Java Content Repository (JCR) which stores content in a tree structure which is fitting for a web site.
Quick Steps for installation and IDE configuration:
You can get started by downloading the Sling jar from the below url
To start of with the instance use the below command and it will start your instance in the port 8080 as defined in the properties file of Sling which could be modified as required .
Default login credentials would be username : admin and password : admin .
java -jar org.apache.sling.launchpad-7-standalone.jar
To easily configure the Sling in your IDE , Apache provides a Sling IDE Tooling which would give you with basic functionality to create a Sling Content/Bundle Project and setting up the server.The tooling kit can be downloaded from the below url :
After successful installation of IDE Tooling you will be able to create sling project .To deploy the project on the instance Sling IDE Tooling Kit also provides the feature to for creating a new server to deploy the content on the user specific requirement .
Magic of POST operation :
Sling also provides a RESTful api for creating, deleting, modifying and transforming content. This means I can create content with simple form posts .
Below is a simple create operation :
<form action="/myresource" method="POST"> <input type="text" name="username"> <input type="submit" value="Submit" /> </form>
This would result in the creation of the node under root folder with property username it and would look like this :
For various other operation you could have a look in the below url
Small issues or pain points that I faced are :
Second, when we are using these post operation it would always redirect the page on submission to display the status of the POST operation performed as below :
So in-order to redirect it to user-defined path after any CRUD operation we need to add a property as below in our form that should be hidden :
<input type="hidden" name=":redirect" value="redirect_path" />
Thus far I’ve been pretty happy with the result. I have a custom site that gives me the experience I want. Looking forward to continuing to add new features. Enjoy!