diff --git a/README.en.md b/README.en.md index 9b0e96b..4113de6 100644 --- a/README.en.md +++ b/README.en.md @@ -71,30 +71,36 @@ sudo gem install --local color-tomato-theme-1.0.1.gem The site can be built using the `jekyll build` command. After that, we get the `_site` folder with the generated pages and the `assets` subfolder from the theme. We move the contents of this subfolder back -to the `_site` folder — we get shorter links, that are used in the theme. Additionally, we copy from theme -the redirection file to the root of the site for all subdirectories, if they don't contain the `index.html` -file. After that we bypass HTML pages and optimize a number of tags also for shortness and for correctness. -The script is intended for this purpose. +to the `_site` folder — we get shorter links, that are used in the theme. After that we bypass HTML pages +and optimize a number of tags also for shortness and for correctness. Additionally, we copy from theme the +redirection file to the root of the site for all subdirectories, if they don't contain the `index.html` +file. The script is intended for this purpose. ```shell -echo "Optimization of gathered content." +echo "Optimizing gathered content." cd _site || exit cp -r assets/* . rm -r assets -find . -type d -print0 | xargs -I{} -0 -n 1 cp -n return.html {}/index.html +echo "Optimizing a number of tags." +function optimize_html { + echo "Optimize: $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-html 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|
|
|g' "$1" + sed -i 's|
|
|g' "$1" + sed -i -r 's|||g' "$1" + sed -i -r 's|||g' "$1" +} +export -f optimize_html +echo "Launching parallel processing of gathered pages and optimizing a number of tags." +find . -type f -name "*.html" -print0 | xargs -I{} -n1 -0 -P0 bash -c 'optimize_html "{}"' +echo "Transition page to the root of the site for directories without a main page." +find . -type d -print0 | xargs -I{} -n1 -0 -P0 cp -n return.html {}/index.html rm -r return.html -find . -type f -name '*.html' | sort -r | while read -r file; do - sed -i 's/layout-padding=""/layout-padding/g' "$file" - sed -i 's/ class="language-plaintext highlighter-rouge"//g' "$file" - sed -i 's/ class="language-java highlighter-rouge"//g' "$file" - sed -i 's/ class="language-html highlighter-rouge"//g' "$file" - sed -i 's/ class="language-js highlighter-rouge"//g' "$file" - sed -i 's/ class="language-bash highlighter-rouge"//g' "$file" - sed -i 's/
/
/g' "$file"
-  sed -i 's/<\/code><\/pre><\/div><\/div>/<\/code><\/pre><\/div>/g' "$file"
-  sed -i -r 's///g' "$file"
-  sed -i -r 's///g' "$file"
-done
 ```
 
 ### Directory structure
diff --git a/README.md b/README.md
index c469527..4a0b7bd 100644
--- a/README.md
+++ b/README.md
@@ -71,29 +71,35 @@ sudo gem install --local color-tomato-theme-1.0.1.gem
 
 Сборка сайта выполняется командой `jekyll build`. После этого мы получаем папку `_site` с собранными
 страницами и подпапку `assets` из темы. Перемещаем содержимое этой подпапки обратно в папку `_site` —
-получаем короткие ссылки, которые используются в теме. Дополнительно копируем из темы файл перенаправления в
-корень сайта для всех подкаталогов, если в них отсутствует файл `index.html`. После этого обходим страницы
-HTML и оптимизируем ряд тегов также для краткости и для корректности. Скрипт предназначен для этой цели.
+получаем короткие ссылки, которые используются в теме. После этого обходим страницы HTML и оптимизируем ряд
+тегов также для краткости и для корректности. Дополнительно копируем из темы файл перенаправления в корень
+сайта для всех подкаталогов, если в них отсутствует файл `index.html`. Скрипт предназначен для этой цели.
 
 ```shell
 echo "Оптимизация собранного контента."
 cd _site || exit
 cp -r assets/* .
 rm -r assets
-find . -type d -print0 | xargs -I{} -0 -n 1 cp -n return.html {}/index.html
+echo "Оптимизация ряда тегов."
+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-html 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|
|
|g' "$1" + sed -i 's|
|
|g' "$1" + sed -i -r 's|||g' "$1" + sed -i -r 's|||g' "$1" +} +export -f optimize_html +echo "Запуск параллельной обработки собранных страниц и оптимизации ряда тегов." +find . -type f -name "*.html" -print0 | xargs -I{} -n1 -0 -P0 bash -c 'optimize_html "{}"' +echo "Страница перехода в корень сайта для каталогов без заглавной страницы." +find . -type d -print0 | xargs -I{} -n1 -0 -P0 cp -n return.html {}/index.html rm -r return.html -find . -type f -name '*.html' | sort -r | while read -r file; do - sed -i 's/layout-padding=""/layout-padding/g' "$file" - sed -i 's/ class="language-plaintext highlighter-rouge"//g' "$file" - sed -i 's/ class="language-java highlighter-rouge"//g' "$file" - sed -i 's/ class="language-html highlighter-rouge"//g' "$file" - sed -i 's/ class="language-js highlighter-rouge"//g' "$file" - sed -i 's/ class="language-bash highlighter-rouge"//g' "$file" - sed -i 's/
/
/g' "$file"
-  sed -i 's/<\/code><\/pre><\/div><\/div>/<\/code><\/pre><\/div>/g' "$file"
-  sed -i -r 's///g' "$file"
-  sed -i -r 's///g' "$file"
-done
 ```
 
 ### Структура каталогов