Anonymous avatar Anonymous committed 67a60ec

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

Comments (0)

Files changed (2)

example-site/includes/css/screen.css

 
 	/* Code Styling */
 
-	#content p.code {
+	#content pre.code {
+		width:auto;
+		margin-top:10px;
 		padding:10px;
 		background:#333333;
 		font-family:Courier;
-		font-size:12px;
+		font-size:10px;
 		color:#ffffff;
 	}
 

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="http://www.example-site.com/hello">example-site.com/hello</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 example-site.com/hello 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>
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.