WEBVTT

00:00.000 --> 00:12.000
This is Zavier Lombain.

00:12.000 --> 00:13.000
Perfect.

00:13.000 --> 00:18.000
Well, it sounded very German to me, but it could be more French, but it's great.

00:18.000 --> 00:19.000
It's great.

00:19.000 --> 00:20.000
Okay, great.

00:20.000 --> 00:21.000
Thank you very much.

00:21.000 --> 00:24.000
And he's going to talk about Nexus S, which is an

00:24.000 --> 00:26.000
opportunity for building static sites.

00:26.000 --> 00:31.000
Please, one welcome and a round of applause for Zavier Lombain.

00:31.000 --> 00:33.000
Thank you.

00:33.000 --> 00:35.000
Zavier Lombain.

00:35.000 --> 00:37.000
Zavier Lombain, look forward to your presentation.

00:37.000 --> 00:38.000
Thank you.

00:38.000 --> 00:42.000
So this is just a tiny library that I made for my own static site that I

00:42.000 --> 00:43.000
generate.

00:43.000 --> 00:44.000
It's called Nix.

00:44.000 --> 00:46.000
It pronounced it like your a snake.

00:46.000 --> 00:49.000
So if you just need to make a static site, probably your best

00:49.000 --> 00:52.000
bet is to use something like 11T or Jkill.

00:52.000 --> 00:54.000
You might have weird needs like me.

00:54.000 --> 00:58.000
For example, when I build my site, I also generate a bunch of

00:58.000 --> 01:01.000
PNGs from a bunch of SVGs.

01:01.000 --> 01:04.000
And I just want to script that in a certain way.

01:04.000 --> 01:07.000
I also have like an L web app that I want to build at the same

01:07.000 --> 01:08.000
time.

01:08.000 --> 01:13.000
And I also want to like display some source code in like custom

01:13.000 --> 01:15.000
programming languages with like custom tree set or

01:15.000 --> 01:16.000
grammar.

01:16.000 --> 01:17.000
So weird stuff.

01:17.000 --> 01:20.000
And if you need to do weird stuff to generate your websites,

01:20.000 --> 01:22.000
you're best bet is to probably roll your own.

01:22.000 --> 01:24.000
It's not extremely difficult.

01:24.000 --> 01:26.000
It's like you need a file conversion and a build system.

01:26.000 --> 01:28.000
And so you could basically just use make and

01:28.000 --> 01:29.000
time doc.

01:29.000 --> 01:30.000
That works relatively well.

01:30.000 --> 01:33.000
Pondoc is amazing and make gets the job done.

01:33.000 --> 01:34.000
You know.

01:34.000 --> 01:37.000
But there's something better than make than you can use.

01:37.000 --> 01:38.000
Of course.

01:38.000 --> 01:40.000
This is the next step room.

01:40.000 --> 01:45.000
So Nix is a library that basically takes pages.

01:45.000 --> 01:48.000
A page in your website would be a derivation in Nix.

01:48.000 --> 01:52.000
It takes pages and then provides you functions that convert pages from

01:52.000 --> 01:55.000
one format to another and aggregates them together.

01:55.000 --> 01:58.000
So here I have a basic example of a website that has a bunch of

01:58.000 --> 02:00.000
knockdown pages in a directory.

02:00.000 --> 02:04.000
And then I define a processor that as I call them,

02:04.000 --> 02:05.000
which is knockdown to HTML.

02:05.000 --> 02:09.000
It uses Pondoc to convert knockdown pages into HTML.

02:09.000 --> 02:11.000
And then just below that.

02:11.000 --> 02:16.000
I use this map directory function to convert every page in

02:16.000 --> 02:20.000
a folder into month-down and then finally at the end I

02:20.000 --> 02:22.000
aggregate them in a directory.

02:22.000 --> 02:26.000
And this is already basically a kind of a website.

02:26.000 --> 02:32.000
Each page in Nix comes with a few attributes on top of the derivation attributes.

02:32.000 --> 02:34.000
So I have a file name.

02:34.000 --> 02:38.000
I have the text of the page which can be used to like transform it

02:38.000 --> 02:39.000
some ways.

02:39.000 --> 02:42.000
I also have the metadata which is usually extracted from the page.

02:42.000 --> 02:45.000
For example, if you use Pondoc, you can use it to extract the title of a

02:45.000 --> 02:50.000
knockdown document and like a Janelle preemble from a knockdown document

02:50.000 --> 02:52.000
to get some additional metadata.

02:52.000 --> 02:55.000
And then you can use this to generate some more complex things.

02:55.000 --> 02:58.000
Like here I have an example of the same website but I want to

02:58.000 --> 03:00.000
generate an index page for it.

03:00.000 --> 03:04.000
And so the first thing that I do is I build a list of HTML links

03:04.000 --> 03:08.000
from the page title and the file names that are in the metadata.

03:08.000 --> 03:11.000
I mean, more generally in the attributes of the pages.

03:11.000 --> 03:16.000
And then I concat all these links into a new page index.html.

03:16.000 --> 03:20.000
And then I create a new directory with all my pages plus my new index

03:20.000 --> 03:23.000
that I just created.

03:23.000 --> 03:24.000
Yeah.

03:24.000 --> 03:28.000
And then if you're using a static site generator typically you won't

03:28.000 --> 03:31.000
use a templating language like moustache.

03:31.000 --> 03:33.000
You could use that with nix.

03:33.000 --> 03:35.000
But we already have a programming language that works pretty well.

03:35.000 --> 03:37.000
So might as well reuse it.

03:37.000 --> 03:42.000
And what is practice I do with this is I use nix as the templating

03:42.000 --> 03:43.000
language.

03:43.000 --> 03:48.000
So here I define a functiononeyat that takes a title in a content and

03:48.000 --> 03:51.000
those are again like used from like those attributes of the page.

03:51.000 --> 03:57.000
And so it's a function that will cool because with the attributes of the page.

03:57.000 --> 03:59.000
And then be used to interpret them into it.

03:59.000 --> 04:03.000
So at the bottom I have this like nix.html.šats template,

04:03.000 --> 04:06.000
it's template, and then I feed it whatever page I want to

04:06.000 --> 04:08.000
instantiate in that template.

04:08.000 --> 04:11.000
But we can do something much worse than this, which

04:11.000 --> 04:16.000
is abuse import from derivation and with index to do

04:16.000 --> 04:19.000
something like you have here at the bottom, which is

04:19.000 --> 04:22.000
it's a knockdown file, but in practice it's going to be

04:22.000 --> 04:26.000
inserted, like it behave like it's in a like nix double

04:26.000 --> 04:29.000
quoted string, and so you can do string into a

04:29.000 --> 04:31.000
position in it, like it was nix, and you can

04:31.000 --> 04:34.000
call nix functions in it and everything.

04:34.000 --> 04:38.000
And it's kind of awful theoretically, but it works really well.

04:38.000 --> 04:40.000
This is what I use for my websites.

04:40.000 --> 04:44.000
It's very convenient, and you can use nix, like it's

04:44.000 --> 04:46.000
php.

04:46.000 --> 04:47.000
And that's it for me.

04:47.000 --> 04:49.000
You can check out the website at this code

04:49.000 --> 04:52.000
Berkeley, and this is my website, which is built with this.

04:59.000 --> 05:01.000
Thank you.

