diff --git a/.github/docs/CSS.md b/.github/docs/CSS.md index b132941..45327d6 100644 --- a/.github/docs/CSS.md +++ b/.github/docs/CSS.md @@ -925,8 +925,76 @@ Critical hover interactions defined in `@media (hover: hover)` block: color: var(--confident-bg); text-transform: uppercase; } + +### Category Header Actions + +```css +.category-header-actions { + display: flex; + align-items: center; + gap: 0.4rem; + margin-left: auto; +} ``` +Flex container for the right-side header elements (toggle button, always-hide text). + +### Category Toggle Button + +```css +.category-toggle-btn { + background: none; + border: none; + cursor: pointer; + font-size: 0.8rem; + color: var(--low-text); + padding: 0.1rem 0.3rem; + border-radius: 4px; + opacity: 0.4; + line-height: 1; + transition: opacity 0.2s; + touch-action: manipulation; +} +.category-toggle-btn:hover { opacity: 1; } +``` + +The ✕/✓ toggle button. Default opacity is 0.4 (faint), full opacity on hover for discoverability. Clicking toggles between hide (✕) and show (✓). + +### Category Always Hide Text + +```css +.category-always-hide { + font-size: 0.65rem; + color: var(--text-color); + opacity: 0.6; + cursor: pointer; + text-decoration: underline dotted; + white-space: nowrap; + user-select: none; + touch-action: manipulation; +} +.category-always-hide.active { + color: var(--confident-bg); + opacity: 1; + text-decoration: underline; +} +``` + +Dotted-underline "Always hide" text shown when a category is hidden. Clicking persists the preference to localStorage. The `.active` class is added when the preference is active (category is in `alwaysHiddenCategories`), switching to a solid purple underline. + +### Hidden Category Block + +```css +.category-block.category-hidden { + opacity: 0.35; +} +.category-block.category-hidden .tag { + pointer-events: none; +} +``` + +When `.category-hidden` is applied, the entire block is grayed out at 35% opacity and all child tag elements become non-interactive (clicks, taps, and other pointer events are blocked). + --- ## Tags diff --git a/.github/docs/JS.md b/.github/docs/JS.md index 2620fc4..7404049 100644 --- a/.github/docs/JS.md +++ b/.github/docs/JS.md @@ -85,6 +85,8 @@ let currentTheme = 'system'; // 'system', 'light', 'dark' let activePreset = 'standard'; // 'conservative'/'standard'/'liberal'/'custom' let addedTags = new Set(); // User-added tags let removedTags = new Set(); // User-removed tags +let hiddenCategories = new Set(); // Session-hidden categories (per upload) +let alwaysHiddenCategories = new Set(); // Persisted hidden categories (localStorage) let maxTags = 200; // Max tags to request let autoMetaTagSet = new Set(); // Auto-detected meta tags let perTagAutoDisable = new Set(); // Per-tag auto disable @@ -106,6 +108,8 @@ let isFullscreenActive = false; // Fullscreen modal state | `activePreset` | string | 'standard' | Threshold preset | | `addedTags` | Set | - | User-added tags | | `removedTags` | Set | - | User-removed tags | +| `hiddenCategories` | Set | - | Session-only hidden categories (per upload, non-persistent) | +| `alwaysHiddenCategories` | Set | - | Persistently hidden categories from localStorage | | `maxTags` | int | 200 | API top_k parameter | | `autoMetaTagSet` | Set | - | Auto meta tags | | `perTagAutoDisable` | Set | - | Disabled auto tags | @@ -580,11 +584,15 @@ function isTagIncluded(tagObj, threshold) { ### filterTags(threshold) -Filters tags by probability threshold. +Filters tags by probability threshold and excludes tags from hidden categories. ```javascript function filterTags(threshold) { - return allTags.filter(t => !ratingTags.has(t.tag) && isTagIncluded(t, threshold)); + return allTags.filter(t => { + if (ratingTags.has(t.tag)) return false; + if (hiddenCategories.has(t.category)) return false; + return isTagIncluded(t, threshold); + }); } ``` @@ -617,6 +625,10 @@ function displayTags(tags) { categoriesContainer.innerHTML = ''; Object.keys(grouped).sort((a, b) => { + const aAlways = alwaysHiddenCategories.has(a); + const bAlways = alwaysHiddenCategories.has(b); + if (aAlways && !bAlways) return 1; + if (!aAlways && bAlways) return -1; const ia = displayCategoryOrder.indexOf(a); const ib = displayCategoryOrder.indexOf(b); if (ia !== -1 && ib !== -1) return ia - ib; @@ -658,6 +670,71 @@ function displayTags(tags) { } ``` +### Category Toggle Functions + +The toggle button (✕/✓) and "Always hide" text are rendered inside each `.category-header` by `displayTags()`. + +#### Toggle Button Handler + +The toggle and always-hide logic is handled inline within `displayTags()` via direct `addEventListener` calls on the rendered elements: + +**Toggle button (✕/✓)**: +```javascript +toggleBtn.addEventListener('click', (e) => { + e.stopPropagation(); + if (hiddenCategories.has(cat)) { + hiddenCategories.delete(cat); + catDiv.classList.remove('category-hidden'); + toggleBtn.textContent = '✕'; + alwaysHideEl.style.display = 'none'; + } else { + hiddenCategories.add(cat); + catDiv.classList.add('category-hidden'); + toggleBtn.textContent = '✓'; + alwaysHideEl.style.display = 'inline'; + } +}); +``` + +**Always hide text**: +```javascript +alwaysHideEl.addEventListener('click', (e) => { + e.stopPropagation(); + if (alwaysHiddenCategories.has(cat)) { + alwaysHiddenCategories.delete(cat); + alwaysHideEl.classList.remove('active'); + } else { + alwaysHiddenCategories.add(cat); + hiddenCategories.add(cat); + catDiv.classList.add('category-hidden'); + toggleBtn.textContent = '✓'; + alwaysHideEl.style.display = 'inline'; + alwaysHideEl.classList.add('active'); + } + saveSettings(); +}); +``` + +#### displayTags Integration + +`displayTags()` renders each `.category-header` with a `.category-header-actions` flex container on the right side containing: +- A `.category-toggle-btn` (✕ when visible, ✓ when hidden) +- A `.category-always-hide` span (only present when category is hidden; gets `.active` class and purple underline when persisted) + +The function determines `isHidden` and `isAlways` state per category on each render call. The `.category-block` receives `.category-hidden` class when `isHidden` is true. Tags inside hidden blocks are made non-interactive via CSS `pointer-events: none`. + +#### State Flow + +``` +uploadImage() → hiddenCategories = new Set(alwaysHiddenCategories) → displayTags() + ↓ +Click ✕ → hiddenCategories.add(cat) → DOM: add class, ✓, show always-hide + ↓ +Click ✓ → hiddenCategories.delete(cat) → DOM: remove class, ✕, hide always-hide + ↓ +Always hide click → toggles alwaysHiddenCategories, saves → DOM: add/remove .active class +``` + --- ## 9. Tag States (CSS data-level) @@ -876,6 +953,7 @@ async function uploadImage(file) { autoMetaTagSet = new Set(autoMeta); addedTags.clear(); removedTags.clear(); + hiddenCategories = new Set(alwaysHiddenCategories); // Re-apply persistent hidden currentFormat = savedFormat; updateLocalFormatUI(); displayTags(allTags); @@ -936,6 +1014,7 @@ function initHammer() { attachHammerTap(resetBtn, () => { allThreshold = 0.60; confidentThreshold = 0.70; savedFormat = 'e621'; currentFormat = savedFormat; currentTheme = 'system'; activePreset = 'standard'; maxTags = 200; + alwaysHiddenCategories.clear(); document.querySelectorAll('#themeToggle .theme-option').forEach(btn => { btn.classList.toggle('active', btn.dataset.value === 'system'); }); diff --git a/.github/docs/TAGGING.md b/.github/docs/TAGGING.md index 2cd4c28..a680722 100644 --- a/.github/docs/TAGGING.md +++ b/.github/docs/TAGGING.md @@ -656,4 +656,52 @@ for idx, val in zip(indices, values): ### Frontend Rendering -See [JS.md](JS.md) for frontend display logic. \ No newline at end of file +See [JS.md](JS.md) for frontend display logic. + +--- + +## Category Hiding/Exclusion + +Users can hide entire tag categories (e.g., Fetishes, Body Color) to reduce visual clutter and exclude them from copy output. + +### UI Interaction + +Each `.category-block` renders a faint ✕ toggle button in the top-right of its header area: + +| Action | Control | Effect | +|--------|---------|--------| +| **Hide** | Click ✕ | Gray out category (opacity 0.35), disable tag interaction, exclude from copy | +| **Show** | Click ✓ (formerly ✕) | Restore full opacity, re-enable interaction, include in copy | +| **Persist** | Click "Always hide" text (appears when hidden) | Save preference to localStorage, survives page reload | +| **Unpersist** | Click "Always hide" again | Remove localStorage preference | + +### Behavior + +- **Hidden categories**: The `.category-block` gets `.category-hidden` class → opacity 0.35. All `.tag` children get `pointer-events: none`, making them non-interactive. +- **Copy exclusion**: Hidden categories are filtered out in `filterTags()` before clipboard copy. +- **Per-upload reset**: `hiddenCategories` (session-only) is cleared on each new upload. `alwaysHiddenCategories` (persistent) is re-applied from localStorage. +- **Manual tag corrections** (`addedTags`/`removedTags`) are preserved across hide/unhide operations. +- **Always-hidden reordering**: Categories in `alwaysHiddenCategories` are sorted to the end of the display, keeping them out of the way. Removing the "always hide" preference restores their original position. + +### State Management + +| Variable | Type | Scope | Persistence | +|----------|------|-------|-------------| +| `hiddenCategories` | `Set` | Session (per upload) | Not persisted | +| `alwaysHiddenCategories` | `Set` | Global | localStorage via `e621tagger-settings` | + +### localStorage + +Stored as `alwaysHiddenCategories` array inside the `e621tagger-settings` JSON object: + +```json +{ + "alwaysHiddenCategories": ["Fetishes, Specifics, Interactions", "Body Color"], + "allThreshold": 0.60, + ... +} +``` + +### Reset + +The **Reset** button in settings clears both `alwaysHiddenCategories` and removes it from `localStorage`. \ No newline at end of file diff --git a/hydra/_subcat.py b/hydra/_subcat.py index 0a9b739..860869c 100644 --- a/hydra/_subcat.py +++ b/hydra/_subcat.py @@ -1319,25 +1319,25 @@ _SUBCATEGORY_MAP = { 'costume': 'accessory', 'count': 'other', 'counter': 'accessory', - 'countershade_arms': 'body_feature', - 'countershade_balls': 'body_feature', - 'countershade_body': 'body_feature', - 'countershade_breasts': 'body_feature', - 'countershade_butt': 'body_feature', - 'countershade_crotch': 'body_feature', - 'countershade_ears': 'body_feature', - 'countershade_face': 'body_feature', - 'countershade_feet': 'body_feature', - 'countershade_fur': 'body_feature', - 'countershade_genitalia': 'body_feature', - 'countershade_hands': 'body_feature', - 'countershade_legs': 'body_feature', - 'countershade_neck': 'body_feature', - 'countershade_scales': 'body_feature', - 'countershade_tail': 'body_feature', - 'countershade_thighs': 'body_feature', - 'countershade_torso': 'body_feature', - 'countershading': 'body_feature', + 'countershade_arms': 'color', + 'countershade_balls': 'color', + 'countershade_body': 'color', + 'countershade_breasts': 'color', + 'countershade_butt': 'color', + 'countershade_crotch': 'color', + 'countershade_ears': 'color', + 'countershade_face': 'color', + 'countershade_feet': 'color', + 'countershade_fur': 'color', + 'countershade_genitalia': 'color', + 'countershade_hands': 'color', + 'countershade_legs': 'color', + 'countershade_neck': 'color', + 'countershade_scales': 'color', + 'countershade_tail': 'color', + 'countershade_thighs': 'color', + 'countershade_torso': 'color', + 'countershading': 'color', 'covered_eyes': 'pose', 'covered_nipples': 'body_feature', 'covering': 'action', @@ -5435,38 +5435,38 @@ _SUBCATEGORY_MAP = { 'tally_marks': 'text', 'talon_hands': 'body_feature', 'talons': 'body_feature', - 'tan_areola': 'body_feature', + 'tan_areola': 'color', 'tan_background': 'setting', - 'tan_balls': 'body_feature', - 'tan_belly': 'body_feature', - 'tan_body': 'body_feature', + 'tan_balls': 'color', + 'tan_belly': 'color', + 'tan_body': 'color', 'tan_bottomwear': 'accessory', - 'tan_breasts': 'body_feature', + 'tan_breasts': 'color', 'tan_clothing': 'accessory', - 'tan_countershading': 'body_feature', - 'tan_ears': 'body_feature', - 'tan_eyebrows': 'body_feature', - 'tan_face': 'body_feature', - 'tan_feathers': 'body_feature', - 'tan_fur': 'body_feature', - 'tan_genitals': 'body_feature', - 'tan_hair': 'body_feature', - 'tan_horn': 'body_feature', - 'tan_inner_ear': 'body_feature', - 'tan_line': 'color', - 'tan_markings': 'body_feature', - 'tan_nipples': 'body_feature', - 'tan_nose': 'body_feature', + 'tan_countershading': 'color', + 'tan_ears': 'color', + 'tan_eyebrows': 'color', + 'tan_face': 'color', + 'tan_feathers': 'color', + 'tan_fur': 'color', + 'tan_genitals': 'color', + 'tan_hair': 'color', + 'tan_horn': 'color', + 'tan_inner_ear': 'color', + 'tan_line': 'body_feature', + 'tan_markings': 'color', + 'tan_nipples': 'color', + 'tan_nose': 'color', 'tan_pants': 'accessory', - 'tan_penis': 'body_feature', - 'tan_scales': 'body_feature', - 'tan_sheath': 'body_feature', - 'tan_skin': 'body_feature', - 'tan_tail': 'body_feature', - 'tan_tail_tip': 'body_feature', + 'tan_penis': 'color', + 'tan_scales': 'color', + 'tan_sheath': 'color', + 'tan_skin': 'color', + 'tan_tail': 'color', + 'tan_tail_tip': 'color', 'tan_topwear': 'accessory', - 'tan_tuft': 'body_feature', - 'tan_vulva': 'body_feature', + 'tan_tuft': 'color', + 'tan_vulva': 'color', 'tank_(vehicle)': 'accessory', 'tank_top': 'accessory', 'tape': 'accessory', diff --git a/static/css/style.css b/static/css/style.css index 1f1889a..4a5c2d8 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -595,6 +595,46 @@ h1 { color: var(--confident-bg); text-transform: uppercase; } +.category-header-actions { + display: flex; + align-items: center; + gap: 0.3rem; + margin-left: auto; +} +.category-toggle-btn { + background: none; + border: none; + cursor: pointer; + font-size: 0.8rem; + color: var(--low-text); + padding: 0.1rem 0.3rem; + border-radius: 4px; + opacity: 0.4; + transition: opacity 0.2s; + touch-action: manipulation; + line-height: 1; +} +.category-toggle-btn:hover { opacity: 1; } +.category-always-hide { + font-size: 0.7rem; + color: var(--low-text); + cursor: pointer; + opacity: 0.6; + white-space: nowrap; + transition: opacity 0.2s, color 0.2s; +} +.category-always-hide:hover { opacity: 1; } +.category-always-hide.active { + color: var(--confident-bg); + opacity: 1; + text-decoration: underline; +} +.category-block.category-hidden { + opacity: 0.35; +} +.category-block.category-hidden .tag { + pointer-events: none; +} .category-tags { display: flex; flex-wrap: wrap; gap: 0.27rem; } .tag { diff --git a/static/js/script.js b/static/js/script.js index 61fd7dd..9dc24c8 100644 --- a/static/js/script.js +++ b/static/js/script.js @@ -56,6 +56,8 @@ document.addEventListener('DOMContentLoaded', () => { let maxTags = 200; let autoMetaTagSet = new Set(); let perTagAutoDisable = new Set(); + let hiddenCategories = new Set(); + let alwaysHiddenCategories = new Set(); const tagDescriptionCache = new Map(); let currentPopup = null; @@ -83,6 +85,7 @@ document.addEventListener('DOMContentLoaded', () => { activePreset = settings.activePreset ?? 'standard'; maxTags = settings.maxTags ?? 200; if (!ALLOWED_MAX_TAGS.includes(maxTags)) maxTags = 200; + alwaysHiddenCategories = new Set(settings.alwaysHiddenCategories || []); document.querySelectorAll('#themeToggle .theme-option').forEach(btn => { btn.classList.toggle('active', btn.dataset.value === currentTheme); @@ -111,7 +114,8 @@ document.addEventListener('DOMContentLoaded', () => { function saveSettings() { localStorage.setItem('e621tagger-settings', JSON.stringify({ allThreshold, confidentThreshold, defaultFormat: savedFormat, - theme: currentTheme, activePreset, maxTags + theme: currentTheme, activePreset, maxTags, + alwaysHiddenCategories: [...alwaysHiddenCategories] })); } @@ -435,7 +439,7 @@ function refreshTagClasses() { } function filterTags(threshold) { - return allTags.filter(t => !ratingTags.has(t.tag) && isTagIncluded(t, threshold)); + return allTags.filter(t => !ratingTags.has(t.tag) && !hiddenCategories.has(t.category) && isTagIncluded(t, threshold)); } function formatTags(tags) { @@ -579,6 +583,10 @@ function refreshTagClasses() { categoriesContainer.innerHTML = ''; Object.keys(grouped).sort((a, b) => { + const aAlways = alwaysHiddenCategories.has(a); + const bAlways = alwaysHiddenCategories.has(b); + if (aAlways && !bAlways) return 1; + if (!aAlways && bAlways) return -1; const ia = displayCategoryOrder.indexOf(a); const ib = displayCategoryOrder.indexOf(b); if (ia !== -1 && ib !== -1) return ia - ib; @@ -587,11 +595,17 @@ function refreshTagClasses() { return a.localeCompare(b); }).forEach(cat => { const catTags = grouped[cat]; + const isHidden = hiddenCategories.has(cat); + const isAlways = alwaysHiddenCategories.has(cat); const catDiv = document.createElement('div'); - catDiv.className = 'category-block'; + catDiv.className = 'category-block' + (isHidden ? ' category-hidden' : ''); catDiv.innerHTML = `
${escapeHtml(cat)} +
+ Always hide + +
`; @@ -616,6 +630,37 @@ function refreshTagClasses() { attachTagEvents(tagEl, item); tagsContainer.appendChild(tagEl); }); + const toggleBtn = catDiv.querySelector('.category-toggle-btn'); + toggleBtn.addEventListener('click', (e) => { + e.stopPropagation(); + if (hiddenCategories.has(cat)) { + hiddenCategories.delete(cat); + catDiv.classList.remove('category-hidden'); + toggleBtn.textContent = '✕'; + alwaysHideEl.style.display = 'none'; + } else { + hiddenCategories.add(cat); + catDiv.classList.add('category-hidden'); + toggleBtn.textContent = '✓'; + alwaysHideEl.style.display = 'inline'; + } + }); + const alwaysHideEl = catDiv.querySelector('.category-always-hide'); + alwaysHideEl.addEventListener('click', (e) => { + e.stopPropagation(); + if (alwaysHiddenCategories.has(cat)) { + alwaysHiddenCategories.delete(cat); + alwaysHideEl.classList.remove('active'); + } else { + alwaysHiddenCategories.add(cat); + hiddenCategories.add(cat); + catDiv.classList.add('category-hidden'); + toggleBtn.textContent = '✓'; + alwaysHideEl.style.display = 'inline'; + alwaysHideEl.classList.add('active'); + } + saveSettings(); + }); categoriesContainer.appendChild(catDiv); }); } @@ -691,6 +736,7 @@ function refreshTagClasses() { autoMetaTagSet = new Set(autoMeta); addedTags.clear(); removedTags.clear(); + hiddenCategories = new Set(alwaysHiddenCategories); currentFormat = savedFormat; updateLocalFormatUI(); displayTags(allTags); @@ -760,6 +806,8 @@ function refreshTagClasses() { attachHammerTap(resetBtn, () => { allThreshold = 0.60; confidentThreshold = 0.70; savedFormat = 'e621'; currentFormat = savedFormat; currentTheme = 'system'; activePreset = 'standard'; maxTags = 200; + alwaysHiddenCategories.clear(); + hiddenCategories.clear(); document.querySelectorAll('#themeToggle .theme-option').forEach(btn => { btn.classList.toggle('active', btn.dataset.value === 'system'); @@ -774,6 +822,7 @@ function refreshTagClasses() { updateTheme('system'); applyThresholds(); saveSettings(); + if (allTags.length) displayTags(allTags); }); presetBtns.forEach(btn => { diff --git a/templates/index.html b/templates/index.html index b7bd401..66d6fda 100644 --- a/templates/index.html +++ b/templates/index.html @@ -195,7 +195,8 @@ • Blue – medium confidence (≥ All threshold).
• Gray – low confidence (below thresholds).
• Click a tag to force it to be included (green) or excluded (red) from copying, tags adjusted like that will ignore any thresholds.
- • Long press or right-click a tag to show the description from e621 wiki.

+ • Long press or right-click a tag to show the description from e621 wiki.
+ • Click ✕ on a category header to gray it out and exclude those tags from copying. Click ✓ to reveal. While hidden, tap "Always hide" to save permanently.

💄 Pro Tip: Narrow down basic detection so that it is almost always correct, and then manually add or remove tags.