diff options
author | Colin Okay <colin@cicadas.surf> | 2022-08-25 09:07:14 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-08-25 09:07:14 -0500 |
commit | 1a2ee6435c94185e960cb3b6fc032d38914a8caa (patch) | |
tree | c8c1f1be3a82ea9fd6fcdde10b0bd65ec7941750 | |
parent | 2294c8551cb2187e97339cbee4be44c873ab94c6 (diff) |
-rw-r--r-- | flexo.lisp | 33 |
1 files changed, 22 insertions, 11 deletions
@@ -36,6 +36,10 @@ (defun mark-autorefresh-true (directory) (when *auto-refresh-key* (alexandria:write-string-into-file + (auto-refresh-script-ps) + (format nil "~a/auto-refresh-script.js" directory) + :if-exists :supersede) + (alexandria:write-string-into-file "true" (format nil "~a/~a.json" directory *auto-refresh-key*) :if-exists :supersede ))) @@ -43,6 +47,10 @@ (defun mark-autorefresh-false (directory) (when *auto-refresh-key* (alexandria:write-string-into-file + (auto-refresh-script-ps) + (format nil "~a/auto-refresh-script.js" directory) + :if-exists :supersede) + (alexandria:write-string-into-file "false" (format nil "~a/~a.json" directory *auto-refresh-key*) :if-exists :supersede ))) @@ -62,17 +70,20 @@ (defun auto-refresh-script () (when *auto-refresh-key* (with-html - (:script - (ps:ps - (let ((poll-url (+ "/" (ps:lisp flexo::*auto-refresh-key*) ".json"))) - (set-interval - (lambda () - (let ((fetched (fetch poll-url))) - (ps:chain fetched - (then (lambda (resp) (ps:chain resp (json)))) - (then (lambda (json) - (when json (ps:chain location (reload)))))))) - 1000))))))) + (:script :src "/auto-refresh-script.js")))) + +(defun auto-refresh-script-ps () + (ps:ps + (set-interval + (lambda () + (let ((fetched + (fetch + (ps:lisp (format nil "/~a.json" flexo::*auto-refresh-key*))))) + (ps:chain fetched + (then (lambda (resp) (ps:chain resp (json)))) + (then (lambda (json) + (when json (ps:chain location (reload)))))))) + 1000))) (defun table-subset-p (tab1 tab2 &key (test 'equal)) "TEST compares values" |