biff

A web framework + self-hosted deployment solution for Clojure. Repo: https://github.com/jacobobryant/biff. Docs: https://biff.findka.com
rainbow_bamboo 2020-09-09T19:09:17.034600Z

Related: I'm trying to add a static page, so I edit the pages in static.clj https://github.com/jacobobryant/biff/blob/cd775ae4d31206f9aa9f2b8af5a30c6e3f7a0a4c/example/src/example/static.clj#L46 to include {"/page" page-hiccup} Now "/page" loads, but it's loaded as a file to download, not a webpage. If I set the path to "/page.html" and link to that, the page loads as a webpage as expected. Is this the intended usage, or am I missing a step?

2020-09-09T21:06:22.038100Z

It'll work if you add a terminal slash (`{"/page/" page-hiccup}`). In that case, Biff writes the file to /page/index.html (see https://github.com/jacobobryant/biff/blob/cd775ae4d31206f9aa9f2b8af5a30c6e3f7a0a4c/src/biff/system.clj#L192), and /page requests will get redirected to /page/.

💯 1
2020-09-09T21:07:35.039200Z

Perhaps I should add an in-code comment about that or something

rainbow_bamboo 2020-09-09T21:35:07.044400Z

The step that I was missing was that when I tried to create a "/page/" path, I think that we try to create the /page/index.html in the resources folder, but that directory /page did not exist for me so I had to manually create /page before it was able to access the directory.

rainbow_bamboo 2020-09-09T21:35:29.044700Z

https://github.com/jacobobryant/biff/blob/cd775ae4d31206f9aa9f2b8af5a30c6e3f7a0a4c/src/biff/system.clj#L195 Is this the call to export-rum where the html is generated? I'm trying to generate html5 pages, so I'm trying to use hiccup/html5 instead.

2020-09-09T22:00:44.047600Z

yes, that's where the html is generated. just below that line there's a io/make-parents call which should create the page directory. do you have a stack trace handy? Also, are you generating the html with hiccup/html5 first, e.g. {"/page/" (hiccup/html5 some-hiccup)} ? if not, biff will try to render it with rum which might break.

rainbow_bamboo 2020-09-09T22:05:48.049700Z

Checked it again, it's automatically creating the folder as expected. I must've have been mistaken somewhere

rainbow_bamboo 2020-09-09T22:07:30.050900Z

My intent was to replace rum-export with a version that uses hiccup/html5

2020-09-09T22:19:13.054300Z

:thumbsup: should be pretty straightforward. Don't set :biff/static-pages, and instead, thread the result of start-biff through your own custom fn, e.g.

(defn export-html5 [{:keys [yourapp.biff.static/root] :as sys}]
  ; write the html to the root directory
  sys)

(-> ...
  (start-biff 'yourapp)
  export-html5)
(edit: include yourapp in the key namespace)

2020-09-09T22:28:31.057500Z

(aside: I've been thinking lately about how the yourapp.biff/foo vs biff/foo thing is confusing and in most cases unnecessary. The purpose of it was to allow multiple start-biff calls in the same process, i.e. so they could have non-conflicting namespaces. But most people will likely only be running one biff instance, at least at first, so maybe better to turn off the namespace shenanigans by default but keep them as an option for those who want to run multiple instances)

2020-09-09T22:28:38.057700Z

just made an issue: https://github.com/jacobobryant/biff/issues/46