Customizing buildHtmlMulti - Rib

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

Joel McCracken

So, I notice that the selection of files (via the glob sent into build html multi) is done at the same step as when files are rendered

Joel McCracken

however, I need to insert a previous step

Joel McCracken

basically soemthing like

  1. find relevant files
  2. process them (find all the valid links)
  3. render files
Joel McCracken

right now in order to do this, I am learning shake APIs

Joel McCracken

I figure I can use writeHtml itself manually

Joel McCracken

if you have any thoughts, please let me know, i might be missing something

Sridhar Ratnakumar

buildHtmlMulti is a small function, composing two other functions: getDirectoryFiles' and buildHtml. And buildHtml too is a small function composing two other functions: readSource and writeHtml. You can always use these other functions to do what you specifically want.

Sridhar Ratnakumar

The only recommended 'requirement' is that you use writeHtml (or writeFileCached if writing a non-HTML) ultimately, to actually write the generated file to disk, because it takes care of caching it using the mechanism provided by Shake (so you never write the same file twice, unnecessarily)

Sridhar Ratnakumar

Aside from that, you can drop down to the low-level of Shake and use that if you want. After all the third argument to Rib.App.run is simply a shake's Action monad.

Sridhar Ratnakumar

(Of course, use ribInputDir and ribOutDir to get the two directory arguments you passed to run)

Sridhar Ratnakumar

Here's an example: https://github.com/open-editions/open-editions.org/pull/5/files#diff-98a3ddc5c474fd14c4ee9401c03197a1R113

To do this we simply extend Rib.s buildHtmlMulti to our custom target HTML path. This mechanism should probably be implemented upstream, in customizabe fashion. Also update URLs in the HTML. Includ...
Sridhar Ratnakumar

In a way, ultimately you can dropdown to Shake and use only readSource and writeHtml from Rib.Shake without bothering about the higher-level functions.

Sridhar Ratnakumar

In 0.6 all these functions in Rib/Shake.hs have been dramatically simplified, so take a look at the source. The intention is to let the user use what they want, and skip the rest. These functions can also provide a 'template' for writing your own.

Joel McCracken

good advice, thanks, I think this looks like its going to work.