Commits

Greg Slepak committed 9f0cdb6

added docs on DFLY_SELF and added new DFLY_PAGE

Comments (0)

Files changed (5)

   * added utf8-urlencode/decode functions to Request, they handle foreign characters perfectly.
   * much improved the smtp module that comes with newLISP and added it to the inactive plugins.
   * added 'SET_DFLY_SELF' function and the corresponding DFLY_SELF and DFLY_SELF_DIR global symbols.
+  * added 'DFLY_PAGE' to point to the currently loaded, host-unqualified web URL
 
 Version 0.51
 

example-site/dragonfly-api/dragonfly.lsp.html

 
 
 
+<br/><br/><center>- &sect; -</center><br/>
+<a name="_DFLY_PAGE"></a><h3><font color=#CC0000>DFLY_PAGE</font></h3>
+<b>syntax: DFLY_PAGE</b><br/>
+ <p>The web-friendly, host-unqualified URL to the "current page"</p>
+ <pre> ; load http://www.mysite.com/foo/bar?baz
+ DFLY_PAGE ;=> "/foo/bar"
+ ; load http://www.mysite.com
+ DFLY_PAGE ;=> "/"</pre>
+
+<br/><br/><center>- &sect; -</center><br/>
+<a name="_DFLY_SELF"></a><h3><font color=#CC0000>DFLY_SELF</font></h3>
+<b>syntax: DFLY_SELF</b><br/>
+ <p>The full, local path (on the server) to the currently loaded file
+ or view being displayed.</p>
+ <b>example:</b>
+ <pre> ; load http://www.mysite.com/foo/bar?baz
+ DFLY_SELF ;=> "/home/www/mysite.com/foo/bar.html"</pre>
+ <b>see:</b> the <tt>SET_DFLY_SELF</tt> function in utils.lsp for more info
+
+<br/><br/><center>- &sect; -</center><br/>
+<a name="_DFLY_SELF_DIR"></a><h3><font color=#CC0000>DFLY_SELF_DIR</font></h3>
+<b>syntax: DFLY_SELF_DIR</b><br/>
+ <p>The full, local path (on the server) to the directory holding
+ the currently loaded file or view being displayed.</p>
+ <b>example:</b>
+ <pre> ; load http://www.mysite.com/foo/bar?baz
+ DFLY_SELF_DIR ;=> "/home/www/mysite.com/foo/"</pre>
+ <b>see:</b> the <tt>SET_DFLY_SELF</tt> function in utils.lsp for more info
+
 
 
 

example-site/dragonfly-api/index.html

 <center><h1>Index</h1></center>
 <a href="dragonfly.lsp.html"><br/><br/><h2>Module:&nbsp;dragonfly.lsp</h2></a>
 <p>The heart of Dragonfly - A newLISP web framework for rapid web development.</p>
-<a href="dragonfly.lsp.html#_STDOUT">STDOUT</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_activate-plugin">activate-plugin</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_web-root">web-root</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_view-path">view-path</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_partial-path">partial-path</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_resource-path">resource-path</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_include">include</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_display-file">display-file</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_display-partial">display-partial</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_display-view">display-view</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_display-error">display-error</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_eval-template">eval-template</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_die">die</a>&nbsp; &nbsp; <a href="log.lsp.html"><br/><br/><h2>Module:&nbsp;log.lsp</h2></a>
+<a href="dragonfly.lsp.html#_DFLY_PAGE">DFLY_PAGE</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#_DFLY_SELF">DFLY_SELF</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#_DFLY_SELF_DIR">DFLY_SELF_DIR</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#_STDOUT">STDOUT</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_activate-plugin">activate-plugin</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_web-root">web-root</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_view-path">view-path</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_partial-path">partial-path</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_resource-path">resource-path</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_include">include</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_display-file">display-file</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_display-partial">display-partial</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_display-view">display-view</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_display-error">display-error</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_eval-template">eval-template</a>&nbsp; &nbsp; <a href="dragonfly.lsp.html#Dragonfly_die">die</a>&nbsp; &nbsp; <a href="log.lsp.html"><br/><br/><h2>Module:&nbsp;log.lsp</h2></a>
 <p>Provides convenient logging facility for all of Dragonfly.</p>
 <a href="log.lsp.html#Dragonfly_log-func">log-func</a>&nbsp; &nbsp; <a href="log.lsp.html#Dragonfly_log-debug">log-debug</a>&nbsp; &nbsp; <a href="log.lsp.html#Dragonfly_log-info">log-info</a>&nbsp; &nbsp; <a href="log.lsp.html#Dragonfly_log-warn">log-warn</a>&nbsp; &nbsp; <a href="log.lsp.html#Dragonfly_log-err">log-err</a>&nbsp; &nbsp; <a href="request.lsp.html"><br/><br/><h2>Module:&nbsp;request.lsp</h2></a>
 <p></p>
 <p></p>
 <a href="response.lsp.html#Response_status">status</a>&nbsp; &nbsp; <a href="response.lsp.html#Response_header">header</a>&nbsp; &nbsp; <a href="response.lsp.html#Response_cookie">cookie</a>&nbsp; &nbsp; <a href="response.lsp.html#Response_send-headers">send-headers</a>&nbsp; &nbsp; <a href="response.lsp.html#Response_redirect">redirect</a>&nbsp; &nbsp; <a href="response.lsp.html#Response_send-headers-with-status">send-headers-with-status</a>&nbsp; &nbsp; <a href="response.lsp.html#Response_content-type">content-type</a>&nbsp; &nbsp; <a href="response.lsp.html#Response_extension->type">extension->type</a>&nbsp; &nbsp; <a href="utils.lsp.html"><br/><br/><h2>Module:&nbsp;utils.lsp</h2></a>
 <p></p>
-<a href="utils.lsp.html#_add-to-load-path">add-to-load-path</a>&nbsp; &nbsp; <a href="utils.lsp.html#_regex-captcha">regex-captcha</a>&nbsp; &nbsp; <a href="utils.lsp.html#_load-files-in-dir">load-files-in-dir</a>&nbsp; &nbsp; <a href="utils.lsp.html#_wrap-func">wrap-func</a>&nbsp; &nbsp; <a href="utils.lsp.html#_into-ctx-assoc">into-ctx-assoc</a>&nbsp; &nbsp; <a href="utils.lsp.html#_NEWLISP64">NEWLISP64</a>&nbsp; &nbsp; <a href="utils.lsp.html#_get-ptr">get-ptr</a>&nbsp; &nbsp; <a href="utils.lsp.html#_throw-not-implemented">throw-not-implemented</a>&nbsp; &nbsp; <a href="ObjNL.lsp.html"><br/><br/><h2>Module:&nbsp;ObjNL.lsp</h2></a>
+<a href="utils.lsp.html#_add-to-load-path">add-to-load-path</a>&nbsp; &nbsp; <a href="utils.lsp.html#_regex-captcha">regex-captcha</a>&nbsp; &nbsp; <a href="utils.lsp.html#_load-files-in-dir">load-files-in-dir</a>&nbsp; &nbsp; <a href="utils.lsp.html#_wrap-func">wrap-func</a>&nbsp; &nbsp; <a href="utils.lsp.html#_into-ctx-assoc">into-ctx-assoc</a>&nbsp; &nbsp; <a href="utils.lsp.html#_SET_DFLY_SELF">SET_DFLY_SELF</a>&nbsp; &nbsp; <a href="utils.lsp.html#_NEWLISP64">NEWLISP64</a>&nbsp; &nbsp; <a href="utils.lsp.html#_get-ptr">get-ptr</a>&nbsp; &nbsp; <a href="utils.lsp.html#_throw-not-implemented">throw-not-implemented</a>&nbsp; &nbsp; <a href="ObjNL.lsp.html"><br/><br/><h2>Module:&nbsp;ObjNL.lsp</h2></a>
 <p>Objective newLISP - Real Object Oriented Programming for newLISP</p>
 <a href="ObjNL.lsp.html#_ObjNL">ObjNL</a>&nbsp; &nbsp; <a href="ObjNL.lsp.html#ObjNL_ObjNL">ObjNL</a>&nbsp; &nbsp; <a href="ObjNL.lsp.html#ObjNL_dealloc">dealloc</a>&nbsp; &nbsp; <a href="ObjNL.lsp.html#ObjNL_equals">equals</a>&nbsp; &nbsp; <a href="ObjNL.lsp.html#_new-class">new-class</a>&nbsp; &nbsp; <a href="ObjNL.lsp.html#_instantiate">instantiate</a>&nbsp; &nbsp; <a href="ObjNL.lsp.html#_add-interface">add-interface</a>&nbsp; &nbsp; <a href="ObjNL.lsp.html#_deallocate">deallocate</a>&nbsp; &nbsp; <a href="ObjNL.lsp.html#_implements?">implements?</a>&nbsp; &nbsp; <a href="ObjNL.lsp.html#_retain">retain</a>&nbsp; &nbsp; <a href="ObjNL.lsp.html#_release">release</a>&nbsp; &nbsp; <a href="ObjNL.lsp.html#_autorelease">autorelease</a>&nbsp; &nbsp; <a href="ObjNL.lsp.html#_push-autorelease-pool">push-autorelease-pool</a>&nbsp; &nbsp; <a href="ObjNL.lsp.html#_pop-autorelease-pool">pop-autorelease-pool</a>&nbsp; &nbsp; <a href="ObjNL.lsp.html#_.">.</a>&nbsp; &nbsp; <a href="ObjNL.lsp.html#_.&">.&</a>&nbsp; &nbsp; 
 <br/><br/><center>- &part; -</center><br/>

example-site/dragonfly-api/utils.lsp.html

  ))</pre>
 <br/><br/>
 <br/><br/><center>- &sect; -</center><br/>
+<a name="_SET_DFLY_SELF"></a><h3><font color=#CC0000>SET_DFLY_SELF</font></h3>
+<b>syntax: (<font color=#CC0000>SET_DFLY_SELF</font> <em>str-filepath</em>)</b><br/>
+<b>parameter: </b><em>str-filepath</em> - The path to the file being served, or the primary file responsible for handling this route.<br/>
+ <p>Routes should call this global function with the path to the file that's being displayed
+ or the file that's principly in charge of handling this route. This function will then
+ set the global variables <tt>DFLY_SELF</tt> and <tt>DFLY_SELF_DIR</tt> to point to that file and its
+ parent directory, respectively.</p>
+ <p>The default routes <tt>Route.Static</tt> and <tt>Route.Resource</tt> call this function first thing
+ in their <tt>Route:run</tt> methods, prior to loading the files. This is the recommended way of
+ calling this function.</p>
+<br/><br/><center>- &sect; -</center><br/>
 <a name="_NEWLISP64"></a><h3><font color=#CC0000>NEWLISP64</font></h3>
 <b>syntax: NEWLISP64</b><br/>
  <p>A constant that is <tt>true</tt> if we're running the 64-bit version of newLISP.</p>

example-site/dragonfly-framework/dragonfly.lsp

 	(env "QUERY_STRING" QUERY_STRING)
 )
 
+;; @syntax DFLY_PAGE
+;; <p>The web-friendly, host-unqualified URL to the "current page"</p>
+;; <pre> ; load http://www.mysite.com/foo/bar?baz
+;; DFLY_PAGE ;=> "/foo/bar"
+;; ; load http://www.mysite.com
+;; DFLY_PAGE ;=> "/"</pre>
+(if (empty? QUERY_STRING)
+	(constant (global 'DFLY_PAGE) "/")
+	(constant (global 'DFLY_PAGE) ((parse QUERY_STRING {[?&]} 0) 0))
+)
+
+;; @syntax DFLY_SELF
+;; <p>The full, local path (on the server) to the currently loaded file
+;; or view being displayed.</p>
+;; <b>example:</b>
+;; <pre> ; load http://www.mysite.com/foo/bar?baz
+;; DFLY_SELF ;=> "/home/www/mysite.com/foo/bar.html"</pre>
+;; <b>see:</b> the 'SET_DFLY_SELF' function in utils.lsp for more info
+
+;; @syntax DFLY_SELF_DIR
+;; <p>The full, local path (on the server) to the directory holding
+;; the currently loaded file or view being displayed.</p>
+;; <b>example:</b>
+;; <pre> ; load http://www.mysite.com/foo/bar?baz
+;; DFLY_SELF_DIR ;=> "/home/www/mysite.com/foo/"</pre>
+;; <b>see:</b> the 'SET_DFLY_SELF' function in utils.lsp for more info
+
 ; seed the random number generator immediately.
 (seed (time-of-day))
 
 (context Route.Static)
 
 (define (matches?)
-	(set 'chunks (parse QUERY_STRING {[\?&]} 0))
+	(set 'chunks (parse QUERY_STRING {[?&]} 0))
 	(if (empty? chunks)
 		(push DF:DEFAULT_VIEW chunks))
 	(set 'path (set 'DF:_ (first chunks)))