5 ms·
Show HN: PWA generator / HTML helper lib for Clojure
- spacegangster 6y agoMy lib for Clojure, using it in a real project. Currently planning next iteration, probably will include prefetch links and streamline cache-busting. Most brutal critique is welcome as well as other forms of feedback. Cheers!
- jetti 6y agoI'm relatively new to Clojure and have been interested in writing something like this. I have a few questions/comments: - What made you decide to write CacheBustHelper in Java? I believe something like: (defn bust-cache [input-stream] (with-open [rdr (clojure.java.io/reader input-stream)] (doseq [b (.read rdr) :when (not= -1 b)] nil))) I'm not sure the performance difference between the two though. - Does it work with any web backend framework? Could I use something like Luminus or Fulcro? Does the request just have to follow the Ring request format? - Looks like lines 183 through 198 on core.clj could be when instead of if - what about making update-if-present: (defn update-if-present [m & v] (reduce (fn [acc [k f]] (if (contains? acc k) (update acc k f) acc)) m (partition 2 v))) That would allow you to do the following: (update-if-present page-data :twitter-image cache-bust-one :og-image cache-bust-one :favicon cache-bust-one :link-apple-icon cache-bust-one :link-apple-startup-image cache-bust-one :link-image-src cache-bust-one :script cache-bust :script-sync cache-bust :js-module cache-bust :stylesheet cache-bust :stylesheet-async cache-bust :manifest cache-bust-one) Those are just some things I noticed on first glance. -
- spacegangster 6y agowhoa, thanks a lot for the comment! I'll add it to my todo list, and will look into it when I'll be doing the next iteration!
- jetti 6y agoI haven't tested any of that code so it may not work perfectly. I have another question: did you model this on any existing html generating solution (such as reagent/om/rum)? I am looking at those projects for inspiration and a guide on how to do this kind of generation
- spacegangster 6y agoWell, HTML is generated by Hiccup, it's a solid veteran library
- jetti 6y agoYea, I totally missed that. I'm working on a ClojureScript library so there is no Hiccup and I'm planning on targeting Vue instead of React which means reagent and sablono are both out too.
- spacegangster 6y agofreaking cool! have you seen recent React take on atoms? I haven't dived into that, but from the surface it sounded like they're playing with Vue's approach. Perhaps Vue is more developed in its own approach though :-)
- jetti 6y agoI have not seen that. I'm not very familiar with standard React, I've only briefly worked on a React codebase and the rest of the time I've used React via Reagent