diff options
-rw-r--r-- | README.md | 27 | ||||
-rwxr-xr-x | phl-org.sh | 87 | ||||
-rw-r--r-- | phlog.org | 27 |
3 files changed, 141 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..ca54354 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +### phl-org + +This is a simple shell script to maintain a phlog (i.e., a +gopher-based-blog) using org-mode. + +The idea is to organise each of your phlog post as an org-mode entry. +A post will start on the first line beginning with a "* " (star-space), +and last until another line beginning with "* " is found. + +Each post will be put in a separate directory, named after the title +(with spaces replaced with "_"). + +`phl-org.sh` will also create a gophermap for your phlog. + +The program currently uses `par` as a filter to indent and justify your +phlogs. Change the variable `FILTER` to use your own preferred +formatting options/tools. + +#### Example: + +A sample of an org-mode file to be fed to `phl-org.sh` is provided in +`phlog.org`. To generate the phlogs and the corresponding gophermap you +just type: + + $ phl-org.sh phlog.org + + diff --git a/phl-org.sh b/phl-org.sh new file mode 100755 index 0000000..f8d04c2 --- /dev/null +++ b/phl-org.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env sh + +# +# phl-org: manage a phlog with org-mode +# +# KatolaZ <katolaz@freaknet.org> (2018) +# + +INFILE=${1:-/dev/stdin} +DESTDIR=${2:-"."} +pad=" " +FILTER="par 68ftp4" +headpad="+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" + +## if you are under *BSD, you'd probably use SED=gsed +## +#SED=gsed + +SED=sed + +## function +write_gophermap(){ + + buff=$1 + curdir=$2 + curfile=$3 + INDEX=$4 + if [ ! -d "$curdir" ]; then + mkdir "$curdir"; + fi + echo $buff | eval "$FILTER" > "$curfile" + echo "1$curdir\t$curdir" >> $INDEX +} + + +##function +gophermap_header(){ + + GOPHERMAP=$1 + + cat <<EOF>$GOPHERMAP ++++++++++++++++++++++++++++++ ++ This is my gopherhole + ++++++++++++++++++++++++++++++ + + +EOF + +} + + + +## function +org2phlog(){ + + FILEIN=$1 + INDEX=$2 + curfile="" + buff="" + IFS=" +" + while read line; do + + #echo $wholeline | ${SED} -r -e '/^\* /p' + if [ -n "$(echo $line | ${SED} -r -n -e '/^\* /p')" ]; then + if [ -n "$curfile" ]; then + write_gophermap $buff $curfile "$curfile/gophermap" $INDEX + fi + buff="$headpad\n\n$pad$line\n\n$headpad" + curfile=$(echo $line | ${SED} -r -e 's/^\* //g' -e 's/\ /_/g;s/\t/_/g;s/</-/g;s/>/-/g;s/://g') + if [ -z "$curfile" ]; then + curfile="(blank)" + fi + curfile="$curfile" + else + buff="${buff}\n $line" + fi + done<$FILEIN + if [ -n "$curfile" ]; then + write_gophermap $buff $curfile "$curfile/gophermap" $INDEX + fi +} + +#echo "INFILE: $INFILE" + +gophermap_header ./gophermap +org2phlog $INFILE ./gophermap diff --git a/phlog.org b/phlog.org new file mode 100644 index 0000000..8f75901 --- /dev/null +++ b/phlog.org @@ -0,0 +1,27 @@ + + + +* Second post <2017-11-12 Sun 22:38> + +This is the second post. The system seems to work by now. + +The shell script works without major problems and generates +a visually pleasant kind of posts, mainly due to the usage +of 'par' to justify paragraphs. + + +* First experiments with phl-org <2017-11-12 Sun 20:37> + +I decided I will make some experiments with phlogging. + +My intention is to use Emacs' org-mode. The idea is to organise each long +post as an org-mode entry. A post will start on the first line +beginning with a "* " (star-space), and last until another line +beginning with "* " is found. + +Each post will be put in a separate directory, named after the title +(with spaces replaced with "_"). + +The org-mode buffer will be processes by a simple shell script, called +'phl-org.sh', which creates the necessary directories (one for each +post), and refreshes the gophermap. |