2024-07-31
This commit is contained in:
parent
8d7c5560c9
commit
1dec4af1c6
2 changed files with 46 additions and 34 deletions
42
README.en.md
42
README.en.md
|
@ -38,30 +38,36 @@ sudo gem install --local older-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
|
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
|
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
|
to the `_site` folder — we get shorter links, that are used in the theme. After that we bypass HTML pages
|
||||||
the redirection file to the root of the site for all subdirectories, if they don't contain the `index.html`
|
and optimize a number of tags also for shortness and for correctness. Additionally, we copy from theme the
|
||||||
file. After that we bypass HTML pages and optimize a number of tags also for shortness and for correctness.
|
redirection file to the root of the site for all subdirectories, if they don't contain the `index.html`
|
||||||
The script is intended for this purpose.
|
file. The script is intended for this purpose.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
echo "Optimization of gathered content."
|
echo "Optimizing gathered content."
|
||||||
cd _site || exit
|
cd _site || exit
|
||||||
cp -r assets/* .
|
cp -r assets/* .
|
||||||
rm -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| 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|<div><div class="highlight">|<div class="highlight">|g' "$1"
|
||||||
|
sed -i 's|</pre></div></div>|</pre></div>|g' "$1"
|
||||||
|
sed -i 's|<hr />|<hr>|g' "$1"
|
||||||
|
sed -i -r 's|<input(.+) />|<input\1>|g' "$1"
|
||||||
|
sed -i -r 's|<img(.+) />|<img\1>|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
|
rm -r return.html
|
||||||
find . -type f -name '*.html' | sort -r | while read -r file; do
|
|
||||||
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/<div><div class="highlight"><pre class="highlight">/<div class="highlight"><pre class="highlight">/g' "$file"
|
|
||||||
sed -i 's/<\/code><\/pre><\/div><\/div>/<\/code><\/pre><\/div>/g' "$file"
|
|
||||||
sed -i 's/<hr \/>/<hr>/g' "$file"
|
|
||||||
sed -i -r 's/<input(.+) \/>/<input\1>/g' "$file"
|
|
||||||
sed -i -r 's/<img(.+) \/>/<img\1>/g' "$file"
|
|
||||||
done
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Directory structure
|
### Directory structure
|
||||||
|
|
38
README.md
38
README.md
|
@ -38,29 +38,35 @@ sudo gem install --local older-tomato-theme-1.0.1.gem
|
||||||
|
|
||||||
Сборка сайта выполняется командой `jekyll build`. После этого мы получаем папку `_site` с собранными
|
Сборка сайта выполняется командой `jekyll build`. После этого мы получаем папку `_site` с собранными
|
||||||
страницами и подпапку `assets` из темы. Перемещаем содержимое этой подпапки обратно в папку `_site` —
|
страницами и подпапку `assets` из темы. Перемещаем содержимое этой подпапки обратно в папку `_site` —
|
||||||
получаем короткие ссылки, которые используются в теме. Дополнительно копируем из темы файл перенаправления в
|
получаем короткие ссылки, которые используются в теме. После этого обходим страницы HTML и оптимизируем ряд
|
||||||
корень сайта для всех подкаталогов, если в них отсутствует файл `index.html`. После этого обходим страницы
|
тегов также для краткости и для корректности. Дополнительно копируем из темы файл перенаправления в корень
|
||||||
HTML и оптимизируем ряд тегов также для краткости и для корректности. Скрипт предназначен для этой цели.
|
сайта для всех подкаталогов, если в них отсутствует файл `index.html`. Скрипт предназначен для этой цели.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
echo "Оптимизация собранного контента."
|
echo "Оптимизация собранного контента."
|
||||||
cd _site || exit
|
cd _site || exit
|
||||||
cp -r assets/* .
|
cp -r assets/* .
|
||||||
rm -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| 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|<div><div class="highlight">|<div class="highlight">|g' "$1"
|
||||||
|
sed -i 's|</pre></div></div>|</pre></div>|g' "$1"
|
||||||
|
sed -i 's|<hr />|<hr>|g' "$1"
|
||||||
|
sed -i -r 's|<input(.+) />|<input\1>|g' "$1"
|
||||||
|
sed -i -r 's|<img(.+) />|<img\1>|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
|
rm -r return.html
|
||||||
find . -type f -name '*.html' | sort -r | while read -r file; do
|
|
||||||
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/<div><div class="highlight"><pre class="highlight">/<div class="highlight"><pre class="highlight">/g' "$file"
|
|
||||||
sed -i 's/<\/code><\/pre><\/div><\/div>/<\/code><\/pre><\/div>/g' "$file"
|
|
||||||
sed -i 's/<hr \/>/<hr>/g' "$file"
|
|
||||||
sed -i -r 's/<input(.+) \/>/<input\1>/g' "$file"
|
|
||||||
sed -i -r 's/<img(.+) \/>/<img\1>/g' "$file"
|
|
||||||
done
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Структура каталогов
|
### Структура каталогов
|
||||||
|
|
Loading…
Add table
Reference in a new issue