diff --git a/FUTURE.md b/FUTURE.md index d6bd0c2..a88187a 100644 --- a/FUTURE.md +++ b/FUTURE.md @@ -24,10 +24,6 @@ Demo between different models - stateless, webpage, windows - Training and documentation tool -- Implement using long polling to optimize CLOG sites for use with - search engines. If not long polling at least initial output sent by - initial html request until first query. - - Optionaly, for local apps, allow direct transport of CLOG data to webpage via apis remove need for websocket transport. diff --git a/source/clog-connection.lisp b/source/clog-connection.lisp index 608bc89..60fa980 100644 --- a/source/clog-connection.lisp +++ b/source/clog-connection.lisp @@ -304,15 +304,19 @@ the default answer. (Private)" (host "0.0.0.0") (port 8080) (boot-file "/boot.html") + (boot-function nil) (static-boot-js nil) (static-root #P"./static-files/")) - "Initialize CLOG on a socket using HOST and PORT to serve BOOT-FILE as -the default route for '/' to establish web-socket connections and static files -located at STATIC-ROOT. If BOOT-FILE is nil no initial clog-path's will be -setup, use clog-path to add. The on-connect-handler needs to indentify the -path by querying the browser. See PATH-NAME (in CLOG-LOCATION). If -static-boot-js is nil then boot.js is served from the file /js/boot.js -instead of the compiled version." + "Initialize CLOG on a socket using HOST and PORT to serve BOOT-FILE +as the default route for '/' to establish web-socket connections and +static files located at STATIC-ROOT. If BOOT-FILE is nil no initial +clog-path's will be setup, use clog-path to add. The +on-connect-handler needs to indentify the path by querying the +browser. See PATH-NAME (in CLOG-LOCATION). If static-boot-js is nil +then boot.js is served from the file /js/boot.js instead of the +compiled version. boot-function if set is called with the url and the +contents of boot-file and its return value replaces the contents sent +to the brower." (set-on-connect on-connect-handler) (when boot-file (set-clog-path "/" boot-file)) @@ -338,6 +342,10 @@ instead of the compiled version." (let ((page-data (make-string (file-length stream))) (post-data)) (read-sequence page-data stream) + (when boot-function + (setf page-data (funcall boot-function + (getf env :path-info) + page-data))) (when (search "multipart/form-data;" (getf env :content-type)) (let ((id (get-universal-time)) @@ -402,6 +410,7 @@ instead of the compiled version." ;;;;;;;;;;;;;;;;;;; (defun set-clog-path (path boot-file) + "Associate URL path to BOOT-FILE" (if boot-file (setf (gethash path *url-to-boot-file*) ;; Make clog-path into a relative path of diff --git a/source/clog-system.lisp b/source/clog-system.lisp index eff4fd4..cfc6056 100644 --- a/source/clog-system.lisp +++ b/source/clog-system.lisp @@ -51,6 +51,7 @@ the same as the clog directy this overides the relative paths used in them.") (host "0.0.0.0") (port 8080) (boot-file "/boot.html") + (boot-function nil) (static-boot-js nil) (static-root (merge-pathnames "./static-files/" (asdf:system-source-directory :clog)))) @@ -64,7 +65,10 @@ is installed in ./static-files\" If the variable clog:*overide-static-root* is set STATIC-ROOT will be ignored. If BOOT-FILE is nil no default boot-file will be set for root path, i.e. /. If static-boot-js is t then boot.js is served from the file /js/boot.js instead of the -compiled version." +compiled version. boot-function if set is called with the url and the +contents of boot-file and its return value replaces the contents sent +to the brower, this allows adding content for search engine optimization, +see tutorial 12 for an example." (when on-new-window-handler (set-on-new-window on-new-window-handler :path "/" :boot-file boot-file)) (unless *clog-running* @@ -76,6 +80,7 @@ compiled version." :host host :port port :boot-file boot-file + :boot-function boot-function :static-boot-js static-boot-js :static-root *static-root*))) diff --git a/static-files/boot.html b/static-files/boot.html index e63f62e..9e19839 100644 --- a/static-files/boot.html +++ b/static-files/boot.html @@ -8,8 +8,10 @@ +
+