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-05 17:12:27 +03:00
|
|
|
<img src="https://raw.githubusercontent.com/srid/rib/master/example/content/static/ribs.svg?sanitize=true" width="150" />
|
2019-07-01 01:06:16 +03:00
|
|
|
|
|
|
|
Rib is a static site generator written in Haskell using sensible technologies
|
2019-07-13 00:03:12 +03:00
|
|
|
like `Shake`, `Lucid` and `Clay`. 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
|
|
|
|
|
|
|
|
See `./example` (author's actual website in fact) 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-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-13 00:03:12 +03:00
|
|
|
example/Main.hs 15 6 90
|
2019-07-02 16:27:37 +03:00
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
```
|
|
|
|
|
|
|
|
With Rib you do not have to deal with the less powerful template engines or
|
|
|
|
write raw HTML/CSS by hand. Do everything in Haskell, and concisely at that!
|
2019-06-18 02:02:02 +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-12 23:25:14 +03:00
|
|
|
nix-shell ../default.nix --run "ghcid -c 'ghci -Wall -i../src Main.hs' -T 'Rib.App.dev Main.settings' --reload=Main.hs"
|
2019-07-11 20:58:46 +03:00
|
|
|
```
|
|
|
|
|
2019-07-13 00:03:12 +03:00
|
|
|
The above command does the following:
|
|
|
|
|
|
|
|
- Drop into a nix-shell with needed Haskell dependencies
|
|
|
|
- Compile the `rib` library and `example` through ghcid
|
|
|
|
- Whenever Haskell sources change ghcid reloads them
|
|
|
|
- Run `example/Main.hs` which in turn runs `Rib.App.run`
|
|
|
|
- This does the following:
|
|
|
|
1. Generate ./content into ./content.generated using Shake
|
|
|
|
2. Listens for changes to ./content, and re-generate them
|
|
|
|
3. Start a HTTP server serving the ./content.generated directory
|
|
|
|
|
|
|
|
Thus, by running that one command you get a production-quality web server
|
|
|
|
serving your statically generated HTML files that automatically get regenerated
|
|
|
|
when the source content changes. What's more, you may change the Haskell sources
|
|
|
|
such as `Main.hs` and ghcid will recompile and relaunch the whole thing. With
|
|
|
|
`rib` you get hot reload for free.
|