Closed saurabhnanda closed 3 years ago
Hello! Glad it looks like slick will help out;
Looking at the example site from the README I'm not quite sure how shake would behave if the list of posts were to be fetched from a Postgres DB instead of the filesystem
There are two different ways I can think of to do this. Probably the simplest (if it works) would be to use cacheActionWith; which allows you to pass a value to use for "change detection" for the action you provide to it. So you'd look up your posts, or maybe just the "updatedAt" timestamp for your post, and you'd pass that as the change-detection value. As long as that value doesn't change, it'll use the cache instead of re-running the provided action.
The other way would be to write a custom oracle; this can be a bit confusing, but should do the trick; your oracle would fetch the posts (or maybe just an 'updatedAt' stamp) from the DB and could then detect whether to force a rebuild or not.
I'd personally recommend trying cacheActionWith
, since I think it'd do what you need.
Is the buildPost function compiling the site/templates/post.html template for each post?
Looks like it probably is; the template compilation could pretty easily be pulled out of the post action and save some time 😄 (it's tough to mix being optimal with being clear in teaching materials)
Is there any in-built support for linking to other existing pages?
I'm curious what this looks like in your head; you can of course just add links in your templates, or build URLs in your haskell code. If you wanted something abstracted you could write a record which contains links and pass that around in your app, but I'm not really sure what exactly you're looking for. Rest-assured, everything is just haskell, so if it doesn't exist you can certainly build it.
Would slick scale to building thousands of pages? Has this ever been tested?
I know that at least one group was building and selling websites using slick, so I suspect it was good enough for them. The key trick here is ensuring your caching rules are firing correctly, which can take a bit of debugging, but once that's correct I don't see why not. Shouldn't take long to whip up a test for it and see how it does if you want to!
Something to watch for when building your site is to avoid long computations that involve blending data from many sources; if you have a complex calculation that needs to run EVERY time any post changes then you're going to have a bad time (but that'd be true no matter which framework you're using)
Best of luck! Let me know how the experiment goes!
I've recently discovered the Shake build system and largely I like what I saw. I was contemplating building a large-scale static site generator on top of Shake + Hakyll, but thankfully I found your project, which means that I don't have to struggle with Hakyll 😄 (was never able to build anything using it!)
To summarize, I'm fairly new to shake and slick, both. So, newbie alert!
Looking at the example site from the README I'm not quite sure how shake would behave if the list of posts were to be fetched from a Postgres DB instead of the filesystem. How would one get shake to rebuild a post page when, say, the post's comments change? (and the comments were stored in a table related to posts)?
Is the
buildPost
function compiling thesite/templates/post.html
template for each post?Is there any in-built support for linking to other existing pages?
Would
slick
scale to building thousands of pages? Has this ever been tested?