This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-16
Channels
- # announcements (62)
- # babashka (12)
- # babashka-sci-dev (73)
- # beginners (16)
- # biff (10)
- # calva (65)
- # cider (13)
- # clerk (8)
- # clojure (31)
- # clojure-europe (16)
- # clojure-nl (1)
- # clojure-norway (19)
- # clojure-spec (24)
- # clojure-uk (5)
- # clojuredesign-podcast (18)
- # clojurescript (18)
- # dev-tooling (2)
- # emacs (30)
- # etaoin (4)
- # gratitude (3)
- # hyperfiddle (20)
- # integrant (2)
- # jobs (4)
- # kaocha (7)
- # malli (1)
- # observability (11)
- # off-topic (11)
- # pathom (12)
- # podcasts-discuss (7)
- # portal (12)
- # quil (3)
- # re-frame (6)
- # releases (1)
- # sql (22)
- # squint (5)
- # testing (79)
- # tools-deps (3)
- # xtdb (20)
generic object browser.
(ns org.stinkless.rekonstruction.browser
(:require [com.biffweb :as biff]
[org.stinkless.rekonstruction.middleware :as mid]))
(defn render-value [valu]
(if (uuid? valu)
[:a {:href (format "/browser/thing/%s" valu)}
"visit"]
[:span (format "%s" valu)]))
(defn- render-thing
[thing]
[:table
(for [[k v] thing]
[:tr [:td (str k)] [:td (render-value v)]])])
(defn- browser-handler [{:keys [biff/db] :as ctx}]
(let [things (biff/q db '{:find [when (pull thing [*])]
:order-by [[when :desc]]
:where [[thing :rekon/when when]]})]
(for [[_when thing] things]
(render-thing thing))))
(defn- get-thing-handler [{:keys [path-params biff/db]}]
(let [thing (biff/lookup db :xt/id (parse-uuid (:thing-id path-params)))]
(render-thing thing)))
(def plugin
{:routes ["/browser" {:middleware [mid/wrap-signed-in]}
["" {:get browser-handler}]
["/thing/:thing-id" {:get get-thing-handler}]]})
First question: Could the use-beholder
component read its on-save
callback(s) from a plugin
key? Any reason against that?
welcome!
Do you have a use-case in mind? e.g. are you wanting to add on-save functionality from a third party plugin?
I think it makes a little more sense to just set the :biff.beholder/on-save
key on the system map since you (typically?) don't need add a bunch of different implementations--since it's tooling-related and not application-related, it doesn't need to accumulate more functionality as you add more features to your app. even schema used to not be added via plugins, but then I made that supported so that the authentication plugin could define some of its own schema.
that being said: you can pretty easily add support for on-save-in-plugins yourself. Just modify the default on-save function so that it iterate through the plugins and calls any functions it finds under the e.g. :on-save key (as a best practice, might want to namespace it, like :com.example/on-save)
my immediate use-case: I was just re-arranging the code from the template. I like to separate the "application core" code from the "UI" and "infrastructure" (say, DB, email) code.
So, I while moving all "web" related code to a separate namespace, I wanted to move generate-assets!
out of the <projectname>.clj
file, but it's used by on-save
... thus, I thought it'd be cleaner if :on-save
was a plugin hook that the "web" plug-in could hook into.... instead of having a top-level on-save
function that "knows" about the "web" plugin. Of course other plugins could use it (say, test frameworks/tooling/monitoring incoming folders, etc)
Hi all. I'm still working on deploying the tutorial. I think I have the server set up, but I'm having a problem with rsync. When I run bb deploy, the app builds, but then I get the following error: bash: line 1: rsync: command not found rsync: connection unexpectedly closed (0 bytes received so far) [sender] I think this has something to do with biff/tasks/src/com/biffweb/tasks.clj, lines 309-327 (push-files-rsync) — but I'm not entirely sure. What's puzzling to me is that the first message seems to be from bash, which says rsync command not found; but then the second line is from rsync — so it seems that rsync is found by that point. In my shell, "which rsync" returns /usr/bin/rsync — which I assume is what (fs/which "rsync") on line 343 is returning. Any suggestions as to how to resolve this would be greatly appreciated.
I know nothing about biff's rsync imp, but I do know the rsync
command, to work, must be installed in both client and server... Maybe you are missing it on the server side?
Ah you know, that at least got me past that error—it wasn't deployed on the other side. Once it is, the rsync error goes away.
you also need curl
Thanks all—with your help, I actually got it serving a website. There are still some teething problems that I need to work on—logs are not working, and it's deploying with git even though rsync is available. But it is at least serving pages!