1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
NDUJA -- an sms-sized ssg
nduja is a static site generator that can fit in a text message or an old-school
tweet, just barely. It's 140 bytes long on the nose. In fact, I'll put the
whole thing here for you:
```
#!/bin/sh
X()(eval "dd<<.
`awk -vRS= '!/^</{$0="<p>"$0"</p>"}//'`
.");N()(X<T>${n%.n});<T||echo '`X<$n`'>T
<L&&. ./L;for n in *.n;do N;done
```
Even though this is so short, it does a lot! It loops through every file ending
in `.n` in the current directory, and then
1. automatically adds `<p>` tags to paragraphs not starting with a `<`
2. expands the template file (T) as a shell here-document with its contents.
if `T` doesn't exist, it's created for you! isn't that neat :)
I've even added in EXTENSIBILITY:
If a library file (L) exists, it'll be sourced, meaning you can define whatever
shell functions you need to make writing your site easier. Crucially, you can
redefine these two functions:
- `X`, the eXpando function, which defines how to plop your content into T.
- `N`, the NDUJA function, which defines what to do to turn a .n file into a
.. whatever.
Go nuts! You could argue that by redefining those two functions, nduja is not
really text-sized, but i don't care! the actual script contains the
functionality you technically need ;)
LICENSE: there isn't one, silly! This program is released to the PUBLIC DOMAIN
see also: unk, nef, ...
|