From 73d09bb9b771f0fbbb60cd4f91623db8fa4709d3 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sat, 3 Aug 2024 19:00:22 +0200 Subject: refactor(templates/latex/academia): Use more common files --- common/scripts/latex/build.sh | 14 +++++ common/scripts/latex/extract_text_from_all.sh | 8 +++ common/scripts/latex/watch.sh | 70 +++++++++++++++++++++ templates/latex/academia/README.md | 14 +---- templates/latex/academia/build.sh | 15 +---- .../academia/scripts/extract_text_from_all.sh | 9 +-- templates/latex/academia/watch.sh | 71 +--------------------- 7 files changed, 96 insertions(+), 105 deletions(-) create mode 100755 common/scripts/latex/build.sh create mode 100755 common/scripts/latex/extract_text_from_all.sh create mode 100755 common/scripts/latex/watch.sh mode change 100644 => 120000 templates/latex/academia/README.md mode change 100755 => 120000 templates/latex/academia/build.sh mode change 100755 => 120000 templates/latex/academia/scripts/extract_text_from_all.sh mode change 100755 => 120000 templates/latex/academia/watch.sh diff --git a/common/scripts/latex/build.sh b/common/scripts/latex/build.sh new file mode 100755 index 0000000..1206ee7 --- /dev/null +++ b/common/scripts/latex/build.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env sh + +# if no parameter is given, use 'dst' as destination directory +if [ -z "$1" ]; then + dst=build +else + dst="$1" +fi + +# find all directories which are not the destination dir or inside it +find . -type d -not -name "$dst" -not -path "./$dst/*" -printf '%P\n' | while IFS= read -r dir; do + mkdir --parents "$dst/$dir" +done +latexmk -outdir="$dst" -file-line-error -pdflatex -recorder "./%INIT_APPLICATION_NAME.tex" diff --git a/common/scripts/latex/extract_text_from_all.sh b/common/scripts/latex/extract_text_from_all.sh new file mode 100755 index 0000000..11b2ac4 --- /dev/null +++ b/common/scripts/latex/extract_text_from_all.sh @@ -0,0 +1,8 @@ +#! /usr/bin/env sh + +grep 'INPUT ./' ./build/main.fls | uniq | sed 's/INPUT //' | while read -r file; do + if ! [ "$(basename "$file")" = preamble.tex ] && ! [ "$(basename "$file")" = gymnasium.png ]; then + printf "\n%% Filename: %s\n" "$file" + grep -v '^\s*%' "$file" + fi +done diff --git a/common/scripts/latex/watch.sh b/common/scripts/latex/watch.sh new file mode 100755 index 0000000..e5147f2 --- /dev/null +++ b/common/scripts/latex/watch.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env sh + +help() { + cat <&2 + exit 1 + ;; + esac +done + +[ -n "$reader" ] && "$reader" ./build/%INIT_APPLICATION_NAME.pdf & + +while true; do + ./build.sh + sleep "$time" +done diff --git a/templates/latex/academia/README.md b/templates/latex/academia/README.md deleted file mode 100644 index ffa08c2..0000000 --- a/templates/latex/academia/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# %INIT_APPLICATION_NAME_STYLIZED - -> %INIT_DESCRIPTION - -Some text about the project. - -## Licence - -This document is licensed under a -Creative Commons Attribution-ShareAlike 4.0 International License. - -You should have received a copy of the license along with this -work. If not, see . diff --git a/templates/latex/academia/README.md b/templates/latex/academia/README.md new file mode 120000 index 0000000..d250a7b --- /dev/null +++ b/templates/latex/academia/README.md @@ -0,0 +1 @@ +../../../common/README.md \ No newline at end of file diff --git a/templates/latex/academia/build.sh b/templates/latex/academia/build.sh deleted file mode 100755 index 1206ee7..0000000 --- a/templates/latex/academia/build.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env sh - -# if no parameter is given, use 'dst' as destination directory -if [ -z "$1" ]; then - dst=build -else - dst="$1" -fi - -# find all directories which are not the destination dir or inside it -find . -type d -not -name "$dst" -not -path "./$dst/*" -printf '%P\n' | while IFS= read -r dir; do - mkdir --parents "$dst/$dir" -done -latexmk -outdir="$dst" -file-line-error -pdflatex -recorder "./%INIT_APPLICATION_NAME.tex" diff --git a/templates/latex/academia/build.sh b/templates/latex/academia/build.sh new file mode 120000 index 0000000..4220aab --- /dev/null +++ b/templates/latex/academia/build.sh @@ -0,0 +1 @@ +../../../common/scripts/latex/build.sh \ No newline at end of file diff --git a/templates/latex/academia/scripts/extract_text_from_all.sh b/templates/latex/academia/scripts/extract_text_from_all.sh deleted file mode 100755 index 11b2ac4..0000000 --- a/templates/latex/academia/scripts/extract_text_from_all.sh +++ /dev/null @@ -1,8 +0,0 @@ -#! /usr/bin/env sh - -grep 'INPUT ./' ./build/main.fls | uniq | sed 's/INPUT //' | while read -r file; do - if ! [ "$(basename "$file")" = preamble.tex ] && ! [ "$(basename "$file")" = gymnasium.png ]; then - printf "\n%% Filename: %s\n" "$file" - grep -v '^\s*%' "$file" - fi -done diff --git a/templates/latex/academia/scripts/extract_text_from_all.sh b/templates/latex/academia/scripts/extract_text_from_all.sh new file mode 120000 index 0000000..6c7f5a8 --- /dev/null +++ b/templates/latex/academia/scripts/extract_text_from_all.sh @@ -0,0 +1 @@ +../../../../common/scripts/latex/extract_text_from_all.sh \ No newline at end of file diff --git a/templates/latex/academia/watch.sh b/templates/latex/academia/watch.sh deleted file mode 100755 index e5147f2..0000000 --- a/templates/latex/academia/watch.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env sh - -help() { - cat <&2 - exit 1 - ;; - esac -done - -[ -n "$reader" ] && "$reader" ./build/%INIT_APPLICATION_NAME.pdf & - -while true; do - ./build.sh - sleep "$time" -done diff --git a/templates/latex/academia/watch.sh b/templates/latex/academia/watch.sh new file mode 120000 index 0000000..fa5d4ea --- /dev/null +++ b/templates/latex/academia/watch.sh @@ -0,0 +1 @@ +../../../common/scripts/latex/watch.sh \ No newline at end of file -- cgit 1.4.1