Skip to content

Instantly share code, notes, and snippets.

@louisswarren

louisswarren/.gitignore

Last active Jun 23, 2020
Embed
What would you like to do?
makebb
posts
threads
www
WWWTHREADSHTML = $(addsuffix .html,$(subst threads,www,$(wildcard threads/*)))
XARGSSORT = xargs -n 1 | sort -V | xargs
THREADTARGETS = $(shell echo $(WWWTHREADSHTML) | $(XARGSSORT))
.PHONY: index
index: allthreads index.html
index.html: threads/* posts/*
.PHONY: allthreads
allthreads: $(THREADTARGETS)
www/%.html: threads/% posts/%-*
echo $(wordlist 2, $(words $^), $^) | $(XARGSSORT) ./makethread.sh $* $< > $@
.PHONY: clean
clean:
rm -f www/*.html
.PHONY: deleteall
deleteall: clean
rm -f threads/* posts/*
.PHONY: jobs
jobs:
mkdir -p jobs
patch -d jobs < testjobs.patch
#!/bin/sh
usage ()
{
echo "Usage: $0 <threadid> <threadfile> [POST ...]"
}
subject=""
while getopts "h" opt; do
case "$opt" in
\?)
usage
exit 1
;;
h)
usage
exit
;;
esac
done
shift $((OPTIND-1))
[ "${1:-}" = "--" ] && shift
if [ -z "$1" ]; then
usage
exit 1
else
threadid="$1"
fi
shift
if [ -z "$1" ]; then
usage
exit 1
else
threadfile="$1"
fi
shift
cat << EOF
<div id="thread-$threadid">
<h1>
EOF
cat "$threadfile"
cat << EOF
</h1>
EOF
while [ -n "$1" ]; do
cat "$1"
shift
done
cat << EOF
</div>
EOF
#!/bin/sh
usage ()
{
echo "Usage: $0 <THREAD>"
}
while getopts "h" opt; do
case "$opt" in
\?)
usage
exit 1
;;
h)
usage
exit
;;
esac
done
shift $((OPTIND-1))
[ "${1:-}" = "--" ] && shift
if [ -z "$1" ]; then
usage
exit 1
elif [ ! -f "threads/$1" ]; then
echo "Unable to post to thread $1"
exit 1
fi
threadid="$1"
lastid=`find posts -type f | cut -d'-' -f 2 | sort -rV | head -n 1`
postid=$((lastid+1))
dest="posts/$threadid-$postid"
touch "$dest"
source ./posttemplate.sh > $dest
echo "Created post $postid in thread $threadid"
#!/bin/sh
usage ()
{
echo "Usage: $0 [-s SUBJECT]"
}
subject=""
while getopts "hs:" opt; do
case "$opt" in
\?)
usage
exit 1
;;
h)
usage
exit
;;
s)
subject="$OPTARG"
;;
esac
done
shift $((OPTIND-1))
[ "${1:-}" = "--" ] && shift
lastid=`find posts -type f | cut -d'-' -f 2 | sort -rV | head -n 1`
threadid=$((lastid+1))
dest="posts/$threadid-$threadid"
touch "$dest"
source ./posttemplate.sh > $dest
echo "$subject" > "threads/$threadid"
echo "Created thread $threadid with subject '$subject'"
cat << EOF
<div id="post-$postid">
EOF
sed 's/^$/<br>/' /dev/stdin
cat << EOF
</div>
EOF
#!/bin/sh
for job in jobs/*; do
case "$job" in
*:newthread)
tail +2 "$job" | ./newthread.sh -s "$(head -n 1 "$job")"
;;
*:newpost)
tail +2 "$job" | ./newpost.sh "$(head -n 1 "$job")"
;;
*)
echo "Could not parse job $job"
;;
esac
done
diff -ruN 1591871834.375702366:127.0.0.1:newthread jobs/1591871834.375702366:127.0.0.1:newthread
--- 1591871834.375702366:127.0.0.1:newthread 1970-01-01 12:00:00.000000000 +1200
+++ jobs/1591871834.375702366:127.0.0.1:newthread 2020-06-23 18:56:39.567201248 +1200
@@ -0,0 +1,6 @@
+Thread 1
+Hi, I'm writing about thread 1.
+
+Best regards,
+Loopback
+1-1
diff -ruN 1591871858.194599302:127.0.0.1:newpost jobs/1591871858.194599302:127.0.0.1:newpost
--- 1591871858.194599302:127.0.0.1:newpost 1970-01-01 12:00:00.000000000 +1200
+++ jobs/1591871858.194599302:127.0.0.1:newpost 2020-06-23 18:56:39.567201248 +1200
@@ -0,0 +1,6 @@
+1
+Oops, forgot my surname.
+
+Best regards,
+Loopback Smith
+1-2
diff -ruN 1591871868.205685555:louis@euler:newpost jobs/1591871868.205685555:louis@euler:newpost
--- 1591871868.205685555:louis@euler:newpost 1970-01-01 12:00:00.000000000 +1200
+++ jobs/1591871868.205685555:louis@euler:newpost 2020-06-23 18:56:39.570534591 +1200
@@ -0,0 +1,3 @@
+1
+Stop talking to yourself.
+1-3
diff -ruN 1591871870.959701118:127.0.0.3:newthread jobs/1591871870.959701118:127.0.0.3:newthread
--- 1591871870.959701118:127.0.0.3:newthread 1970-01-01 12:00:00.000000000 +1200
+++ jobs/1591871870.959701118:127.0.0.3:newthread 2020-06-23 18:56:39.570534591 +1200
@@ -0,0 +1,3 @@
+I can make a thread too
+Not really sure what to say though
+4-4
diff -ruN 1591871873.665086979:127.0.0.6:newpost jobs/1591871873.665086979:127.0.0.6:newpost
--- 1591871873.665086979:127.0.0.6:newpost 1970-01-01 12:00:00.000000000 +1200
+++ jobs/1591871873.665086979:127.0.0.6:newpost 2020-06-23 18:56:39.570534591 +1200
@@ -0,0 +1,3 @@
+4
+Nice thread btw
+4-5
diff -ruN 1591871877.428722173:127.0.0.5:newpost jobs/1591871877.428722173:127.0.0.5:newpost
--- 1591871877.428722173:127.0.0.5:newpost 1970-01-01 12:00:00.000000000 +1200
+++ jobs/1591871877.428722173:127.0.0.5:newpost 2020-06-23 18:56:39.570534591 +1200
@@ -0,0 +1,3 @@
+1
+Hi
+1-6
diff -ruN 1591871878.885539919:127.0.0.3:newpost jobs/1591871878.885539919:127.0.0.3:newpost
--- 1591871878.885539919:127.0.0.3:newpost 1970-01-01 12:00:00.000000000 +1200
+++ jobs/1591871878.885539919:127.0.0.3:newpost 2020-06-23 18:56:39.570534591 +1200
@@ -0,0 +1,3 @@
+4
+Hi
+4-7
diff -ruN 1591871883.090408678:127.0.0.1:newpost jobs/1591871883.090408678:127.0.0.1:newpost
--- 1591871883.090408678:127.0.0.1:newpost 1970-01-01 12:00:00.000000000 +1200
+++ jobs/1591871883.090408678:127.0.0.1:newpost 2020-06-23 18:56:39.570534591 +1200
@@ -0,0 +1,3 @@
+4
+Hi again
+4-8
diff -ruN 1591871884.955326157:louis@euler:newpost jobs/1591871884.955326157:louis@euler:newpost
--- 1591871884.955326157:louis@euler:newpost 1970-01-01 12:00:00.000000000 +1200
+++ jobs/1591871884.955326157:louis@euler:newpost 2020-06-23 18:56:39.570534591 +1200
@@ -0,0 +1,3 @@
+4
+Hi yet again
+4-9
diff -ruN 1591871889.509854221:127.0.0.3:newpost jobs/1591871889.509854221:127.0.0.3:newpost
--- 1591871889.509854221:127.0.0.3:newpost 1970-01-01 12:00:00.000000000 +1200
+++ jobs/1591871889.509854221:127.0.0.3:newpost 2020-06-23 18:56:39.570534591 +1200
@@ -0,0 +1,3 @@
+4
+Hi once again.
+4-10
diff -ruN 1591871902.056748791:127.0.0.1:newpost jobs/1591871902.056748791:127.0.0.1:newpost
--- 1591871902.056748791:127.0.0.1:newpost 1970-01-01 12:00:00.000000000 +1200
+++ jobs/1591871902.056748791:127.0.0.1:newpost 2020-06-23 18:56:39.570534591 +1200
@@ -0,0 +1,3 @@
+1
+Hi!!!!
+1-11
diff -ruN 1591871927.649616593:louis@euler:newthread jobs/1591871927.649616593:louis@euler:newthread
--- 1591871927.649616593:louis@euler:newthread 1970-01-01 12:00:00.000000000 +1200
+++ jobs/1591871927.649616593:louis@euler:newthread 2020-06-23 18:56:39.570534591 +1200
@@ -0,0 +1,3 @@
+Newest thread
+This thread was created last.
+12-12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.