Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d74bee2fc0 | |||
| 6b4dbafab5 | |||
| 18294ec21b | |||
| 78174a8ffc | |||
| ef8a2d27ff | |||
| 2d09aef79d | |||
| bc237a6552 | |||
| 716c25dc26 | |||
| 310ed5440d | |||
| 66f22285ef | |||
| ea221dcfd2 | |||
| e21920262d | |||
| 22de477c17 | |||
| 7d3047c2d2 | |||
| 92711f57c2 | |||
| 56794f5b09 | |||
| 9cb685b569 |
@@ -8,9 +8,13 @@ server {
|
|||||||
access_log /var/log/nginx/typograph.access.log;
|
access_log /var/log/nginx/typograph.access.log;
|
||||||
error_log /var/log/nginx/typograph.error.log;
|
error_log /var/log/nginx/typograph.error.log;
|
||||||
|
|
||||||
# SSL-сертификаты
|
# SSL-сертификаты (их добавит Let's Encrypt)
|
||||||
|
|
||||||
# Рекомендуемые SSL настройки
|
# Рекомендуемые SSL настройки (
|
||||||
|
|
||||||
|
# --- ЗАЩИТА ОТ БОЛЬШИХ ЗАПРОСОВ ---
|
||||||
|
# Ограничиваем максимальный размер тела запроса (например, 1MB)
|
||||||
|
client_max_body_size 1M;
|
||||||
|
|
||||||
# Медиа файлы (загруженные пользователями)
|
# Медиа файлы (загруженные пользователями)
|
||||||
location /media/ {
|
location /media/ {
|
||||||
|
|||||||
@@ -35,7 +35,12 @@ http {
|
|||||||
access_log /dev/stdout;
|
access_log /dev/stdout;
|
||||||
error_log /dev/stderr warn;
|
error_log /dev/stderr warn;
|
||||||
|
|
||||||
# Настройки сжатия gzip для оптимизации передачи данных (сжимать будет nginx внутри контейнера)
|
# --- ЗАЩИТА ОТ БРУТФОРСА ---
|
||||||
|
# Создаем зону в памяти, где будут храниться IP-адреса (1MB -- 16000 IP).
|
||||||
|
# rate=5r/s - разрешаем 5 запросов в секунду (мягкий лимит).
|
||||||
|
limit_req_zone $binary_remote_addr zone=one:1m rate=5r/s;
|
||||||
|
|
||||||
|
# Настройки сжатия gzip
|
||||||
gzip on;
|
gzip on;
|
||||||
gzip_proxied any;
|
gzip_proxied any;
|
||||||
gzip_comp_level 6;
|
gzip_comp_level 6;
|
||||||
@@ -59,7 +64,34 @@ http {
|
|||||||
# Убираем токены версии nginx для безопасности
|
# Убираем токены версии nginx для безопасности
|
||||||
server_tokens off;
|
server_tokens off;
|
||||||
|
|
||||||
|
# --- ЗАЩИТА ОТ БОЛЬШИХ ЗАПРОСОВ ---
|
||||||
|
# Ограничиваем максимальный размер тела запроса (например, 1MB)
|
||||||
|
client_max_body_size 1M;
|
||||||
|
|
||||||
|
# --- КАСТОМНЫЕ СТРАНИЦЫ ОШИБОК ---
|
||||||
|
error_page 500 /500.html;
|
||||||
|
error_page 502 /502.html;
|
||||||
|
error_page 503 /503.html;
|
||||||
|
error_page 504 /504.html;
|
||||||
|
|
||||||
|
location = /500.html { root /app/public/static_collected; internal; } # файл будет сюда скопирован при сборке образа
|
||||||
|
location = /502.html { root /app/public/static_collected; internal; }
|
||||||
|
location = /503.html { root /app/public/static_collected; internal; }
|
||||||
|
location = /504.html { root /app/public/static_collected; internal; }
|
||||||
|
|
||||||
|
# Прямая раздача favicon.ico
|
||||||
|
location = /favicon.ico {
|
||||||
|
alias /app/public/static_collected/favicon.ico;
|
||||||
|
access_log off;
|
||||||
|
log_not_found off;
|
||||||
|
expires 30d;
|
||||||
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
|
# --- ЗАЩИТА ОТ БРУТФОРСА ---
|
||||||
|
# Применяем зону 'one', разрешаем "всплеск" до 10 запросов.
|
||||||
|
limit_req zone=one burst=10 nodelay;
|
||||||
|
|
||||||
proxy_pass http://app_server;
|
proxy_pass http://app_server;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
|
# Этот файл предназначен для продакшен окружения. Его необходимо скопировать на продакшн-сервер под именем
|
||||||
|
# `docker-compose.yml` в корневой каталог проекта.
|
||||||
|
# Перед запуском убедитесь, что в корне проекта есть файл `.env` с необходимыми переменными окружения.
|
||||||
|
# Также необходимо создать папки `data` и `media` в корне проекта и убедиться, что у пользователя, под которым
|
||||||
|
# запускается docker-контейнер, есть права на запись в эти папки.
|
||||||
|
# Для первого запуска backend-контейнера, возможно, потребуется временно изменить владельца папки `data` на root
|
||||||
|
# и раскомментировать соответствующие строки в секции etpgrf-backend (смотри комментарии в коде ниже).
|
||||||
|
|
||||||
version: '3.8'
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
@@ -7,13 +15,43 @@ services:
|
|||||||
image: git.cube2.ru/erjemin/2026-etpgrf-site:latest
|
image: git.cube2.ru/erjemin/2026-etpgrf-site:latest
|
||||||
# Перезапускать всегда (если упал или сервер перезагрузился)
|
# Перезапускать всегда (если упал или сервер перезагрузился)
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
# Метка для Watchtower, чтобы он обновлял только этот контейнер
|
# Метка для Watchtower, чтобы он обновлял только этот контейнер
|
||||||
labels:
|
labels:
|
||||||
- "com.centurylinklabs.watchtower.scope=etpgrf"
|
- "com.centurylinklabs.watchtower.scope=etpgrf"
|
||||||
|
|
||||||
# Запускаем collectstatic перед стартом
|
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
command: sh -c "python etpgrf_site/manage.py collectstatic --noinput && gunicorn --bind 0.0.0.0:8000 --chdir /app/etpgrf_site etpgrf_site.wsgi"
|
# При первом старте, временно запускаем как root, чтобы контейнер мог создать файл БД в хостовом томе
|
||||||
|
# ser: "0:0"
|
||||||
|
# command: >
|
||||||
|
# sh -c "mkdir -p /app/data &&
|
||||||
|
# chown -R 1000:1000 /app/data 2>/dev/null || true &&
|
||||||
|
# chmod -R 0775 /app/data 2>/dev/null || true &&
|
||||||
|
# python etpgrf_site/manage.py migrate --noinput &&
|
||||||
|
# python etpgrf_site/manage.py collectstatic --noinput &&
|
||||||
|
# cp /app/etpgrf_site/typograph/templates/500.html /app/public/static_collected/50x.html &&
|
||||||
|
# gunicorn --bind 0.0.0.0:8000 --chdir /app/etpgrf_site etpgrf_site.wsgi"
|
||||||
|
#
|
||||||
|
# После первого запуска, на хосте убедиться что файл БД создан. Возвращаем docker-compose.yml (это тот фал который
|
||||||
|
# вы сейчас читаете). После останавливаем контейнеры: и сменить владельца папки data. Для этого останавливаем контейнеры:
|
||||||
|
# `sudo docker-compose -f stop`
|
||||||
|
# возвращаем docker-compose.ym в исходный вид (этот файл). И снова запускаем:
|
||||||
|
# `sudo docker-compose -f docker-compose.prod.yml up -d`
|
||||||
|
# Теперь нам нужно узнать UID/GID пользователя внутри контейнера, выполнив на хосте команду:
|
||||||
|
# `sudo docker exec -it etpgrf-site-etpgrf-backend-1 id`
|
||||||
|
# Увидим что-то типа `uid=999(appuser) gid=999(appuser) groups=999(appuser)`. После этого сменить владельца папки
|
||||||
|
# data на хосте:
|
||||||
|
# `sudo chown -R 999:999 ./data`
|
||||||
|
# С папкой media можно сделать то же самое, если там будут проблемы с правами.
|
||||||
|
# `sudo chown -R 999:999 ./media`
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
# А обычно запускаем в безопасном режиме: миграции, потом collectstatic, потом копируем 500.html для Nginx, потом сервер
|
||||||
|
command: >
|
||||||
|
sh -c "python etpgrf_site/manage.py migrate --noinput &&
|
||||||
|
python etpgrf_site/manage.py collectstatic --noinput &&
|
||||||
|
cp /app/etpgrf_site/typograph/templates/500.html /app/public/static_collected/500.html &&
|
||||||
|
gunicorn --bind 0.0.0.0:8000 --chdir /app/etpgrf_site etpgrf_site.wsgi"
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
# База данных (папка data должна быть создана на хосте)
|
# База данных (папка data должна быть создана на хосте)
|
||||||
@@ -36,11 +74,6 @@ services:
|
|||||||
etpgrf-nginx:
|
etpgrf-nginx:
|
||||||
image: nginx:1.25-alpine
|
image: nginx:1.25-alpine
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
# Метка для Watchtower (хотя nginx:alpine обновляется редко, но пусть будет)
|
|
||||||
labels:
|
|
||||||
- "com.centurylinklabs.watchtower.scope=etpgrf"
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
# Конфиг берем из репозитория
|
# Конфиг берем из репозитория
|
||||||
- ./config/nginx/etpgrf--internal-nginx.conf:/etc/nginx/nginx.conf:ro
|
- ./config/nginx/etpgrf--internal-nginx.conf:/etc/nginx/nginx.conf:ro
|
||||||
@@ -72,12 +105,11 @@ services:
|
|||||||
# Берем учетные данные из .env файла
|
# Берем учетные данные из .env файла
|
||||||
- REPO_USER=${REPO_USER}
|
- REPO_USER=${REPO_USER}
|
||||||
- REPO_PASS=${REPO_PASS}
|
- REPO_PASS=${REPO_PASS}
|
||||||
- WATCHTOWER_REGISTRY_URL=git.cube2.ru
|
|
||||||
# Ограничиваем область видимости только этим проектом
|
# Ограничиваем область видимости только этим проектом
|
||||||
- WATCHTOWER_SCOPE=etpgrf
|
- WATCHTOWER_SCOPE=etpgrf
|
||||||
# Если нужно указать реестр явно (обычно watchtower сам понимает из имени образа)
|
# Если нужно указать реестр явно (обычно watchtower сам понимает из имени образа)
|
||||||
# - WATCHTOWER_REGISTRY_URL=git.cube2.ru
|
# - WATCHTOWER_REGISTRY_URL=git.cube2.ru
|
||||||
command: --interval 300 --cleanup # Проверять каждые 5 минут
|
command: --interval 1800 --cleanup # Проверять каждые 30 минут
|
||||||
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
9
etpgrf_site/__init__.py
Normal file
9
etpgrf_site/__init__.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
"""сайт etpgrf - сайт на django для тестирования и представления библиотеки экранной типографики etpgrf.
|
||||||
|
Основные возможности:
|
||||||
|
- Веб-интерфейс для ввода текста и настройки параметров типографики.
|
||||||
|
"""
|
||||||
|
__version__ = "0.1.3"
|
||||||
|
__author__ = "Sergei Erjemin"
|
||||||
|
__email__ = "erjemin@gmail.com"
|
||||||
|
__license__ = "MIT"
|
||||||
|
__copyright__ = "Copyright 2026 Sergei Erjemin"
|
||||||
@@ -7,11 +7,6 @@ from django.contrib.staticfiles.storage import staticfiles_storage
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path(route='adm-in/', view=admin.site.urls),
|
path(route='adm-in/', view=admin.site.urls),
|
||||||
path(
|
|
||||||
route="favicon.ico",
|
|
||||||
view=RedirectView.as_view(url=staticfiles_storage.url("favicon.ico")),
|
|
||||||
name="favicon",
|
|
||||||
),
|
|
||||||
path(route='', view=include('typograph.urls')),
|
path(route='', view=include('typograph.urls')),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from .models import DailyStat
|
||||||
|
|
||||||
# Register your models here.
|
@admin.register(DailyStat)
|
||||||
|
class DailyStatAdmin(admin.ModelAdmin):
|
||||||
|
list_display = (
|
||||||
|
'date',
|
||||||
|
'index_views',
|
||||||
|
'process_requests',
|
||||||
|
'copy_count',
|
||||||
|
'chars_in',
|
||||||
|
'chars_out',
|
||||||
|
'chars_copied',
|
||||||
|
'avg_processing_time_ms_formatted',
|
||||||
|
)
|
||||||
|
list_filter = ('date',)
|
||||||
|
search_fields = ('date',)
|
||||||
|
ordering = ('-date',)
|
||||||
|
|
||||||
|
# Делаем поля только для чтения
|
||||||
|
readonly_fields = [field.name for field in DailyStat._meta.fields]
|
||||||
|
|
||||||
|
def has_add_permission(self, request):
|
||||||
|
# Запрещаем добавлять записи вручную
|
||||||
|
return False
|
||||||
|
|
||||||
|
def has_delete_permission(self, request, obj=None):
|
||||||
|
# Запрещаем удалять записи
|
||||||
|
return False
|
||||||
|
|
||||||
|
@admin.display(description='Среднее время (мс)', ordering='total_processing_time_ms')
|
||||||
|
def avg_processing_time_ms_formatted(self, obj):
|
||||||
|
return f"{obj.avg_processing_time_ms:.2f}"
|
||||||
|
|||||||
33
etpgrf_site/typograph/migrations/0001_initial.py
Normal file
33
etpgrf_site/typograph/migrations/0001_initial.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# Generated by Django 6.0.1 on 2026-01-20 16:23
|
||||||
|
|
||||||
|
import django.utils.timezone
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='DailyStat',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('date', models.DateField(default=django.utils.timezone.now, unique=True, verbose_name='Дата')),
|
||||||
|
('index_views', models.PositiveIntegerField(default=0, verbose_name='Просмотры главной')),
|
||||||
|
('process_requests', models.PositiveIntegerField(default=0, verbose_name='Запросы на обработку')),
|
||||||
|
('chars_in', models.BigIntegerField(default=0, verbose_name='Символов на входе')),
|
||||||
|
('chars_out', models.BigIntegerField(default=0, verbose_name='Символов на выходе')),
|
||||||
|
('total_processing_time_ms', models.FloatField(default=0.0, verbose_name='Суммарное время обработки (мс)')),
|
||||||
|
('settings_stats', models.JSONField(default=dict, verbose_name='Статистика настроек')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Дневная статистика',
|
||||||
|
'verbose_name_plural': 'Дневная статистика',
|
||||||
|
'ordering': ['-date'],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 6.0.1 on 2026-01-20 19:15
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('typograph', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='dailystat',
|
||||||
|
name='copy_count',
|
||||||
|
field=models.PositiveIntegerField(default=0, verbose_name='Копирований в буфер'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 6.0.1 on 2026-01-20 20:47
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('typograph', '0002_dailystat_copy_count'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='dailystat',
|
||||||
|
name='chars_copied',
|
||||||
|
field=models.BigIntegerField(default=0, verbose_name='Символов скопировано'),
|
||||||
|
),
|
||||||
|
]
|
||||||
0
etpgrf_site/typograph/migrations/__init__.py
Normal file
0
etpgrf_site/typograph/migrations/__init__.py
Normal file
@@ -1,3 +1,67 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
# Create your models here.
|
class DailyStat(models.Model):
|
||||||
|
"""
|
||||||
|
Модель для хранения агрегированной статистики использования за день.
|
||||||
|
"""
|
||||||
|
date = models.DateField(
|
||||||
|
verbose_name="Дата",
|
||||||
|
unique=True,
|
||||||
|
default=timezone.now
|
||||||
|
)
|
||||||
|
|
||||||
|
# Основные метрики
|
||||||
|
index_views = models.PositiveIntegerField(
|
||||||
|
verbose_name="Просмотры главной",
|
||||||
|
default=0
|
||||||
|
)
|
||||||
|
process_requests = models.PositiveIntegerField(
|
||||||
|
verbose_name="Запросы на обработку",
|
||||||
|
default=0
|
||||||
|
)
|
||||||
|
copy_count = models.PositiveIntegerField(
|
||||||
|
verbose_name="Копирований в буфер",
|
||||||
|
default=0
|
||||||
|
)
|
||||||
|
|
||||||
|
# Объемы
|
||||||
|
chars_in = models.BigIntegerField(
|
||||||
|
verbose_name="Символов на входе",
|
||||||
|
default=0
|
||||||
|
)
|
||||||
|
chars_out = models.BigIntegerField(
|
||||||
|
verbose_name="Символов на выходе",
|
||||||
|
default=0
|
||||||
|
)
|
||||||
|
chars_copied = models.BigIntegerField(
|
||||||
|
verbose_name="Символов скопировано",
|
||||||
|
default=0
|
||||||
|
)
|
||||||
|
|
||||||
|
# Производительность
|
||||||
|
total_processing_time_ms = models.FloatField(
|
||||||
|
verbose_name="Суммарное время обработки (мс)",
|
||||||
|
default=0.0
|
||||||
|
)
|
||||||
|
|
||||||
|
# Статистика по использованным настройкам
|
||||||
|
settings_stats = models.JSONField(
|
||||||
|
verbose_name="Статистика настроек",
|
||||||
|
default=dict
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = "Дневная статистика"
|
||||||
|
verbose_name_plural = "Дневная статистика"
|
||||||
|
ordering = ['-date']
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"Статистика за {self.date.strftime('%Y-%m-%d')}"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def avg_processing_time_ms(self):
|
||||||
|
"""Среднее время обработки одного запроса."""
|
||||||
|
if self.process_requests == 0:
|
||||||
|
return 0.0
|
||||||
|
return self.total_processing_time_ms / self.process_requests
|
||||||
|
|||||||
86
etpgrf_site/typograph/templates/404.html
Normal file
86
etpgrf_site/typograph/templates/404.html
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="ru">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Ошибка сервера 404 — ETPGRF</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: #f8f8f2;
|
||||||
|
color: #1f1f19;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
body {
|
||||||
|
background-color: #151111;
|
||||||
|
color: #eceff1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 3.5rem;
|
||||||
|
font-weight: lighter;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
color: #00ccff99;
|
||||||
|
margin-left: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
margin-left: 28px;
|
||||||
|
opacity: 0.8;
|
||||||
|
line-height: 150%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 500;
|
||||||
|
text-decoration: none;
|
||||||
|
color: #151111;
|
||||||
|
background-color: transparent;
|
||||||
|
border: #4a4a44 dashed 1px;
|
||||||
|
border-radius: 0.375rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
h1 {
|
||||||
|
color: #00ccff99;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
border: #b0bec5 dashed 1px;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn:hover {
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div style="top: 20%; position: relative;">
|
||||||
|
<a href="/">
|
||||||
|
<picture>
|
||||||
|
<source srcset="/static/svg/logo-etpgrf-site-dark.svg" media="(prefers-color-scheme: dark)">
|
||||||
|
<img src="/static/svg/logo-etpgrf-site-light.svg"
|
||||||
|
alt="ETPGRF — единая типографика для веба" width="717" height="151">
|
||||||
|
</picture>
|
||||||
|
</a>
|
||||||
|
<h1>404: Страница не найдена</h1>
|
||||||
|
<p>
|
||||||
|
Запра­шиваемая страница не найдена.<br/>
|
||||||
|
Контент мог быть удалён, перемещён или его тут никогда и не было.<br/>
|
||||||
|
<a class="btn" href="/">На главную</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
86
etpgrf_site/typograph/templates/500.html
Normal file
86
etpgrf_site/typograph/templates/500.html
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="ru">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Ошибка сервера 500 — ETPGRF</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: #f8f8f2;
|
||||||
|
color: #1f1f19;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
body {
|
||||||
|
background-color: #151111;
|
||||||
|
color: #eceff1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 3.5rem;
|
||||||
|
font-weight: lighter;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
color: #00ccff99;
|
||||||
|
margin-left: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
margin-left: 28px;
|
||||||
|
opacity: 0.8;
|
||||||
|
line-height: 150%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 500;
|
||||||
|
text-decoration: none;
|
||||||
|
color: #151111;
|
||||||
|
background-color: transparent;
|
||||||
|
border: #4a4a44 dashed 1px;
|
||||||
|
border-radius: 0.375rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
h1 {
|
||||||
|
color: #00ccff99;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
border: #b0bec5 dashed 1px;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn:hover {
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div style="top: 20%; position: relative;">
|
||||||
|
<a href="/">
|
||||||
|
<picture>
|
||||||
|
<source srcset="/static/svg/logo-etpgrf-site-dark.svg" media="(prefers-color-scheme: dark)">
|
||||||
|
<img src="/static/svg/logo-etpgrf-site-light.svg"
|
||||||
|
alt="ETPGRF — единая типографика для веба" width="717" height="151">
|
||||||
|
</picture>
|
||||||
|
</a>
|
||||||
|
<h1>500: Внутренняя ошибка сервера</h1>
|
||||||
|
<p>
|
||||||
|
Извините, что-то сломалось на сервере или пошло не так.<br/>
|
||||||
|
Пожалуйста, попробуйте позже.<br/>
|
||||||
|
<a class="btn" href="/">На главную</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
86
etpgrf_site/typograph/templates/typograph/403.html
Normal file
86
etpgrf_site/typograph/templates/typograph/403.html
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="ru">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Ошибка сервера 403 — ETPGRF</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: #f8f8f2;
|
||||||
|
color: #1f1f19;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
body {
|
||||||
|
background-color: #151111;
|
||||||
|
color: #eceff1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 3.5rem;
|
||||||
|
font-weight: lighter;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
color: #00ccff99;
|
||||||
|
margin-left: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
margin-left: 28px;
|
||||||
|
opacity: 0.8;
|
||||||
|
line-height: 150%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 500;
|
||||||
|
text-decoration: none;
|
||||||
|
color: #151111;
|
||||||
|
background-color: transparent;
|
||||||
|
border: #4a4a44 dashed 1px;
|
||||||
|
border-radius: 0.375rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
h1 {
|
||||||
|
color: #00ccff99;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
border: #b0bec5 dashed 1px;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn:hover {
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div style="top: 20%; position: relative;">
|
||||||
|
<a href="/">
|
||||||
|
<picture>
|
||||||
|
<source srcset="/static/svg/logo-etpgrf-site-dark.svg" media="(prefers-color-scheme: dark)">
|
||||||
|
<img src="/static/svg/logo-etpgrf-site-light.svg"
|
||||||
|
alt="ETPGRF — единая типографика для веба" width="717" height="151">
|
||||||
|
</picture>
|
||||||
|
</a>
|
||||||
|
<h1>403: Доступ запрещён, необходимо автори­зоваться</h1>
|
||||||
|
<p>
|
||||||
|
Записанная в адресной строке страница требует аутенти­фикации.<br/>
|
||||||
|
Пожалуйста, войдите в систему и повторите попытку.<br/>
|
||||||
|
<a class="btn" href="/">На главную</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -3,46 +3,78 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
{# --- SEO & Meta Tags --- #}
|
||||||
<title>{% block title %}ETPGRF — единая типографика для веба{% endblock %}</title>
|
<title>{% block title %}ETPGRF — единая типографика для веба{% endblock %}</title>
|
||||||
{# Favicons #} <link rel="icon" type="image/png" href="{% static 'favicon-96x96.png' %}" sizes="96x96" />
|
<meta name="description" content="{% block description %}Бесплатный онлайн-типограф для подготовки текстов к публикации в вебе. Расставка неразрывных пробелов, правильных кавычек («ёлочки»), тире, спецсимволы, отбивка, компоновка, висячая пунктуация. Идеально для верстки сайтов, статей и постов.{% endblock %}">
|
||||||
<link rel="icon" href="{% static 'favicon-light.svg' %}" type="image/svg+xml" media="(prefers-color-scheme: light)">
|
<meta name="keywords" content="типограф, типографика, онлайн типограф, подготовка текста для веба, html типограф, неразрывные пробелы, кавычки елочки, длинное тире, очистка текста от мусора, интернет верстка, муравьев">
|
||||||
<link rel="icon" href="{% static 'favicon-dark.svg' %}" type="image/svg+xml" media="(prefers-color-scheme: dark)">
|
<meta name="author" content="Sergei Erjemin">
|
||||||
|
|
||||||
|
{# --- Open Graph (Facebook, VK, LinkedIn, Telegram) --- #}
|
||||||
|
<meta property="og:type" content="website" />
|
||||||
|
<meta property="og:site_name" content="ETPGRF" />
|
||||||
|
<meta property="og:url" content="{{ request.build_absolute_uri }}" />
|
||||||
|
<meta property="og:title" content="{% block og_title %}ETPGRF — единая типографика для веба{% endblock %}" />
|
||||||
|
<meta property="og:description" content="{% block og_description %}Сделайте ваш текст профессиональным и готовым к публикации в интернете за один клик. Умная типографика для веб-дизайнеров, редакторов и контент-менеджеров.{% endblock %}" />
|
||||||
|
<meta property="og:image" content="{% block og_image %}{{ request.scheme }}://{{ request.get_host }}{% static 'img/etpgrf-logo-for-fb-vk-x.gif' %}{% endblock %}" />
|
||||||
|
<meta property="og:image:width" content="1200" />
|
||||||
|
<meta property="og:image:height" content="630" />
|
||||||
|
|
||||||
|
{# --- Twitter Cards (X) --- #}
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
<meta name="twitter:title" content="{% block twitter_title %}ETPGRF — единая типографика для веба{% endblock %}" />
|
||||||
|
<meta name="twitter:description" content="{% block twitter_description %}Сделайте ваш текст профессиональным и готовым к публикации в интернете за один клик.{% endblock %}" />
|
||||||
|
<meta name="twitter:image" content="{% block twitter_image %}{{ request.scheme }}://{{ request.get_host }}{% static 'img/etpgrf-logo-for-fb-vk-x.gif' %}{% endblock %}" />
|
||||||
|
|
||||||
|
{# --- Favicons --- #}
|
||||||
|
<link rel="icon" href="{{ request.scheme }}://{{ request.get_host }}{% static 'favicon.ico' %}" type="image/x-icon" />
|
||||||
|
<link rel="icon" type="image/png" href="{% static 'favicon-96x96.png' %}" />
|
||||||
|
<link rel="icon" href="{% static 'favicon-light.svg' %}" type="image/svg+xml" media="(prefers-color-scheme: light)" />
|
||||||
|
<link rel="icon" href="{% static 'favicon-dark.svg' %}" type="image/svg+xml" media="(prefers-color-scheme: dark)" />
|
||||||
<link rel="icon" type="image/svg+xml" href="{% static 'favicon.svg' %}" />
|
<link rel="icon" type="image/svg+xml" href="{% static 'favicon.svg' %}" />
|
||||||
{# Fallback для старых браузеров #}<link rel="shortcut icon" href="{% static 'favicon.ico' %}" sizes="any" />
|
<link rel="apple-touch-icon" sizes="180x180" href="{% static 'apple-touch-icon.png' %}" />
|
||||||
{# iOS Icon #}<link rel="apple-touch-icon" sizes="180x180" href="{% static 'apple-touch-icon.png' %}" />
|
|
||||||
<link rel="manifest" href="{% static 'site.webmanifest' %}" />
|
<link rel="manifest" href="{% static 'site.webmanifest' %}" />
|
||||||
{# Bootstrap 5 CSS #}<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"/>
|
{# Bootstrap 5 CSS #}<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"/>
|
||||||
{# Bootstrap Icons #}<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css"/>
|
{# Bootstrap Icons #}<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css"/>
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--bg-image-text: url("{% static 'svg/logo-etpgrf-site-light-txt.svg' %}");
|
||||||
|
--bg-image-logo: url("{% static 'svg/logo-etpgrf-site-light-compact.svg' %}");
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root {
|
||||||
|
--bg-image-text: url("{% static 'svg/logo-etpgrf-site-dark-txt.svg' %}");
|
||||||
|
--bg-image-logo: url("{% static 'svg/logo-etpgrf-site-dark-compact.svg' %}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
{# Custom CSS #}<link href="{% static 'css/etpgrf.css' %}" rel="stylesheet"/>
|
{# Custom CSS #}<link href="{% static 'css/etpgrf.css' %}" rel="stylesheet"/>
|
||||||
{# HTMX #}<script src="https://unpkg.com/htmx.org@1.9.10"></script>
|
{# HTMX #}<script src="https://unpkg.com/htmx.org@1.9.10"></script>
|
||||||
{# Alpine.js #}<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
{# Alpine.js #}<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
||||||
{# Polyfill for Import Maps #}<script async src="https://ga.jspm.io/npm:es-module-shims@1.10.0/dist/es-module-shims.js"></script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
{# ШАПКА и главное меню #}
|
{# ШАПКА с логотипом и главное меню #}<nav id="main-navbar" class="navbar navbar-expand-lg mb-4">
|
||||||
<nav id="main-navbar" class="navbar navbar-expand-lg mb-4">
|
<div id="logo" class="container logo-big" style="background-image: var(--bg-image-logo);">
|
||||||
<div class="container">
|
<a class="navbar-brand" href="/" style="background-image: var(--bg-image-text);"
|
||||||
<a class="navbar-brand" href="/">
|
title="ETPGRF — единая типографика для веба">
|
||||||
<img id="logo-img" class="logo-img" src=""
|
|
||||||
data-src-light="{% static 'svg/logo-etpgrf-site-light.svg' %}"
|
|
||||||
data-src-light-compact="{% static 'svg/logo-etpgrf-site-light-compact.svg' %}"
|
|
||||||
data-src-dark="{% static 'svg/logo-etpgrf-site-dark.svg' %}"
|
|
||||||
data-src-dark-compact="{% static 'svg/logo-etpgrf-site-dark-compact.svg' %}"
|
|
||||||
alt="ETPGRF — единая типографика для веба">
|
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div id="content-container" class="container">
|
{# Контент #}<div id="content-container" class="container">
|
||||||
{% block content %}{% endblock %}
|
{% block content %}{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{# Футер #}
|
{# Футер #}<footer class="footer mt-auto py-2 mt-4">
|
||||||
<footer class="footer mt-auto py-3">
|
<div class="container d-flex justify-content-between align-items-center">
|
||||||
<div class="container">
|
<span class="text-muted small nowrap me-2">© Sergei Erjemin, 2025–{% now 'Y' %}.</span>
|
||||||
<span class="text-muted small">© Sergei Erjemin, 2025–{% now 'Y' %}</span>
|
<nobr class="text-muted small mx-2"><i class="bi bi-tags me-1" title="Версия библиотеки etpgrf / Версия сайта"></i>v0.1.3 / v0.1.6
|
||||||
<span class="text-muted small float-end">v0.1.1</span>
|
</nobr>
|
||||||
|
{# Сводная статистика (HTMX) #}<span class="text-muted small ms-2" hx-get="{% url 'stats_summary' %}" hx-trigger="load">
|
||||||
|
...
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
@@ -60,13 +92,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{# Bootstrap JS #}
|
{# Bootstrap JS #}<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
{# Custom JS #}<script src="{% static 'js/base.js' %}" defer></script>
|
||||||
|
|
||||||
{# Custom JS #}
|
|
||||||
<script src="{% static 'js/base.js' %}" defer></script>
|
|
||||||
|
|
||||||
{% block scripts %}{% endblock %}
|
{% block scripts %}{% endblock %}
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -4,14 +4,40 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<h3>Типограф</h3>
|
|
||||||
|
{# SEO-текст и описание #}
|
||||||
|
<div class="mb-4">
|
||||||
|
<h1 class="h3 mb-3">Онлайн-типограф для веба</h1>
|
||||||
|
<p>
|
||||||
|
Интернет-типограф <strong>etpgrf</strong> — инструмент для подготовки текста для публикации
|
||||||
|
в вебе. Расстановка неразрывных пробелов перед союзами и предлогами, замена кавычек
|
||||||
|
на «ёлочки» (или “лапки” для англоя­зычного текста), отбивка и компоновка тире,
|
||||||
|
инициалов, единиц измерения, переносы в словах, обработка псевдо­графики и преобра­зование
|
||||||
|
их в спецсимволы, висячая пунктуация. Получите готовый и валидный HTML-код для вставки
|
||||||
|
на ваш сайт или публикацию в блог.
|
||||||
|
</p>
|
||||||
|
<p class="text-muted small">
|
||||||
|
Исходный код etpgrf-типографа доступен в нескольких репози­ториях
|
||||||
|
(<a href="https://github.com/erjemin/etpgrf" target="_blank">GitHub</a>,
|
||||||
|
<a href="https://gitverse.ru/erjemin/etpgrf" target="_blank">GitVerse</a>,
|
||||||
|
<a href="https://git.cube2.ru/erjemin/2025-etpgrf" target="_blank">Сube2</a>, и <a
|
||||||
|
href="https://pypi.org/project/etpgrf/" target="_blank">PyPI</a>), распрос­траняется под лицензией
|
||||||
|
<a href="https://opensource.org/licenses/MIT" target="_blank">MIT</a>, может быть установлен
|
||||||
|
локально, на ваш сайт или интегри­рован в ваши проекты как Python-библиотека.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<form hx-post="{% url 'process_text' %}" hx-target="#result-area" hx-swap="innerHTML">
|
<form hx-post="{% url 'process_text' %}" hx-target="#result-area" hx-swap="innerHTML">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
||||||
{# ГЛАВНОЕ ПОЛЕ ВВОДА: ТЕКСТ ДЛЯ ТИПОГРАФИРОВАНИЯ #}
|
{# ГЛАВНОЕ ПОЛЕ ВВОДА #}
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
|
<label class="form-label fw-bold small text-muted ls-1">
|
||||||
|
<i class="bi bi-file-text me-1"></i> Исходный текст:
|
||||||
|
</label>
|
||||||
<textarea class="form-control" name="text" rows="10" placeholder="Вставьте текст сюда..."></textarea>
|
<textarea class="form-control" name="text" rows="10" placeholder="Вставьте текст сюда..."></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{# Блок настроек (Collapse) #}
|
{# Блок настроек (Collapse) #}
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<button class="btn btn-outline-secondary btn-sm mb-2" type="button" data-bs-toggle="collapse"
|
<button class="btn btn-outline-secondary btn-sm mb-2" type="button" data-bs-toggle="collapse"
|
||||||
@@ -239,12 +265,22 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Кнопка отправки -->
|
<!-- Кнопка отправки -->
|
||||||
<button type="submit" class="btn btn-primary btn-lg w-100">Типографировать</button>
|
<button type="submit" class="btn btn-primary btn-lg w-100" onclick="sendGoal('etpgrf-btn-pressed')">Типографировать</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-12 mt-4">
|
<div class="col-md-12 my-4">
|
||||||
<h3>Результат</h3>
|
<div class="d-flex justify-content-between align-items-end mb-2">
|
||||||
|
<label class="form-label fw-bold small text-muted ls-1 mb-0">
|
||||||
|
<i class="bi bi-code-slash me-1"></i> Результат обработки:
|
||||||
|
</label>
|
||||||
|
<div class="d-flex align-items-center">
|
||||||
|
<span id="processing-time" class="small text-muted me-3 nowrap"></span>
|
||||||
|
<button id="btn-copy" class="btn btn-sm btn-outline-secondary d-none" title="Копировать в буфер обмена">
|
||||||
|
<i class="bi bi-clipboard me-1"></i> Копировать в буфер обмена
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div id="cm-result-wrapper" class="result-box p-0"></div>
|
<div id="cm-result-wrapper" class="result-box p-0"></div>
|
||||||
<div id="result-area" style="display: none;"></div>
|
<div id="result-area" style="display: none;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
12
etpgrf_site/typograph/templates/typograph/stats_summary.html
Normal file
12
etpgrf_site/typograph/templates/typograph/stats_summary.html
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{% load typograph_extras %}<nobr class="ms-3 float-end" title="Скопировано в буфер текстов/символов">
|
||||||
|
<i class="bi bi-clipboard-check me-1"></i>{{ copied|humanize_num }} / {{ chars_copied|humanize_num }}
|
||||||
|
</nobr>
|
||||||
|
<nobr class="ms-3 float-end" title="На выход получено символов">
|
||||||
|
<i class="bi bi-box-arrow-right me-1"></i>{{ chars_out|humanize_num }}
|
||||||
|
</nobr>
|
||||||
|
<nobr class="ms-3 float-end" title="На вход обработано текстов/символов">
|
||||||
|
<i class="bi bi-box-arrow-in-right me-1"></i>{{ processed|humanize_num }} / {{ chars_in|humanize_num }}
|
||||||
|
</nobr>
|
||||||
|
<nobr class="ms-3 float-end" title="Просмотров">
|
||||||
|
<i class="bi bi-eye me-1"></i>{{ views|humanize_num }}
|
||||||
|
</nobr>
|
||||||
45
etpgrf_site/typograph/templatetags/typograph_extras.py
Normal file
45
etpgrf_site/typograph/templatetags/typograph_extras.py
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
from django import template
|
||||||
|
from django.utils.safestring import mark_safe
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
@register.filter(name='humanize_num')
|
||||||
|
def humanize_num(value):
|
||||||
|
"""
|
||||||
|
Форматирует число с тонкими пробелами в качестве разделителя тысяч
|
||||||
|
и сокращает большие числа до M (миллионы) или k (тысячи).
|
||||||
|
|
||||||
|
Примеры:
|
||||||
|
1234 -> 1 234
|
||||||
|
1234567 -> 1,2M
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
num = int(value)
|
||||||
|
if num > 1_000_000_000:
|
||||||
|
val = num / 1_000_000_000
|
||||||
|
suffix = " B"
|
||||||
|
elif num > 1_000_000:
|
||||||
|
val = num / 1_000_000
|
||||||
|
suffix = " M"
|
||||||
|
elif num > 1_000:
|
||||||
|
val = num / 1_000
|
||||||
|
suffix = " k"
|
||||||
|
else:
|
||||||
|
# Больше 1B -- форматируем с пробелами
|
||||||
|
return mark_safe(f"{num:,}".replace(",", " "))
|
||||||
|
|
||||||
|
# Форматируем float:
|
||||||
|
# {:,.1f} - разделитель тысяч (запятая) и 1 знак после точки
|
||||||
|
# 1234567.89 -> "1,234,567.9"
|
||||||
|
formatted = f"{val:,.2f}"
|
||||||
|
|
||||||
|
# Меняем английскую запятую (разделитель тысяч) на тонкий пробел
|
||||||
|
# Меняем английскую точку (десятичный разделитель) на запятую
|
||||||
|
# Но тут проблема: replace делает все сразу.
|
||||||
|
# "1,234.5" -> replace(",", " ") -> "1 234.5" -> replace(".", ",") -> "1 234,5"
|
||||||
|
formatted = formatted.replace(",", " ").replace(".", ",")
|
||||||
|
|
||||||
|
return mark_safe(f"{formatted}{suffix}")
|
||||||
|
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
return value
|
||||||
@@ -2,6 +2,8 @@ from django.urls import path
|
|||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path(route='', view=views.index, name='index'),
|
path('', views.index, name='index'),
|
||||||
path(route='process/', view=views.process_text, name='process_text'),
|
path('process/', views.process_text, name='process_text'),
|
||||||
|
path('stats/summary/', views.get_stats_summary, name='stats_summary'),
|
||||||
|
path('stats/track-copy/', views.track_copy, name='track_copy'),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,12 +1,73 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse, JsonResponse
|
||||||
|
from django.db.models import F, Sum
|
||||||
|
from django.utils import timezone
|
||||||
|
from django.views.decorators.http import require_POST
|
||||||
from etpgrf.typograph import Typographer
|
from etpgrf.typograph import Typographer
|
||||||
from etpgrf.layout import LayoutProcessor
|
from etpgrf.layout import LayoutProcessor
|
||||||
from etpgrf.hyphenation import Hyphenator
|
from etpgrf.hyphenation import Hyphenator
|
||||||
|
from .models import DailyStat
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
|
# Увеличиваем счетчик просмотров главной
|
||||||
|
try:
|
||||||
|
today = timezone.now().date()
|
||||||
|
stat, created = DailyStat.objects.get_or_create(date=today)
|
||||||
|
DailyStat.objects.filter(pk=stat.pk).update(index_views=F('index_views') + 1)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Stat error: {e}")
|
||||||
|
|
||||||
return render(request, template_name='typograph/index.html')
|
return render(request, template_name='typograph/index.html')
|
||||||
|
|
||||||
|
|
||||||
|
def get_stats_summary(request):
|
||||||
|
"""Возвращает сводную статистику."""
|
||||||
|
try:
|
||||||
|
stats = DailyStat.objects.aggregate(
|
||||||
|
views=Sum('index_views'),
|
||||||
|
processed=Sum('process_requests'),
|
||||||
|
copied=Sum('copy_count'),
|
||||||
|
chars_in=Sum('chars_in'),
|
||||||
|
chars_out=Sum('chars_out'),
|
||||||
|
chars_copied=Sum('chars_copied')
|
||||||
|
)
|
||||||
|
|
||||||
|
context = {
|
||||||
|
'views': stats['views'] or 0,
|
||||||
|
'processed': stats['processed'] or 0,
|
||||||
|
'copied': stats['copied'] or 0,
|
||||||
|
'chars_in': stats['chars_in'] or 0,
|
||||||
|
'chars_out': stats['chars_out'] or 0,
|
||||||
|
'chars_copied': stats['chars_copied'] or 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
return render(request, 'typograph/stats_summary.html', context)
|
||||||
|
except Exception:
|
||||||
|
return HttpResponse("...")
|
||||||
|
|
||||||
|
|
||||||
|
@require_POST
|
||||||
|
def track_copy(request):
|
||||||
|
"""Увеличивает счетчик копирований и количество скопированных символов."""
|
||||||
|
try:
|
||||||
|
char_count = int(request.POST.get('char_count', 0))
|
||||||
|
|
||||||
|
today = timezone.now().date()
|
||||||
|
stat, created = DailyStat.objects.get_or_create(date=today)
|
||||||
|
DailyStat.objects.filter(pk=stat.pk).update(
|
||||||
|
copy_count=F('copy_count') + 1,
|
||||||
|
chars_copied=F('chars_copied') + char_count
|
||||||
|
)
|
||||||
|
return HttpResponse("OK")
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
return HttpResponse("Invalid char_count", status=400)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Stat error: {e}")
|
||||||
|
return HttpResponse("Error", status=500)
|
||||||
|
|
||||||
|
|
||||||
def process_text(request):
|
def process_text(request):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
text = request.POST.get(key='text', default='')
|
text = request.POST.get(key='text', default='')
|
||||||
@@ -71,22 +132,71 @@ def process_text(request):
|
|||||||
'sanitizer': sanitizer_option,
|
'sanitizer': sanitizer_option,
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- ДИАГНОСТИКА ---
|
# Обрабатываем текст с замером времени
|
||||||
# print("Typographer options:", options)
|
start_time = time.perf_counter()
|
||||||
# -------------------
|
# Создаем экземпляр типографа и передаем настройки в него
|
||||||
|
|
||||||
# Создаем экземпляр типографа
|
|
||||||
typo = Typographer(**options)
|
typo = Typographer(**options)
|
||||||
|
# Обрабатываем текст в Типографе
|
||||||
# Обрабатываем текст
|
|
||||||
processed = typo.process(text)
|
processed = typo.process(text)
|
||||||
# print("Processed text length:", len(processed))
|
end_time = time.perf_counter()
|
||||||
# print("Processed text:", processed)
|
|
||||||
|
|
||||||
return render(
|
duration_ms = (end_time - start_time) * 1000
|
||||||
|
|
||||||
|
# --- СБОР СТАТИСТИКИ ---
|
||||||
|
try:
|
||||||
|
today = timezone.now().date()
|
||||||
|
stat, created = DailyStat.objects.get_or_create(date=today)
|
||||||
|
|
||||||
|
# 1. Атомарное обновление счетчиков
|
||||||
|
DailyStat.objects.filter(pk=stat.pk).update(
|
||||||
|
process_requests=F('process_requests') + 1,
|
||||||
|
chars_in=F('chars_in') + len(text),
|
||||||
|
chars_out=F('chars_out') + len(processed),
|
||||||
|
total_processing_time_ms=F('total_processing_time_ms') + duration_ms
|
||||||
|
)
|
||||||
|
|
||||||
|
# 2. Обновление JSON с настройками (не атомарно, а значит при высокой нагрузке возможны потери данных)
|
||||||
|
# Перечитываем объект, чтобы получить актуальный JSON
|
||||||
|
stat.refresh_from_db()
|
||||||
|
current_stats = stat.settings_stats
|
||||||
|
|
||||||
|
def inc_stat(key, value):
|
||||||
|
k = f"{key}:{value}"
|
||||||
|
current_stats[k] = current_stats.get(k, 0) + 1
|
||||||
|
|
||||||
|
# Собираем статистику по опциям
|
||||||
|
# langs может быть строкой или списком
|
||||||
|
lang_val = options['langs']
|
||||||
|
if isinstance(lang_val, list):
|
||||||
|
lang_val = lang_val[0] if lang_val else 'ru'
|
||||||
|
inc_stat('lang', lang_val)
|
||||||
|
|
||||||
|
inc_stat('mode', options['mode'])
|
||||||
|
|
||||||
|
if options['quotes']: inc_stat('feature', 'quotes')
|
||||||
|
if layout_enabled: inc_stat('feature', 'layout')
|
||||||
|
if options['unbreakables']: inc_stat('feature', 'unbreakables')
|
||||||
|
if hyphenation_enabled: inc_stat('feature', 'hyphenation')
|
||||||
|
if options['symbols']: inc_stat('feature', 'symbols')
|
||||||
|
if hanging_enabled: inc_stat('feature', 'hanging')
|
||||||
|
if sanitizer_enabled: inc_stat('feature', 'sanitizer')
|
||||||
|
|
||||||
|
stat.settings_stats = current_stats
|
||||||
|
stat.save(update_fields=['settings_stats'])
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Stat error: {e}")
|
||||||
|
# -----------------------
|
||||||
|
|
||||||
|
response = render(
|
||||||
request,
|
request,
|
||||||
template_name='typograph/result_fragment.html',
|
template_name='typograph/result_fragment.html',
|
||||||
context={'processed_text': processed}
|
context={'processed_text': processed}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Добавляем заголовок с временем обработки (с запятой вместо точки)
|
||||||
|
response['X-Processing-Time'] = f"{duration_ms:.4f}".replace('.', ',')
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
return HttpResponse(status=405)
|
return HttpResponse(status=405)
|
||||||
|
|||||||
87
public/static/502.html
Normal file
87
public/static/502.html
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="ru">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Ошибка сервера 502 — ETPGRF</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: #f8f8f2;
|
||||||
|
color: #1f1f19;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
body {
|
||||||
|
background-color: #151111;
|
||||||
|
color: #eceff1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 3.5rem;
|
||||||
|
font-weight: lighter;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
color: #00ccff99;
|
||||||
|
margin-left: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
margin-left: 28px;
|
||||||
|
opacity: 0.8;
|
||||||
|
line-height: 150%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 500;
|
||||||
|
text-decoration: none;
|
||||||
|
color: #151111;
|
||||||
|
background-color: transparent;
|
||||||
|
border: #4a4a44 dashed 1px;
|
||||||
|
border-radius: 0.375rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
h1 {
|
||||||
|
color: #00ccff99;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
border: #b0bec5 dashed 1px;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn:hover {
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div style="top: 20%; position: relative;">
|
||||||
|
<a href="/">
|
||||||
|
<picture>
|
||||||
|
<source srcset="/static/svg/logo-etpgrf-site-dark.svg" media="(prefers-color-scheme: dark)">
|
||||||
|
<img src="/static/svg/logo-etpgrf-site-light.svg"
|
||||||
|
alt="ETPGRF — единая типографика для веба" width="717" height="151">
|
||||||
|
</picture>
|
||||||
|
</a>
|
||||||
|
<h1>502: Bad Gateway</h1>
|
||||||
|
<p>
|
||||||
|
Внутренняя ошибка сервера.<br/>
|
||||||
|
Недоступен Gunicorn-сервис, база данных или произошла ошибка при обработке запроса.<br />
|
||||||
|
Пожалуйста, попробуйте позже.<br/>
|
||||||
|
<a class="btn" href="/">На главную</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
86
public/static/503.html
Normal file
86
public/static/503.html
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="ru">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Ошибка сервера 503 — ETPGRF</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: #f8f8f2;
|
||||||
|
color: #1f1f19;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
body {
|
||||||
|
background-color: #151111;
|
||||||
|
color: #eceff1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 3.5rem;
|
||||||
|
font-weight: lighter;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
color: #00ccff99;
|
||||||
|
margin-left: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
margin-left: 28px;
|
||||||
|
opacity: 0.8;
|
||||||
|
line-height: 150%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 500;
|
||||||
|
text-decoration: none;
|
||||||
|
color: #151111;
|
||||||
|
background-color: transparent;
|
||||||
|
border: #4a4a44 dashed 1px;
|
||||||
|
border-radius: 0.375rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
h1 {
|
||||||
|
color: #00ccff99;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
border: #b0bec5 dashed 1px;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn:hover {
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div style="top: 20%; position: relative;">
|
||||||
|
<a href="/">
|
||||||
|
<picture>
|
||||||
|
<source srcset="/static/svg/logo-etpgrf-site-dark.svg" media="(prefers-color-scheme: dark)">
|
||||||
|
<img src="/static/svg/logo-etpgrf-site-light.svg"
|
||||||
|
alt="ETPGRF — единая типографика для веба" width="717" height="151">
|
||||||
|
</picture>
|
||||||
|
</a>
|
||||||
|
<h1>503: Слишком много запросов</h1>
|
||||||
|
<p>
|
||||||
|
Сервер временно перегружен запросами или находится на техническом обслуживании.<br/>
|
||||||
|
Пожалуйста, попробуйте позже.<br/>
|
||||||
|
<a class="btn" href="/">На главную</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
87
public/static/504.html
Normal file
87
public/static/504.html
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="ru">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Ошибка сервера 50x — ETPGRF</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: #f8f8f2;
|
||||||
|
color: #1f1f19;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
body {
|
||||||
|
background-color: #151111;
|
||||||
|
color: #eceff1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 3.5rem;
|
||||||
|
font-weight: lighter;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
color: #00ccff99;
|
||||||
|
margin-left: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
margin-left: 28px;
|
||||||
|
opacity: 0.8;
|
||||||
|
line-height: 150%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 500;
|
||||||
|
text-decoration: none;
|
||||||
|
color: #151111;
|
||||||
|
background-color: transparent;
|
||||||
|
border: #4a4a44 dashed 1px;
|
||||||
|
border-radius: 0.375rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
h1 {
|
||||||
|
color: #00ccff99;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
border: #b0bec5 dashed 1px;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn:hover {
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div style="top: 20%; position: relative;">
|
||||||
|
<a href="/">
|
||||||
|
<picture>
|
||||||
|
<source srcset="/static/svg/logo-etpgrf-site-dark.svg" media="(prefers-color-scheme: dark)">
|
||||||
|
<img src="/static/svg/logo-etpgrf-site-light.svg"
|
||||||
|
alt="ETPGRF — единая типографика для веба" width="717" height="151">
|
||||||
|
</picture>
|
||||||
|
</a>
|
||||||
|
<h1>504: Gateway Timeout</h1>
|
||||||
|
<p>
|
||||||
|
Сервер не смог ответить вовремя.<br/>
|
||||||
|
Возможно, текст для типографа слишком большой илия сервер перегружен.<br/>
|
||||||
|
Пожалуйста, попробуйте позже.<br/>
|
||||||
|
<a class="btn" href="#">Обновить страницу</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -48,40 +48,52 @@ body {
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Навбар: используем переменную для фона */
|
#main-navbar {
|
||||||
.navbar {
|
z-index: 1000;
|
||||||
background-color: var(--bs-navbar-bg) !important;
|
background-color: var(--bs-navbar-bg) !important;
|
||||||
border-bottom: 1px solid var(--bs-border-color);
|
border-bottom: 1px solid var(--bs-border-color);
|
||||||
padding: 0; /* Убираем отступы у навбара */
|
padding: 0;
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
height: 105px;
|
backdrop-filter: blur(8px); /* Эффект размытия */
|
||||||
z-index: 1000;
|
|
||||||
backdrop-filter: blur(4px); /* Эффект размытия */
|
|
||||||
box-shadow: 0 -25px 30px 15px var(--bs-border-color);
|
box-shadow: 0 -25px 30px 15px var(--bs-border-color);
|
||||||
|
/* transition: height 0.3s ease, background-color 0.3s ease; /* Анимация высоты */
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar-brand {
|
#main-navbar > .container {
|
||||||
padding: 0; /* Убираем отступы у бренда */
|
background: no-repeat left;
|
||||||
|
background-size: contain;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Стили для скролла */
|
#main-navbar > .container.logo-big {
|
||||||
.navbar-scrolled {
|
background-image: var(--bg-image-text);
|
||||||
height: 55px;
|
transition: .4s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Логотип */
|
#main-navbar > .container:not(.logo-big) {
|
||||||
.logo-img {
|
background-image: none;
|
||||||
width: 70%;
|
transition: .4s ease;
|
||||||
margin-left: -3%; /* Немного сдвигаем влево, чтобы буквы ETPGRF логотипа выровнять */
|
|
||||||
height: 151px; /* Ограничиваем высоту */
|
|
||||||
object-fit: contain; /* Вписываем, сохраняя пропорции */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Уменьшаем логотип при скролле */
|
#main-navbar > #logo > .navbar-brand {
|
||||||
.navbar-scrolled .logo-img {
|
display: block; /* Блок, чтобы работали размеры */
|
||||||
height: 78px; /* Компактная высота */
|
background: no-repeat left;
|
||||||
margin-left: -5%;
|
background-size: contain;
|
||||||
|
margin-left: -1.5%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#main-navbar > #logo.logo-big > .navbar-brand {
|
||||||
|
height: 105px;
|
||||||
|
width: 500px;
|
||||||
|
opacity: 1;
|
||||||
|
transition: .4s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
#main-navbar > #logo:not(.logo-big) > .navbar-brand {
|
||||||
|
height: 60px;
|
||||||
|
width: 285px;
|
||||||
|
transition: .4s ease;
|
||||||
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Контент растягивается, чтобы прижать футер */
|
/* Контент растягивается, чтобы прижать футер */
|
||||||
|
|||||||
BIN
public/static/img/etpgrf-logo-for-fb-vk-x.gif
Normal file
BIN
public/static/img/etpgrf-logo-for-fb-vk-x.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
@@ -1,91 +1,83 @@
|
|||||||
(function () {
|
(function () {
|
||||||
const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
"use strict";
|
||||||
const logoImg = document.getElementById('logo-img');
|
|
||||||
const navbar = document.getElementById('main-navbar');
|
|
||||||
|
|
||||||
// --- АВТОМАТИЧЕСКОЕ ПЕРЕКЛЮЧЕНИЕ ТЕМЫ (Dark/Light) ---
|
// --- АВТОМАТИЧЕСКОЕ ПЕРЕКЛЮЧЕНИЕ ТЕМЫ (Dark/Light) ---
|
||||||
|
const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
||||||
|
|
||||||
function updateTheme(e) {
|
function updateTheme(e) {
|
||||||
const theme = e.matches ? 'dark' : 'light';
|
const theme = e.matches ? 'dark' : 'light';
|
||||||
document.documentElement.setAttribute('data-bs-theme', theme);
|
document.documentElement.setAttribute('data-bs-theme', theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- ОБНОВЛЕНИЕ ЛОГОТИПА ПРИ СКРОЛЛЕ И СМЕНЕ ТЕМЫ ---
|
// Установить при загрузке
|
||||||
function updateLogo() {
|
|
||||||
const isDark = darkModeMediaQuery.matches;
|
|
||||||
// Используем getBoundingClientRect для определения позиции контента
|
|
||||||
if (document.getElementById('content-container').getBoundingClientRect().top < 78) {
|
|
||||||
navbar.classList.add('navbar-scrolled');
|
|
||||||
logoImg.src = isDark ? logoImg.dataset.srcDarkCompact : logoImg.dataset.srcLightCompact;
|
|
||||||
} else {
|
|
||||||
navbar.classList.remove('navbar-scrolled');
|
|
||||||
logoImg.src = isDark ? logoImg.dataset.srcDark : logoImg.dataset.srcLight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Инициализация
|
|
||||||
updateTheme(darkModeMediaQuery);
|
updateTheme(darkModeMediaQuery);
|
||||||
updateLogo();
|
// Слушать изменения
|
||||||
document.addEventListener('DOMContentLoaded', updateLogo);
|
darkModeMediaQuery.addEventListener('change', updateTheme);
|
||||||
|
|
||||||
// Слушаем скролл
|
|
||||||
window.addEventListener('scroll', updateLogo);
|
|
||||||
|
|
||||||
// Слушаем смену темы
|
// --- ЛОГОТИП И СКРОЛЛ ---
|
||||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', updateLogo);
|
function updateLogo() {
|
||||||
|
const navbar = document.getElementById('logo');
|
||||||
|
if (!navbar) return;
|
||||||
|
const scrollY = window.scrollY;
|
||||||
|
|
||||||
// --- КУКИ ---
|
// Гистерезис: включаем после 60px, выключаем до 10px
|
||||||
|
// Это предотвращает дребезг на границе
|
||||||
|
if (scrollY > 60) {
|
||||||
|
navbar.classList.remove('logo-big');
|
||||||
|
} else if (scrollY < 10) {
|
||||||
|
navbar.classList.add('logo-big');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Инициализация логотипа при загрузке и скролле
|
||||||
|
// document.addEventListener('DOMContentLoaded', updateLogo);
|
||||||
|
window.addEventListener('scroll', updateLogo, { passive: true });
|
||||||
|
|
||||||
|
|
||||||
|
// --- КУКИ И СЧЕТЧИКИ ---
|
||||||
const COOKIE_KEY = 'cookie_consent';
|
const COOKIE_KEY = 'cookie_consent';
|
||||||
const TTL_MS = 90 * 24 * 60 * 60 * 1000; // 90 дней: 90 * 24 * 60 * 60 * 1000 = 7776000000)
|
const TTL_MS = 90 * 24 * 60 * 60 * 1000; // 90 дней
|
||||||
|
const MAILRU_ID = "3734603";
|
||||||
const banner = document.getElementById('cookie-banner');
|
const YANDEX_ID = "106310834";
|
||||||
const acceptButton = document.getElementById('cookie-accept');
|
|
||||||
|
|
||||||
function loadCounters() {
|
function loadCounters() {
|
||||||
// console.log("Загрузка счетчиков (Яндекс, Google)...");
|
// console.log("Загрузка счетчиков...");
|
||||||
// Код Яндекс.Метрики
|
try {
|
||||||
(function (m, e, t, r, i, k, a) {
|
// Mail.ru
|
||||||
m[i] = m[i] || function () { (m[i].a = m[i].a || []).push(arguments) };
|
|
||||||
m[i].l = 1 * new Date();
|
|
||||||
for (var j = 0; j < document.scripts.length; j++) { if (document.scripts[j].src === r) { return; } }
|
|
||||||
k = e.createElement(t), a = e.getElementsByTagName(t)[0], k.async = 1, k.src = r, a.parentNode.insertBefore(k, a)
|
|
||||||
})(window, document, 'script', 'https://mc.yandex.ru/metrika/tag.js?id=106310834', 'ym');
|
|
||||||
ym(106310834, 'init', {
|
|
||||||
ssr: true, webvisor: true, clickmap: true, ecommerce: "dataLayer",
|
|
||||||
accurateTrackBounce: true, trackLinks: true
|
|
||||||
});
|
|
||||||
|
|
||||||
// Код Google Analytics
|
|
||||||
// window.dataLayer = window.dataLayer || [];
|
|
||||||
// function gtag(){dataLayer.push(arguments);}
|
|
||||||
// gtag('js', new Date());
|
|
||||||
// gtag('config', 'G-XXXXXXXXXX');
|
|
||||||
|
|
||||||
// Код Top.Mail.Ru
|
|
||||||
var _tmr = window._tmr || (window._tmr = []);
|
var _tmr = window._tmr || (window._tmr = []);
|
||||||
_tmr.push({id: "3734603", type: "pageView", start: (new Date()).getTime()});
|
_tmr.push({id: MAILRU_ID, type: "pageView", start: (new Date()).getTime()});
|
||||||
(function (d, w, id) {
|
(function (d, w, id) {
|
||||||
if (d.getElementById(id)) return;
|
if (d.getElementById(id)) return;
|
||||||
var ts = d.createElement("script");
|
var ts = d.createElement("script"); ts.type = "text/javascript"; ts.async = true; ts.id = id;
|
||||||
ts.type = "text/javascript"; ts.async = true; ts.id = id; ts.src = "https://top-fwz1.mail.ru/js/code.js";
|
ts.src = "https://top-fwz1.mail.ru/js/code.js";
|
||||||
var f = function () {
|
var f = d.getElementsByTagName("script")[0]; f.parentNode.insertBefore(ts, f);
|
||||||
var s = d.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ts, s);
|
})(document, window, "topmailru-code");
|
||||||
};
|
|
||||||
if (w.opera == "[object Opera]") {
|
// Яндекс.Метрика
|
||||||
d.addEventListener("DOMContentLoaded", f, false);
|
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
|
||||||
} else { f(); }
|
m[i].l=1*new Date();
|
||||||
})(document, window, "tmr-code");
|
for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
|
||||||
// <noscript><div><img src="https://top-fwz1.mail.ru/counter?id=3734603;js=na" style="position:absolute;left:-9999px;" alt="Top.Mail.Ru" /></div></noscript>
|
k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
|
||||||
// alert("Отладка. Счетчики загружены (здесь должен быть реальный код счетчиков).");
|
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
|
||||||
|
|
||||||
|
window.ym(YANDEX_ID, "init", {
|
||||||
|
clickmap:true,
|
||||||
|
trackLinks:true,
|
||||||
|
accurateTrackBounce:true
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Ошибка загрузки счетчиков:", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkConsent() {
|
function checkConsent() {
|
||||||
|
try {
|
||||||
const stored = localStorage.getItem(COOKIE_KEY);
|
const stored = localStorage.getItem(COOKIE_KEY);
|
||||||
if (!stored) return false;
|
if (!stored) return false;
|
||||||
|
|
||||||
try {
|
|
||||||
const data = JSON.parse(stored);
|
const data = JSON.parse(stored);
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
// Проверяем, не истек ли срок
|
|
||||||
if (now - data.timestamp > TTL_MS) {
|
if (now - data.timestamp > TTL_MS) {
|
||||||
localStorage.removeItem(COOKIE_KEY);
|
localStorage.removeItem(COOKIE_KEY);
|
||||||
return false;
|
return false;
|
||||||
@@ -96,6 +88,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Инициализация куки-баннера
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
const banner = document.getElementById('cookie-banner');
|
||||||
|
const acceptButton = document.getElementById('cookie-accept');
|
||||||
|
|
||||||
|
if (banner && acceptButton) {
|
||||||
if (checkConsent()) {
|
if (checkConsent()) {
|
||||||
loadCounters();
|
loadCounters();
|
||||||
} else {
|
} else {
|
||||||
@@ -103,12 +101,28 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
acceptButton.addEventListener('click', function () {
|
acceptButton.addEventListener('click', function () {
|
||||||
const data = {
|
const data = { value: true, timestamp: Date.now() };
|
||||||
value: true,
|
|
||||||
timestamp: Date.now()
|
|
||||||
};
|
|
||||||
localStorage.setItem(COOKIE_KEY, JSON.stringify(data));
|
localStorage.setItem(COOKIE_KEY, JSON.stringify(data));
|
||||||
banner.style.display = 'none';
|
banner.style.display = 'none';
|
||||||
loadCounters();
|
loadCounters();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Глобальная функция для отправки целей
|
||||||
|
window.sendGoal = function(goalName) {
|
||||||
|
if (!checkConsent()) return;
|
||||||
|
// console.log("Sending goal:", goalName);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (window._tmr) {
|
||||||
|
window._tmr.push({ id: MAILRU_ID, type: "reachGoal", goal: goalName, value: 1 });
|
||||||
|
}
|
||||||
|
if (typeof window.ym === 'function') {
|
||||||
|
window.ym(YANDEX_ID, 'reachGoal', goalName);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Ошибка отправки цели:", e);
|
||||||
|
}
|
||||||
|
};
|
||||||
})();
|
})();
|
||||||
@@ -19,9 +19,11 @@ import {
|
|||||||
} from "../codemirror/editor.js";
|
} from "../codemirror/editor.js";
|
||||||
|
|
||||||
const resultWrapper = document.getElementById('cm-result-wrapper');
|
const resultWrapper = document.getElementById('cm-result-wrapper');
|
||||||
|
const btnCopy = document.getElementById('btn-copy');
|
||||||
|
const sourceTextarea = document.querySelector('textarea[name="text"]');
|
||||||
|
const processingTimeSpan = document.getElementById('processing-time');
|
||||||
|
|
||||||
const themeCompartment = new Compartment();
|
const themeCompartment = new Compartment();
|
||||||
|
|
||||||
function getTheme() {
|
function getTheme() {
|
||||||
return window.matchMedia('(prefers-color-scheme: dark)').matches ? oneDark : [];
|
return window.matchMedia('(prefers-color-scheme: dark)').matches ? oneDark : [];
|
||||||
}
|
}
|
||||||
@@ -47,8 +49,10 @@ const charNames = {
|
|||||||
0x2063: "Invisible Comma (невидимая запятая для семантической разметки математических выражений — ⁣)",
|
0x2063: "Invisible Comma (невидимая запятая для семантической разметки математических выражений — ⁣)",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const PLACEHOLDER_TEXT = "Здесь появится результат...";
|
||||||
|
|
||||||
const resultState = EditorState.create({
|
const resultState = EditorState.create({
|
||||||
doc: "Здесь появится результат...",
|
doc: PLACEHOLDER_TEXT,
|
||||||
extensions: [
|
extensions: [
|
||||||
lineNumbers(),
|
lineNumbers(),
|
||||||
highlightActiveLineGutter(),
|
highlightActiveLineGutter(),
|
||||||
@@ -83,17 +87,100 @@ const resultView = new EditorView({
|
|||||||
parent: resultWrapper
|
parent: resultWrapper
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Обработка ответа от сервера (HTMX)
|
||||||
document.body.addEventListener('htmx:afterSwap', function (evt) {
|
document.body.addEventListener('htmx:afterSwap', function (evt) {
|
||||||
if (evt.detail.target.id === 'result-area') {
|
if (evt.detail.target.id === 'result-area') {
|
||||||
const newContent = evt.detail.xhr.response;
|
const newContent = evt.detail.xhr.response;
|
||||||
|
|
||||||
|
// Обновляем редактор
|
||||||
resultView.dispatch({
|
resultView.dispatch({
|
||||||
changes: {from: 0, to: resultView.state.doc.length, insert: newContent}
|
changes: {from: 0, to: resultView.state.doc.length, insert: newContent}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Показываем кнопку копирования
|
||||||
|
if (btnCopy) {
|
||||||
|
btnCopy.classList.remove('d-none');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Показываем время обработки из заголовка
|
||||||
|
if (processingTimeSpan) {
|
||||||
|
const time = evt.detail.xhr.getResponseHeader('X-Processing-Time');
|
||||||
|
if (time) {
|
||||||
|
processingTimeSpan.innerHTML = `<i class="bi bi-cpu me-1"></i>${time} ms`;
|
||||||
|
processingTimeSpan.style.display = 'inline';
|
||||||
|
} else {
|
||||||
|
processingTimeSpan.style.display = 'none';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Скрываем кнопку и сбрасываем редактор при изменении исходного текста
|
||||||
|
if (sourceTextarea) {
|
||||||
|
sourceTextarea.addEventListener('input', () => {
|
||||||
|
if (btnCopy) {
|
||||||
|
btnCopy.classList.add('d-none');
|
||||||
|
}
|
||||||
|
if (processingTimeSpan) {
|
||||||
|
processingTimeSpan.innerText = '';
|
||||||
|
}
|
||||||
|
// Сбрасываем редактор на плейсхолдер
|
||||||
|
if (resultView.state.doc.toString() !== PLACEHOLDER_TEXT) {
|
||||||
|
resultView.dispatch({
|
||||||
|
changes: {from: 0, to: resultView.state.doc.length, insert: PLACEHOLDER_TEXT}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
|
||||||
resultView.dispatch({
|
resultView.dispatch({
|
||||||
effects: themeCompartment.reconfigure(getTheme())
|
effects: themeCompartment.reconfigure(getTheme())
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// --- КОПИРОВАНИЕ В БУФЕР ---
|
||||||
|
if (btnCopy) {
|
||||||
|
btnCopy.addEventListener('click', async () => {
|
||||||
|
const text = resultView.state.doc.toString();
|
||||||
|
|
||||||
|
// Отправляем цель в метрику
|
||||||
|
if (typeof window.sendGoal === 'function') {
|
||||||
|
window.sendGoal('etpgrf-copy-pressed');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Отправляем статистику на сервер
|
||||||
|
const ch_count_copy2clipboard = new FormData();
|
||||||
|
ch_count_copy2clipboard.append('char_count', text.length);
|
||||||
|
|
||||||
|
fetch('/stats/track-copy/', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
|
||||||
|
},
|
||||||
|
body: ch_count_copy2clipboard
|
||||||
|
}).catch(err => console.error("Ошибка отправки статистики:", err));
|
||||||
|
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(text);
|
||||||
|
|
||||||
|
// Визуальное подтверждение
|
||||||
|
const originalHtml = btnCopy.innerHTML;
|
||||||
|
const originalClass = btnCopy.className;
|
||||||
|
|
||||||
|
btnCopy.innerHTML = '<i class="bi bi-check-lg me-1"></i> Скопировано!';
|
||||||
|
btnCopy.classList.remove('btn-outline-secondary', 'btn-outline-primary');
|
||||||
|
btnCopy.classList.add('btn-success');
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
btnCopy.innerHTML = originalHtml;
|
||||||
|
btnCopy.className = originalClass;
|
||||||
|
btnCopy.classList.remove('d-none');
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Ошибка копирования:', err);
|
||||||
|
alert('Не удалось скопировать текст.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
1
public/static/svg/logo-etpgrf-site-dark-txt.svg
Normal file
1
public/static/svg/logo-etpgrf-site-dark-txt.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 45 KiB |
1
public/static/svg/logo-etpgrf-site-light-txt.svg
Normal file
1
public/static/svg/logo-etpgrf-site-light-txt.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 45 KiB |
Reference in New Issue
Block a user