diff --git a/build.sh b/build.sh index c404931..e5ec690 100755 --- a/build.sh +++ b/build.sh @@ -1,10 +1,8 @@ #!/bin/bash echo "Сборка сайта в двух помидорных темах и оптимизация результатов." time_ms="$(date '+%s%3N')" -# удаление каталогов предыдущей сборки -rm -rf _site -rm -rf _site_older -rm -rf _site_color +# удаление каталогов предыдущей сборки, если таковые имеются +find . -maxdepth 1 -type d -name "_site*" -exec rm -rf {} \; # сборка сайта в двух помидорных темах function jekyll_build { case "$1" in @@ -22,8 +20,8 @@ function jekyll_build { jekyll build --disable-disk-cache --quiet } export -f jekyll_build -# запуск параллельной сборки сайта в двух помидорных темах -printf '%s\0' {older,color} | xargs -I{} -n1 -0 -P0 bash -c 'jekyll_build "{}"' +# запуск параллельной сборки сайта в двух помидорных темах оформления +printf 'jekyll_build "%s"\0' {older,color} | xargs -n1 -0 -P0 bash -c # объединение двух сборок cp -r _site_older/_site . cp -r _site_color/_site ./_site/color @@ -41,24 +39,21 @@ cp -r color/assets/* . rm -r color/assets rm -r color/404.html rm -r color/return.html -# оптимизация ряда тегов -function optimize_html { - echo "Оптимизация: $1" - sed -i 's|layout-padding=""|layout-padding|g' "$1" - sed -i 's| class="language-plaintext highlighter-rouge"||g' "$1" - sed -i 's| class="language-java highlighter-rouge"||g' "$1" - sed -i 's| class="language-js highlighter-rouge"||g' "$1" - sed -i 's| class="language-bash highlighter-rouge"||g' "$1" - sed -i 's|
` and add the title — as a result, we get a short and +the constructed tree in a container `` and add the header — as a result, we get a short and concise Markdown file with links. ```bash @@ -36,17 +36,13 @@ function directory_tree { local head="$2" local tail="$3" # prefix for current element - if [ "one" == "$4" ]; then - echo -n "/" - else - echo -ne "\n$head" - fi + [ "one" == "$4" ] && printf '%s' "/" || printf '\n%s' "$head" # current element of the tree - echo -n "${path##*/}" + printf '%s' "${path##*/}" # recursive calls for subdirectories if [ -d "$path" ]; then local list # array of files and directories - readarray -t list <<<"$(list_directory_contents "$path")" + readarray -t list < <(list_directory_contents "$path") local size=${#list[@]} # length of array local i # counter for ((i = 0; i < size; i++)); do @@ -62,15 +58,11 @@ function directory_tree { done fi } -# line of exclusions for "ls" from ".gitignore" list — the untracked files +# line of exclusions for "ls" from the list of untracked files ".gitignore" exclusions="-I'.git' $(sed -E "s|^(.*)$|-I'\1'|" .gitignore | tr '\n' ' ')" -# put the tree in a container, add a title and output to a file -{ - echo "## Directory tree" - echo -ne "\n" - directory_tree . - echo -e "\n" -} >DIRECTORY_TREE.md +# place the tree in a container, add a header and output to a file +printf '%s\n' "## Directory tree" "" "" \ + "$(directory_tree . | grep '\S')" "" >DIRECTORY_TREE.md ``` Run the script in the root of the repository and save the obtained file. diff --git a/jekyll_site/ru/2023/08/03/directory-tree.md b/jekyll_site/ru/2023/08/03/directory-tree.md index 47809c2..2d09901 100644 --- a/jekyll_site/ru/2023/08/03/directory-tree.md +++ b/jekyll_site/ru/2023/08/03/directory-tree.md @@ -35,17 +35,13 @@ function directory_tree { local head="$2" local tail="$3" # префикс для текущего элемента - if [ "one" == "$4" ]; then - echo -n "/" - else - echo -ne "\n$head" - fi + [ "one" == "$4" ] && printf '%s' "/" || printf '\n%s' "$head" # текущий элемент дерева - echo -n "${path##*/}" + printf '%s' "${path##*/}" # рекурсивные вызовы для подкаталогов if [ -d "$path" ]; then local list # массив файлов и каталогов - readarray -t list <<<"$(list_directory_contents "$path")" + readarray -t list < <(list_directory_contents "$path") local size=${#list[@]} # длина массива local i # счётчик for ((i = 0; i < size; i++)); do @@ -61,15 +57,11 @@ function directory_tree { done fi } -# строка исключений для "ls" из списка ".gitignore" — неотслеживаемые файлы +# строка исключений для "ls" из списка неотслеживаемых файлов ".gitignore" exclusions="-I'.git' $(sed -E "s|^(.*)$|-I'\1'|" .gitignore | tr '\n' ' ')" # помещаем дерево в контейнер, добавляем заголовок и выводим в файл -{ - echo "## Дерево каталогов" - echo -ne "\n" - directory_tree . - echo -e "\n" -} >DIRECTORY_TREE.md +printf '%s\n' "## Дерево каталогов" "" "" \ + "$(directory_tree . | grep '\S')" "" >DIRECTORY_TREE.md ``` Запускаем скрипт в корне репозитория и сохраняем полученный файл. diff --git a/package.sh b/package.sh index e1420ed..0239b0b 100755 --- a/package.sh +++ b/package.sh @@ -2,4 +2,4 @@ echo "Создание архива для последующего развёртывания." cd _site || exit rm -rf ../pomodoro5.zip -7z a ../pomodoro5.zip . +7z a ../pomodoro5.zip . | grep -E '\S'