From 2143e966c9e4d830c58f4b3b0429210640ade3e2 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 24 Nov 2026 13:33:30 +0000 Subject: [PATCH] Fix white archive page. --- .../com/oly/static_sites/do_blog/core.cljs | 20 ++++++++++++------- .../com/oly/static_sites/do_blog/routes.cljc | 1 + .../src/com/oly/static_sites/do_blog/ssr.clj | 1 + .../com/oly/static_sites/do_blog/views.cljc | 13 +++++++++--- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/bases/do-blog/src/com/oly/static_sites/do_blog/core.cljs b/bases/do-blog/src/com/oly/static_sites/do_blog/core.cljs index 5ccae4f..0126ca1 100644 --- a/bases/do-blog/src/com/oly/static_sites/do_blog/core.cljs +++ b/bases/do-blog/src/com/oly/static_sites/do_blog/core.cljs @@ -10,7 +10,8 @@ :refer [state load-index! latest-article org->document]] [com.oly.static-sites.do-blog.pages.chess-board :as chess] [com.oly.static-sites.do-blog.pages.chess.state :as chess-state] - [com.oly.static-sites.do-blog.pages.chess.vstate :as viking-state]) + [com.oly.static-sites.do-blog.pages.chess.vstate :as viking-state] + [com.oly.static-sites.do-blog.pages.matrix-widget :as widget]) (:require-macros [cl-eorg.macros :refer [org-doc->move-process]])) ;; Copy org documents into public/ and write org-meta-index.edn at compile time. @@ -40,6 +41,8 @@ (defn handle-action [[action & args]] (case action :search/set-terms (swap! state assoc-in [:search :terms] (first args)) + :widget/set-draft (swap! widget/widget-state assoc :draft (first args)) + :widget/send (widget/send-message! (:draft @widget/widget-state)) (js/console.warn "Unknown action" (pr-str action)))) (defn dispatch [{:replicant/keys [dom-event]} actions] @@ -47,12 +50,14 @@ ;; Navigation -(defn fetch-text [path on-success on-error] - (GET path {:response-format (text-response-format) - :handler on-success - :error-handler (fn [error] - (js/console.error "Failed to fetch" path (clj->js error)) - (on-error error))})) +(defn fetch-text + ([path on-success] (fetch-text path on-success nil)) + ([path on-success on-error] + (GET path {:response-format (text-response-format) + :handler on-success + :error-handler (fn [error] + (js/console.error "Failed to fetch" path (clj->js error)) + (when on-error (on-error error)))}))) (defn show-route! [match & {:as extra}] (swap! state merge @@ -97,6 +102,7 @@ (add-watch state ::render (fn [_ _ _ _] (render!))) (add-watch chess-state/game-state ::render (fn [_ _ _ _] (render!))) (add-watch viking-state/game-state ::render (fn [_ _ _ _] (render!))) + (add-watch widget/widget-state ::render (fn [_ _ _ _] (render!))) (fetch-text "/documents/org-meta-index.edn" (fn [response] (load-index! (reader/read-string response)) diff --git a/bases/do-blog/src/com/oly/static_sites/do_blog/routes.cljc b/bases/do-blog/src/com/oly/static_sites/do_blog/routes.cljc index 067a180..99e90ce 100644 --- a/bases/do-blog/src/com/oly/static_sites/do_blog/routes.cljc +++ b/bases/do-blog/src/com/oly/static_sites/do_blog/routes.cljc @@ -11,6 +11,7 @@ ["/archive/{*tag}" {:name :archive}] ["/chess/" {:name :chess}] ["/about/" {:name :about}] + ["/widget/" {:name :widget}] ["/posts/{*path}" {:name :posts}]]) (def router (rc/router routes)) diff --git a/bases/do-blog/src/com/oly/static_sites/do_blog/ssr.clj b/bases/do-blog/src/com/oly/static_sites/do_blog/ssr.clj index dd0c954..bdab288 100644 --- a/bases/do-blog/src/com/oly/static_sites/do_blog/ssr.clj +++ b/bases/do-blog/src/com/oly/static_sites/do_blog/ssr.clj @@ -52,6 +52,7 @@ ["/" (page-state "/" (doc latest))] [(href :about) (page-state (href :about) nil)] [(href :chess) (page-state (href :chess) nil)] + [(href :widget) (page-state (href :widget) nil)] [(archive-href "") (page-state (archive-href "") nil)]] (for [tag tags :let [url (archive-href tag)]] diff --git a/bases/do-blog/src/com/oly/static_sites/do_blog/views.cljc b/bases/do-blog/src/com/oly/static_sites/do_blog/views.cljc index 62c9424..89b8cf0 100644 --- a/bases/do-blog/src/com/oly/static_sites/do_blog/views.cljc +++ b/bases/do-blog/src/com/oly/static_sites/do_blog/views.cljc @@ -25,6 +25,7 @@ :archive (if (str/blank? tag) "Past articles" (str "Articles tagged " tag)) :chess "Chess" :about "About" + :widget "Matrix widget" "Page not found"))] (if (str/blank? title) site-name @@ -58,6 +59,10 @@ #?(:clj (defmethod page :chess [_state] [:p.lh-copy "Loading the chess board…"])) +;; Likewise the Matrix widget (pages/matrix_widget.cljs). +#?(:clj (defmethod page :widget [_state] + [:p.pa3.lh-copy "Loading the Matrix widget…"])) + (defn loading-bar [loading] (when loading [:div.fixed.top-0.left-0.w-100.bg-green.white.f6.tc.pa1.z-999 @@ -126,6 +131,8 @@ (search-articles {:search terms})))]]])) (defn app [state] - (layout state (if (:not-found? state) - (not-found-page) - (page state)))) + (cond + (:not-found? state) (layout state (not-found-page)) + ;; The widget is embedded in a Matrix client, so it skips the site chrome. + (= :widget (-> state :route :data :name)) (page state) + :else (layout state (page state))))