Clarify the concept of what a default route to on-new-window handler is

This commit is contained in:
David Botton 2022-04-10 16:20:24 -04:00
parent bde06426a0
commit 90595e50aa
3 changed files with 20 additions and 8 deletions

View file

@ -94,11 +94,11 @@ example."
(defun set-on-new-window (on-new-window-handler
&key (path "/") (boot-file "/boot.html"))
"Set or change the on-new-window handler or set a new one for PATH
using BOOT_FILE. Paths should always begin with a '/'. If PATH is set to
\"default\" will use boot-file when the route can not be determined, ie
a static html file including boot.js that has not been added with this
function. If BOOT-FILE is nil path is removed."
"Set or change the ON-NEW-WINDOW-HANDLER for PATH using
BOOT_FILE. Paths should always begin with a forward slash '/'. If PATH
is set to \"default\" any path without another route and there is no
static file matching the requested path ON-NEW-WINDOW-HANDLER and
BOOT-FILE will be used. If BOOT-FILE is nil path is removed."
(clog-connection:set-clog-path path boot-file)
(if boot-file
(setf (gethash path *url-to-on-new-window*) on-new-window-handler)

View file

@ -0,0 +1,10 @@
<html>
<head>
<script src="/js/jquery.min.js" type="text/javascript"></script>
<script src="/js/boot.js" type="text/javascript"></script>
</head>
<body>
<p>I am just a regular file but I include boot.js. I am in the static-root
of the tutorial and demo apps.</p>
</body>
</html>

View file

@ -38,6 +38,7 @@
<li><a href='/page2'>/page2</a> - a CLOG app using an alternative boot file
<li><a href='/page3'>/page3</a> - tutorial 11 as part of this tutorial
<li><a href='/tutorial/tut-11.html'>/tutorial/tut-11.html</a> - an html file using boot.js
<li><a href='/tutorial/some-file.html'>/tutorial/some-file.html</a> - an html file using boot.js
<li><a href='/tutorial/regular-file.html'>'/tutorial/regular-file.html</a> - a regular html file
</ul>"))
@ -78,7 +79,7 @@
"/tutorial/tut-11.html")
(on-tutorial11 body))
(t
(create-div body :content "No dice!"))))
(create-div body :content "No dice! What do I do with you?"))))
(defun add-search-optimizations (path content)
;; The default boot.html that comes with CLOG has template
@ -117,9 +118,10 @@
(set-on-new-window 'on-tutorial11 :path "/page3"
:boot-file "/tutorial/tut-11.html")
;; Setting a "default" path says that any use of an included boot.js
;; file will route to this function, in this case #'on-default
;; file by static html file will route to this function, in this case on-default
;; which will determine if this is coming from the path used in tutorial
;; 11 - "http://127.0.0.1:8080/tutorial/tut-11.html" and if it does
;; use on-tutorial11, and if not say "No Dice!"
;; use on-tutorial11, and if not say "No Dice!" such as when one pics
;; some-file.html which also loads boot.js
(set-on-new-window 'on-default :path "default")
(open-browser))