This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-20
Channels
- # adventofcode (29)
- # announcements (7)
- # aws (1)
- # babashka (3)
- # beginners (43)
- # biff (20)
- # clj-kondo (44)
- # cljs-dev (20)
- # clojure (74)
- # clojure-europe (24)
- # clojure-finland (2)
- # clojure-nl (13)
- # clojure-norway (3)
- # clojurescript (31)
- # code-reviews (1)
- # community-development (12)
- # cursive (3)
- # datomic (6)
- # emacs (1)
- # fulcro (25)
- # interop (7)
- # introduce-yourself (2)
- # leiningen (30)
- # nbb (3)
- # overtone (1)
- # podcasts (5)
- # polylith (24)
- # practicalli (1)
- # reclojure (1)
- # reitit (13)
- # rum (7)
- # shadow-cljs (12)
- # sql (23)
- # squint (51)
- # test-check (1)
- # testing (2)
- # tools-deps (2)
I'm working on making a top navigation bar for my site built with Biff, and I want to display certain elements based on whether the user is logged in or not (including "Sign in" and "Sign out" buttons). Given that it's an element common to all pages, I initially thought it would make the most sense to load it into app/ui.clj
, as an element called by ui/page
that precedes the body
, like so:
(def topbar
[:nav
[:div.container.flex.flex-wrap.items-center.justify-between.mx-auto
[:a.text-blue-500.text-xl.font-semibold {:href "/"} "App Title"]
[:a.text-blue-500 {:href "/genre"} "Genres"]
[:a.text-blue-500 {:href "/user/followed"} "Followed"]
[:a.text-blue-500 {:href "/app"} "Dashboard"]
[:a.text-blue-500 {:href "/app/user/settings"} "Settings"]]
[:.h-5]])
(defn page [opts & body]
(base
opts
[:.p-3.mx-auto.max-w-screen-sm.w-full
topbar
body]))
However, ui/page
has no access to the sys
map that would allow me to check if the user is logged in or not. I have a couple of hacky ways that I could try to do this--maybe make another <feat>/page
that wraps ui/page
on each individual route, or change ui/page
itself to accepts the sys
map--but I'm not sure if either of these are considered "idiomatic" for Biff. Is there any ideal, idiomatic way to do this, or am I better off chasing one of the hackier solutions above?I just pass the system map in! i.e. opts
is the system map... which is possibly confusing. I've been thinking I should rename all occurrences of sys
, req
, or opts
to ctx
and have the docs refer to it as the context map.
I originally used the term opts
in some places because you aren't necessarily passing in the system map and thus sys
felt inappropriate. So ctx
feels like a more general, clearer term. (Either that or maybe stuff
, data
, ...)
cloned a Biff project to a new machine and getting File does not exist: dev
when running bb dev
… thoughts?
bb.edn has
{:deps {local/deps {:local/root "tasks"}}
:tasks {dev com.biffweb.tasks/dev
format com.biffweb.tasks/format
clean com.biffweb.tasks/clean
deploy com.biffweb.tasks/deploy
soft-deploy com.biffweb.tasks/soft-deploy
refresh com.biffweb.tasks/refresh
restart com.biffweb.tasks/restart
logs com.biffweb.tasks/logs
prod-repl com.biffweb.tasks/prod-repl
prod-dev com.biffweb.tasks/prod-dev
hello wiki.treeplanet.tasks/hello
post-receive com.biffweb.tasks/post-receive
run-cmd com.biffweb.tasks/run-cmd}}
and the task directory is there.what's your bb --version
?
Haha! You’re onto it. Just after posting this I realized I had a very old version. I then attempted to update it with brew, but I had originally installed it on this machine with the curl script. I then reran the curl install script, and now I’m having a lot of fun as running, say, bb
throws
Error: Could not find or load main class clojure.main
Caused by: java.lang.ClassNotFoundException: clojure.main
so working through that.Seems related to this: https://github.com/babashka/babashka/issues/1070
running bb
outside the project directory works, but not inside of it. However, I’m glad to say that bb --version
outside the project shows I now have Babashka v1.0.168 REPL.
(I don’t have an M1 MacBook as the OP of the issue did, fyi)
bb --version
and bb
work inside the Biff project directory if I rename bb.edn
to something else.
On my phone right now but this sounds like an issue with your #CLX41ASCS installation. I don't use brew but I think that has caused some problems in the past?
I think you'll get a solution faster over at #CLX41ASCS
Oh you said it works outside the project, Ican check it out in half an hour or so
I did find this: https://clojurians.slack.com/archives/CLX41ASCS/p1637532964060200?thread_ts=1637530620.056800&cid=CLX41ASCS
Aha! I removed ~/.deps.clj
and that solved the issue. This is a directory created by babashka.
Thank you for all the help! 😀
Oh, the old version of babashka created deps.clj and confused the new one? That's interesting
I just saw a mention of deleting ~/deps.clj
in that thread I linked to above and tried it. My situation is a bit unusual, though… I cloned a project down into a machine that had early versions of bb and so on. Truly a corner case and not a Biff thing, that’s for sure.