1
0
Fork 0

2023-08-31

This commit is contained in:
Gennadiy 2023-12-17 08:21:01 +03:00
parent 7eae1f2a80
commit 853a6d51b9
9 changed files with 131 additions and 139 deletions

View file

@ -7,7 +7,7 @@ appearance resembles the default design theme on GitHub Pages. Both themes suppl
each other and are similar to each other, commonalities and differences between them
are marked in the list of features.
- [Color tomato](https://hub.mos.ru/golovin.gg/color-tomato-theme/blob/master/README.en.md) — color selection during the build.
- [Color tomato](https://hub.mos.ru/golovin/color-tomato-theme/blob/master/README.en.md) — color selection during the build.
- Older tomato — lightweight decoration theme.
### Features
@ -23,25 +23,62 @@ are marked in the list of features.
- [ ] Color selection during the build, green is the default color.
- [ ] Scroll-to-top button in Material style.
### Site structure
### Installation
The folder with the Jekyll site should contain two mandatory files with dependencies
and parameters — all other files are the site content itself. This theme is written
with the expectation, that the site contents is separated into two sub-folders by
language and consist of articles and main pages, where the main pages are lists of
articles with short descriptions.
Run the script from the theme folder, build the *gem* package and install it.
```shell
rm older-tomato-theme-1.0.1.gem
gem build older-tomato-theme.gemspec
sudo gem install --local older-tomato-theme-1.0.1.gem
```
### After build
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. 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.
```shell
echo "Optimization of gathered content."
cd _site || exit
cp -r assets/* .
rm -r assets
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
Folder with the Jekyll site should contain two mandatory files: with dependencies `Gemfile`
and with parameters `_config.yml` — all other files are the site content itself. This theme
is written with the expectation, that the site contents is separated into two subdirectories
by language and consist of publications and main pages, where the main pages are lists of
publications with short descriptions.
```
jekyll-site
├ ru
│ ├ . . . - articles
│ └ index.md - main page
├ en
│ ├ . . . - articles
│ └ index.md - main page
├ . . .
├ Gemfile - dependencies
└ _config.yml - parameters
jekyll_site
ru
│ ├─ . . . — publications
│ └─ index.md — main page
en
│ ├─ . . . — publications
│ └─ index.md — main page
. . .
├─ Gemfile — dependencies
└─ _config.yml — parameters
```
### Dependencies
@ -54,16 +91,6 @@ gem "jekyll"
gem "older-tomato-theme"
```
### Installation
Run the script from the theme folder, build the *gem* package and install it.
```bash
rm older-tomato-theme-0.1.0.gem
gem build older-tomato-theme.gemspec
sudo gem install --local older-tomato-theme-0.1.0.gem
```
### Site parameters
`_config.yml` — a list of common parameters for the site, including parameters for the build.
@ -95,8 +122,9 @@ author: "Толстой Л.Н."
author_translated: "Tolstoy L.N."
# addition to footer caption for translated pages
translation_caption: "translation from Russian"
# design theme and default layout for the build
# design theme for the build
theme: older-tomato-theme
# layout for the build
defaults:
- scope:
path: ""
@ -132,7 +160,7 @@ url_translated: /en/2023/01/16/spinning-spatial-cross.html
# title of translated page for original pages,
# or the original page for translated pages
title_translated: Spinning spatial cross
# date parameters should be specified only on article
# date parameters should be specified only on publication
# pages and should not be specified on main pages,
# main pages display the date the site was last built
date: 2023.01.15
@ -149,32 +177,6 @@ translation_caption: "translation from Russian"
---
```
### After build
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. After that we bypass HTML
pages and optimize some tags also for shortness and for correctness. The script is designed for this.
```bash
echo "Optimization of gathered content."
cd _site || exit
cp -r assets/* .
rm -r assets
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
```
---
©Golovin G.G.,Code with comments,translation from Russian,2021-2023
© Golovin G.G., Code with comments, translation from Russian, 2021-2023

110
README.md
View file

@ -7,7 +7,7 @@
дополняют друг друга и похожи друг на друга, общие черты и различия между ними отмечены
в списке свойств.
- [Цветной помидор](https://hub.mos.ru/golovin.gg/color-tomato-theme/blob/master/README.md) — выбор цвета во время сборки.
- [Цветной помидор](https://hub.mos.ru/golovin/color-tomato-theme/blob/master/README.md) — выбор цвета во время сборки.
- Старый помидор — легковесная тема оформления.
### Свойства
@ -23,24 +23,61 @@
- [ ] Выбор цвета во время сборки, зелёный цвет по умолчанию.
- [ ] Кнопка прокрутки вверх в стиле Material.
### Установка
Запускаем скрипт из папки с темой, собираем пакет *gem* и устанавливаем его.
```shell
rm older-tomato-theme-1.0.1.gem
gem build older-tomato-theme.gemspec
sudo gem install --local older-tomato-theme-1.0.1.gem
```
### После сборки
Сборка сайта выполняется командой `jekyll build`. После этого мы получаем папку `_site` с собранными
страницами и подпапку `assets` из темы. Перемещаем содержимое этой подпапки обратно в папку `_site`
получаем короткие ссылки, которые используются в теме. После этого обходим страницы HTML и оптимизируем
ряд тегов также для краткости и для корректности. Скрипт предназначен для этой цели.
```shell
echo "Оптимизация собранного контента."
cd _site || exit
cp -r assets/* .
rm -r assets
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
```
### Структура каталогов
Папка с сайтом на Jekyll должна содержать два обязательных файла с зависимостями и
параметрами, все остальные файлы — это содержимое самого сайта. Эта тема написана с
расчётом, что содержимое сайта разделено на две подпапки по языкам и состоит из статей
и заглавных страниц, где заглавные страницы — это списки статей с краткими описаниями.
Папка с сайтом на Jekyll должна содержать два обязательных файла: с зависимостями `Gemfile`
и с параметрами `_config.yml`, все остальные файлы — это содержимое самого сайта. Эта тема
написана с расчётом, что содержимое сайта разделено на два подкаталога по языкам и состоит
из публикаций и заглавных страниц, где заглавные страницы — это списки публикаций с краткими
описаниями.
```
jekyll-site
├ ru
│ ├ . . . - статьи
│ └ index.md - заглавная страница
├ en
│ ├ . . . - статьи
│ └ index.md - заглавная страница
├ . . .
├ Gemfile - зависимости
└ _config.yml - параметры
jekyll_site
ru
│ ├─ . . . — публикации
│ └─ index.md — заглавная страница
en
│ ├─ . . . — публикации
│ └─ index.md — заглавная страница
. . .
├─ Gemfile — зависимости
└─ _config.yml — параметры
```
### Зависимости
@ -53,16 +90,6 @@ gem "jekyll"
gem "older-tomato-theme"
```
### Установка
Запускаем скрипт из папки с темой, собираем пакет *gem* и устанавливаем его.
```bash
rm older-tomato-theme-0.1.0.gem
gem build older-tomato-theme.gemspec
sudo gem install --local older-tomato-theme-0.1.0.gem
```
### Параметры сайта
`_config.yml` — список общих параметров для сайта, включая параметры для сборки.
@ -94,8 +121,9 @@ author: "Толстой Л.Н."
author_translated: "Tolstoy L.N."
# дополнение к подписи в футере для переведённых страниц
translation_caption: "translation from Russian"
# тема оформления и макет по умолчанию для сборки
# тема оформления для сборки
theme: older-tomato-theme
# макет для сборки
defaults:
- scope:
path: ""
@ -131,7 +159,7 @@ url_translated: /en/2023/01/16/spinning-spatial-cross.html
# заголовок переведённой страницы для оригинальных страниц,
# или оригинальной страницы для переведённых страниц
title_translated: Spinning spatial cross
# дата должна быть указана только на страницах статей,
# дата должна быть указана только на страницах публикаций,
# и не должна быть указана на заглавных страницах,
# заглавные страницы отображают дату последней сборки сайта
date: 2023.01.15
@ -148,32 +176,6 @@ translation_caption: "translation from Russian"
---
```
### После сборки
Сборка сайта выполняется командой `jekyll build`. После этого мы получаем папку `_site` с собранными
страницами и подпапку `assets` из темы. Перемещаем содержимое этой подпапки обратно в папку `_site`
получаем короткие ссылки, которые используются в теме. После этого обходим страницы HTML и оптимизируем
некоторые теги также для краткости и для корректности. Скрипт предназначен для этого.
```bash
echo "Оптимизация собранного контента."
cd _site || exit
cp -r assets/* .
rm -r assets
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
```
---
© Головин Г.Г., Код с комментариями,2021-2023
© Головин Г.Г., Код с комментариями, 2021-2023

View file

@ -19,18 +19,12 @@
<a href="{{ page.url_translated | relative_url }}" style="margin: 0 17px;">
<b>{{ page.lang | default: 'ru' | upcase }}</b>
</a>
{%- else %}
<!-- page language -->
<b style="color: #aaa; margin: 0 17px;">{{ page.lang | default: 'ru' | upcase }}</b>
{%- endif %}
{%- if site.color_tomato_baseurl %}
<!-- color tomato -->
<a href="{{ site.color_tomato_baseurl | append: page.canonical_url }}" style="height: 30px; margin: 2px 0 0 16px;">
<img src="/img/typewriter.svg" width="30" height="30" alt="typewriter">
</a>
{%- else %}
<!-- typewriter -->
<img src="/img/typewriter.svg" width="30" height="30" alt="typewriter" style="margin: 2px 0 0 16px;">
{%- endif %}
</div>
<hr>

View file

@ -26,13 +26,17 @@
"datePublished":"{{ page.date | date_to_xmlschema }}",
{%- endif %}
"dateModified":"{{ site.time | date_to_xmlschema }}",
"inLanguage":"{{ page.lang | default: 'ru' }}",
{%- if page.lang == site.lang %}
"author": {
"@type":"Person",
{%- if page.lang == site.lang %}
"name":"{{ page.author | default: site.author }}",
{%- else %}
"name":"{{ page.author | default: site.author_translated }}",
{%- endif %}
"url":"{{ site.homepage_url }}"
},
{%- if page.url_translated %}
{%- if page.lang == site.lang %}
"workTranslation": {
"@type":"{% if page.date %}BlogPosting{% else %}Blog{% endif %}",
"@id":"{{ site.url | append: page.url_translated }}",
@ -43,13 +47,7 @@
"@type":"Person",
"name":"{{ page.author_translated | default: site.author_translated }}",
"url":"{{ site.homepage_url }}"
}
{%- else %}
"author": {
"@type":"Person",
"name":"{{ page.author | default: site.author_translated }}",
"url":"{{ site.homepage_url }}"
},
"translationOfWork": {
"@type":"{% if page.date %}BlogPosting{% else %}Blog{% endif %}",
"@id":"{{ site.url | append: page.url_translated }}",
@ -60,8 +58,10 @@
"@type":"Person",
"name":"{{ page.author_translated | default: site.author }}",
"url":"{{ site.homepage_url }}"
}
{%- endif %}
}
}
},
{%- endif %}
"inLanguage":"{{ page.lang | default: 'ru' }}"
}</script>
<!-- end seo template -->

View file

@ -22,7 +22,7 @@ a:hover {
text-decoration: underline;
}
.toolbar a > b {
.toolbar b {
font-size: 22px;
font-weight: 500;
}

View file

@ -1,14 +1,6 @@
---
layout: null
---
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="30" height="30" viewBox="0 0 30 30">
{%- if site.color_tomato_baseurl %}
<g fill="#222" stroke="#222" stroke-width="0.1">
{%- else %}
<g fill="#aaa" stroke="#aaa" stroke-width="0.1">
{%- endif %}
<path d="M 8 3 A 1.0001 1.0001 0 0 0 7 4 L 7 11 L 9 11 L 9 5 L 21 5 L 21 11 L 23 11 L 23 4 A 1.0001 1.0001 0 0 0 22 3 L 8 3 z M 6 13 C 4.895 13 4 13.895 4 15 L 3 15 A 1.0001 1.0001 0 1 0 3 17 L 4 17 L 4 24 C 4 25.657 5.343 27 7 27 L 23 27 C 24.657 27 26 25.657 26 24 L 26 17 L 27 17 A 1.0001 1.0001 0 1 0 27 15 L 26 15 C 26 13.895 25.105 13 24 13 L 17 13 C 16.448 13 16 13.448 16 14 C 16 14.552 16.448 15 17 15 L 19 15 C 19.552 15 20 15.448 20 16 C 20 16.552 19.552 17 19 17 L 11 17 C 10.448 17 10 16.552 10 16 C 10 15.448 10.448 15 11 15 L 13 15 C 13.552 15 14 14.552 14 14 C 14 13.448 13.552 13 13 13 L 6 13 z M 9 19 C 9.552 19 10 19.448 10 20 C 10 20.552 9.552 21 9 21 C 8.448 21 8 20.552 8 20 C 8 19.448 8.448 19 9 19 z M 13 19 C 13.552 19 14 19.448 14 20 C 14 20.552 13.552 21 13 21 C 12.448 21 12 20.552 12 20 C 12 19.448 12.448 19 13 19 z M 17 19 C 17.552 19 18 19.448 18 20 C 18 20.552 17.552 21 17 21 C 16.448 21 16 20.552 16 20 C 16 19.448 16.448 19 17 19 z M 21 19 C 21.552 19 22 19.448 22 20 C 22 20.552 21.552 21 21 21 C 20.448 21 20 20.552 20 20 C 20 19.448 20.448 19 21 19 z M 11 22 C 11.552 22 12 22.448 12 23 C 12 23.552 11.552 24 11 24 C 10.448 24 10 23.552 10 23 C 10 22.448 10.448 22 11 22 z M 15 22 C 15.552 22 16 22.448 16 23 C 16 23.552 15.552 24 15 24 C 14.448 24 14 23.552 14 23 C 14 22.448 14.448 22 15 22 z M 19 22 C 19.552 22 20 22.448 20 23 C 20 23.552 19.552 24 19 24 C 18.448 24 18 23.552 18 23 C 18 22.448 18.448 22 19 22 z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -10,8 +10,10 @@ permalink: pagesmap.xml
{%- if page.title %}
<url>
<loc>{{ page.url | absolute_url }}</loc>
{%- if page.url_translated %}
<xhtml:link rel="alternate" hreflang="{% if page.lang == site.lang %}{{ site.lang | default: 'ru' }}{% else %}{{ page.lang | default: 'en' }}{% endif %}" href="{{ page.url | absolute_url }}"/>
<xhtml:link rel="alternate" hreflang="{% if page.lang == site.lang %}{{ page.lang | default: 'en' }}{% else %}{{ site.lang | default: 'ru' }}{% endif %}" href="{{ page.url_translated | absolute_url }}"/>
{%- endif %}
{%- comment %}<!-- date format ISO-8601 -->{% endcomment %}
<lastmod>{{ site.time | date_to_xmlschema }}</lastmod>
<changefreq>daily</changefreq>

View file

@ -1,4 +1,4 @@
#!/bin/bash
rm older-tomato-theme-0.1.0.gem
rm older-tomato-theme-1.0.1.gem
gem build older-tomato-theme.gemspec
sudo gem install --local older-tomato-theme-0.1.0.gem
sudo gem install --local older-tomato-theme-1.0.1.gem

View file

@ -1,11 +1,11 @@
Gem::Specification.new do |spec|
spec.name = "older-tomato-theme"
spec.version = "0.1.0"
spec.version = "1.0.1"
spec.authors = ["Golovin G.G."]
spec.email = ["gennadiy.golovin@internet.ru"]
spec.summary = "older-tomato-theme"
spec.homepage = "https://hub.mos.ru/golovin.gg"
spec.homepage = "https://hub.mos.ru/golovin"
spec.license = "Nonstandard"
spec.files = `git ls-files -z`.split("\x0").select { |f| f.match(%r!^(_includes|_layouts|assets)!i) }