Go to file
Case Duckworth 9ae2eef082 Shorten 2021-02-04 12:31:19 -06:00
I init 2021-01-30 23:47:05 -06:00
.gitignore init 2021-01-30 23:47:05 -06:00
LICENSE init 2021-01-30 23:47:05 -06:00
README.md Undo fancy logic 2021-01-31 00:17:31 -06:00
nef Shorten 2021-02-04 12:31:19 -06:00

README.md

NEF

an even smaller static site generator


from the mind that brought you UNK, comes the new and improved SON OF UNK, NEF. Where UNK was a bloated one thousand bytes, the entirety of NEF is four hundred forty-four, over a fifty per cent reduction in size.

installation

clone this repo. NEF requires a POSIX environment.

use

create the following files and directories in the same directory as NEF:

  • L, the Layout file, which gets expanded by NEF. if L isn't provided, a default L will be generated.
  • H, the Html generator, which converts the input files to HTML. if H isn't provided, a default function H is called, which is pretty stupid: it wraps blank-line-separated paragraphs in <p> blocks. otherwise, it's pure HTML (mostly; see layouts, below).
  • I/, where the Input files, like pages, go. each page should have a name of the form NAME.OUT-FMT.IN-FMT, where NAME is the basename of the file, OUT-FMT is the output format (usually HTML), and IN-FMT is the input format (whatever -- in this repo it's called .h).
  • S/, where the Static files, like CSS and images, go.

layouts

the L file is basically a big here-doc, meaning that you can write arbitrary shell in it however you'd like. the following variables and functions are made available to L's environment (in addition, of course, to whatever NEF's environment is):

  • X, the eXpander. it turns L into a here-doc. make sure to escape your files properly!
  • H, the Htmlizer. it's a dumb awk function. even if you have a file H in NEF's directory, this function will still be here, taunting you with its stupidity.
  • P, aliased to echo.
  • T, aliased to sed q, which pulls the first line from a file. aka, the Title.
  • \$H, which keeps track of whether you're using the H file or function. you probably don't need this. but it's here.
  • \$F, the Filename of the current input file.
  • \$N, the baseName (without I/) of the current input file.

the default L also runs each input file through the X function (UNK devotees will be aware of the X function; it's basically shab but stupider and smaller), meaning that input files can basically function as templates themselves, and create their own fun.

uh, yeah, that's it

look, the script is a super short POSIX shell script. it's barely usable by itself. you're probably going to throw it out and write something else -- that's what I do.

copying

UNK used the WTFPL, which is the shortest license I've been able to find. however, for NEF, 443 bytes is far too long: it basically doubles the size of the repo! so I wrote my own license, which I'm calling the good choices license, or GCL for short. you can read the LICENSE file, or just read it here:

(c) 2020 Case Duckworth <acdw@acdw.net>

Everyone is permitted to do whatever with this software, without limitation. This software comes without any warranty whatsoever. Don't hurt yourself. Make good choices.

a trim 169 bytes, exclusive of the copyright information!

i mean, shit, if you wanna copy the thing, here it is, copy it:

#!/bin/sh
rm -r O;mkdir O;cp -r S O;alias P=echo T=sed\ q
X()(eval "\$(P 'cat<<.';cat;P;P .)");H()(awk -F'
' -vRS='' '!/^<.*>$/{$0="<p>"$0"</p>"}{print}')
[ -x H ]&&H=./H||H=H
[ -f L ]||P '<!DOCTYPE html><title>\$(T $F)</title>
<style>body{max-width:70ch;padding:1%}</style>
<h1>\$(T $F)</h1>\$(sed 1d \$F|X|\$H)<hr>/ \$(for P in I/*;do
[ \$P = \$F ]||(N=${P#I/};P "<a href=./${N%.*}>\$(T $P)</a> ")
done)'>L;for F in I/*;do N=\${F#I/};X<L>O/\${N%.*};done

or view the website or view the source code.

contributing

uh... send me an email? yeah. do that.