incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r820125 [4/4] - in /websites/staging/sling/trunk/content: ./ documentation/ documentation/bundles/ documentation/getting-started/ documentation/the-sling-engine/ documentation/the-sling-engine/authentication/ documentation/tutorials-how-tos/
Date Sun, 03 Jun 2012 17:58:07 GMT
Modified: websites/staging/sling/trunk/content/documentation/tutorials-how-tos/46-line-blog.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/tutorials-how-tos/46-line-blog.html
(original)
+++ websites/staging/sling/trunk/content/documentation/tutorials-how-tos/46-line-blog.html
Sun Jun  3 17:58:06 2012
@@ -82,60 +82,51 @@
         <a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/documentation.html">Documentation</a>&nbsp;&raquo&nbsp;<a
href="/documentation/tutorials-how-tos.html">Tutorials & How-Tos</a>
       </div>
       <h1>46 Line Blog</h1>
-      <p>This tutorial is based on the first <em>Sling Gems</em> on dev.day.com:
The <a href="">Sling gems: a blog in 46 lines of code</a>. It has slightly been
adapted to fit here.</p>
+      <p>This tutorial is based on the first <em>Sling Gems</em> on dev.day.com:
The <a href="http://dev.day.com/microsling/content/blogs/main/sling-46-lines-blog.html">Sling
gems: a blog in 46 lines of code</a>. It has slightly been adapted to fit here.</p>
 <p>In this tutorial, the SlingPostServlet and the sling.js library are brought together
using 46 (no kidding: <em>fourty-six</em>) lines of code to create a simple blog
(or let's say <em>bloggish</em>) application.</p>
-<p>I used this example in my <a href="">http://us.apachecon.com/c/acus2009/sessions/284</a>
presentation at ApacheCon US 09 in Oakland (slides will be available soon), and I think it's
a good testimony to the power and simplicity of Sling.</p>
+<p>I used this example in my <a href="http://www.slideshare.net/bdelacretaz/rapid-jcr-applications-development-with-sling-1196003">Rapid
JCR application development with Apache Sling</a> presentation at ApacheCon US 09 in
Oakland (slides will be available soon), and I think it's a good testimony to the power and
simplicity of Sling.</p>
 <h2 id="audience">Audience</h2>
-<p>Although this is a simple sample, it requires some custom settings to work. If you're
just starting with Sling, <a href="">SLINGxSITE:Discover Sling in 15 minutes</a>
might be a better choice.</p>
+<p>Although this is a simple sample, it requires some custom settings to work. If you're
just starting with Sling, <a href="/documentation/getting-started/discover-sling-in-15-minutes.html">Discover
Sling in 15 minutes</a> might be a better choice.</p>
 <h2 id="step-0-start-configure-and-login-to-sling">Step 0: Start, configure and login
to Sling</h2>
-<p>See <a href="">SLINGxSITE:Getting and Building Sling</a> for how to
start Sling. Start it on port 8888 for the below links to work.</p>
-<p>For this sample we need the optional <em>org.apache.sling.samples.path-based.rtp</em>
bundle, if it's not present in the <a href="">OSGi console</a>, install and start
it. That bundle is not released yet so you might need to build it yourself, from its [source|http://svn.apache.org/repos/asf/sling/trunk/samples/path-based-rtp].
The bundle must then appear in the [OSGI console's list of bundles|http://localhost:8888/system/console/bundles],
with name = <em>org.apache.sling.samples.path-based.rtp</em> and status = <em>Active</em>.</p>
-<p>Then, login using http://localhost:8888/?sling:authRequestLogin=1 which should prompt
you for a username and password, use <em>admin</em> and <em>admin</em>.
Once that's done, http://localhost:8888/index.html should say <em>You are currently
logged in as user </em>admin<em> to workspace </em>default**.</p>
+<p>See <a href="/documentation/development/getting-and-building-sling.html">Getting
and Building Sling</a> for how to start Sling. Start it on port 8888 for the below links
to work.</p>
+<p>For this sample we need the optional <em>org.apache.sling.samples.path-based.rtp</em>
bundle, if it's not present in the <a href="http://localhost:8888/system/console/bundles">OSGi
console</a>, install and start it. That bundle is not released yet so you might need
to build it yourself, from its <a href="http://svn.apache.org/repos/asf/sling/trunk/samples/path-based-rtp">source</a>.
The bundle must then appear in the <a href="http://localhost:8888/system/console/bundles">OSGI
console's list of bundles</a>, with name = <em>org.apache.sling.samples.path-based.rtp</em>
and status = <em>Active</em>.</p>
+<p>Then, login using <a href="http://localhost:8888/?sling:authRequestLogin=1">http://localhost:8888/?sling:authRequestLogin=1</a>
which should prompt you for a username and password, use <em>admin</em> and <em>admin</em>.
Once that's done, <a href="http://localhost:8888/index.html">http://localhost:8888/index.html</a>
should say <em>You are currently logged in as user </em>admin<em> to workspace
</em>default**.</p>
 <h2 id="step-1-creating-content">Step 1: Creating content</h2>
 <p>The easiest way to create content in Sling is to use an HTTP POST request, let's
use a simple HTML form:</p>
-<p>{code:html}
-<html>
-  <body>
-    <h1>Sling microblog</h1></p>
-<div class="codehilite"><pre><span class="nt">&lt;div&gt;</span>
-  <span class="nt">&lt;form</span> <span class="na">method=</span><span
class="s">&quot;POST&quot;</span><span class="nt">&gt;</span>
-    Title:<span class="nt">&lt;br/&gt;</span>
-    <span class="nt">&lt;input</span> <span class="na">type=</span><span
class="s">&quot;text&quot;</span> <span class="na">name=</span><span
class="s">&quot;title&quot;</span> <span class="na">style=</span><span
class="s">&quot;width:100%&quot;</span><span class="nt">/&gt;</span>
-
-    <span class="nt">&lt;br/&gt;</span>Text:<span class="nt">&lt;br/&gt;</span>
-    <span class="nt">&lt;textarea</span> <span class="na">style=</span><span
class="s">&quot;width:100%&quot;</span> <span class="na">name=</span><span
class="s">&quot;text&quot;</span><span class="nt">&gt;&lt;/textarea&gt;</span>
-
-    <span class="nt">&lt;br/&gt;</span>
-    <span class="nt">&lt;input</span> <span class="na">type=</span><span
class="s">&quot;submit&quot;</span> <span class="na">value=</span><span
class="s">&quot;save&quot;</span><span class="nt">/&gt;</span>
-    <span class="nt">&lt;input</span> <span class="na">type=</span><span
class="s">&quot;hidden&quot;</span> <span class="na">name=</span><span
class="s">&quot;:redirect&quot;</span> <span class="na">value=</span><span
class="s">&quot;*.html&quot;</span><span class="nt">/&gt;</span>
-  <span class="nt">&lt;/form&gt;</span>
-<span class="nt">&lt;/div&gt;</span>
-
-<span class="c">&lt;!-- code of step 2 comes here --&gt;</span>
+<div class="codehilite"><pre><span class="nt">&lt;html&gt;</span>
+  <span class="nt">&lt;body&gt;</span>
+    <span class="nt">&lt;h1&gt;</span>Sling microblog<span class="nt">&lt;/h1&gt;</span>
+
+    <span class="nt">&lt;div&gt;</span>
+      <span class="nt">&lt;form</span> <span class="na">method=</span><span
class="s">&quot;POST&quot;</span><span class="nt">&gt;</span>
+        Title:<span class="nt">&lt;br/&gt;</span>
+        <span class="nt">&lt;input</span> <span class="na">type=</span><span
class="s">&quot;text&quot;</span> <span class="na">name=</span><span
class="s">&quot;title&quot;</span> <span class="na">style=</span><span
class="s">&quot;width:100%&quot;</span><span class="nt">/&gt;</span>
+
+        <span class="nt">&lt;br/&gt;</span>Text:<span class="nt">&lt;br/&gt;</span>
+        <span class="nt">&lt;textarea</span> <span class="na">style=</span><span
class="s">&quot;width:100%&quot;</span> <span class="na">name=</span><span
class="s">&quot;text&quot;</span><span class="nt">&gt;&lt;/textarea&gt;</span>
+
+        <span class="nt">&lt;br/&gt;</span>
+        <span class="nt">&lt;input</span> <span class="na">type=</span><span
class="s">&quot;submit&quot;</span> <span class="na">value=</span><span
class="s">&quot;save&quot;</span><span class="nt">/&gt;</span>
+        <span class="nt">&lt;input</span> <span class="na">type=</span><span
class="s">&quot;hidden&quot;</span> <span class="na">name=</span><span
class="s">&quot;:redirect&quot;</span> <span class="na">value=</span><span
class="s">&quot;*.html&quot;</span><span class="nt">/&gt;</span>
+      <span class="nt">&lt;/form&gt;</span>
+    <span class="nt">&lt;/div&gt;</span>
+
+    <span class="c">&lt;!-- code of step 2 comes here --&gt;</span>
+  <span class="nt">&lt;/body&gt;</span>
+<span class="nt">&lt;/html&gt;</span>
 </pre></div>
 
 
-<p></body>
-</html></p>
-<div class="codehilite"><pre><span class="n">That</span><span
class="s">&#39;s two input fields, a submit button and a hidden field that tells Sling
what to do after the POST (in this case: redirect to the html view of the node that was just
created).</span>
-
-<span class="s">To test the form, start Sling and save the above script as  {footnote}ESP
is Sling&#39;</span><span class="n">s</span> <span class="n">server</span><span
class="o">-</span><span class="n">side</span> <span class="n">javascript</span>
<span class="n">language</span><span class="p">{</span><span class="n">footnote</span><span
class="p">}</span> <span class="n">in</span> <span class="n">the</span>
<span class="n">Sling</span> <span class="n">repository</span> <span
class="o">-</span> <span class="n">a</span> <span class="n">WebDAV</span>
<span class="n">mount</span> <span class="n">is</span> <span class="n">the</span>
<span class="n">easiest</span> <span class="n">way</span> <span
class="n">to</span> <span class="k">do</span> <span class="n">that</span><span
class="o">.</span> <span class="n">Browsing</span> <span class="n">to</span>
 <span class="p">{</span><span class="n">footnote</span><span class="p">}</span>
<span class="n">This</span> <span class="n">assum
 es</span> <span class="n">your</span> <span class="n">instance</span>
<span class="n">of</span> <span class="n">Sling</span> <span class="n">is</span>
<span class="n">running</span> <span class="n">on</span> <span
class="n">port</span> <span class="mi">8888</span><span class="o">.</span>
<span class="n">If</span> <span class="n">that</span><span class="s">&#39;s
not the case, adjust the example URLs accordingly. {footnote} should display the above form.</span>
-
-<span class="s">Input some data (using &quot;foo&quot; for the title, for the
sake of our examples below), save the form, and Sling</span>
-<span class="s">should display the form again, using the URL of the node that was just
created.</span>
-
-<span class="s">{note:title=AccessDeniedException?}</span>
-<span class="s">If you get an error saying _javax.jcr.AccessDeniedException: ...not
allowed to add or modify item_ it means that you are not logged in as user _admin_. See instructions
above for logging in.</span>
-<span class="s">{note}</span>
-
-<span class="s">At this point you&#39;</span><span class="n">re</span>
<span class="n">probably</span> <span class="n">looking</span> <span
class="n">at</span> <span class="n">an</span> <span class="n">empty</span>
<span class="n">form</span> <span class="n">with</span> <span class="n">an</span>
<span class="n">URL</span> <span class="n">ending</span> <span
class="n">in</span> <span class="n">_foo_</span><span class="p">,</span>
<span class="k">if</span> <span class="n">you</span> <span class="n">used</span>
<span class="n">that</span> <span class="k">for</span> <span class="n">the</span>
<span class="n">title</span><span class="o">.</span> <span class="n">Or</span>
<span class="n">_foo_0_</span> <span class="ow">or</span> <span
class="n">_foo_1_</span> <span class="k">if</span> <span class="n">other</span>
<span class="n">_foo_s</span> <span class="n">already</span> <span
class="n">existed</span><span class="o">.</span> <span class="n">Don</span><span
class="s">&#39;t worry
  about not seeing your content, we&#39;</span><span class="n">ll</span>
<span class="n">fix</span> <span class="n">that</span> <span class="n">right</span>
<span class="n">away</span><span class="o">.</span>
-
-<span class="n">h2</span><span class="o">.</span> <span class="n">Step</span>
<span class="mi">2</span><span class="p">:</span> <span class="n">Where</span><span
class="s">&#39;s my content?</span>
-
-<span class="s">To verify that our content has been created, we can have a look at
the JSON data at , which should display our new node&#39;</span><span class="n">s</span>
<span class="nb">values</span><span class="p">:</span>
-
-<span class="p">{</span><span class="n">code:javascript</span><span
class="p">}</span>
-<span class="p">{</span>
+<p>That's two input fields, a submit button and a hidden field that tells Sling what
to do after the POST (in this case: redirect to the html view of the node that was just created).</p>
+<p>To test the form, start Sling and save the above script as  <sup id="fnref:esp"><a
href="#fn:esp" rel="footnote">1</a></sup>  in the Sling repository - a WebDAV
mount is the easiest way to do that. Browsing to <a href="http://localhost:8888/content/blog/*.html">http://localhost:8888/content/blog/*.html</a>
<sup id="fnref:port"><a href="#fn:port" rel="footnote">2</a></sup>
should display the above form.</p>
+<p>Input some data (using "foo" for the title, for the sake of our examples below),
save the form, and Sling should display the form again, using the URL of the node that was
just created.</p>
+<p>{note:title=AccessDeniedException?}
+If you get an error saying <em>javax.jcr.AccessDeniedException: ...not allowed to add
or modify item</em> it means that you are not logged in as user <em>admin</em>.
See instructions above for logging in.
+{note}</p>
+<p>At this point you're probably looking at an empty form with an URL ending in <em>foo</em>,
if you used that for the title. Or <em>foo_0</em> or <em>foo_1</em>
if other _foo_s already existed. Don't worry about not seeing your content, we'll fix that
right away.</p>
+<h2 id="step-2-wheres-my-content">Step 2: Where's my content?</h2>
+<p>To verify that our content has been created, we can have a look at the JSON data
at <a href="http://localhost:8888/content/blog/foo.tidy.json">http://localhost:8888/content/blog/foo.tidy.json</a>,
which should display our new node's values:</p>
+<div class="codehilite"><pre><span class="p">{</span>
   <span class="s">&quot;jcr:primaryType&quot;</span><span class="p">:</span>
<span class="s">&quot;nt:unstructured&quot;</span><span class="p">,</span>
   <span class="s">&quot;text&quot;</span><span class="p">:</span>
<span class="s">&quot;This is the foo text&quot;</span><span class="p">,</span>
   <span class="s">&quot;title&quot;</span><span class="p">:</span>
<span class="s">&quot;foo&quot;</span>
@@ -145,14 +136,14 @@
 
 <p>That's reassuring, but what we really want is for these values to be displayed on
the editing form for our post.</p>
 <p>Thanks to the <em>sling.js</em> client library, we just need to add
a <code>Sling.wizard()</code> call to our form to display those values. Let's
first add a <code>&lt;head&gt;</code> element to our form to load the
<em>sling.js</em> library, before the existing <code>&lt;body&gt;</code>
of course:</p>
-<p>{code:html}
-<head>
-  <script src="/system/sling.js"></script>
-</head></p>
-<div class="codehilite"><pre>And add the  after the form, where we had the _code
of step 2 comes here_ comment:
+<div class="codehilite"><pre><span class="nt">&lt;head&gt;</span>
+  <span class="nt">&lt;script</span> <span class="na">src=</span><span
class="s">&quot;/system/sling.js&quot;</span><span class="nt">&gt;&lt;/script&gt;</span>
+<span class="nt">&lt;/head&gt;</span>
+</pre></div>
+
 
-{code:html}
-<span class="c">&lt;!-- code of step 2 comes here --&gt;</span>
+<p>And add the <code>Sling.wizard()</code> after the form, where we had
the <em>code of step 2 comes here</em> comment:</p>
+<div class="codehilite"><pre><span class="c">&lt;!-- code of step 2
comes here --&gt;</span>
 <span class="nt">&lt;script&gt;</span>Sling.wizard();<span class="nt">&lt;/script&gt;</span>
 </pre></div>
 
@@ -162,38 +153,31 @@
 <h2 id="step-3-navigation">Step 3: Navigation</h2>
 <p>The <em>sling.js</em> library provides utilities to access and manipulate
content. For our blog, we'll use the <code>getContent(path)</code> method to list
the siblings of the current node.</p>
 <p>Add the following code to your script, after the <code>Sling.wizard()</code>
call that was added in step 2:</p>
-<p>{code:html}
-<h3>Navigation</h3>
-<ul>
-    <li><em><a href="/content/blog/*.html"><a href="">Create new
post</a></a></em></li>
-    <script>
-      var posts = Sling.getContent("/content/blog", 2);
+<div class="codehilite"><pre><span class="nt">&lt;h3&gt;</span>Navigation<span
class="nt">&lt;/h3&gt;</span>
+<span class="nt">&lt;ul&gt;</span>
+    <span class="nt">&lt;li&gt;&lt;em&gt;&lt;a</span> <span
class="na">href=</span><span class="s">&quot;/content/blog/*.html&quot;</span><span
class="nt">&gt;</span>[Create new post]()<span class="nt">&lt;/a&gt;&lt;/em&gt;&lt;/li&gt;</span>
+    <span class="nt">&lt;script&gt;</span>
+      var posts = Sling.getContent(&quot;/content/blog&quot;, 2);
       for(var i in posts) {
-        document.write("<li>"
-          + "<a href='/content/blog/" + i + ".html'>"  <br />
-          + posts<a href="">i</a>.title
-          + "</a></li>");
+        document.write(&quot;<span class="nt">&lt;li&gt;</span>&quot;
+          + &quot;<span class="nt">&lt;a</span> <span class="na">href=</span><span
class="s">&#39;/content/blog/&quot; + i + &quot;.html&#39;</span><span
class="nt">&gt;</span>&quot;    
+          + posts[i]().title
+          + &quot;<span class="nt">&lt;/a&gt;&lt;/li&gt;</span>&quot;);
       }
-    </script>
-</ul></p>
-<div class="codehilite"><pre><span class="n">The</span> <span
class="n">first</span> <span class="nb">link</span> <span class="n">to</span>
 <span class="n">brings</span> <span class="n">us</span> <span
class="n">back</span> <span class="n">to</span> <span class="k">our</span>
<span class="n">content</span> <span class="n">creating</span> <span
class="n">form</span><span class="p">,</span> <span class="n">which</span>
<span class="n">is</span> <span class="n">nothing</span> <span
class="k">else</span> <span class="n">than</span> <span class="n">the</span>
<span class="n">editing</span> <span class="n">form</span> <span
class="n">reading</span> <span class="n">empty</span> <span class="nb">values</span>
<span class="ow">and</span> <span class="n">posting</span> <span
class="n">to</span> <span class="n">the</span> <span class="s">&quot;magic
star&quot;</span> <span class="n">URL</span><span class="o">.</span>
-
-<span class="n">The</span> <span class="n">rest</span> <span class="n">of</span>
<span class="n">the</span> <span class="n">javascript</span> <span
class="n">runs</span> <span class="n">client</span><span class="o">-</span><span
class="n">side</span><span class="p">,</span> <span class="n">as</span>
<span class="n">it</span> <span class="n">is</span> <span class="ow">not</span>
<span class="n">embedded</span> <span class="n">in</span>  <span
class="n">code</span> <span class="n">markers</span><span class="p">,</span>
<span class="n">calls</span> <span class="n">the</span>  <span
class="n">method</span> <span class="n">to</span> <span class="n">get</span>
<span class="n">two</span> <span class="n">levels</span> <span
class="n">of</span> <span class="n">node</span> <span class="n">data</span>
<span class="n">below</span> <span class="p">,</span> <span class="ow">and</span>
<span class="n">displays</span> <span class="n">links</span> <span
class="n">to</span> <span class="n">no
 des</span> <span class="n">that</span> <span class="n">it</span>
<span class="n">finds</span><span class="o">.</span>
-
-<span class="n">That</span><span class="s">&#39;s a basic navigation,
of course, in a real blog we&#39;</span><span class="n">d</span> <span
class="n">need</span> <span class="n">some</span> <span class="n">paging</span>
<span class="ow">and</span> <span class="n">contextualization</span>
<span class="n">to</span> <span class="n">cope</span> <span class="n">with</span>
<span class="n">large</span> <span class="n">numbers</span> <span
class="n">of</span> <span class="n">posts</span><span class="o">.</span>
-
-<span class="n">Nevertheless</span><span class="p">,</span> <span
class="n">with</span> <span class="n">this</span> <span class="n">addition</span>
<span class="k">our</span> <span class="n">ESP</span> <span class="n">script</span>
<span class="n">allows</span> <span class="n">us</span> <span class="n">to</span>
<span class="n">create</span><span class="p">,</span> <span class="n">edit</span>
<span class="ow">and</span> <span class="n">navigate</span> <span
class="n">blog</span> <span class="n">posts</span> <span class="o">-</span>
<span class="ow">not</span> <span class="n">bad</span> <span class="k">for</span>
<span class="mi">46</span> <span class="n">lines</span> <span class="n">of</span>
<span class="n">code</span><span class="p">,</span> <span class="n">including</span>
<span class="n">comments</span><span class="p">,</span> <span class="n">whitespace</span>
<span class="ow">and</span> <span class="n">output</span> <span
class="n">formatting</span><span class="o">.</sp
 an>
-
-<span class="n">h2</span><span class="o">.</span> <span class="n">Step</span>
<span class="mi">4</span><span class="p">:</span> <span class="n">Data</span>
<span class="n">first</span><span class="p">,</span> <span class="n">structure</span>
<span class="n">later</span>
-
-<span class="n">You</span> <span class="n">might</span> <span
class="n">have</span> <span class="n">heard</span> <span class="n">this</span>
<span class="n">mantra</span><span class="p">,</span> <span class="n">which</span>
<span class="n">we</span> <span class="n">apply</span> <span class="n">in</span>
<span class="n">many</span> <span class="n">areas</span> <span
class="n">of</span> <span class="n">Sling</span><span class="o">.</span>
-
-<span class="n">In</span> <span class="n">this</span> <span class="k">case</span><span
class="p">,</span> <span class="n">adding</span> <span class="n">a</span>
<span class="k">new</span> <span class="n">field</span> <span class="n">to</span>
<span class="k">our</span> <span class="n">blog</span> <span class="n">posts</span>
<span class="n">could</span> <span class="ow">not</span> <span
class="n">be</span> <span class="n">easier:</span> <span class="n">just</span>
<span class="n">add</span> <span class="n">an</span> <span class="n">input</span>
<span class="n">field</span> <span class="n">to</span> <span class="n">the</span>
<span class="n">form</span><span class="p">,</span> <span class="ow">and</span>
<span class="n">Sling</span> <span class="n">will</span> <span
class="k">do</span> <span class="n">the</span> <span class="n">rest</span><span
class="o">.</span>
+    <span class="nt">&lt;/script&gt;</span>
+<span class="nt">&lt;/ul&gt;</span>
+</pre></div>
 
-<span class="n">Adding</span> <span class="n">this</span> <span
class="n">inside</span> <span class="k">our</span> <span class="n">script</span><span
class="err">&#39;</span><span class="n">s</span>  <span class="n">element</span><span
class="p">,</span> <span class="k">for</span> <span class="n">example:</span>
 
-<span class="p">{</span><span class="n">code:html</span><span
class="p">}</span>
-<span class="sr">&lt;br/&gt;</span><span class="n">Author:</span><span
class="sr">&lt;br/&gt;</span>
+<p>The first link to <code>/content/blog/*</code> brings us back to our
content creating form, which is nothing else than the editing form reading empty values and
posting to the "magic star" URL. </p>
+<p>The rest of the javascript runs client-side, as it is not embedded in <code>&lt;%
%&gt;</code> code markers, calls the <code>sling.getContent</code> method
to get two levels of node data below <code>/content/blog</code>, and displays
links to nodes that it finds.</p>
+<p>That's a basic navigation, of course, in a real blog we'd need some paging and contextualization
to cope with large numbers of posts.</p>
+<p>Nevertheless, with this addition our ESP script allows us to create, edit and navigate
blog posts - not bad for 46 lines of code, including comments, whitespace and output formatting.</p>
+<h2 id="step-4-data-first-structure-later">Step 4: Data first, structure later</h2>
+<p>You might have heard this mantra, which we apply in many areas of Sling.</p>
+<p>In this case, adding a new field to our blog posts could not be easier: just add
an input field to the form, and Sling will do the rest.</p>
+<p>Adding this inside our script's <code>&lt;form&gt;</code> element,
for example:</p>
+<div class="codehilite"><pre><span class="sr">&lt;br/&gt;</span><span
class="n">Author:</span><span class="sr">&lt;br/&gt;</span>
 <span class="o">&lt;</span><span class="n">input</span> <span
class="n">type</span><span class="o">=</span><span class="s">&quot;author&quot;</span>
<span class="n">name</span><span class="o">=</span><span class="s">&quot;author&quot;</span>
<span class="n">style</span><span class="o">=</span><span class="s">&quot;width:100%&quot;</span><span
class="o">/&gt;</span>
 </pre></div>
 
@@ -204,11 +188,20 @@
 <p>That's correct - as we are using only Sling client-facing features at this point
(HTTP POST and <code>sling.js</code>), we do not necessarily need to use ESP code.</p>
 <p>To keep things simple, we'll refrain from adding ESP-based features at this point,
but you can of course use any ESP code in the <em>blog.esp</em> "script".</p>
 <h2 id="thats-the-power-of-sling">That's the power of Sling</h2>
-<p>The 46-line blog is a good example of the power of Sling. It leverages the <a
href="">SlingPostServlet</a>, which handles POST requests in a form-friendly way,
and the <code>[sling.js|http://svn.apache.org/repos/asf/sling/trunk/bundles/servlets/post/src/main/resources/system/sling.js]</code>
client library, which provides high-level functionality on the client side.</p>
+<p>The 46-line blog is a good example of the power of Sling. It leverages the <a
href="/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html">SlingPostServlet</a>,
which handles POST requests in a form-friendly way, and the <a href="http://svn.apache.org/repos/asf/sling/trunk/bundles/servlets/post/src/main/resources/system/sling.js"><code>sling.js</code></a>
client library, which provides high-level functionality on the client side.</p>
+<div class="footnote">
 <hr />
-<p>///Footnotes Go Here///</p>
+<ol>
+<li id="fn:esp">
+<p>ESP is Sling's server-side javascript language&#160;<a href="#fnref:esp"
rev="footnote" title="Jump back to footnote 1 in the text">&#8617;</a></p>
+</li>
+<li id="fn:port">
+<p>This assumes your instance of Sling is running on port 8888. If that's not the case,
adjust the example URLs accordingly.&#160;<a href="#fnref:port" rev="footnote" title="Jump
back to footnote 2 in the text">&#8617;</a></p>
+</li>
+</ol>
+</div>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1341347 by fmeschbe on Tue, 22 May 2012 08:25:18 +0000
+        Rev. 1345726 by fmeschbe on Sun, 3 Jun 2012 17:57:55 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project

Modified: websites/staging/sling/trunk/content/documentation/tutorials-how-tos/jackrabbit-persistence.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/tutorials-how-tos/jackrabbit-persistence.html
(original)
+++ websites/staging/sling/trunk/content/documentation/tutorials-how-tos/jackrabbit-persistence.html
Sun Jun  3 17:58:06 2012
@@ -82,8 +82,7 @@
         <a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/documentation.html">Documentation</a>&nbsp;&raquo&nbsp;<a
href="/documentation/tutorials-how-tos.html">Tutorials & How-Tos</a>
       </div>
       <h1>Jackrabbit Persistence</h1>
-      <h1 id="jackrabbit-persistence">Jackrabbit Persistence</h1>
-<p>Out-of-the-box the embedded Jackrabbit repository used by Sling (the Embedded Jackrabbit
Repository bundle) uses Derby to persist the JCR nodes and properties. For some applications
or environments it may be required or required to replace Derby with another backing store
such as PostgreSQL or Oracle.</p>
+      <p>Out-of-the-box the embedded Jackrabbit repository used by Sling (the Embedded
Jackrabbit Repository bundle) uses Derby to persist the JCR nodes and properties. For some
applications or environments it may be required or required to replace Derby with another
backing store such as PostgreSQL or Oracle.</p>
 <p>This page is based on the journey of Tony Giaccone to get Sling running with a PostgreSQL
based Jackrabbit instance.</p>
 <h2 id="management-summary">Management Summary</h2>
 <p>To replace Derby as the persistence manager for Jackrabbit the following steps are
required:</p>
@@ -94,8 +93,8 @@
 </ol>
 <p>When you are not using the Derby persistence manager, you may safely remove the
Derby bundle from your Sling instance.</p>
 <h2 id="jdbc-driver">JDBC Driver</h2>
-<p>The hardest thing to do is probably getting the JDBC driver for your database. One
option is to look at the bundles provided by Spring Source in their repository at http://www.springsource.com/repository/.</p>
-<p>Another option is to create the bundle on your own using Peter Kriens' <a href="">BND
Tool</a>:</p>
+<p>The hardest thing to do is probably getting the JDBC driver for your database. One
option is to look at the bundles provided by Spring Source in their repository at <a href="http://www.springsource.com/repository/">http://www.springsource.com/repository/</a>.</p>
+<p>Another option is to create the bundle on your own using Peter Kriens' <a href="http://www.aqute.biz/Code/Bnd">BND
Tool</a>:</p>
 <ol>
 <li>Get the JDBC driver for your database from the driver provider</li>
 <li>
@@ -106,8 +105,8 @@ $ mv postgresql-8.4-701.jdbc3.bar postgr
 </li>
 <li>
 <p>Deploy the driver to your local Maven 2 Repository (Required if adding the JDBC
driver to a Maven build, e.g. using the Sling Launchpad Plugin)</p>
-<p>$ mvn install:install-file -DgroupId=postgresql -DartifactId=postgresql -Dversion=8.4.701.jdbc3
\
-        -Dpackaging=jar -Dfile=postgresql-8.4-701.jdbc3-bnd.jar </p>
+<p>$ mvn install:install-file -DgroupId=postgresql -DartifactId=postgresql -Dversion=8.4.701.jdbc3
\  <br />
+        -Dpackaging=jar -Dfile=postgresql-8.4-701.jdbc3-bnd.jar</p>
 </li>
 </ol>
 <p>Tony reports no success with the Spring Source bundle, whily the BND approach worked
for the PostgreSQL JDBC driver.</p>
@@ -116,14 +115,14 @@ $ mv postgresql-8.4-701.jdbc3.bar postgr
 <ol>
 <li>Uninstall the Apache Derby bundle</li>
 <li>Install the JDBC bundle prepared in the first step</li>
-<li>Stop the Jackrabbit Embedded Repository bundle\
+<li>Stop the Jackrabbit Embedded Repository bundle  <br />
 This needs to be reconfigured and restarted anyway. So lets just stop it to prevent failures
in the next step.</li>
 <li>Refresh the packages (click the <em>Refresh Packages</em> button)</li>
 </ol>
 <p>Alternatively, you may wish to stop Sling after uninstalling Derby and installing
the JDBC bundle. Technically, this is not required, though.</p>
 <h2 id="reconfiguring-jackrabbit">Reconfiguring Jackrabbit</h2>
 <p>To actually use a persistence manager other than the default (Derby) persistence
manager, you have to configure Jackrabbit to use it. Create a <code>repository.xml</code>
file in the <code>sling/jackrabbit</code> folder before starting Sling for the
first time. If the repository was already started, you can also modify the existing file.</p>
-<p>To prepare a repository.xml file before first startup, use the <code>[repository.xml]()</code>
as a template and modify it by replacing the <code>&lt;PersistenceManager&gt;</code>
elements to refer to the selected persistence manager.</p>
+<p>To prepare a repository.xml file before first startup, use the <a href="http://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-server/src/main/resources/repository.xml"><code>repository.xml</code></a>
as a template and modify it by replacing the <code>&lt;PersistenceManager&gt;</code>
elements to refer to the selected persistence manager.</p>
 <p>If the file already exists, you can modifiy this existing file and there is no need
to get the original from the SVN repository.</p>
 <p>For example to use PostgreSQL instead of Derby modify the <code>&lt;PersistenceManager&gt;</code>
elements as follows:</p>
 <div class="codehilite"><pre><span class="nt">&lt;Repository&gt;</span>
@@ -163,9 +162,9 @@ This needs to be reconfigured and restar
 <p>If you reconfigure Jackrabbit to use the new persistence manager, the existing repository
data in the <code>sling/jackrabbit</code> directory, except the <code>repository.xml</code>
file, of course, should now be removed.</p>
 <p>Finally either start Sling or start the Jackrabbit Embedded Repository bundle.</p>
 <h2 id="credits">Credits</h2>
-<p>This description is based on Tony Giaccone's description <a href="">Swapping
Postgres for Derby</a> sent to the Sling Users mailing list.</p>
+<p>This description is based on Tony Giaccone's description <a href="http://markmail.org/message/wlbfrukmjjsl33hh">Swapping
Postgres for Derby</a> sent to the Sling Users mailing list.</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1341347 by fmeschbe on Tue, 22 May 2012 08:25:18 +0000
+        Rev. 1345726 by fmeschbe on Sun, 3 Jun 2012 17:57:55 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project



Mime
View raw message