Commits

Greg Slepak committed 1373405

- renamed dragonfly_views to dragonfly_templates
- added dragonfly_errors
- creating awesome jQuery magical continue.html partial

Comments (0)

Files changed (14)

example-site/dragonfly-framework/plugins-active/dragonfly_basic.lsp

 ;; <p>Writes a title including the current navigation entry.</p>
 ;; 
 (define (title websitename)
-  (print (string (title-case (replace "_" viewname " ")) " " websitename  ))
+  (print (string (title-case (replace "_" (copy viewname) " ")) " " websitename  ))
 )
 
 ;; @syntax (Dragonfly:css <css-media> <css-location>)
 				setTimeout(function() {
 					if (load_text)
 						$(id).html(load_text);
-				}, 500);
+				}, 1000);
 				$.ajax({
 					url: "%s",
 					data: "%s",

example-site/views/404.html

 <body>
   <div class="dialog">
     <h1>We're sorry, but something went wrong. (404)</h1>
-    <p>We couldn't find the page or file You asked for. Start over right <a href="./">here</a>.</p>
+    <p>We couldn't find the page or file you asked for. Start over right <a href="/">here</a>.</p>
   </div>
 </body>
 </html>

example-site/views/500.html

 <body>
   <div class="dialog">
     <h1>We're sorry, but something went wrong.</h1>
-    <p>We've been notified about this issue and we'll take a look at it shortly. Start over right <a href="./">here</a>.</p>
+    <p>We've been notified about this issue and we'll take a look at it shortly. Start over right <a href="/">here</a>.</p>
 	<div class="backtrace">
 		<%=(join (parse (last (last-error)) "\n") "<br/>")%>
 	</div>

example-site/views/dragonfly_builtin_plugins.html

 			Have a look in the <span class="code">plugins-inactive/artfulcode</span> folder to see the included ones. Documentation for all of Jeff's modules can be found <a href="http://static.artfulcode.net/newlisp/">here</a>.
 		</p>
 		<h2>Misc</h2>
-		<p>
-			Additional plugins include:
-			<ul>
-				<li>nldb.lsp - a simple list-based database by <a href="http://unbalanced-parentheses.nfshost.com/">cormullion</a></li>
-				<li>path.lsp - a FOOP class for manipulating file paths</li>
-			</ul>
-		</p>
+		<p>Additional plugins include:</p>
+		<ul>
+			<li>nldb.lsp - a simple list-based database by <a href="http://unbalanced-parentheses.nfshost.com/">cormullion</a></li>
+			<li>path.lsp - a FOOP class for manipulating file paths</li>
+		</ul>
 		<h2>More Plugins</h2>
 		<p>
 			Modules make for excellent plugins! There's a <a href="http://www.newlisp.org/modules/">list</a> of available modules on newLISP's site. The newLISP distribution comes with a bunch of them, including functions for cryptography, SMTP, databases, and more!
 			If you have a plugin you'd like to contribute, let us know on the <a href="http://newlispfanclub.alh.net/forum/">newLISP forums</a>!
 		</p>
 		
-		<p class="continue"><% (link_to "CONTINUE &raquo;" "dragonfly_api") %></p>
-		<div class="clear"></div>
+		<% (display-partial "continue") %>
+		
 		<div class="line-dotted"></div>
 
 		<% (benchmark-result) %>

example-site/views/dragonfly_create_routes.html

 		<p>
 			If it does, it will attempt to display the file "index" by calling the <span class="code">DF:display-file</span> function with the path to the file.
 		</p>
-		<p class="continue"><% (link_to "CONTINUE &raquo;" "dragonfly_views") %></p>
-		<div class="clear"></div>
+		
+		<% (display-partial "continue") %>
+		
 		<div class="line-dotted"></div>
 
 		<% (benchmark-result) %>

example-site/views/dragonfly_errors.html

+<% (display-partial "doctype") %>
+<head>
+	<% (display-partial "header") %>
+</head>
+
+<body>
+
+<div id="wrap">
+	<div id="header">
+		<% (display-partial "navigation") %>	
+		<div class="clear"></div>
+	</div>
+
+	<div id="content">
+				
+		<div class="title nomargin">
+			<p><% (title "| Dragonfly web framework") %><p>
+		</div>
+		
+		<h1>Handling Errors</h1>
+		<p class="extract">blah blah blah</p>
+
+		<p>
+			blahbity blah blah blah
+		</p>
+		
+		
+		<% (display-partial "continue") %>
+		
+		<div class="line-dotted"></div>
+
+		<% (benchmark-result) %>
+		
+		<div class="line-dotted"></div>
+		
+		
+	</div><!-- END CONTENT -->
+	
+</div><!-- END WRAP -->
+<% (display-partial "footer") %>
+

example-site/views/dragonfly_plugins.html

 		<p class="info"><b>INFORMATION</b><br/>
 			Dragonfly overloads the <span class="code">load</span> function (which <span class="code">module</span> uses) to ensure that modules, like plugins, are loaded only once.
 		</p>
-		<p class="continue"><% (link_to "CONTINUE &raquo;" "dragonfly_builtin_plugins") %></p>
-		<div class="clear"></div>
+		
+		<% (display-partial "continue") %>
 		
 		<div class="line-dotted"></div>
 

example-site/views/dragonfly_routes.html

 				var req_url = '<%=(web-root "wings" (find "newLISP" SERVER_SOFTWARE))%>';
 				req_url += '/' + $('#wings_id').val();
 				req_url += $('#response_format').val();
-				$('#wings_request').html(req_url);
-				$('#wings_resp').html('loading...');
+				$('#wings_request').text(req_url);
+				$('#wings_resp').text('loading...');
 				$.ajax({
 					url: req_url,
 					success: function (data, status) {
-						$('#wings_resp').html(data);
+						$('#wings_resp').text(data);
 					},
 					error: function (xmlReq, status, error) {
-						$('#wings_resp').html('Error ' + xmlReq.status + '!');
+						$('#wings_resp').text('Error ' + xmlReq.status + '!');
 					}
 				});
 				return false;
 		<p>
 			Because of these considerations, as well as the complexities of supporting nested resources in a generic fashion, Dragonfly does not encourage this sort of design pattern by supporting it out-of-the-box. However, if you need such behavior, you've got everything you need to <%(link_to "create it" "dragonfly_create_routes")%>. :-)
 		</p>
-		<p class="continue"><% (link_to "CONTINUE &raquo;" "dragonfly_create_routes") %></p>
-		<div class="clear"></div>
+		
+		<% (display-partial "continue") %>
+		
 		<div class="line-dotted"></div>
 
 		<% (benchmark-result) %>

example-site/views/dragonfly_tables.html

 		<% (table_close) %>
 		<br/><br/>
 
-		<% (form-generate-from-columns "blog.nldb" entries) %>
+		<%  ; this doesn't work, therefore it's commented out until it's fixed
+			;(form-generate-from-columns "blog.nldb" entries)
+		%>
 		
 		<div class="line-dotted"></div>
 

example-site/views/dragonfly_templates.html

+<% (display-partial "doctype") %>
+<head>
+	<% (display-partial "header") %>
+</head>
+
+<body>
+
+<div id="wrap">
+	<div id="header">
+		<% (display-partial "navigation") %>	
+		<div class="clear"></div>
+	</div>
+
+	<div id="content">
+				
+		<div class="title nomargin">
+			<p><% (title "| Dragonfly web framework") %><p>
+		</div>
+		
+		<h1>Templates</h1>
+		<p class="extract">In Dragonfly, templates are files that have newLISP code embedded in them. This code is evaluated server-side, generating a final document that's presented to visitors.</p>
+
+		<p>
+			Templates can be anything, but usually they're html files with newLISP code embedded in them. When you download Dragonfly, take a look at the files in <span class="code">example-site/views</span>, those are all templates, but they're also referred to as <b>views</b>.
+		</p>
+		<p>
+			The term "view" comes from the V in MVC (<a href="http://en.wikipedia.org/wiki/Model–view–controller">model-view-controller</a>), a paradigm that Dragonfly follows only loosely (notably missing the 'model' aspect).
+		</p>
+		<p>
+			Views are typically used to represent the data of a <i>model</i>, but Dragonfly doesn't really care to enforce this (although you are certainly welcome to). In this document the term 'view' will be used to refer to templates in the directory specified by <span class="code">DF:VIEWS_PATH</span>.
+		</p>
+		<h2>Where routes come into the picture</h2>
+		<p>
+			<span class="code">Route.Static</span> (one of the <%(link_to "default views" "dragonfly_routes")%>) contains, by default, two request transformations for handling views:
+		</p>
+		<pre class="code">
+    (begin (set 'viewname _)
+           (string VIEWS_PATH "/" _))
+    (begin (set 'viewname _)
+           (string VIEWS_PATH "/" _ VIEW_EXTENSION))</pre>
+		<p>
+			The last transformation listed there is responsible for transforming a request to this URL:
+		</p>
+		<p><span class="code">http://rundragonfly.com/dragonfly_templates</span></p>
+		<p>Into a request for this file:</p>
+		<p><span class="code">/home/www/rundragonfly.com/views/dragonfly_templates.html</span></p>
+		<p>All of the files handled by <span class="code">Route.Static</span> eventually get passed through the function <span class="code">eval-template</span>, which searches for any newLISP code between <span class="code">OPEN_TAG</span> and <span class="code">CLOSE_TAG</span> and evaluates it.</p>
+		<h2>Writing templates</h2>
+		<p>
+			By default, the <span class="code">OPEN_TAG</span> is <span class="code">&lt;%</span> and the <span class="code">CLOSE_TAG</span> is <span class="code">%&gt;</span>. Let's say we want to create an HTML file that displays the current time on the server, we might go about it like this:
+		</p>
+<pre class="code">
+&lt;html&gt;
+&lt;body&gt;
+	The time is: &lt;% (date) %&gt;
+&lt;/body&gt;
+&lt;/html&gt;</pre>
+		<p>
+			That, however, will result in a page that says:
+		</p>
+		<div class="resultbox">
+			The time is: 
+		</div>
+		<p>
+			That's because evaluated expressions do not output anything unless they call <span class="code">print</span> or <span class="code">println</span>. We can fix it by rewriting it like so:
+		</p>
+		<pre class="code">The time is: &lt;% (print (date)) %&gt;</pre>
+		<div class="resultbox">
+			The time is: <% (print (date)) %>
+		</div>
+		<p>
+			You can append an equals sign after the <span class="code">OPEN_TAG</span> to achieve the same result in fewer keystrokes:
+		</p>
+		<pre class="code">The time is: &lt;%= (date) %&gt;</pre>
+		<div class="resultbox">
+			The time is: <%= (date) %>
+		</div>
+		<p class="info"><b>INFORMATION</b><br/>You can use all functions from newLISP and Dragonfly (<%(link_to "api" "dragonfly_api")%>), as well as functions provided by <%(link_to "plugins" "dragonfly_plugins")%>.</p>
+		<h2>Configuration</h2>
+		<p>
+			Below is a list of configuration parameters that you'll find in <b>config.lsp</b> related to templates.
+		</p>
+		<h3 class="param">OPEN_TAG</h3>
+		<p>Default value: <span class="code"><b>"&lt;%"</b></span></p>
+		<h3 class="param">CLOSE_TAG</h3>
+		<p>Default value: <span class="code"><b>"%&gt;"</b></span></p>
+		<h3 class="param">VIEWS_PATH</h3>
+		<p>Default value: <span class="code"><b>(string DOCUMENT_ROOT "/views")</b></span></p>
+		<p>
+			The location of views (for use with 'display-view' function).
+		</p>
+		
+		<h3 class="param">PARTIALS_PATH</h3>
+		<p>Default value: <span class="code"><b>(string DOCUMENT_ROOT "/views/partials")</b></span></p>
+		<p>
+			The location of partials (for use with 'display-partial' function).
+		</p>
+		
+		<h3 class="param">DEFAULT_VIEW</h3>
+		<p>Default value: <span class="code"><b>"welcome"</b></span></p>
+		<p>
+			The default view (when a user visits '/') sans file extension.
+		</p>
+		
+		<h3 class="param">VIEW_EXTENSION</h3>
+		<p>Default value: <span class="code"><b>".html"</b></span></p>
+		<p>
+			Used by one of the transformations in <span class="code">Route.Static</span> so that a request to <span class="code">/welcome</span> loads the file <span class="code">/views/welcome.html</span>.
+		</p>
+		
+		<% (display-partial "continue") %>
+		
+		<div class="line-dotted"></div>
+
+		<% (benchmark-result) %>
+		
+		<div class="line-dotted"></div>
+		
+		
+	</div><!-- END CONTENT -->
+	
+</div><!-- END WRAP -->
+<% (display-partial "footer") %>
+

example-site/views/dragonfly_views.html

-<% (display-partial "doctype") %>
-<head>
-	<% (display-partial "header") %>
-</head>
-
-<body>
-
-<div id="wrap">
-	<div id="header">
-		<% (display-partial "navigation") %>	
-		<div class="clear"></div>
-	</div>
-
-	<div id="content">
-				
-		<div class="title nomargin">
-			<p><% (title "| Dragonfly web framework") %><p>
-		</div>
-		
-		<h1>Templates</h1>
-		<p class="extract">In Dragonfly, templates are files that have newLISP code embedded in them. This code is evaluated server-side, generating a final document that's presented to visitors.</p>
-
-		<p>
-			Templates can be anything, but usually they're html files with newLISP code embedded in them. When you download Dragonfly, take a look at the files in <span class="code">example-site/views</span>, those are all templates, but they're also referred to as <b>views</b>.
-		</p>
-		<p>
-			The term "view" comes from the V in MVC (<a href="http://en.wikipedia.org/wiki/Model–view–controller">model-view-controller</a>), a paradigm that Dragonfly follows only loosely (notably missing the 'model' aspect).
-		</p>
-		<p>
-			Views are typically used to represent the data of a <i>model</i>, but Dragonfly doesn't really care to enforce this (although you are certainly welcome to). In this document the term 'view' will be used to refer to templates in the directory specified by <span class="code">DF:VIEWS_PATH</span>.
-		</p>
-		<h2>Where routes come into the picture</h2>
-		<p>
-			<span class="code">Route.Static</span> (one of the <%(link_to "default views" "dragonfly_routes")%>) contains, by default, two request transformations for handling views:
-		</p>
-		<pre class="code">
-    (begin (set 'viewname _)
-           (string VIEWS_PATH "/" _))
-    (begin (set 'viewname _)
-           (string VIEWS_PATH "/" _ VIEW_EXTENSION))</pre>
-		<p>
-			The last transformation listed there is responsible for transforming a request to this URL:
-		</p>
-		<p><span class="code">http://rundragonfly.com/dragonfly_views</span></p>
-		<p>Into a request for this file:</p>
-		<p><span class="code">/home/www/rundragonfly.com/views/dragonfly_views.html</span></p>
-		<p>All of the files handled by <span class="code">Route.Static</span> eventually get passed through the function <span class="code">eval-template</span>, which searches for any newLISP code between <span class="code">OPEN_TAG</span> and <span class="code">CLOSE_TAG</span> and evaluates it.</p>
-		<h2>Writing templates</h2>
-		<p>
-			By default, the <span class="code">OPEN_TAG</span> is <span class="code">&lt;%</span> and the <span class="code">CLOSE_TAG</span> is <span class="code">%&gt;</span>. Let's say we want to create an HTML file that displays the current time on the server, we might go about it like this:
-		</p>
-<pre class="code">
-&lt;html&gt;
-&lt;body&gt;
-	The time is: &lt;% (date) %&gt;
-&lt;/body&gt;
-&lt;/html&gt;</pre>
-		<p>
-			That, however, will result in a page that says:
-		</p>
-		<div class="resultbox">
-			The time is: 
-		</div>
-		<p>
-			That's because evaluated expressions do not output anything unless they call <span class="code">print</span> or <span class="code">println</span>. We can fix it by rewriting it like so:
-		</p>
-		<pre class="code">The time is: &lt;% (print (date)) %&gt;</pre>
-		<div class="resultbox">
-			The time is: <% (print (date)) %>
-		</div>
-		<p>
-			You can append an equals sign after the <span class="code">OPEN_TAG</span> to achieve the same result in fewer keystrokes:
-		</p>
-		<pre class="code">The time is: &lt;%= (date) %&gt;</pre>
-		<div class="resultbox">
-			The time is: <%= (date) %>
-		</div>
-		<p class="info"><b>INFORMATION</b><br/>You can use all functions from newLISP and Dragonfly (<%(link_to "api" "dragonfly_api")%>), as well as functions provided by <%(link_to "plugins" "dragonfly_plugins")%>.</p>
-		<h2>Configuration</h2>
-		<p>
-			Below is a list of configuration parameters that you'll find in <b>config.lsp</b> related to templates.
-		</p>
-		<h3 class="param">OPEN_TAG</h3>
-		<p>Default value: <span class="code"><b>"&lt;%"</b></span></p>
-		<h3 class="param">CLOSE_TAG</h3>
-		<p>Default value: <span class="code"><b>"%&gt;"</b></span></p>
-		<h3 class="param">VIEWS_PATH</h3>
-		<p>Default value: <span class="code"><b>(string DOCUMENT_ROOT "/views")</b></span></p>
-		<p>
-			The location of views (for use with 'display-view' function).
-		</p>
-		
-		<h3 class="param">PARTIALS_PATH</h3>
-		<p>Default value: <span class="code"><b>(string DOCUMENT_ROOT "/views/partials")</b></span></p>
-		<p>
-			The location of partials (for use with 'display-partial' function).
-		</p>
-		
-		<h3 class="param">DEFAULT_VIEW</h3>
-		<p>Default value: <span class="code"><b>"welcome"</b></span></p>
-		<p>
-			The default view (when a user visits '/') sans file extension.
-		</p>
-		
-		<h3 class="param">VIEW_EXTENSION</h3>
-		<p>Default value: <span class="code"><b>".html"</b></span></p>
-		<p>
-			Used by one of the transformations in <span class="code">Route.Static</span> so that a request to <span class="code">/welcome</span> loads the file <span class="code">/views/welcome.html</span>.
-		</p>
-		<p class="continue"><% (link_to "CONTINUE &raquo;" "dragonfly_plugins") %></p>
-		<div class="clear"></div>
-		<div class="line-dotted"></div>
-
-		<% (benchmark-result) %>
-		
-		<div class="line-dotted"></div>
-		
-		
-	</div><!-- END CONTENT -->
-	
-</div><!-- END WRAP -->
-<% (display-partial "footer") %>
-

example-site/views/dragonfly_welcome.html

 
 		<h3 class="code">Step 3: That's it!</h3>
 		<p>You're ready to run Dragonfly!</p>
-		<p class="continue"><% (link_to "CONTINUE &raquo;" "dragonfly_routes") %></p>
-		<div class="clear"></div>
+		
+		<% (display-partial "continue") %>
+		
 		<div class="line-dotted"></div>
 
 		<% (benchmark-result) %>

example-site/views/partials/continue.html

+<p class="continue"><a id="continue_link" href="">CONTINUE &raquo;</a></p>
+<div class="clear"></div>
+
+<script type="text/javascript" charset="utf-8">
+	$('#continue_link').attr('href', function () {
+		var viewpath = "<%=(web-root viewname (find {newLISP} SERVER_SOFTWARE))%>";
+		var ourlink = $("#user_guide_menu dd > a[href='"+viewpath+"']:first");
+		var nextlink = ourlink.parent().nextAll('dd:first').children('a:first').not(ourlink);
+		// if there's a next link in the current column return its href
+		// otherwise return the first link from the next nav column over
+		if ( nextlink.length !== 0 )
+			return nextlink.attr('href');
+		else
+			return ourlink.parent().parent().next().find('dd a:first').attr('href');
+	});
+</script>

example-site/views/partials/navigation.html

 	<li><% (link_to "Welcome" "welcome") %></li>
 	<li>
 		<a href="#" class="menu_toggle">User Guide</a> 
-		<div class="menu clearfix" style="display:none;">
+		<div id="user_guide_menu" class="menu clearfix" style="display:none;">
 			<dl class="L">
 				<dt>Getting started</dt>
 				<dd><% (link_to  "Setting up Dragonfly" "dragonfly_welcome") %></dd>
 				<dd><% (link_to  "Creating your own routes" "dragonfly_create_routes") %></dd>
 				
 				<dt>Templates</dt>
-				<dd><% (link_to  "Creating templates and views" "dragonfly_views") %></dd>
+				<dd><% (link_to  "Creating templates and views" "dragonfly_templates") %></dd>
+				<dd><% (link_to  "Handling errors using templates" "dragonfly_errors") %></dd>
 				
 				<dt>Plugins</dt>
 				<dd><% (link_to  "Using and creating plugins" "dragonfly_plugins") %></dd>