User:Lindenb/Notebook/UMR915/20110616

From OpenWetWare
Jump to navigationJump to search

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

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

<html>

Content created /content/mynode

<tbody> </tbody>
Status
201
Message
Created
Location <a href="/mynode" id="Location">/mynode</a>
Parent Location <a href="/content" id="ParentLocation">/content</a>
Path
/content/mynode
Referer <a href="" id="Referer"></a>
ChangeLog
created("/content");<br/>created("/content/mynode");<br/>modified("/content/mynode/sling:resourceType");<br/>modified("/content/mynode/title");<br/>

<a href="">Go Back</a>

<a href="/mynode">Modified Resource</a>

<a href="/content">Parent of Modified Resource</a>

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

Resource dumped by HtmlRendererServlet

Resource path: /content/mynode

Resource metadata: {sling.resolutionPathInfo=.html, sling.resolutionPath=/content/mynode}

Resource type: foo/bar

Resource super type: -

Resource properties

title: MyTitle
sling:resourceType: foo/bar
jcr:primaryType: nt:unstructured

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

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