diff options
| author | LLLL Colonq <llll@colonq> | 2025-05-01 17:06:41 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2025-05-01 17:06:41 -0400 |
| commit | fb01362a9dd816fc0d0e50052ab4764dd30e46f3 (patch) | |
| tree | d581df21e161a0483d8b02ea4519debb4501a4a7 /src/gizmo/wasp-cyclone.el | |
| parent | b21ecce6645fc17c520b722de3d96e550c77c490 (diff) | |
You know we love updating with a horrendous commit message
Diffstat (limited to 'src/gizmo/wasp-cyclone.el')
| -rw-r--r-- | src/gizmo/wasp-cyclone.el | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/src/gizmo/wasp-cyclone.el b/src/gizmo/wasp-cyclone.el index d77061e7..0223e8bc 100644 --- a/src/gizmo/wasp-cyclone.el +++ b/src/gizmo/wasp-cyclone.el @@ -7,6 +7,8 @@ (require 'wasp-heartrate) (require 'wasp-chatsummary) (require 'wasp-alert-message) +(require 'wasp-fakechat) +(require 'wasp-bannerads) (defconst w/gizmo-buffer-names (list @@ -23,7 +25,7 @@ (defun w/gizmo-tag-window () "Tag the current window as containing a gizmo." (interactive) - (when-let ((w (selected-window))) + (when-let* ((w (selected-window))) (add-to-list 'w/gizmo-windows w))) (defun w/gizmo-cycle-window (w) @@ -42,6 +44,11 @@ (--each w/gizmo-windows (w/gizmo-cycle-window it))) +(defun w/gizmo-ensure-shown (buf) + "Ensure that BUF is shown in one of the windows." + (unless (--any (s-equals? (buffer-name (window-buffer it)) (buffer-name (get-buffer buf))) w/gizmo-windows) + (set-window-buffer (car w/gizmo-windows) buf))) + (defvar w/gizmo-cycle-timer nil) (defun w/run-gizmo-cycle-timer () "Run the gizmo cycle timer." @@ -49,9 +56,32 @@ (cancel-timer w/gizmo-cycle-timer)) (w/gizmo-cycle) (setq - w/gizmo-cycle-timer - (run-with-timer 300 nil #'w/run-gizmo-cycle-timer))) + w/gizmo-cycle-timer + (run-with-timer 300 nil #'w/run-gizmo-cycle-timer))) (w/run-gizmo-cycle-timer) +(require 'htmlize) +(defvar w/gizmo-html-cache (ht-create)) +(defun w/gizmo-render-html (buf) + "Render BUF to HTML with embedded images." + (let* ( (htmlize-output-type 'inline-css) + (htmlize-force-inline-images t) + (buf (htmlize-buffer buf)) + (html (with-current-buffer buf (buffer-string)))) + (kill-buffer buf) + html)) +(defun w/gizmo-upload (buf) + "Upload the HTML contents of BUF to the database." + (let* ( (b (get-buffer buf)) + (nm (buffer-name b)) + (render (w/gizmo-render-html b)) + (cached (ht-get w/gizmo-html-cache nm))) + (unless (and cached (s-equals? cached render)) + (ht-set w/gizmo-html-cache nm render) + (w/db-hset-then "gizmos" nm + render + (lambda (_) + (w/pub '(gizmo buffer update) (list nm))))))) + (provide 'wasp-cyclone) ;;; wasp-cyclone.el ends here |
