about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2022-09-16 14:55:51 -0500
committerCase Duckworth2022-09-16 14:55:51 -0500
commit0da76871ae527c6d97717c3f8359763ebe9bd329 (patch)
treeb2513eec64426b7ea412ffbda9695eb62fb51f71
downloadshite-0da76871ae527c6d97717c3f8359763ebe9bd329.tar.gz
shite-0da76871ae527c6d97717c3f8359763ebe9bd329.zip
Initial commit
-rw-r--r--COPYING10
-rw-r--r--Makefile23
-rw-r--r--README.md69
-rwxr-xr-xshite90
4 files changed, 192 insertions, 0 deletions
diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..f52335b --- /dev/null +++ b/COPYING
@@ -0,0 +1,10 @@
1SHITE v.💩
2Copyright (C) 2022 C. Duckworth <acdw@acdw.net>
3
4Everyone is permitted to do whatever with this software, without
5limitation. This software comes without any warranty whatsoever,
6but with two pieces of advice:
7
8- Don't hurt yourself.
9- Make good choices.
10
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..fe6ac4b --- /dev/null +++ b/Makefile
@@ -0,0 +1,23 @@
1# SHITE
2# by C. Duckworth <acdw@acdw.net>
3
4PREFIX=/usr/local
5NAME=shite
6
7SCRIPT=$(PWD)/$(NAME)
8
9help:
10 @echo "SHITE: by C. Duckworth"
11 @echo "Makefile targets:"
12 @echo "install: install to $(DESTDIR)$(PREFIX)."
13 @echo "link: symlink to $(DESTDIR)$(PREFIX)."
14 @echo "uninstall: remove from $(DESTDIR)$(PREFIX)"
15
16install: $(SCRIPT)
17 install -D $< $(DESTDIR)$(PREFIX)/bin/$(NAME)
18
19link: $(SCRIPT)
20 ln -sf $< $(DESTDIR)$(PREFIX)/bin/$(NAME)
21
22uninstall:
23 -rm -f $< $(DESTDIR)$(PREFIX)/bin/$(NAME)
diff --git a/README.md b/README.md new file mode 100644 index 0000000..96b23ce --- /dev/null +++ b/README.md
@@ -0,0 +1,69 @@
1# shite
2## what it says on the tin
3
4`shite` shits out a site using posix `sh`, `awk`, and `cp`---that's it.
5Of course, it is shite. But it'll make a site.
6
7## use
8
9make a site directory somewhere on your system and fill it with HTML files.
10these can be just the body parts of these files---they will be enclosed with a
11template, which is discussed below. you can also ignore enclosing paragraphs
12with `<p>` tags---paragraphs not starting with `<` will automatically be
13enclosed with them.
14
15when you run `shite`, it will collect all HTML files, run them through various
16templates, and shit them out into the `out/` directory in the site directory.
17each page will be sent through `.template.html` and into `out/PAGE/index.html`,
18where `PAGE` is the filename without `.html`. Then they'll be collected into an
19index using `.index.html`, and into an RSS 2.0 feed using `.feed.xml`.
20
21`.template.html`, `index.html`, and `.feed.xml` are treated as sh `heredocs`.
22that is, any `$variable`, `$(function)`, or the like will be expanded. `title`,
23`body`, and `pubdate` are provided for convenience; you can define others in
24`.shite.sh`. a very simple template could look like this:
25
26```
27<!DOCTYPE html>
28<title>$(title)</title>
29$(body)
30```
31
32every other file in the site directory---that is, any file or directory that
33isn't an HTML or XML file---will be copied to `out/` recursively, so go nuts!
34
35### installation
36
37```
38# make install
39```
40
41### invocation
42
43invoking `shite` is simple:
44
45```
46$ shite [-d DOMAIN] [-C DIRECTORY]
47```
48
49`DOMAIN` is your site's domain for the feed generator; the default is
50the name of the site directory. `DIRECTORY` will change the directory before
51generating a site, so you can run `shite` from anywhere.
52
53## license
54
55Copyright (C) 2022 c. Duckworth and licensed under the Good Choices License.
56See COPYING for details.
57
58## contributing
59
60Send me an [email](mailto:shite+git@me.acdw) with comments, complaints, and
61merge requests. if you want.
62
63## testimonials
64
65> oh dang that is fancy
66~ m455
67
68> hehe, nah it's shite
69~ acdw
diff --git a/shite b/shite new file mode 100755 index 0000000..ebd9e1e --- /dev/null +++ b/shite
@@ -0,0 +1,90 @@
1#!/bin/sh
2# shite --- shit out a site
3# by C. Duckworth <acdw@acdw.net>
4
5expand() {
6 end="expand_$(date +%s)_${count:=0}"
7 eval "$(
8 echo "cat <<$end"
9 cat "$@"
10 echo
11 echo "$end"
12 )" && count=$((count + 1))
13}
14
15body() {
16 awk 'NR==1{next;}{print;}'
17}
18
19phtml() {
20 awk 'BEGIN{RS="";}/^[ \t]*</{print;next;}{print "<p>"$0"</p>";}'
21}
22
23title() {
24 awk 'BEGIN{FS=" ";}NR==1{print $1;quit;}'
25}
26
27pubdate() {
28 awk 'BEGIN{FS=" ";}NR==1{print $2;quit;}'
29}
30
31filters() {
32 body | phtml
33}
34
35pages() {
36 for file; do
37 echo >&2 "$file"
38 filters <"$file" |
39 expand .template.html >out/"${1%.html}"/index.html
40 done
41}
42
43index() {
44 for file; do
45 echo >&2 "index: $file"
46 echo "<li><a href=\"$file\">$(title "$file")</a></li>"
47 done | expand .index.html >out/index.html
48}
49
50feed() {
51 for file; do
52 echo >&2 "feed: $file"
53 echo "<item>"
54 echo " <title>$(title "$file")</title>"
55 echo " <link>$DOMAIN/${file%.html}/</link>"
56 echo " <guid>$DOMAIN/${file%.html}/</guid>"
57 if test -n "$(pubdate "$file")"; then
58 echo " <pubDate>$(pubdate "$file")</pubDate>"
59 fi
60 echo "</item>"
61 done | expand .feed.xml >out/feed.xml
62}
63
64main() {
65 DOMAIN="${SHITE_DOMAIN:-${PWD##*/}}"
66 SOURCE="$PWD"
67 while getopts d:C: opt; do
68 case "$opt" in
69 d) DOMAIN="$OPTARG" ;;
70 C) SOURCE="$OPTARG" ;;
71 *) exit 1 ;;
72 esac
73 done
74 shift "$((OPTIND - 1))"
75
76 cd "$SOURCE"
77 mkdir -p out
78 test -f .shite.sh && . .shite.sh
79 pages *.html
80 index *.html
81 feed *.html
82 for file in *; do
83 test "${file#*.}" = html && continue
84 test "${file#*.}" = xml && continue
85 cp -r "$file" out/
86 done
87}
88
89test -n "$DEBUG" && set -x
90test -n "$SOURCE" || main "$@"