User:Lindenb/Notebook/UMR915/20110616

From OpenWetWare
Jump to: navigation, search
Owwnotebook icon.png

20110615        Top        20110628       


SLING

download sling standalone http://mirror.mkhelif.fr/apache//sling/org.apache.sling.launchpad-6-standalone.jar 35.1 (Mo)

Start the server:
java -jar org.apache.sling.launchpad-6-standalone.jar 
16.06.2011 21:32:54.972 *INFO* [main] Setting sling.home=sling (default)
16.06.2011 21:32:54.974 *INFO* [main] Starting Sling in sling (/home/lindenb/tmp/SLING/sling)
16.06.2011 21:32:55.001 *INFO* [main] Checking launcher JAR in folder sling
16.06.2011 21:32:55.022 *INFO* [main] Installing new launcher: jar:file:/home/lindenb/tmp/SLING/org.apache.sling.launchpad-6-standalone.jar!/resources/org.apache.sling.launchpad.base.jar, 2.3.0 (org.apache.sling.launchpad.base.jar.1308252775021)
16.06.2011 21:32:55.023 *INFO* [main] Loading launcher class org.apache.sling.launchpad.base.app.MainDelegate from org.apache.sling.launchpad.base.jar.1308252775021
16.06.2011 21:32:55.067 *INFO* [main] Starting launcher ...
16.06.2011 21:32:55.073 *INFO* [main] HTTP server port: 8080
16.06.2011 21:32:57.722 *INFO* [main] Startup completed

Sling20110616a.jpg

$ curl -u admin:admin -F"sling:resourceType=fo-F"title=MyTitle" http://localhost:8080/content/mynode

<html>

   <h1>Content created /content/mynode</h1>
   <table>
       <tbody>
           <tr>
               <td>Status</td>
               <td><div id="Status">201</div></td>
           </tr>
           <tr>
               <td>Message</td>
               <td><div id="Message">Created</div></td>
           </tr>
           <tr>
               <td>Location</td>
               <td><a href="/mynode" id="Location">/mynode</a></td>
           </tr>
           <tr>
               <td>Parent Location</td>
               <td><a href="/content" id="ParentLocation">/content</a></td>
           </tr>
           <tr>
               <td>Path</td>
               <td><div id="Path">/content/mynode</div></td>
           </tr>
           <tr>
               <td>Referer</td>
               <td><a href="" id="Referer"></a></td>
           </tr>
           <tr>
               <td>ChangeLog</td>
               <td><div id="ChangeLog"><pre>created("/content");<br/>created("/content/mynode");<br/>modified("/content/mynode/sling:resourceType");<br/>modified("/content/mynode/title");<br/></pre></div></td>
           </tr>
       </tbody>
   </table>
   <p><a href="">Go Back</a></p>
   <p><a href="/mynode">Modified Resource</a></p>
   <p><a href="/content">Parent of Modified Resource</a></p>
</html>

Looking at: http://localhost:8080/mynode/sling:resourceType returns a text/plain file:

foo/bar

Looking at: http://localhost:8080/mynode/title returns a text/plain file:

MyTitle

http://localhost:8080/mynode/ returns a 403

http://localhost:8080/content/mynode.html returns HTML:

<html><h1>Resource dumped by HtmlRendererServlet</h1>

<p>Resource path: <b>/content/mynode</b></p> <p>Resource metadata: <b>{sling.resolutionPathInfo=.html, sling.resolutionPath=/content/mynode}</b></p> <p>Resource type: <b>foo/bar</b></p> <p>Resource super type: <b>-</b></p>

<h2>Resource properties</h2> <p> title: <b>MyTitle</b><br /> sling:resourceType: <b>foo/bar</b><br /> jcr:primaryType: <b>nt:unstructured</b><br />

</p></html>

http://localhost:8080/content/mynode.json returns:

{
"title":"MyTitle",
"sling:resourceType":"foo/bar",
"jcr:primaryType":"nt:unstructured"
}

http://localhost:8080/content/mynode.xml returns:

<?xml version="1.0" encoding="UTF-8"?>
<mynode jcr:primaryType="nt:unstructured" sling:resourceType="foo/bar" title="MyTitle" xmlns:ocm="http://jackrabbit.apache.org/ocm" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:fn_old="http://www.w3.org/2004/10/xpath-functions" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:slingevent="http://sling.apache.org/jcr/event/1.0" xmlns:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:rep="internal" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"/>


curl -X MKCOL -u admin:admin http://localhost:8080/apps/foo ( -X/--request <command> Specify request command to use ) curl -X MKCOL -u admin:admin http://localhost:8080/apps/foo/bar

edit file: html.esp:

<html>
  <body>
    <div style="background-color:orange;">
    <h1><%= currentNode.title %></h1>
    <img src="http://sling.apache.org/site/media.data/logo.png"/>
    </div>
  </body>
</html>

upload html.esp curl -u admin:admin -T html.esp http://localhost:8080/apps/foo/bar/html.esp

now http://localhost:8080/mynode.html returns: <html><div style="background-color:orange;"> <h1>MyTitle</h1> <img src="http://sling.apache.org/site/media.data/logo.png"/> </div></html>

Trying SVG:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   xmlns="http://www.w3.org/2000/svg"
   width="500"
   height="500"
   version="1.1"
   >
	<text transform="rotate(12)" x="50" y="50" style="font-size:20px;">
	<%= currentNode.title %>
	</text>
</svg>

curl -u admin:admin -T html.esp http://localhost:8080/apps/foo/bar/svg.esp fails to returns the SVG doc. The HTML document is returned ,not SVG.