fusch.online

git / lists / casts

git.fusch.online/twtxt2html

Convert twtxt files to html
git clone git://git.fusch.online/twtxt2html
Log / Files / Issues

commit 2adb618a24e962e0af90755bfb9e1cecddf3ddd9
Author: tutti <tutti@fusch.online>
Date:   Tue, 19 Nov 2019 13:10:40 +0100

init

Diffstat:
Atwtxt2html.sh | 27+++++++++++++++++++++++++++
1 file changed, 27 insertions(+), 0 deletions(-)

diff --git a/twtxt2html.sh b/twtxt2html.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + + +[[ -z $1 || -z $2 ]] && { + cat <<EOF +usage: ${0##*/} <twtxt.txt> <remote_base_url> +EOF + exit +} + +[[ ! -f $1 ]] && exit +twtxt=$1 +url=$2 + +sort -r $twtxt | while read -r line; do + date=$(date -d "$(cut -d"$(printf "\t")" -f1 <<< "$line")" +"%Y/%m/%d %H:%M") + + cat <<EOF +<div class="twtxt"> + <div class="user"> + <a href="$url/$USER.txt">@$USER</a> + <span class="date">($date)</span> + </div> + <p>$(cut -d"$(printf "\t")" -f2- <<< "$line" | markdown -f +autolink)</p> +</div> +EOF +done