arthur.bebou

Le site arthur.bebou.netlib.re - retour accueil

git clone git://bebou.netlib.re/arthur.bebou
Log | Files | Refs |

commit 1dc91c741677206a3c64e27d1811f09e4104572b
parent 16bc295c624329f77beee7e60a123a88f09e17d4
Auterice: Arthur Pons <arthur.pons@unistra.fr>
Date:   Mon,  3 Jun 2024 20:23:35 +0200

Factorisation dans common

Quelques trucs communs à page et à atomic dans common

Diffstat:
Matomic | 15+--------------
Acommon | 20++++++++++++++++++++
Mpage | 22+++-------------------
3 files changed, 24 insertions(+), 33 deletions(-)

diff --git a/atomic b/atomic @@ -1,19 +1,6 @@ #! /bin/sh -the=$(mktemp -d) - -printlayout() { - layoutfile="$1";shift - cat | while read line - do - echo $@ | tr ' ' '\n' > "$the/vars" - echo "$line" | tr ' ' '\n' > "$the/stdin" - eval $(paste -d'\n' "$the/vars" "$the/stdin" | xargs -d'\n' printf '%s="%s";') - . $layoutfile - done -} - -the() cat $the/$1 +. ./common cat public/articles.tsv | sort -t' ' -rk5 | diff --git a/common b/common @@ -0,0 +1,20 @@ +#! /bin/sh + +the=$(mktemp -d) +trap "rm -rf $the" EXIT + +the() { + cd $the + cat "$@" +} + +printlayout() { + layoutfile="$1";shift + cat | while read line + do + echo $@ | tr ' ' '\n' > "$the/vars" + echo "$line" | tr ' ' '\n' > "$the/stdin" + eval $(paste -d'\n' "$the/vars" "$the/stdin" | xargs -d'\n' printf '%s="%s";') + . $layoutfile + done +} diff --git a/page b/page @@ -1,9 +1,9 @@ #! /usr/bin/env dash +. ./common + STYLE=/style.css -the=$(mktemp -d) -trap "rm -rf $the" EXIT TARGET="${2:-html}" file="$1" @@ -22,8 +22,8 @@ save_md() { (roff) cat $the/md | lowdown -tms >> "$the/$1" ;; esac } -save_html() cat >> "$the/$1" +save_html() cat >> "$the/$1" alias sectionmd:='<<\endsection save_md' alias sectionhtml:='<<\endsection save_html' @@ -39,22 +39,6 @@ description() description="$*" alias publication:=":" -the() { - cd $the - cat "$@" -} - -printlayout() { - layoutfile="$1";shift - cat | while read line - do - echo $@ | tr ' ' '\n' > "$the/vars" - echo "$line" | tr ' ' '\n' > "$the/stdin" - eval $(paste -d'\n' "$the/vars" "$the/stdin" | xargs -d'\n' printf '%s="%s";') - . $layoutfile - done -} - grep -E "^##+" "$file" > $the/titles < $the/titles lowdown | grep -v '^$' |