2019-07-01 01:06:16 +03:00
|
|
|
# rib
|
2019-06-18 02:02:02 +03:00
|
|
|
|
2019-07-01 01:06:16 +03:00
|
|
|
<!--
|
|
|
|
Credit for this image: https://www.svgrepo.com/svg/24439/ribs
|
|
|
|
-->
|
2019-07-17 03:13:01 +03:00
|
|
|
<img src="https://raw.githubusercontent.com/srid/rib/master/doc/a/static/ribs.svg?sanitize=true" width="150" />
|
2019-07-01 01:06:16 +03:00
|
|
|
|
2019-07-17 03:06:58 +03:00
|
|
|
Rib is a static site generator written in Haskell that reuses existing tools
|
|
|
|
(`Shake`, `Lucid` and `Clay`) and is thus non-monolithic. It is nearly done but
|
|
|
|
still a work in progress and will soon be ready for general use.
|
2019-07-02 16:27:37 +03:00
|
|
|
|
|
|
|
## Example
|
|
|
|
|
2019-07-17 03:06:58 +03:00
|
|
|
See `./example` to see how the `Rib` library can be used to write your own
|
|
|
|
static site generator in a few lines of code which includes the HTML and CSS of
|
|
|
|
the site:
|
2019-07-02 16:27:37 +03:00
|
|
|
|
|
|
|
```
|
2019-07-12 23:40:24 +03:00
|
|
|
$ cloc --by-file example/Main.hs
|
2019-07-02 16:27:37 +03:00
|
|
|
[...]
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
File blank comment code
|
|
|
|
-------------------------------------------------------------------------------
|
2019-07-17 03:06:58 +03:00
|
|
|
example/Main.hs 10 3 45
|
2019-07-02 16:27:37 +03:00
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
```
|
|
|
|
|
2019-07-17 03:06:58 +03:00
|
|
|
See `./doc` for a real-world example---Rib's own documentation site.
|
|
|
|
|
|
|
|
(Refer to `Rib.Simple` if you need further customization of the Shake action.)
|
2019-07-14 03:33:40 +03:00
|
|
|
|
|
|
|
With Rib you do not have to deal with less powerful template engines or
|
2019-07-02 16:27:37 +03:00
|
|
|
write raw HTML/CSS by hand. Do everything in Haskell, and concisely at that!
|
2019-06-18 02:02:02 +03:00
|
|
|
|
2019-07-17 03:06:58 +03:00
|
|
|
---
|
|
|
|
|
2019-07-13 00:03:12 +03:00
|
|
|
To get the example site up and running run:
|
2019-06-29 01:06:37 +03:00
|
|
|
|
|
|
|
```bash
|
2019-07-13 00:03:12 +03:00
|
|
|
cd ./example
|
2019-07-13 22:11:04 +03:00
|
|
|
../ghcid
|
2019-07-11 20:58:46 +03:00
|
|
|
```
|
|
|
|
|
2019-07-13 22:11:04 +03:00
|
|
|
This will:
|
2019-07-13 00:03:12 +03:00
|
|
|
|
|
|
|
- Drop into a nix-shell with needed Haskell dependencies
|
2019-07-13 22:11:04 +03:00
|
|
|
- Compile the `rib` library and `example/Main.hs` through ghcid
|
2019-07-13 00:03:12 +03:00
|
|
|
- Whenever Haskell sources change ghcid reloads them
|
2019-07-18 16:42:38 +03:00
|
|
|
- Run `example/Main.hs:buildAction` (as if with `serve -w` CLI arguments)
|
2019-07-13 00:03:12 +03:00
|
|
|
- This does the following:
|
2019-07-14 19:50:59 +03:00
|
|
|
1. Convert sources in `./example/a` into `./example/b` using Shake
|
|
|
|
2. Listens for changes to `./example/a`, and re-generate them (i.e., the `-w` argument)
|
|
|
|
3. Start a HTTP server serving the `./example/b` directory (i.e, the `serve` command)
|
|
|
|
|
|
|
|
Thus, by running that one command one gets a production-quality web server
|
|
|
|
serving the statically generated HTML files which automatically get regenerated
|
|
|
|
when the source content changes. What's more, we may change the Haskell sources
|
2019-07-14 22:39:16 +03:00
|
|
|
such as `Main.hs` and ghcid will recompile and relaunch the whole thing.
|
2019-07-14 19:50:59 +03:00
|
|
|
|
|
|
|
With `rib` we get hot reload for free.
|