add: draft

This commit is contained in:
2025-12-29 15:47:10 +03:00
parent 56af36451b
commit 3a6848a630
7 changed files with 227 additions and 21 deletions

View File

@@ -1,3 +1,22 @@
from django.shortcuts import render
from django.http import HttpResponse
from etpgrf import Typographer
# Create your views here.
# Инициализируем типограф один раз (как рекомендовано в спеке)
# Можно вынести настройки в settings.py, но пока так
typo = Typographer(langs='ru', process_html=True, hanging_punctuation='both')
def index(request):
return render(request, template_name='typograph/index.html')
def process_text(request):
if request.method == 'POST':
text = request.POST.get(key='text', default='')
# Обрабатываем текст
processed = typo.process(text)
# Возвращаем только фрагмент для HTMX
return render(request, template_name='typograph/result_fragment.html', context={'processed_text': processed})
return HttpResponse(status=405)