mod: настройки типографа (06) режимы layout
This commit is contained in:
@@ -7,8 +7,7 @@
|
|||||||
<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">
|
|
||||||
<textarea class="form-control" name="text" rows="10" placeholder="Вставьте текст сюда..."></textarea>
|
<textarea class="form-control" name="text" rows="10" placeholder="Вставьте текст сюда..."></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -55,22 +54,37 @@
|
|||||||
<label class="form-check-label fw-bold" for="optQuotes">Обработка кавычек</label>
|
<label class="form-check-label fw-bold" for="optQuotes">Обработка кавычек</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Группа "Знаки и отбивка" (Layout) -->
|
{# Группа "Компоновка и отбивка" (Layout) #}<div x-data="{ enabled: true }" class="mb-2">
|
||||||
<div x-data="{ enabled: true }" class="mb-2">
|
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="checkbox" name="layout" id="optLayout" checked x-model="enabled">
|
<input class="form-check-input" type="checkbox" name="layout" id="optLayout" checked x-model="enabled">
|
||||||
<label class="form-check-label fw-bold" for="optLayout">Компоновка и отбивка</label>
|
<label class="form-check-label fw-bold" for="optLayout">Компоновка и отбивка</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="ms-3">
|
|
||||||
|
<!-- Настройки (видны, когда включено) -->
|
||||||
|
<div class="ms-3" x-show="enabled" x-transition>
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="checkbox" name="layout_initials" id="optLayoutInitials" checked :disabled="!enabled">
|
<input class="form-check-input" type="checkbox" name="layout_initials" id="optLayoutInitials" checked>
|
||||||
<label class="form-check-label" for="optLayoutInitials">Инициалы <small class="text-muted">(А. С. Пушкин) и акронимы записанные через точку (U. S. S.)</small></label>
|
<label class="form-check-label" for="optLayoutInitials">Инициалы <small class="text-muted">(А. С. Пушкин)</small></label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox" name="layout_units" id="optLayoutUnits" checked :disabled="!enabled">
|
<!-- Единицы измерения с кастомным полем -->
|
||||||
|
<div x-data="{ unitsEnabled: true }" class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" name="layout_units" id="optLayoutUnits" checked
|
||||||
|
x-model="unitsEnabled">
|
||||||
<label class="form-check-label" for="optLayoutUnits">Единицы измерения <small class="text-muted">(10 км)</small></label>
|
<label class="form-check-label" for="optLayoutUnits">Единицы измерения <small class="text-muted">(10 км)</small></label>
|
||||||
|
|
||||||
|
<!-- Поле для кастомных единиц -->
|
||||||
|
<div class="mt-1" x-show="unitsEnabled" x-transition>
|
||||||
|
<input type="text" class="form-control form-control-sm" name="layout_units_custom"
|
||||||
|
placeholder="Доп. единицы (через пробел): бит байт">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Описание (видно, когда выключено) -->
|
||||||
|
<div class="ms-3 form-text text-muted small" x-show="!enabled" x-transition>
|
||||||
|
Обработка тире, чисел, инициалов, сокращений и единиц измерения отключена.
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-check mb-2">
|
<div class="form-check mb-2">
|
||||||
|
|||||||
@@ -18,11 +18,20 @@ def process_text(request):
|
|||||||
layout_option = False # По умолчанию выключен
|
layout_option = False # По умолчанию выключен
|
||||||
|
|
||||||
if layout_enabled:
|
if layout_enabled:
|
||||||
|
# Обработка единиц измерения
|
||||||
|
process_units = request.POST.get('layout_units') == 'on'
|
||||||
|
if process_units:
|
||||||
|
# Если включено, проверяем кастомные единицы
|
||||||
|
custom_units = request.POST.get('layout_units_custom', '').strip()
|
||||||
|
if custom_units:
|
||||||
|
# Если есть кастомные, передаем их списком (библиотека сама объединит с дефолтными)
|
||||||
|
process_units = custom_units.split()
|
||||||
|
|
||||||
# Если включен, создаем процессор с тонкими настройками
|
# Если включен, создаем процессор с тонкими настройками
|
||||||
layout_option = LayoutProcessor(
|
layout_option = LayoutProcessor(
|
||||||
langs=langs,
|
langs=langs,
|
||||||
process_initials_and_acronyms=request.POST.get('layout_initials') == 'on',
|
process_initials_and_acronyms=request.POST.get('layout_initials') == 'on',
|
||||||
process_units=request.POST.get('layout_units') == 'on'
|
process_units=process_units
|
||||||
)
|
)
|
||||||
|
|
||||||
# 3. Читаем Sanitizer
|
# 3. Читаем Sanitizer
|
||||||
|
|||||||
Reference in New Issue
Block a user