This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-08-30
Channels
- # announcements (3)
- # asami (20)
- # babashka (15)
- # beginners (47)
- # biff (25)
- # calva (11)
- # catalyst (2)
- # cider (11)
- # clojure (24)
- # clojure-brasil (3)
- # clojure-europe (21)
- # clojure-norway (34)
- # clojure-uk (2)
- # clojurescript (9)
- # clr (2)
- # datomic (10)
- # fulcro (14)
- # hyperfiddle (58)
- # introduce-yourself (1)
- # jobs (3)
- # malli (5)
- # meander (6)
- # missionary (4)
- # nbb (30)
- # off-topic (6)
- # podcasts-discuss (1)
- # shadow-cljs (13)
- # slack-help (5)
- # tools-build (4)
- # vim (20)
- # xtdb (20)
How does one make error 500 look the same as the other parts of the webpage?
Should I assoc
the on-error
into each request when it happens?
Previously there was a parameter where I could provide the on-error
handler for wrap-internal-error
but now that code is marked as deprecated.
I'd like to know if there is a different place where I could provide on-error
so that it would be picked up by both places.
If I provide on-error
like this then it's picked up for 40x
errors but not 50x
:
(def handler (-> (biff/reitit-handler {:routes routes
:on-error #'ui/error-page-handler})
biff/wrap-base-defaults))
And this:
(defn error-page-handler [{:keys [status]}]
{:status status
:headers {"content-type" "text/html"}
:body (->> (page {} [:h1 {} (biff-util/http-status->msg status)])
rum/render-static-markup)})
I think I'd like to be able to specify biff.middleware/on-error
but I don't know where to do it.You can set it on the system map, since the system map gets merged into incoming ring requests by the use-jetty
component:
(def initial-system
{:biff.middleware/on-error #'ui/error-page-handler
:biff/plugins #'plugins
...})
Reading through the code again, it looks like you'll need to set it in both places--on the system map for 50x errors and in biff/reitit-handler
for 40x errors.
I should probably modify the default template so that it starts out with a custom on-error
function in ui.clj
, since that probably should be overridden by most projects. I'll make a note of that.
and maybe see if there's a way to have biff/reitit-handler
reuse the :biff.middleware/on-error
value from the system map...
built this calendar component with biff and it turned out really nice https://twitter.com/_jonesian/status/1696745494440272216?s=20
That's awesome 🙂 I'll add that link to the (not explicitly existing yet) "things built with biff" section in the docs
Is there something special that needs to be done for tailwind classes that uses /
? Like w-1/4
? I'm getting "Invalid token" errors thrown when trying to use classes with a slash in them.
Are you trying to specify this class like so: [:div.w-1/4 ...]
?
That's not possible using clojure keywords. I usually do the following instead:
[:div.any.other.classes.without-slashes {:class "w-1/4"} ...]
You can also mix them--I usually do symbols, but there are some tailwind classes that aren't valid clojure symbols:
[:div {:class '[px-4
"mt-[55px]"]}
...]
Is there a way to get the XTDB node in the REPL? I'd like to run some ad hoc queries without having to initiate an HTTP request.
From the docs, it seems like I could get it from the system map, but I always get nil
when trying to deref the biff/system
atom.
theres a
(defn get-context
[]
(biff/assoc-db @main/system))
method that you can call to get access(defn get-context []
(biff/assoc-db @main/system))
from the repl namespaceie:
(let [{:keys [biff/db]} (get-context)]
(biff/q db '{:find (pull w [*])
:where [[w :workout/created-at]]}))
:man-facepalming: I was trying to deref biff/system
instead of my.namespace/system
It's all good now. 😅
Thanks!
I see the repl
namespace now. Don't know how I missed it
Had the same issue. @U7YNGKDHA probably worth mentioning in some paragraph in getting started?
it is 🙂 though it is quite possible I should make that more prominent somehow; I'll think about that.
Probably, an example on how to query db without http request/with repl? Everyone will have this need pretty quickly and many will try this before they'll update anything in htmx)
You mean like the example in repl.clj
? I could turn the "Jacking in" section into a "REPL-driven development" section and then paste in the example from repl.clj
.
I think that should be enough. Nobody will miss REPL-driven development section when they look for repl.
I click a button and def
stuff that I want to use in the namespace.
Then I can simply use DB and even my IDs that I had submitted into the handler.
(defn handler [ctx]
(def my-stuff (:my-stuff ctx))
(def my-more-stuff (:my-stuff1 ctx))
200)