clerk

Drew Verlee 2024-07-17T16:28:31.085469Z

on https://github.clerk.garden/ it says 1. Add a :nextjournal.clerk to :aliases in your deps.edn file: when the . should likely be a / 1. Add a :nextjournal/clerk to :aliases in your deps.edn file:

mkvlr 2024-07-17T16:39:19.579199Z

correct, thank you!

Drew Verlee 2024-07-17T17:17:27.960239Z

@mkvlr np. I have another question about garden. I don't understand this bit: > ;; if you just want to build one notebook, set :index by 'set' do we mean, provide a path to a file that can be interpreted as an index? backing up, what i want to do have garden build a collection of notebooks, and also host the index page, so people can see all my notebooks. i'm thinking each notebook will be it's own gitsubmodel of the larger git notebook*s* directory. So what i would provide clerk is the url to the github top level repo, in that case, how do i configure my deps.edn? Assuming my files are like this /clerk-notebooks/deps.edn <--- what should go in this clerk-notebooks/notebook1/deps.edn clerk-notebooks/notebook2/deps.edn clerk-notebooks/notebook1/src/some-clj-file-that-will-become-a-wepage.clj ... etc... I'm not sure what would go in the top level deps.edn.

{:aliases
 {:nextjournal/clerk
  {
   :exec-fn nextjournal.clerk/build!
   :exec-args {:index ???}}}} 
I believe i basically want what clerk.vision is dong or maybe the clerk demo page https://github.clerk.garden/nextjournal/clerk-demo/commit/ff0b806e7da3e42865803bc3ceeb26444e136a51/ looking at the demo page's deps.edn aliases...
{:nextjournal/clerk {:extra-paths ["datasets"]
                               :exec-fn nextjournal.clerk/build!
                               ;; notebooks to be built, accepts globs patterns
                               :exec-args {:git/url ""
                                           :paths ["index.md"
                                                   "notebooks/slideshow.md"
                                                   "notebooks/introduction.clj"
                                                   "notebooks/data_science.clj"
                                                   "notebooks/images.clj"
                                                   "notebooks/logo.clj"
                                                   "notebooks/semantic.clj"
                                                   "notebooks/sicmutils.clj"
                                                   "notebooks/rule_30.clj"
                                                   "notebooks/zipper_with_scars.clj"]}
                               :main-opts ["-m" "babashka.cli.exec"]}}
So its calling build and passing it a git url, some main-opts, a index.md (i guess clerk reads the .md, pulls out the code, runs it, then inserts the result?) The whole thing seems kinda close to understandable, but i'm not quiet seeing the easy path.

mkvlr 2024-07-17T17:35:22.171509Z

@drewverlee yes to your q regarding :index

mkvlr 2024-07-17T17:36:26.550369Z

for your larger question, you want build a collection of notebooks where the individual repos are in different git repos?

mkvlr 2024-07-17T17:37:55.289529Z

you only need to set index if you want to override clerk‘s buitin one

Drew Verlee 2024-07-17T17:40:12.605749Z

Gotcha. I'm probably having trouble seeing what i want here because i don't need it yet (e.g i don't have two notebooks) I'm guessing once i do, the options for linking to them will be very obvious (e.g i just have a separate web page that literally holds links [:a {:src ...}] to them lol)

mkvlr 2024-07-17T17:41:31.976689Z

you’ll need to use clerk/doc-url for the link targets

mkvlr 2024-07-17T17:42:50.954449Z

like in https://github.com/nextjournal/clerk/blob/main/index.clj

Drew Verlee 2024-07-17T17:43:33.364089Z

what does that do?

mkvlr 2024-07-17T17:44:48.663909Z

make sure the links work when running using a clerk server as well as during build

Drew Verlee 2024-07-17T17:45:16.640739Z

gotcha.

Drew Verlee 2024-07-17T18:07:16.373149Z

my local notebook build works, but my garden build fails (should i keep asking garden question here)? Here is the garden https://build.github.clerk.garden/drewverlee/seven-troubleshooting-tips-for-squashing-software-bugs/commit/81a3c1dbdadec47342d7ee332073b0bd33139923/?update=1. here is the https://github.com/drewverlee/seven-troubleshooting-tips-for-squashing-software-bugs I'm guessing this has to do with git deps git urls not being about to pull in a deps? Or clerk not being about to? The library involved in the deps issue is arrowic and it's being used to build a notebook http://arrowic/arrowic%20{:mvn/version%20"0.1.1"} with the mvn/version (as opposed to git/url). I can use mvn/version, but then i would either need to not use the latest version of arrowic or publish the latest to maven.

mkvlr 2024-07-17T18:12:23.112449Z

does :git/sha work? think plain :sha was deprecated a while back

Drew Verlee 2024-07-17T18:12:58.747139Z

hmm

Drew Verlee 2024-07-17T18:15:16.742429Z

trying it now...

mkvlr 2024-07-17T18:16:20.895829Z

you can try upgrading your Clojure cli and see if you can repro the error locally with clojure -X

Drew Verlee 2024-07-17T18:16:59.068369Z

still fails with git/sha.

Drew Verlee 2024-07-17T18:17:31.507629Z

e.g updated sha -> git/sha then did the ?update=1

Drew Verlee 2024-07-17T18:18:13.717259Z

actually, let me triple check..

mkvlr 2024-07-17T18:22:22.735239Z

sec, trying…

mkvlr 2024-07-17T18:23:07.716919Z

@mkair ~/d/seven-troubleshooting-tips-for-squashing-software-bugs (master)> clojure -X:nextjournal/clerk
👷🏼 Clerk is building 1 notebooks…
🧐 Parsing… Done in 339.019ms. ✅
🔬 Analyzing… Done in 640.721ms. ✅
🔨 Building "src/drewverlee/seven_troubleshooting_tips_for_squashing_software_bugs.clj"… Done in 2337.320ms. ✅
📦 Static app bundle created in 41.755ms. Total build time was 3359.783ms.

mkvlr 2024-07-17T18:23:15.482939Z

ok, works for me locally, too

mkvlr 2024-07-17T18:29:55.268359Z

don’t understand what’s going on either 😑 I’ll need to get back to you on this in the coming days. Might be that we need to add something to babashka to avoid this error

clojure.lang.ExceptionInfo: Method serverClose on class org.httpkit.server.AsyncChannel not allowed! {:type :sci/error, :line nil, :column nil, :file nil}

Drew Verlee 2024-07-17T18:30:54.204879Z

no worries. Thanks for looking into it!

mkvlr 2024-07-17T19:21:07.633269Z

strange…

mkvlr 2024-07-17T19:21:35.718459Z

does io.github.jackrusher/arrowic {:git/sha ,,,} work?

mkvlr 2024-07-17T19:23:07.739149Z

the article looks great btw 👏

Drew Verlee 2024-07-17T19:28:06.119989Z

why would io.github.jackrusher/arrowic {:git/sha ,,,} work? is that what your supposed to do for the ... idk, namespace side of the slash? ill give it a try. Thanks If you read the whole thing, please give feedback! If you can solve the 'bug' help me understand it 🙂 laughcry

Drew Verlee 2024-07-17T19:29:59.090699Z

one thing that i'm going to add to my workflow is a dalle-3 to picture tool. So i can produce images and inline them easily. I mean, its easy to overdo. But it's a powerful way to add decent pictures. Idk, maybe it makes the article worse though? i suppose its all about how well done it is?

Drew Verlee 2024-07-17T19:31:25.159969Z

though, on with a less then ideal internet connection, those pictures are loading really slow...

Drew Verlee 2024-07-17T19:36:26.347669Z

actually, i need to proof read this again. All the tech stuff gets in the way of really looking carefully at the wording...

Drew Verlee 2024-07-17T19:38:05.517069Z

annoyingly the best place to edit the english is in chrome, looking at the github repo, where i can have grammarly on.

mkvlr 2024-07-17T19:39:44.627279Z

yep, not focusing enough on the prose is a downside of authoring in clerk I’ve certainly experienced myself

dobladez 2024-07-17T20:58:08.138059Z

I'm trying to work on non-trivial clerk viewers... and it's been... humbling.. 😬. I'll try to explain here what I'm trying to do 🧵 ...

dobladez 2024-07-17T21:01:03.199029Z

I want to write a custom viewer for a nested data structure. This viewer needs to do its own transform-fn logic, render its own things, and at certain locations I want it to render generic data, for which I want clerks' standard "pick a viewer" and "recursion" magic to happen. Am I clear? is there a way to achieve that? Here's a rough idea of what I'm trying to do (of course it's wrong):

(def test-viewer-inner
    {:name `test-viewer-inner
     :pred (fn [maybe] (and (map? maybe) (contains? maybe :test-1)))
     :transform-fn (comp clerk/mark-presented
                         (clerk/update-val
                          (fn [v]
                            (clerk/html [:div.inline-flex.gap-2
                                         [:strong "test-viewer-inner:"]
                                         [:pre (prn-str v)]]))))})


(def test-viewer
    {:name `test-viewer
     :pred (fn [maybe] (and (map? maybe) (contains? maybe :test)))
     :transform-fn (fn [wrapped]
                     (-> wrapped
                         clerk/mark-preserve-keys
                         clerk/mark-presented
                         (update :nextjournal/value
                                 (fn [value]
                                   {:extra-data [1 2 3 "four"]
                                    :value value }))))
     :render-fn '(fn [{:keys [extra-data value presented-value]}]
                   (let []
                     [:div.border.border-black.px-1.py-2
                      [:h3 "test-viewer:"]
                      [:div
                       [:h4 "value:"]
                       [nextjournal.clerk.render/inspect value]]]))})

 
(clerk/add-viewers! [test-viewer test-viewer-inner])

{:test true
 :a-number 4
 :a-string "testing"
 :a-nested-value-a {:test-1 "value-A"} ;; <-- I want `test-viewer-inner` to render this
}
I do understand that the viewers/recursion happens on the server-side, so I guess I somehow have to do something with value on transform-fn, but I don't find the way. I'd appreciate any help! Thanks!

dobladez 2024-07-17T21:16:20.565309Z

(so... I guess I wished I could use clerk/mark-presented only on :extra-data on the example)