- Extract 8 common route patterns into factory functions in routes/shared.py (favourite, upload, replace cover, save defaults, clone, save JSON, get missing, clear covers) — removes ~1,100 lines across 9 route files - Extract generic _sync_category() in sync.py — 7 sync functions become one-liner wrappers, removing ~350 lines - Extract shared detail page JS into static/js/detail-common.js — all 9 detail templates now call initDetailPage() with minimal config - Extract layout inline JS into static/js/layout-utils.js (~185 lines) - Extract library toolbar JS into static/js/library-toolbar.js - Fix finalize missing-image bug: raise RuntimeError instead of logging warning so job is marked failed - Fix missing scheduler default in _default_checkpoint_data() - Fix N+1 query in Character.get_available_outfits() with batch IN query - Convert all print() to logger across services and routes - Add missing tags display to styles, scenes, detailers, checkpoints detail - Update delete buttons to use trash.png icon with solid red background - Update CLAUDE.md to reflect new architecture Net reduction: ~1,600 lines Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
287 lines
18 KiB
HTML
287 lines
18 KiB
HTML
{% extends "layout.html" %}
|
|
|
|
{% block content %}
|
|
<!-- JSON Editor Modal -->
|
|
<div class="modal fade" id="jsonEditorModal" tabindex="-1" aria-hidden="true">
|
|
<div class="modal-dialog modal-lg modal-dialog-centered">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">Edit JSON — {{ outfit.name }}</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<ul class="nav nav-tabs mb-3" role="tablist">
|
|
<li class="nav-item"><button class="nav-link active" id="json-simple-tab" type="button">Simple</button></li>
|
|
<li class="nav-item"><button class="nav-link" id="json-advanced-tab" type="button">Advanced JSON</button></li>
|
|
</ul>
|
|
<div id="json-editor-error" class="alert alert-danger d-none"></div>
|
|
<div id="json-simple-panel"></div>
|
|
<div id="json-advanced-panel" class="d-none">
|
|
<textarea id="json-editor-textarea" class="form-control font-monospace" rows="20" spellcheck="false"></textarea>
|
|
</div>
|
|
<script type="application/json" id="json-raw-data">{{ outfit.data | tojson }}</script>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
|
<button type="button" class="btn btn-primary" id="json-save-btn">Save</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-4">
|
|
<div class="card mb-4">
|
|
<div class="img-container" style="height: auto; min-height: 400px; cursor: pointer;" onclick="openGallery([this.querySelector('img') ? this.querySelector('img').src : this.src || ''], 0)">
|
|
{% if outfit.image_path %}
|
|
<img src="{{ url_for('static', filename='uploads/' + outfit.image_path) }}" alt="{{ outfit.name }}" class="img-fluid" data-preview-path="{{ outfit.image_path }}">
|
|
{% else %}
|
|
<span class="text-muted">No Image Attached</span>
|
|
{% endif %}
|
|
</div>
|
|
<div class="card-body">
|
|
{# Character Selector #}
|
|
<div class="mb-3">
|
|
<label for="character_select" class="form-label">Preview with Character</label>
|
|
<select class="form-select" id="character_select" name="character_slug" form="generate-form">
|
|
<option value="">-- No Character (Outfit Only) --</option>
|
|
<option value="__random__" {% if selected_character == '__random__' or not selected_character %}selected{% endif %}>🎲 Random Character</option>
|
|
{% for char in characters %}
|
|
<option value="{{ char.slug }}" {% if selected_character == char.slug %}selected{% endif %}>{{ char.name }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
<div class="form-text">Select a character to preview this outfit on their model.</div>
|
|
</div>
|
|
|
|
{# Additional Prompts #}
|
|
<div class="mb-2">
|
|
<label for="extra_positive" class="form-label">Additional Positive</label>
|
|
<textarea class="form-control form-control-sm font-monospace" id="extra_positive" name="extra_positive" rows="2" placeholder="e.g. masterpiece, best quality" form="generate-form">{{ extra_positive or '' }}</textarea>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="extra_negative" class="form-label">Additional Negative</label>
|
|
<textarea class="form-control form-control-sm font-monospace" id="extra_negative" name="extra_negative" rows="2" placeholder="e.g. blurry, low quality" form="generate-form">{{ extra_negative or '' }}</textarea>
|
|
</div>
|
|
|
|
<div class="d-grid gap-2">
|
|
<div class="input-group input-group-sm mb-1">
|
|
<span class="input-group-text">Seed</span>
|
|
<input type="number" class="form-control" id="seed-input" name="seed" form="generate-form" placeholder="Random" min="1" step="1">
|
|
<button type="button" class="btn btn-outline-secondary" id="seed-clear-btn" title="Clear (random)">×</button>
|
|
</div>
|
|
<button type="submit" name="action" value="preview" class="btn btn-success" form="generate-form" data-requires="comfyui">Generate Preview</button>
|
|
<button type="button" class="btn btn-outline-info" id="endless-btn" onclick="window._endlessStart()" data-requires="comfyui">Endless</button>
|
|
<button type="button" class="btn btn-danger d-none" id="endless-stop-btn" onclick="window._endlessStop()">Stop Endless</button>
|
|
<small class="text-muted d-none" id="endless-counter"></small>
|
|
<button type="submit" form="generate-form" formaction="{{ url_for('save_outfit_defaults', slug=outfit.slug) }}" class="btn btn-sm btn-outline-secondary mt-2">Save as Default Selection</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="progress-container" class="mb-4 d-none">
|
|
<label id="progress-label" class="form-label">Generating...</label>
|
|
<div class="progress" role="progressbar" aria-label="Generation Progress" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
|
|
<div id="progress-bar" class="progress-bar progress-bar-striped progress-bar-animated" style="width: 0%">0%</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card mb-4 {% if preview_image %}border-success{% else %}border-secondary d-none{% endif %}" id="preview-card">
|
|
<div class="card-header {% if preview_image %}bg-success{% else %}bg-secondary{% endif %} text-white d-flex justify-content-between align-items-center" id="preview-card-header">
|
|
<span>Selected Preview</span>
|
|
<form action="{{ url_for('replace_outfit_cover_from_preview', slug=outfit.slug) }}" method="post" class="m-0" id="replace-cover-form">
|
|
<input type="hidden" name="preview_path" id="preview-path" value="{{ preview_image or '' }}">
|
|
<button type="submit" class="btn btn-sm btn-outline-light" id="replace-cover-btn" {% if not preview_image %}disabled{% endif %}>Replace Cover</button>
|
|
</form>
|
|
</div>
|
|
<div class="card-body p-0">
|
|
<div class="img-container" style="height: auto; min-height: 400px; cursor: pointer;" onclick="openGallery([this.querySelector('img') ? this.querySelector('img').src : this.src || ''], 0)">
|
|
<img id="preview-img" src="{{ url_for('static', filename='uploads/' + preview_image) if preview_image else '' }}" alt="Preview" class="img-fluid">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{% set tags = outfit.data.tags if outfit.data.tags is mapping else {} %}
|
|
{% if tags %}
|
|
<div class="card mb-4">
|
|
<div class="card-header bg-dark text-white"><span>Tags</span></div>
|
|
<div class="card-body">
|
|
{% if tags.outfit_type %}<span class="badge bg-info">{{ tags.outfit_type }}</span>{% endif %}
|
|
{% if outfit.is_nsfw %}<span class="badge bg-danger">NSFW</span>{% endif %}
|
|
{% if outfit.is_favourite %}<span class="badge bg-warning text-dark">★ Favourite</span>{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="col-md-8">
|
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
|
<div>
|
|
<h1 class="mb-0">
|
|
{{ outfit.name }}
|
|
<button class="btn btn-sm btn-link text-decoration-none fav-toggle-btn" data-url="/outfit/{{ outfit.slug }}/favourite" title="Toggle favourite">
|
|
<span style="font-size:1.2rem;">{% if outfit.is_favourite %}★{% else %}☆{% endif %}</span>
|
|
</button>
|
|
{% if outfit.is_nsfw %}<span class="badge bg-danger" style="font-size:0.6rem;vertical-align:middle;">NSFW</span>{% endif %}
|
|
</h1>
|
|
<a href="{{ url_for('edit_outfit', slug=outfit.slug) }}" class="btn btn-sm btn-link text-decoration-none">Edit Profile</a>
|
|
<form action="{{ url_for('clone_outfit', slug=outfit.slug) }}" method="post" style="display: inline;">
|
|
<button type="submit" class="btn btn-sm btn-link text-decoration-none">Clone Outfit</button>
|
|
</form>
|
|
</div>
|
|
<div class="d-flex gap-2">
|
|
<button type="button" class="btn btn-outline-secondary" data-bs-toggle="modal" data-bs-target="#jsonEditorModal">Edit JSON</button>
|
|
<button type="button" class="btn btn-outline-warning" id="regenerate-tags-btn" onclick="regenerateTags('outfits', '{{ outfit.slug }}')">Regenerate Tags</button>
|
|
<a href="{{ url_for('transfer_resource', category='outfits', slug=outfit.slug) }}" class="btn btn-outline-primary">Transfer</a>
|
|
<a href="{{ url_for('outfits_index') }}" class="btn btn-outline-secondary">Back to Library</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Linked Characters Section -->
|
|
{% if linked_characters %}
|
|
<div class="card mb-4 border-info">
|
|
<div class="card-header bg-info text-white">
|
|
<span><i class="bi bi-people"></i> Assigned to Characters</span>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="d-flex flex-wrap gap-2">
|
|
{% for char in linked_characters %}
|
|
<a href="{{ url_for('detail', slug=char.slug) }}" class="badge bg-secondary text-decoration-none">
|
|
{{ char.name }}
|
|
</a>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<ul class="nav nav-tabs mb-4" id="detailTabs" role="tablist">
|
|
<li class="nav-item" role="presentation">
|
|
<button class="nav-link active" id="settings-tab" data-bs-toggle="tab" data-bs-target="#settings-pane" type="button" role="tab">Settings</button>
|
|
</li>
|
|
<li class="nav-item" role="presentation">
|
|
<button class="nav-link" id="previews-tab" data-bs-toggle="tab" data-bs-target="#previews-pane" type="button" role="tab">
|
|
Previews{% if existing_previews %} <span class="badge bg-secondary">{{ existing_previews|length }}</span>{% endif %}
|
|
</button>
|
|
</li>
|
|
{% if outfit.data.get('lora', {}).get('lora_name', '') != '' %}
|
|
<li class="nav-item" role="presentation">
|
|
<button class="nav-link" id="strengths-tab" data-bs-toggle="tab" data-bs-target="#strengths-pane" type="button" role="tab">Strengths</button>
|
|
</li>
|
|
{% endif %}
|
|
</ul>
|
|
|
|
<div class="tab-content" id="detailTabContent">
|
|
<div class="tab-pane fade show active" id="settings-pane" role="tabpanel">
|
|
<form id="generate-form" action="{{ url_for('generate_outfit_image', slug=outfit.slug) }}" method="post">
|
|
{# Wardrobe section #}
|
|
{% set wardrobe = outfit.data.get('wardrobe', {}) %}
|
|
<div class="card mb-4">
|
|
<div class="card-header bg-light d-flex justify-content-between align-items-center">
|
|
<strong>Wardrobe</strong>
|
|
</div>
|
|
<div class="card-body">
|
|
<dl class="row mb-0">
|
|
{% for key, value in wardrobe.items() %}
|
|
{% set is_default = outfit.default_fields is not none and ('wardrobe::' ~ key) in outfit.default_fields %}
|
|
<dt class="col-sm-4 text-capitalize {% if is_default %}text-accent{% endif %}">
|
|
<input class="form-check-input me-1" type="checkbox" name="include_field" value="wardrobe::{{ key }}"
|
|
{% if preferences is not none %}
|
|
{% if 'wardrobe::' + key in preferences %}checked{% endif %}
|
|
{% elif outfit.default_fields is not none %}
|
|
{% if is_default %}checked{% endif %}
|
|
{% else %}
|
|
{% if value %}checked{% endif %}
|
|
{% endif %}>
|
|
{{ key.replace('_', ' ') }}
|
|
{% if is_default %}<span class="badge bg-primary ms-1" style="font-size: 0.55rem; vertical-align: middle;">DEF</span>{% endif %}
|
|
</dt>
|
|
<dd class="col-sm-8 {% if is_default %}text-accent{% endif %}">{{ value if value else '--' }}</dd>
|
|
{% endfor %}
|
|
</dl>
|
|
</div>
|
|
</div>
|
|
|
|
{# LoRA section #}
|
|
{% set lora = outfit.data.get('lora', {}) %}
|
|
{% if lora %}
|
|
<div class="card mb-4">
|
|
<div class="card-header bg-light"><strong>LoRA</strong></div>
|
|
<div class="card-body">
|
|
<dl class="row mb-0">
|
|
{% for key, value in lora.items() %}
|
|
{% set is_default = outfit.default_fields is not none and ('lora::' ~ key) in outfit.default_fields %}
|
|
<dt class="col-sm-4 text-capitalize {% if is_default %}text-accent{% endif %}">
|
|
<input class="form-check-input me-1" type="checkbox" name="include_field" value="lora::{{ key }}"
|
|
{% if preferences is not none %}
|
|
{% if 'lora::' + key in preferences %}checked{% endif %}
|
|
{% elif outfit.default_fields is not none %}
|
|
{% if is_default %}checked{% endif %}
|
|
{% else %}
|
|
{% if value %}checked{% endif %}
|
|
{% endif %}>
|
|
{{ key.replace('_', ' ') }}
|
|
{% if is_default %}<span class="badge bg-primary ms-1" style="font-size: 0.55rem; vertical-align: middle;">DEF</span>{% endif %}
|
|
</dt>
|
|
<dd class="col-sm-8 {% if is_default %}text-accent{% endif %}">{{ value if value else '--' }}</dd>
|
|
{% endfor %}
|
|
</dl>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</form>
|
|
</div>
|
|
|
|
<div class="tab-pane fade" id="previews-pane" role="tabpanel">
|
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
|
<span class="text-muted small">{{ existing_previews|length }} preview(s)</span>
|
|
<div class="d-flex gap-2">
|
|
<button type="button" id="generate-all-btn" class="btn btn-primary btn-sm" data-requires="comfyui">Generate All Characters</button>
|
|
<button type="button" id="stop-all-btn" class="btn btn-danger btn-sm d-none">Stop</button>
|
|
</div>
|
|
</div>
|
|
<div id="batch-progress" class="mb-3 d-none">
|
|
<label id="batch-label" class="form-label small fw-semibold"></label>
|
|
<div class="progress" style="height: 8px;">
|
|
<div id="batch-bar" class="progress-bar progress-bar-striped progress-bar-animated" style="width: 0%"></div>
|
|
</div>
|
|
</div>
|
|
<div id="preview-gallery" class="row row-cols-2 row-cols-md-3 g-2">
|
|
{% for img in existing_previews %}
|
|
<div class="col">
|
|
<img src="{{ url_for('static', filename='uploads/' + img) }}"
|
|
class="img-fluid rounded"
|
|
style="cursor: pointer; aspect-ratio: 1; object-fit: cover; width: 100%;"
|
|
onclick="openGallery([this.querySelector('img') ? this.querySelector('img').src : this.src || ''], 0)"
|
|
|
|
data-preview-path="{{ img }}">
|
|
</div>
|
|
{% else %}
|
|
<div class="col-12 text-muted small" id="gallery-empty">No previews yet. Generate some!</div>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
|
|
{% set sg_has_lora = outfit.data.get('lora', {}).get('lora_name', '') != '' %}
|
|
{% if sg_has_lora %}
|
|
<div class="tab-pane fade" id="strengths-pane" role="tabpanel">
|
|
{% set sg_entity = outfit %}
|
|
{% set sg_category = 'outfits' %}
|
|
{% include 'partials/strengths_gallery.html' %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block scripts %}
|
|
<script src="/static/js/detail-common.js"></script>
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
initDetailPage({
|
|
batchItems: [{% for char in characters %}{ slug: "{{ char.slug }}", name: {{ char.name | tojson }} },{% endfor %}],
|
|
jsonEditorUrl: '{{ url_for("save_outfit_json", slug=outfit.slug) }}'
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %} |