2023-08-31

This commit is contained in:
Gennadiy 2023-12-17 08:23:05 +03:00
parent 6a0b3393cc
commit 77839ad820
12 changed files with 84 additions and 69 deletions

4
.gitattributes vendored
View file

@ -10,5 +10,5 @@ jekyll_site/en/2023/03/** linguist-language=Java
jekyll_site/ru/2023/06/** linguist-language=JavaScript jekyll_site/ru/2023/06/** linguist-language=JavaScript
jekyll_site/en/2023/06/** linguist-language=JavaScript jekyll_site/en/2023/06/** linguist-language=JavaScript
jekyll_site/ru/2023/08/** linguist-language=Bash jekyll_site/ru/2023/08/** linguist-language=Shell
jekyll_site/en/2023/08/** linguist-language=Bash jekyll_site/en/2023/08/** linguist-language=Shell

View file

@ -1,5 +1,5 @@
## Исходные тексты ## Исходные тексты
- Используемые форматы — Markdown, Liquid, YAML. - Используемые форматы — Markdown, Liquid, YAML.
- Инструмент сборки — Jekyll с помидорными темами оформления. - Инструмент сборки — Jekyll и помидорные темы оформления.
- Управление процессами — Bash скрипты. - Управление процессами — Bash скрипты.

View file

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
echo "Сборка сайта в двух помидорных темах и оптимизация результатов." echo "Сборка сайта в двух помидорных темах и оптимизация результатов."
milliseconds=$(date '+%s%3N') currentTimeMillis=$(date '+%s%3N')
rm -rf _site rm -rf _site
rm -rf _site_older rm -rf _site_older
rm -rf _site_color rm -rf _site_color
@ -13,7 +13,7 @@ cp -r jekyll_site/ru/index.md _site_older
cp -r jekyll_site/_config_older.yml _site_older/_config.yml cp -r jekyll_site/_config_older.yml _site_older/_config.yml
cp -r jekyll_site/Gemfile_older _site_older/Gemfile cp -r jekyll_site/Gemfile_older _site_older/Gemfile
cd _site_older || exit cd _site_older || exit
jekyll build jekyll build --disable-disk-cache
cp -r _site .. cp -r _site ..
cd .. cd ..
echo "Сборка цветного помидора." echo "Сборка цветного помидора."
@ -25,7 +25,7 @@ cp -r jekyll_site/ru/index.md _site_color
cp -r jekyll_site/_config_color.yml _site_color/_config.yml cp -r jekyll_site/_config_color.yml _site_color/_config.yml
cp -r jekyll_site/Gemfile_color _site_color/Gemfile cp -r jekyll_site/Gemfile_color _site_color/Gemfile
cd _site_color || exit cd _site_color || exit
jekyll build jekyll build --disable-disk-cache
cp -r _site ../_site/color cp -r _site ../_site/color
cd .. cd ..
echo "Копирование без сборки." echo "Копирование без сборки."
@ -52,4 +52,4 @@ find . -type f -name '*.html' | sort -r | while read -r file; do
sed -i 's/<hr \/>/<hr>/g' "$file" sed -i 's/<hr \/>/<hr>/g' "$file"
sed -i -r 's/<img(.+) \/>/<img\1>/g' "$file" sed -i -r 's/<img(.+) \/>/<img\1>/g' "$file"
done done
echo "Время выполнения сборки: $(("$(date '+%s%3N')" - "$milliseconds")) мс." echo "Время выполнения сборки: $(("$(date '+%s%3N')" - "$currentTimeMillis")) мс."

View file

@ -1,18 +1,28 @@
# site parameters # название сайта для подписи в футере
name: "Код с комментариями" name: "Код с комментариями"
# подпись в футере для переведённых страниц
name_translated: "Code with comments" name_translated: "Code with comments"
# URL адрес сайта, включая протокол
url: "https://pomodoro5.mircloud.ru" url: "https://pomodoro5.mircloud.ru"
# подпапка этой сборки для относительных URLs
baseurl: "/color" baseurl: "/color"
homepage_url: "https://git.org.ru/pomodoro/5" # ссылка в верхнем левом углу заглавных страниц
homepage_name: "GIT.ORG.RU" homepage_url: "https://gitea.com/pomodoro/5"
# представление ссылки
homepage_name: "GITEA"
# подпапка альтернативной сборки
older_tomato_baseurl: "" older_tomato_baseurl: ""
# часовой пояс для формата даты ISO-8601
timezone: "Europe/Moscow" timezone: "Europe/Moscow"
# имя автора для SEO-разметки и подписи в футере
author: "Головин Г.Г." author: "Головин Г.Г."
# транслитерация имени автора для переведённых страниц
author_translated: "Golovin G.G." author_translated: "Golovin G.G."
# дополнение к подписи в футере для переведённых страниц
translation_caption: "translation from Russian" translation_caption: "translation from Russian"
# build parameters # тема оформления для сборки
disable_disk_cache: true
theme: color-tomato-theme theme: color-tomato-theme
# макет для сборки
defaults: defaults:
- scope: - scope:
path: "" path: ""

View file

@ -1,18 +1,28 @@
# site parameters # название сайта для подписи в футере
name: "Код с комментариями" name: "Код с комментариями"
# подпись в футере для переведённых страниц
name_translated: "Code with comments" name_translated: "Code with comments"
# URL адрес сайта, включая протокол
url: "https://pomodoro5.mircloud.ru" url: "https://pomodoro5.mircloud.ru"
# подпапка этой сборки для относительных URLs
baseurl: "" baseurl: ""
homepage_url: "https://git.org.ru/pomodoro/5" # ссылка в верхнем левом углу заглавных страниц
homepage_name: "GIT.ORG.RU" homepage_url: "https://gitea.com/pomodoro/5"
# представление ссылки
homepage_name: "GITEA"
# подпапка альтернативной сборки
color_tomato_baseurl: "/color" color_tomato_baseurl: "/color"
# часовой пояс для формата даты ISO-8601
timezone: "Europe/Moscow" timezone: "Europe/Moscow"
# имя автора для SEO-разметки и подписи в футере
author: "Головин Г.Г." author: "Головин Г.Г."
# транслитерация имени автора для переведённых страниц
author_translated: "Golovin G.G." author_translated: "Golovin G.G."
# дополнение к подписи в футере для переведённых страниц
translation_caption: "translation from Russian" translation_caption: "translation from Russian"
# build parameters # тема оформления для сборки
disable_disk_cache: true
theme: older-tomato-theme theme: older-tomato-theme
# макет для сборки
defaults: defaults:
- scope: - scope:
path: "" path: ""

View file

@ -2,7 +2,7 @@
title: Password generator title: Password generator
description: We write a program in JavaScript for the formation of random 20-symbol combinations of latin letters, numbers and special characters. There are 60 variants... description: We write a program in JavaScript for the formation of random 20-symbol combinations of latin letters, numbers and special characters. There are 60 variants...
sections: [Cryptography,Random combinations] sections: [Cryptography,Random combinations]
tags: [javascript,text,symbols,letters,digits,characters,combinations] tags: [javascript,online,text,symbols,letters,digits,characters,combinations]
scripts: [/js/password-generator.js] scripts: [/js/password-generator.js]
styles: [/css/pomodoro5.css] styles: [/css/pomodoro5.css]
canonical_url: /en/2023/06/20/password-generator.html canonical_url: /en/2023/06/20/password-generator.html

View file

@ -1,8 +1,8 @@
--- ---
title: Directory tree with links title: Directory tree with links
description: We write a Bash script for building a directory tree for a repository in the Markdown file. We use only the accessories of Bash and the ls program. We will... description: We write a Bash script for building a directory tree for a repository in the Markdown file. We use only Bash tools and basic Linux software without additional.
sections: [Recursion,File processing,Web-navigation] sections: [Recursion,File processing,Web-navigation]
tags: [linux,bash,markdown,folders,files,references,sorting] tags: [linux,bash,markdown,html,folders,files,references,sorting]
canonical_url: /en/2023/08/04/directory-tree.html canonical_url: /en/2023/08/04/directory-tree.html
url_translated: /ru/2023/08/03/directory-tree.html url_translated: /ru/2023/08/03/directory-tree.html
title_translated: Дерево каталогов со ссылками title_translated: Дерево каталогов со ссылками
@ -10,18 +10,16 @@ date: 2023.08.04
lang: en lang: en
--- ---
We write a Bash script for building a directory tree for a [repository]({{ site.homepage_url }}) in We write a Bash script for building a directory tree for a repository in the Markdown
the Markdown file. We use only the accessories of Bash and the `ls` program. We will use the resulting file. We use only Bash tools and basic Linux software — `ls`, `sed`, `tr` and `echo`
file in the web interface to navigate over the objects of the repository. without additional programs. The obtained file
[`DIRECTORY_TREE.md`]({{ site.homepage_url }} "{{ site.homepage_name }}")
will be used in the web interface to navigate through the objects of the repository.
We create a recursive function and use it to bypass files and directories of the repository. We create a recursive function and use it to bypass all files and directories of the repository,
For each directory, we execute the program `ls` and get a sorted list of files and directories excluding the list from `.gitignore`. We output tree elements as links `<a>`, collapse folders
included in it: first there are directories, then files, first uppercase letters, then lowercase, with one nested element into one line, place the tree in the container `<pre>` and add the title
exclude the untracked files that are not in the repository — we get the directory tree in — as a result, we get a short and concise Markdown file with links.
a sorted form.
We collapse folders with one nested element into one line for conciseness.
We place the generated tree in the `<pre>` container and add the title.
```bash ```bash
#!/bin/bash #!/bin/bash
@ -36,7 +34,7 @@ function directory_tree {
local path="$1" local path="$1"
local head="$2" local head="$2"
local tail="$3" local tail="$3"
# prefix of the current element # prefix for current element
if [ "one" == "$4" ]; then if [ "one" == "$4" ]; then
echo -n "/" echo -n "/"
else else
@ -63,7 +61,7 @@ function directory_tree {
done done
fi fi
} }
# line of exclusions for 'ls' from '.gitignore' file — the untracked files # line of exclusions for 'ls' from '.gitignore' list — the untracked files
exclusions="-I \".git\" $(sed 's/^/ -I "/;s/$/"/' .gitignore | tr -d '\n')" exclusions="-I \".git\" $(sed 's/^/ -I "/;s/$/"/' .gitignore | tr -d '\n')"
# put the tree in a container, add a title and output to a file # put the tree in a container, add a title and output to a file
{ {
@ -74,4 +72,4 @@ exclusions="-I \".git\" $(sed 's/^/ -I "/;s/$/"/' .gitignore | tr -d '\n')"
} >DIRECTORY_TREE.md } >DIRECTORY_TREE.md
``` ```
We save the file `DIRECTORY_TREE.md` in the root of the repository and send the changes to the server. Run the script in the root of the repository and save the obtained file.

View file

@ -12,15 +12,15 @@ lang: en
{%- assign articles = "" | split: "" %} {%- assign articles = "" | split: "" %}
{%- assign articles = articles | push: "Directory tree with links" %} {%- assign articles = articles | push: "Directory tree with links" %}
{%- capture article_brief %} {%- capture article_brief %}
We write a Bash script for building a directory tree for a repository in the Markdown file. We use We write a Bash script for building a directory tree for a repository in the Markdown
only the accessories of Bash and the `ls` program. We will use the resulting file in the web interface file. We use only Bash tools and basic Linux software — `ls`, `sed`, `tr` and `echo`
to navigate over the objects of the repository. without additional programs. The obtained file `DIRECTORY_TREE.md` will be used in the
web interface to navigate through the objects of the repository.
We create a recursive function and use it to bypass files and directories of the repository. We create a recursive function and use it to bypass all files and directories of the repository,
For each directory, we execute the program `ls` and get a sorted list of files and directories excluding the list from `.gitignore`. We output tree elements as links `<a>`, collapse folders
included in it: first there are directories, then files, first uppercase letters, then lowercase, with one nested element into one line, place the tree in the container `<pre>` and add the title
exclude the untracked files that are not in the repository — we get the directory tree in — as a result, we get a short and concise Markdown file with links.
a sorted form.
{%- endcapture %} {%- endcapture %}
{%- assign articles = articles | push: article_brief %} {%- assign articles = articles | push: article_brief %}
{%- assign articles = articles | push: "Password generator" %} {%- assign articles = articles | push: "Password generator" %}

View file

@ -1,4 +1,3 @@
// © Головин Г.Г., Генератор паролей, 2023
'use strict'; 'use strict';
// формирование комбинаций // формирование комбинаций
const generate = function() { const generate = function() {

View file

@ -2,7 +2,7 @@
title: Генератор паролей title: Генератор паролей
description: Пишем программу на JavaScript для формирования случайных 20-значных комбинаций из латинских букв, цифр и спецсимволов. На выбор 60 вариантов 4 столбца по... description: Пишем программу на JavaScript для формирования случайных 20-значных комбинаций из латинских букв, цифр и спецсимволов. На выбор 60 вариантов 4 столбца по...
sections: [Криптография,Случайные комбинации] sections: [Криптография,Случайные комбинации]
tags: [javascript,текст,символы,буквы,цифры,знаки,комбинации] tags: [javascript,онлайн,текст,символы,буквы,цифры,знаки,комбинации]
scripts: [/js/password-generator.js] scripts: [/js/password-generator.js]
styles: [/css/pomodoro5.css] styles: [/css/pomodoro5.css]
canonical_url: /ru/2023/06/19/password-generator.html canonical_url: /ru/2023/06/19/password-generator.html

View file

@ -1,26 +1,24 @@
--- ---
title: Дерево каталогов со ссылками title: Дерево каталогов со ссылками
description: Напишем скрипт Bash для построения дерева каталогов для репозитория в файле Markdown. Будем использовать только средства Bash и программу ls. Полученный... description: Напишем скрипт Bash для построения дерева каталогов для репозитория в файле Markdown. Будем использовать только средства Bash и базовое ПО Linux без...
sections: [Рекурсия,Обработка файлов,Вёб-навигация] sections: [Рекурсия,Обработка файлов,Вёб-навигация]
tags: [linux,bash,markdown,каталоги,файлы,ссылки,сортировка] tags: [linux,bash,markdown,html,каталоги,файлы,ссылки,сортировка]
canonical_url: /ru/2023/08/03/directory-tree.html canonical_url: /ru/2023/08/03/directory-tree.html
url_translated: /en/2023/08/04/directory-tree.html url_translated: /en/2023/08/04/directory-tree.html
title_translated: Directory tree with links title_translated: Directory tree with links
date: 2023.08.03 date: 2023.08.03
--- ---
Напишем скрипт Bash для построения дерева каталогов для [репозитория]({{ site.homepage_url }}) в файле Напишем скрипт Bash для построения дерева каталогов для репозитория в
Markdown. Будем использовать только средства Bash и программу `ls`. Полученный файл будем использовать файле Markdown. Будем использовать только средства Bash и базовое ПО Linux
в вёб-интерфейсе для навигации по объектам репозитория. `ls`, `sed`, `tr` и `echo` — без дополнительных программ. Полученный файл
[`DIRECTORY_TREE.md`]({{ site.homepage_url }} "{{ site.homepage_name }}")
будем использовать в вёб-интерфейсе для навигации по объектам репозитория.
Создаём рекурсивную функцию и с её помощью обходим файлы и каталоги репозитория. Для каждого Создаём рекурсивную функцию и с её помощью обходим все файлы и каталоги репозитория,
каталога выполняем программу `ls` и получаем отсортированный список входящих в него файлов за исключением списка из `.gitignore`. Выводим элементы дерева в виде ссылок `<a>`,
и каталогов: сначала идут каталоги, потом файлы, сначала заглавные буквы, потом строчные, сворачиваем папки с одним вложенным элементом в одну строку, помещаем дерево в контейнер `<pre>`
исключаем неотслеживаемые файлы, которых нет в репозитории — получаем дерево каталогов и добавляем заголовок — в результате получаем краткий и лаконичный файл Markdown со ссылками.
в отсортированном виде.
Папки с одним вложенным элементом сворачиваем в одну строку для лаконичности.
Сформированное дерево помещаем в контейнер `<pre>` и добавляем заголовок.
```bash ```bash
#!/bin/bash #!/bin/bash
@ -35,7 +33,7 @@ function directory_tree {
local path="$1" local path="$1"
local head="$2" local head="$2"
local tail="$3" local tail="$3"
# префикс текущего элемента # префикс для текущего элемента
if [ "one" == "$4" ]; then if [ "one" == "$4" ]; then
echo -n "/" echo -n "/"
else else
@ -62,7 +60,7 @@ function directory_tree {
done done
fi fi
} }
# строка исключений для 'ls' из файла '.gitignore' — неотслеживаемые файлы # строка исключений для 'ls' из списка '.gitignore' — неотслеживаемые файлы
exclusions="-I \".git\" $(sed 's/^/ -I "/;s/$/"/' .gitignore | tr -d '\n')" exclusions="-I \".git\" $(sed 's/^/ -I "/;s/$/"/' .gitignore | tr -d '\n')"
# помещаем дерево в контейнер, добавляем заголовок и выводим в файл # помещаем дерево в контейнер, добавляем заголовок и выводим в файл
{ {
@ -73,4 +71,4 @@ exclusions="-I \".git\" $(sed 's/^/ -I "/;s/$/"/' .gitignore | tr -d '\n')"
} >DIRECTORY_TREE.md } >DIRECTORY_TREE.md
``` ```
Сохраняем файл `DIRECTORY_TREE.md` в корне репозитория и отправляем изменения на сервер. Запускаем скрипт в корне репозитория и сохраняем полученный файл.

View file

@ -11,15 +11,15 @@ title_translated: Code with comments
{%- assign articles = "" | split: "" %} {%- assign articles = "" | split: "" %}
{%- assign articles = articles | push: "Дерево каталогов со ссылками" %} {%- assign articles = articles | push: "Дерево каталогов со ссылками" %}
{%- capture article_brief %} {%- capture article_brief %}
Напишем скрипт Bash для построения дерева каталогов для репозитория в файле Markdown. Будем использовать Напишем скрипт Bash для построения дерева каталогов для репозитория в файле Markdown.
только средства Bash и программу `ls`. Полученный файл будем использовать в вёб-интерфейсе для навигации Будем использовать только средства Bash и базовое ПО Linux — `ls`, `sed`, `tr` и `echo`
по объектам репозитория. — без дополнительных программ. Полученный файл `DIRECTORY_TREE.md` будем использовать
в вёб-интерфейсе для навигации по объектам репозитория.
Создаём рекурсивную функцию и с её помощью обходим файлы и каталоги репозитория. Для каждого Создаём рекурсивную функцию и с её помощью обходим все файлы и каталоги репозитория,
каталога выполняем программу `ls` и получаем отсортированный список входящих в него файлов за исключением списка из `.gitignore`. Выводим элементы дерева в виде ссылок `<a>`,
и каталогов: сначала идут каталоги, потом файлы, сначала заглавные буквы, потом строчные, сворачиваем папки с одним вложенным элементом в одну строку, помещаем дерево в контейнер `<pre>`
исключаем неотслеживаемые файлы, которых нет в репозитории — получаем дерево каталогов и добавляем заголовок — в результате получаем краткий и лаконичный файл Markdown со ссылками.
в отсортированном виде.
{%- endcapture %} {%- endcapture %}
{%- assign articles = articles | push: article_brief %} {%- assign articles = articles | push: article_brief %}
{%- assign articles = articles | push: "Генератор паролей" %} {%- assign articles = articles | push: "Генератор паролей" %}