Le site arthur.bebou.netlib.re - retour accueil
git clone git://bebou.netlib.re/arthur.bebou
Log | Files | Refs |
commit 179dca51ad1c287e0f0032983e6edae8ab929707 parent 9c69831a90f26c2dc3d4c5f1a6c49645cbf7f343 Auterice: Arthur Pons <arthur.pons@unistra.fr> Date: Wed, 11 Sep 2024 16:48:33 +0200 Modification du printlayout Se nomme tsv2layout N'a plus besoin de prendre les noms des variables en argument mais se base sur le header du tsv à la place Modif de makearticletsv en fonction Modif des appels à tsv2layout Modif du nom du dossier temporaire "the" vers "tmpd" Modif du nom de la fonction "the" vers "show" Un peu plus raccord avec francium actuellement Diffstat:
M | atomic | | | 2 | +- |
M | common | | | 34 | +++++++++++++++++++++------------- |
M | contents/index.sh | | | 2 | +- |
M | layouts/atomentry | | | 8 | ++++---- |
M | layouts/atomfeed | | | 2 | +- |
M | layouts/html | | | 4 | ++-- |
M | layouts/md | | | 2 | +- |
M | layouts/plain | | | 2 | +- |
M | makearticlestsv | | | 9 | +++++++++ |
M | page | | | 26 | +++++++++++++------------- |
10 files changed, 54 insertions(+), 37 deletions(-)
diff --git a/atomic b/atomic @@ -4,7 +4,7 @@ cat public/articles.tsv | sort -t' ' -rk5 | - printlayout layouts/atomentry sourcefile destfile title description publication author > $the/entries + tsv2layout layouts/atomentry > $tmpd/entries . layouts/atomfeed diff --git a/common b/common @@ -1,20 +1,28 @@ #! /bin/sh -the=$(mktemp -d) -trap "rm -rf $the" EXIT +tmpd=$(mktemp -d) +trap "rm -rf $tmpd" EXIT -the() { - cd $the - cat "$@" +show() cat $tmpd/$1 + +tsv2layout() { + tee $tmpd/all | + head -n1 | tr '\t' '\n' > $tmpd/vars + tail -n+2 $tmpd/all | + while read line;do + eval $(echo "$line" | tr ' ' '\n' | paste -d '=' $tmpd/vars - | sed -E "s/=/&'/;s/$/'/") + . ./"$1" + done } -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 +tsv2layout() { + tee $tmpd/all | + head -n1 | tr '\t' '\n' > $tmpd/vars + tail -n+2 $tmpd/all | + while read line;do + eval $(echo "$line" | tr ' ' '\n' | paste -d '=' $tmpd/vars - | + sed -E 's/"/\\\"/g' | + sed -E 's/=/&"/;s/$/"/') + . ./"$1" done } diff --git a/contents/index.sh b/contents/index.sh @@ -25,7 +25,7 @@ endsection cat public/articles.tsv | grep -v 'contents/index.sh' | sort -t' ' -k5 -r | - printlayout layouts/listearticles sh html titre desc publication author | + tsv2layout layouts/listearticles | fmt -s | save_md main diff --git a/layouts/atomentry b/layouts/atomentry @@ -1,10 +1,10 @@ <<@@ cat <entry> - <title>$title</title> - <link href="http://arthur.bebou.netlib.re/${destfile##public/}"/> - <id>http://arthur.bebou.netlib.re/$destfile</id> + <title>$titre</title> + <link href="http://arthur.bebou.netlib.re/${html##public/}"/> + <id>http://arthur.bebou.netlib.re/$html</id> <updated>$(date -d "$publication" +%Y-%m-%dT%H:%M:%SZ)</updated> <author><name>${author:-Arthur Pons}</name></author> - <summary>${description:-Description non disponible}</summary> + <summary>${desc:-Description non disponible}</summary> </entry> @@ diff --git a/layouts/atomfeed b/layouts/atomfeed @@ -13,7 +13,7 @@ layout() { <name>Arthur Pons</name> </author> <id>http://arthur.bebou.netlib.re/</id> - $(the entries) + $(show entries) </feed> @@ } diff --git a/layouts/html b/layouts/html @@ -19,8 +19,8 @@ $([ "$file" = "contents/index.sh" -o "$file" = "contents/legal.sh" ] || echo "~$ </header> <body> <main> - $( [ "$file" = "contents/index.sh" ] || the tdm) - $(the main) + $( [ "$file" = "contents/index.sh" ] || show tdm) + $(show main) </main> </body> <footer> diff --git a/layouts/md b/layouts/md @@ -1,6 +1,6 @@ layout () { cat <<@@ # $title -$(the main) +$(show main) @@ } diff --git a/layouts/plain b/layouts/plain @@ -1,6 +1,6 @@ layout () { cat <<@@ $title -$(the main) +$(show main) @@ } diff --git a/makearticlestsv b/makearticlestsv @@ -4,6 +4,15 @@ getattr() { grep -m1 "^$1" | cut -d: -f2- | cut -b2- } +<<. paste -s -d' ' +sh +html +titre +desc +publication +author +. + for article in $(find contents -mindepth 2 -name 'index.sh') do dest=$(echo "$article" | sed 's/^contents/public/;s/sh$/html/') diff --git a/page b/page @@ -10,20 +10,20 @@ file="$1" destfile=$(echo "$file" | sed -E "s/\.sh/.html/" | cut -c10-) save_md() { - cat > $the/md - count=$(wc -w < $the/md) + cat > $tmpd/md + count=$(wc -w < $tmpd/md) time=$(dc -e "2k $count 160 / p" | sed 's/\..*//') cat | case "$TARGET" in - (html) cat $the/md | lowdown >> "$the/$1" ;; - (term) cat $the/md | lowdown -tterm >> "$the/$1" ;; - (md) cat $the/md | + (html) cat $tmpd/md | lowdown >> "$tmpd/$1" ;; + (term) cat $tmpd/md | lowdown -tterm >> "$tmpd/$1" ;; + (md) cat $tmpd/md | sed -E "s,\]\(/,]($url/," | - sed -E "s,($url[^.]*)\.html,\1.md," >> "$the/$1" ;; - (roff) cat $the/md | lowdown -tms >> "$the/$1" ;; + sed -E "s,($url[^.]*)\.html,\1.md," >> "$tmpd/$1" ;; + (roff) cat $tmpd/md | lowdown -tms >> "$tmpd/$1" ;; esac } -save_html() cat >> "$the/$1" +save_html() cat >> "$tmpd/$1" alias sectionmd:='<<\endsection save_md' alias sectionhtml:='<<\endsection save_html' @@ -39,16 +39,16 @@ description() description="$*" alias publication:=":" -grep -E "^##+" "$file" > $the/titles -< $the/titles lowdown | +grep -E "^##+" "$file" > $tmpd/titles +< $tmpd/titles lowdown | grep -v '^$' | cut -d'"' -f2 | - sed -E 's/^/(#/;s/$/)/' > $the/slugs -sed -E 's/^##/ /g;' $the/titles | + sed -E 's/^/(#/;s/$/)/' > $tmpd/slugs +sed -E 's/^##/ /g;' $tmpd/titles | sed -E 's/#/ /g' | sed -E 's/ (\w)/[\1/;s/$/]/' | sed -E 's/([^* ])/* \1/' | - paste - $the/slugs | + paste - $tmpd/slugs | sed '$ a - - -' | save_md tdm