Marc Hildmann  committed 67a60ec

Updated routes page. Added styles for displaying code, information and configuration boxes.

  • Participants
  • Parent commits 65299c7
  • Branches default

Comments (0)

Files changed (2)

File example-site/includes/css/screen.css

 	/* Code Styling */
-	#content p.code {
+	#content pre.code {
+		width:auto;
+		margin-top:10px;
-		font-size:12px;
+		font-size:10px;

File example-site/views/dragonfly_routes

 		<h2>RESTful Routes</h2>
-		<p>Here comes a description about RESTful routes in Dragonfly.</p>
+		<p class="extract">Dragonfly supports RESTful resources. This way it's flexible against any kind of request to Your application.</p>
+		<p>When your Dragonfly application receives an incoming HTTP request, say
+		<p class="code">GET /wings/show</p>
+		<p>
+		the <b>LISTENER</b> within Dragonfly is the piece of code that dispatches the request to the appropriate spot in your application. In this case, the application would most likely end up running the <b>SHOW</b> action within the <b>WINGS</b> resource, displaying the WINGS.</p>
+		<p class="info">The resource <b>WINGS</b> has to be available in Your resource directory</p>
+		<h3 class="code">Example of wings.lsp in /resources</h3>
+		<pre class="code">
+;; @author Greg Slepak
+(DF:activate-plugin "artfulcode/json")
+(context 'Resource.Wings)
+(set 'my-data
+	'((wings (left right))
+	(wings-condition ("good" "excellent"))
+	(wings-opacity 0.5))
+(define (Resource.Wings:Resource.Wings response-format)
+	; defaults to calling show
+	(show response-format)
+(define (show response-format)
+	(if (= response-format "json")
+		(begin
+			(Response:content-type Response:json-type)
+			(print (Json:lisp->json my-data))
+		)
+		(begin
+			(Response:content-type Response:text-type)
+			(print my-data)
+		)
+	)
+(context MAIN)			
+		</pre>
+		<p class="config"><b>Configuration</b><br/>You may enable or disable RESTful handling by setting the constant ENABLE_RESTFUL_HANDLER in config.lsp. Default is set to "true".</p>
+		<p class="config"><b>Configuration</b><br/>Set Your resource directory to whatever You want by changing the constant RESOURCES_PATH in config.lsp. Default is set to "/resources".</p>	
 		<h2>Using views</h2>
 		<p class="extract">A view is simply a web page, or a page fragment, like a header or footer. In fact, views can flexibly be embedded within other views. In that case we call them partials.</p>
 		<h3 class="code">How to load a view</h3>
 		<p>Example: open Your favorite text-editor and enter the following:</p>
-		<p class="code">
-			Hello World
-		</p>
+		<pre class="code">Hello World</pre>
 		<p>Save the file as "hello" into Your views directory. Now open Your browser and navigate to <a href=""></a>. That's it!</p>
 		<p class="info"><b>Information</b><br/>You can put nearly everything into views: (X)HTML, Javascript, newLISP code.</p>
 		<p class="config"><b>Configuration</b><br/>If VIEW_EXTENSION is ".html" for example, then when is called Dragonfly will search for a "hello.html" file in the VIEWS_PATH. It also applies to the partials, too.</p>
+		<h3 class="code">How to call functions inside a view</h3>
+		<pre class="code">&lt;% (benchmark-result) %&gt;</pre>
+		<p>Put Your function call inside our open and close brackets and there You go! That will display some stats about rendering time and memory consumption.</p>
+		<p class="info"><b>Information</b><br/>You can use all functions from newLISP and Dragonfly. Additionally You may write Your own functions inside a plugin and just put the file into the "plugins-active" directory.</p>
 		<h3 class="code">How to load a partial view</h3>
-		<p class="code">
-			(display-partial "header")
-		</p>
+		<pre class="code">&lt;% (display-partial "header") %&gt;</pre>
 		<p>This simple argument would load the "header"-partial from the partials directory.</p>
 		<div class="line-dotted"></div>