incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Sling > GSoC 2010 mini-CMS project
Date Mon, 09 Aug 2010 16:59:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/1/_/styles/combined.css?spaceKey=SLING&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/SLING/GSoC+2010+mini-CMS+project">GSoC
2010 mini-CMS project</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~fpaparoni">Federico
Paparoni</a>
    </h4>
        <br/>
                         <h4>Changes (9)</h4>
                                 
    
<div id="page-diffs">
            <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >In David there are two different nodes
created when you deploy your application: [/content/david|http://code.google.com/p/davidgsoc2010/source/browse/trunk/core/src/main/resources/initial-content/content/david.json]
and [/content/tags|http://code.google.com/p/davidgsoc2010/source/browse/trunk/core/src/main/resources/initial-content/content/tags.json]
. <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >These nodes are defined in the
application folders, using a JSON format. <span class="diff-added-words"style="background-color:
#dfd;">Every information stored in these JSON will be a property of the created nodes.&amp;nbsp;</span>
<br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Let&#39;s
examine the definition of [/content/david|http://code.google.com/p/davidgsoc2010/source/browse/trunk/core/src/main/resources/initial-content/content/david.json]
node: <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">The
most important property is the next one <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{code}
<br>&quot;sling:resourceType&quot;: &quot;david&quot; <br>{code}
<br>This property defines &quot;david&quot; as resource type, so Sling knows
that it will search under the folder /apps/david to find the scripts that will be called on
this node. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">{quote}
<br>{&amp;nbsp; &quot;name&quot;: &quot;david&quot;, &quot;primaryNodeType&quot;:
&quot;nt:unstructured&quot;, &quot;sling:resourceType&quot;: &quot;david&quot;,
&quot;jcr:primaryType&quot;: &quot;nt:unstructured&quot;&amp;nbsp; <br>}
<br>{&amp;nbsp;&quot;name&quot;: &quot;david&quot;,&quot;primaryNodeType&quot;:
&quot;nt:unstructured&quot;,&quot;sling:resourceType&quot;: &quot;david&quot;,&quot;jcr:primaryType&quot;:
&quot;nt:unstructured&quot;&amp;nbsp;} <br>{quote} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">These
JSON files are loaded using the [Maven Bundle Plugin|http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html]
, as you can see in the David [core/pom.xml|http://code.google.com/p/davidgsoc2010/source/browse/trunk/core/pom.xml]
file&amp;nbsp; <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">&lt;\!-\-
initial content to be loaded on bundle installation \--&gt; <br>&amp;nbsp;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;Sling-Initial-Content&gt;
<br>&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp;initial-content;overwrite:=true;uninstall:=true
<br>&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&amp;nbsp;&lt;/Sling-Initial-Content&gt; <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">&amp;nbsp;gege</span>
<span class="diff-added-words"style="background-color: #dfd;"> </span> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{code}
<br>&lt;!-- initial content to be loaded on bundle installation --&gt; <br>&lt;Sling-Initial-Content&gt;
<br>	initial-content;overwrite:=true;uninstall:=true <br>&lt;/Sling-Initial-Content&gt; 
                <br>{code} <br>JSON isn&#39;t the only way to load
initial content. Further informations about content loading can be found in the [Content Loading
Bundle Documentation|http://sling.apache.org/site/content-loading-jcrcontentloader.html] <br></td></tr>
        </table>
</div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="GSoC2010mini-CMSproject-Overview%28fromSLING1438%29"></a>Overview
(from SLING-1438)</h1>

<p>This is a Google Summer of Code 2010, Federico Paparoni has been accepted as a student
to work on it, mentored by Bertrand Delacretaz</p>

<p>The goal is to create a mini-CMS with Sling, that demonstrates Sling best practices.</p>

<p>See <a href="http://tinyurl.com/asfgsoc" class="external-link" rel="nofollow">http://tinyurl.com/asfgsoc</a>
for the full list of GSoC 2010 projects at the ASF, and <a href="http://community.apache.org/gsoc"
class="external-link" rel="nofollow">http://community.apache.org/gsoc</a> for general
GSoC information.</p>


<h1><a name="GSoC2010mini-CMSproject-"></a><font color="#003366"><b>Introduction</b></font></h1>

<p>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.&nbsp;</p>

<p>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.</p>

<p><b><em>OSGi</em></b></p>
<ul>
	<li><a href="http://en.wikipedia.org/wiki/OSGi" class="external-link" rel="nofollow">http://en.wikipedia.org/wiki/OSGi</a></li>
	<li><a href="http://felix.apache.org/" class="external-link" rel="nofollow">http://felix.apache.org/</a></li>
	<li><a href="http://www.osgi.org/Links/BasicEducation" class="external-link" rel="nofollow">http://www.osgi.org/Links/BasicEducation</a></li>
</ul>


<p><b><em>JCR</em></b></p>
<ul>
	<li><a href="http://jackrabbit.apache.org/" class="external-link" rel="nofollow">http://jackrabbit.apache.org/</a></li>
	<li><a href="http://www.ibm.com/developerworks/java/library/j-jcr/" class="external-link"
rel="nofollow">http://www.ibm.com/developerworks/java/library/j-jcr/</a></li>
	<li><a href="http://wiki.apache.org/jackrabbit/DavidsModel" class="external-link"
rel="nofollow">http://wiki.apache.org/jackrabbit/DavidsModel</a></li>
</ul>


<p>The repository for this project can be found at&nbsp;<a href="http://code.google.com/p/davidgsoc2010/"
class="external-link" rel="nofollow">http://code.google.com/p/davidgsoc2010/</a>.</p>

<h1><a name="GSoC2010mini-CMSproject-"></a><font color="#003366"><b>Some
words about David Mini CMS</b></font></h1>

<p>This project shows some features of Apache Sling and can be used for educational
purpose to move your first steps with this framework.</p>

<p>David uses the following opensource library/technologies:</p>

<p><font color="#000000">&nbsp;</font></p>

<ul>
	<li><font color="#003366"><a href="http://jquery.com/" class="external-link"
rel="nofollow">jQuery&nbsp;</a></font> <font color="">1.4.2</font></li>
	<li><font color=""><a href="http://jqueryui.com/" class="external-link" rel="nofollow">jQueryUI&nbsp;</a></font>
<font color="">1.8</font></li>
	<li><font color=""><a href="http://gmarwaha.com/blog/?p=7" class="external-link"
rel="nofollow">LavaLamp </a></font> <font color="">&#45; A menu plugin
for jQuery with cool hover effects&nbsp;</font></li>
	<li><font color=""><a href="http://www.roytanck.com/2008/03/06/wordpress-plugin-wp-cumulus-flash-based-tag-cloud/"
class="external-link" rel="nofollow">WP-Cumulus SWF</a></font> <font color="">&#45;&nbsp;</font><font
color="">used to display tag cloud</font></li>
	<li><font color=""><a href="http://itextpdf.com/" class="external-link" rel="nofollow">iText&nbsp;</a></font></li>
	<li><font color=""><a href="http://ckeditor.com/" class="external-link" rel="nofollow">CKEditor&nbsp;</a></font></li>
</ul>


<p>The available features are</p>
<ul>
	<li>CRUD (Create, Read, Update and Delete) for the content</li>
	<li>Full HTML creation of article</li>
	<li>Creation of PDF rappresentation of a single post or the entire list of contents
available</li>
	<li>Tagging system</li>
	<li>Search by title,text,tag</li>
	<li>Send email to someone with the link of article</li>
	<li>Background service that checks number of articles/tags in the repository</li>
</ul>


<p>These aren't space age features, but are useful to understand how to create an application
using Apache Sling</p>

<h1><a name="GSoC2010mini-CMSproject-FirststepsintoSling"></a><b>First
steps into Sling</b></h1>

<p>Firstly you must setup the environment for Sling, so you can follow the guide at&nbsp;<a
href="http://sling.apache.org/site/getting-and-building-sling.html" class="external-link"
rel="nofollow">http://sling.apache.org/site/getting-and-building-sling.html</a>.</p>

<p>Now that you created your environment, you can setup some other tools that can be
useful during the development:</p>
<ul>
	<li><a href="http://curl.haxx.se/" class="external-link" rel="nofollow">cURL</a>
: Command line tool to send HTTP request</li>
	<li><a href="http://svn.apache.org/repos/asf/sling/trunk/contrib/explorers/jquery/"
class="external-link" rel="nofollow">JCR Explorer</a> : Extension that create a useful
explorer for the JCR repository you are working in</li>
	<li><a href="http://www.bitkinex.com/" class="external-link" rel="nofollow">BitKinex</a>
:&nbsp;FTP/SFTP/HTTP/WebDAV Client that can be used to manage the files you uploaded in
Sling</li>
</ul>


<p>It's time to make our "Hello world" in Apache Sling.&nbsp;<br/>
Open a console and simply launch the next command:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">curl -F<span class="code-quote">"sling:resourceType=foo/bar"</span>
-F<span class="code-quote">"title=Hello world"</span> http:<span class="code-comment">//admin:admin@localhost:8080/content/myfirstnode</span>
</pre>
</div></div>

<p>This is a simple HTTP request, where you pass some parameters and values. Using it
you have created a first resource under Sling.&nbsp;<br/>
The resource is a JCR node, as every resource in Sling, put under folder /content. This node
has two parameters, title and sling:resourceType.&nbsp;</p>

<p>Node creation is a simple task, but you must understand how you can render the information
stored in the nodes using Sling.<br/>
The first document you can read is the next one:&nbsp;<a href="http://dev.day.com/content/ddc/blog/2008/07/cheatsheet/_jcr_content/par/download/file.res/cheatsheet.pdf"
class="external-link" rel="nofollow">http://dev.day.com/content/ddc/blog/2008/07/cheatsheet/_jcr_content/par/download/file.res/cheatsheet.pdf</a><br/>
It simply describes how content resolution works in Sling.&nbsp;</p>

<p>Another important information to better understand Sling, is that a resource is rendered
by a script.<br/>
Script files are stored under the folders /apps or /libs and there is a wide choice of possible
scripting engine:&nbsp;</p>
<ul>
	<li>ESP</li>
	<li>JSP</li>
	<li>Java Servlet</li>
	<li>Scala</li>
	<li>Python</li>
	<li>Groovy</li>
	<li>Ruby</li>
</ul>


<p>To select a script, Sling uses the node's sling:resourceType property. So if we say
that&nbsp;sling:resourceType is foo/bar, Sling will search under the /apps/foo/bar/ folder.<br/>
The following links describes how the scripts work and what type of variables we have during
the script execution:</p>
<ul>
	<li><a href="https://cwiki.apache.org/SLING/scripting-variables.html" class="external-link"
rel="nofollow">https://cwiki.apache.org/SLING/scripting-variables.html</a></li>
	<li><a href="https://cwiki.apache.org/SLING/url-to-script-resolution.html" class="external-link"
rel="nofollow">https://cwiki.apache.org/SLING/url-to-script-resolution.html</a></li>
</ul>


<h1><a name="GSoC2010mini-CMSproject-"></a><font color="#003366"><b>Content
loading</b></font></h1>

<p>You can setup some initial contents that can be used in your application. It is a
useful thing, because with a simple configuration you have some nodes already created when
your application starts.</p>

<p>In David there are two different nodes created when you deploy your application:
<a href="http://code.google.com/p/davidgsoc2010/source/browse/trunk/core/src/main/resources/initial-content/content/david.json"
class="external-link" rel="nofollow">/content/david</a> and <a href="http://code.google.com/p/davidgsoc2010/source/browse/trunk/core/src/main/resources/initial-content/content/tags.json"
class="external-link" rel="nofollow">/content/tags</a> .</p>

<p>These nodes are defined in the application folders, using a JSON format. Every information
stored in these JSON will be a property of the created nodes.&nbsp;</p>

<p>The most important property is the next one</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java"><span class="code-quote">"sling:resourceType"</span>:
<span class="code-quote">"david"</span>
</pre>
</div></div>
<p>This property defines "david" as resource type, so Sling knows that it will search
under the folder /apps/david to find the scripts that will be called on this node.</p>

<p>These JSON files are loaded using the <a href="http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html"
class="external-link" rel="nofollow">Maven Bundle Plugin</a> , as you can see in
the David <a href="http://code.google.com/p/davidgsoc2010/source/browse/trunk/core/pom.xml"
class="external-link" rel="nofollow">core/pom.xml</a> file&nbsp;</p>

<p>&lt;&#33;<del>&#45; initial content to be loaded on bundle installation
&#45;</del>&gt;<br/>
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;&lt;Sling-Initial-Content&gt;<br/>
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;initial-content;overwrite:=true;uninstall:=true<br/>
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;&lt;/Sling-Initial-Content&gt;</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">&lt;!-- initial content to be loaded on bundle installation
--&gt;
&lt;Sling-Initial-Content&gt;
	initial-content;overwrite:=<span class="code-keyword">true</span>;uninstall:=<span
class="code-keyword">true</span>
&lt;/Sling-Initial-Content&gt;                 
</pre>
</div></div>
<p>JSON isn't the only way to load initial content. Further informations about content
loading can be found in the <a href="http://sling.apache.org/site/content-loading-jcrcontentloader.html"
class="external-link" rel="nofollow">Content Loading Bundle Documentation</a></p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/SLING/GSoC+2010+mini-CMS+project">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=20316370&revisedVersion=9&originalVersion=8">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/SLING/GSoC+2010+mini-CMS+project?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message