implement post metadata import and views. implemented series paging and reader view.

This commit is contained in:
Bryan Van Deusen
2026-01-22 22:19:11 -05:00
parent f41acb40f6
commit a05aee5a07
16 changed files with 2298 additions and 8 deletions
+42
View File
@@ -112,6 +112,7 @@
updateCount();
loadCommonTags();
dispatchSelectionChanged();
}
function clearSelection() {
@@ -121,6 +122,7 @@
});
updateCount();
updateCommonTagsDisplay();
dispatchSelectionChanged();
}
function updateCount() {
@@ -129,6 +131,39 @@
}
}
function dispatchSelectionChanged() {
document.dispatchEvent(new CustomEvent('selectionChanged', {
detail: { count: state.selectedIds.size }
}));
}
// Enable select mode programmatically, optionally without opening the bulk panel
function enableSelectMode(skipPanel = false) {
if (state.isSelectMode) return;
state.isSelectMode = true;
document.body.classList.add('select-mode');
dom.selectBtn.textContent = 'Cancel';
dom.selectBtn.classList.add('active');
if (!skipPanel) {
dom.panel.classList.add('active');
updateCommonTagsDisplay();
}
}
// Disable select mode
function disableSelectMode() {
if (!state.isSelectMode) return;
state.isSelectMode = false;
document.body.classList.remove('select-mode');
dom.selectBtn.textContent = 'Select';
dom.selectBtn.classList.remove('active');
dom.panel.classList.remove('active');
clearSelection();
}
function updateSelectionUI() {
// Re-apply selected class to any newly loaded images that are in selection
document.querySelectorAll('.img-clickable').forEach(item => {
@@ -416,6 +451,7 @@
archive: '🗜️',
character: '👤',
series: '📺',
fandom: '🎭',
rating: '⚠️',
source: '🌐',
post: '📌'
@@ -435,4 +471,10 @@
} else {
init();
}
// Expose global API for other scripts (like series editor)
window.selectedImages = state.selectedIds;
window.clearSelection = clearSelection;
window.enableSelectMode = enableSelectMode;
window.disableSelectMode = disableSelectMode;
})();
+105
View File
@@ -14,6 +14,14 @@ document.addEventListener('DOMContentLoaded', () => {
const tagInput = tagForm ? tagForm.querySelector('input[name="name"]') : null;
const tagAutocomplete = document.getElementById('tagAutocomplete');
// Series info elements
const seriesInfoEl = document.getElementById('modalSeriesInfo');
const seriesNameEl = document.getElementById('modalSeriesName');
const pageNumberInput = document.getElementById('modalPageNumber');
const updatePageBtn = document.getElementById('updatePageBtn');
const pageUpdateStatus = document.getElementById('pageUpdateStatus');
let currentSeriesPageId = null;
// Autocomplete state
let autocompleteItems = [];
let autocompleteSelectedIndex = -1;
@@ -53,6 +61,7 @@ document.addEventListener('DOMContentLoaded', () => {
archive: '🗜️',
character: '👤',
series: '📺',
fandom: '🎭',
rating: '⚠️',
source: '🌐',
post: '📌'
@@ -87,6 +96,100 @@ document.addEventListener('DOMContentLoaded', () => {
// ignore
}
}
// ---------------------------
// Series info helpers
// ---------------------------
function hideSeriesInfo() {
if (seriesInfoEl) seriesInfoEl.style.display = 'none';
currentSeriesPageId = null;
if (pageUpdateStatus) pageUpdateStatus.textContent = '';
}
function showSeriesInfo(seriesPage) {
if (!seriesInfoEl || !seriesPage) return;
currentSeriesPageId = seriesPage.id;
// Display series name (strip prefix)
const displayName = seriesPage.series_name.includes(':')
? seriesPage.series_name.split(':', 1)[1]
: seriesPage.series_name;
if (seriesNameEl) {
seriesNameEl.textContent = displayName;
seriesNameEl.href = `/gallery?tag=${encodeURIComponent(seriesPage.series_name)}`;
}
// Display page number
if (pageNumberInput) {
pageNumberInput.value = seriesPage.page_number;
}
if (pageUpdateStatus) pageUpdateStatus.textContent = '';
seriesInfoEl.style.display = 'block';
}
async function loadSeriesInfo(imageId) {
hideSeriesInfo();
if (!imageId) return;
try {
const r = await fetch(`/api/image/${imageId}/series-info`);
const j = await r.json();
if (j.ok && j.in_series) {
showSeriesInfo(j.series_page);
}
} catch {
// ignore
}
}
async function updatePageNumber() {
if (!currentSeriesPageId || !pageNumberInput) return;
const newPageNumber = parseInt(pageNumberInput.value);
if (isNaN(newPageNumber) || newPageNumber < 1) {
if (pageUpdateStatus) pageUpdateStatus.textContent = 'Invalid';
return;
}
if (updatePageBtn) updatePageBtn.disabled = true;
if (pageUpdateStatus) pageUpdateStatus.textContent = 'Saving...';
try {
const fd = new FormData();
fd.append('page_number', newPageNumber);
const r = await fetch(`/api/series/page/${currentSeriesPageId}/update`, {
method: 'POST',
body: fd
});
const j = await r.json();
if (j.ok) {
if (pageUpdateStatus) {
pageUpdateStatus.textContent = '✓';
setTimeout(() => { pageUpdateStatus.textContent = ''; }, 2000);
}
} else {
if (pageUpdateStatus) pageUpdateStatus.textContent = j.error || 'Error';
}
} catch (e) {
if (pageUpdateStatus) pageUpdateStatus.textContent = 'Error';
} finally {
if (updatePageBtn) updatePageBtn.disabled = false;
}
}
// Wire up the save button
if (updatePageBtn) {
updatePageBtn.addEventListener('click', updatePageNumber);
}
// Allow Enter key in page number input to save
if (pageNumberInput) {
pageNumberInput.addEventListener('keydown', (e) => {
if (e.key === 'Enter') {
e.preventDefault();
updatePageNumber();
}
});
}
async function addTag(imageId, name) {
const fd = new FormData();
fd.append('name', name);
@@ -299,6 +402,7 @@ document.addEventListener('DOMContentLoaded', () => {
// NEW: load tags for this image into the modal editor
setEditorImageId(imageId);
loadTags(imageId);
loadSeriesInfo(imageId);
}
function openModal(index) {
@@ -324,6 +428,7 @@ document.addEventListener('DOMContentLoaded', () => {
// clear tag UI
setEditorImageId('');
renderTags([]);
hideSeriesInfo();
history.replaceState({}, '', window.location.pathname + window.location.search);
}
+1
View File
@@ -286,6 +286,7 @@
archive: '🗜️',
character: '👤',
series: '📺',
fandom: '🎭',
rating: '⚠️',
source: '🌐',
post: '📌'
+679
View File
@@ -585,6 +585,63 @@ header {
}
}
/* Series info in modal tag editor */
.modal-series-info {
margin-bottom: 0.75rem;
padding-bottom: 0.75rem;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.series-info-row {
display: flex;
align-items: center;
gap: 0.5rem;
margin-bottom: 0.4rem;
}
.series-info-row:last-child {
margin-bottom: 0;
}
.series-info-label {
color: var(--text-muted);
font-size: 0.85rem;
}
.series-info-link {
color: var(--accent);
text-decoration: none;
font-size: 0.9rem;
}
.series-info-link:hover {
text-decoration: underline;
}
.series-page-input {
width: 60px;
padding: 0.25rem 0.4rem;
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.15);
border-radius: 4px;
color: var(--text);
font-size: 0.85rem;
}
.btn-small {
padding: 0.25rem 0.5rem;
background: var(--btn-secondary);
border: none;
border-radius: 4px;
color: var(--text);
font-size: 0.8rem;
cursor: pointer;
}
.btn-small:hover {
background: var(--btn-secondary-hover);
}
.btn-small:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.page-update-status {
font-size: 0.8rem;
color: var(--text-muted);
}
.tag-editor .tags {
margin: 0 0 0.5rem 0;
min-height: 28px;
@@ -1407,6 +1464,261 @@ select.form-input optgroup {
color: var(--text);
}
/* Post Info Header (shown when filtering by post tag) */
.post-info-header {
background: var(--panel);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 12px;
margin: 0 0 1.5rem 0;
overflow: hidden;
}
.post-info-content {
padding: 1.25rem 1.5rem;
}
.post-title {
margin: 0 0 0.75rem 0;
font-size: 1.35rem;
font-weight: 600;
color: var(--text);
line-height: 1.3;
}
.post-meta {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.5rem 1rem;
margin-bottom: 0.75rem;
font-size: 0.875rem;
color: var(--text-dim);
}
.post-artist {
font-weight: 500;
color: var(--link);
}
.post-platform {
display: inline-flex;
align-items: center;
padding: 0.2rem 0.6rem;
border-radius: 4px;
font-size: 0.75rem;
font-weight: 500;
text-transform: capitalize;
background: rgba(255, 255, 255, 0.1);
color: var(--text-dim);
}
.post-platform-patreon {
background: rgba(255, 66, 77, 0.2);
color: #ff6b6b;
}
.post-platform-subscribestar {
background: rgba(255, 153, 0, 0.2);
color: #ffaa33;
}
.post-platform-hentaifoundry {
background: rgba(139, 92, 246, 0.2);
color: #a78bfa;
}
.post-date {
color: var(--text-muted);
}
.post-count {
color: var(--text-muted);
}
.post-count::before {
content: "•";
margin-right: 0.5rem;
}
.post-description {
margin: 0.75rem 0;
padding: 1rem;
background: rgba(0, 0, 0, 0.2);
border-radius: 8px;
font-size: 0.9rem;
line-height: 1.6;
color: var(--text-dim);
max-height: 200px;
overflow-y: auto;
}
.post-description:empty {
display: none;
}
/* Style any HTML content in descriptions */
.post-description a {
color: var(--link);
}
.post-description a:hover {
color: var(--link-hover);
}
.post-description p {
margin: 0 0 0.75rem 0;
}
.post-description p:last-child {
margin-bottom: 0;
}
.post-description img {
max-width: 100%;
height: auto;
border-radius: 4px;
}
.post-source-link {
display: inline-flex;
align-items: center;
gap: 0.4rem;
margin-top: 0.5rem;
padding: 0.5rem 1rem;
background: rgba(99, 102, 241, 0.15);
border: 1px solid rgba(99, 102, 241, 0.3);
border-radius: 6px;
color: var(--link);
text-decoration: none;
font-size: 0.85rem;
font-weight: 500;
transition: all 0.2s ease;
}
.post-source-link:hover {
background: rgba(99, 102, 241, 0.25);
border-color: rgba(99, 102, 241, 0.5);
color: var(--link-hover);
}
.post-source-link::after {
content: "↗";
font-size: 0.9em;
}
/* Series Header (shown when filtering by series tag) */
.series-header {
background: var(--panel);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 12px;
margin: 0 0 1.5rem 0;
overflow: hidden;
}
.series-header-content {
padding: 1rem 1.25rem;
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
gap: 1rem;
}
.series-header-left {
display: flex;
align-items: center;
gap: 0.75rem;
}
.series-title {
margin: 0;
font-size: 1.25rem;
font-weight: 600;
color: var(--text);
}
.series-page-count {
color: var(--text-muted);
font-size: 0.9rem;
background: rgba(255, 255, 255, 0.08);
padding: 0.25rem 0.6rem;
border-radius: 4px;
}
.series-header-actions {
display: flex;
gap: 0.5rem;
}
/* Series Editor Panel */
.series-editor-panel {
padding: 1rem 1.25rem;
border-top: 1px solid rgba(255, 255, 255, 0.1);
background: rgba(0, 0, 0, 0.2);
}
.series-editor-info {
margin-bottom: 0.75rem;
}
.series-editor-info p {
margin: 0;
color: var(--text-dim);
font-size: 0.85rem;
}
.series-editor-controls {
display: flex;
align-items: flex-end;
gap: 1rem;
flex-wrap: wrap;
}
.series-editor-input {
display: flex;
flex-direction: column;
gap: 0.35rem;
}
.series-editor-input label {
font-size: 0.8rem;
color: var(--text-muted);
}
.series-editor-input input {
width: 100px;
padding: 0.4rem 0.6rem;
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.15);
border-radius: 6px;
color: var(--text);
font-size: 0.9rem;
}
.series-editor-feedback {
margin-top: 0.75rem;
}
.series-editor-feedback .feedback-success {
padding: 0.5rem 0.75rem;
background: rgba(34, 197, 94, 0.15);
border: 1px solid rgba(34, 197, 94, 0.3);
border-radius: 6px;
color: #22c55e;
font-size: 0.85rem;
}
.series-editor-feedback .feedback-error {
padding: 0.5rem 0.75rem;
background: rgba(239, 68, 68, 0.15);
border: 1px solid rgba(239, 68, 68, 0.3);
border-radius: 6px;
color: #ef4444;
font-size: 0.85rem;
}
#seriesEditModeBtn.active {
background: var(--btn-primary);
color: white;
}
@media (max-width: 768px) {
.series-header-content {
flex-direction: column;
align-items: flex-start;
}
.series-editor-controls {
flex-direction: column;
align-items: stretch;
}
.series-editor-input {
flex-direction: row;
align-items: center;
gap: 0.5rem;
}
}
@media (max-width: 768px) {
.post-info-content {
padding: 1rem;
}
.post-title {
font-size: 1.15rem;
}
.post-meta {
font-size: 0.8rem;
}
.post-description {
max-height: 150px;
font-size: 0.85rem;
}
}
/* Gallery content area */
.gallery-infinite {
min-height: 50vh;
@@ -1703,6 +2015,21 @@ body.select-mode .gallery-infinite-container {
color: #ef4444;
}
/* Series section in bulk editor */
.bulk-editor-series {
background: rgba(100, 100, 255, 0.05);
border-top: 1px solid rgba(100, 100, 255, 0.15);
}
.bulk-editor-series h4 {
color: var(--text);
}
.bulk-editor-series .series-editor-controls {
margin-top: 0.5rem;
}
.bulk-editor-series .series-editor-feedback {
margin-top: 0.5rem;
}
/* Text muted helper */
.text-muted {
color: var(--text-muted);
@@ -1727,3 +2054,355 @@ body.select-mode .gallery-infinite-container {
transform: translateY(0);
}
}
/*------------------------------------------------------------------------------
Series Reader View
------------------------------------------------------------------------------*/
.reader-container {
display: flex;
flex-direction: column;
height: calc(100vh - 60px);
background: var(--bg);
margin: -1rem;
}
.reader-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.75rem 1rem;
background: var(--panel);
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
flex-shrink: 0;
}
.reader-header-left {
display: flex;
align-items: center;
gap: 0.75rem;
}
.reader-back-btn {
display: flex;
align-items: center;
justify-content: center;
width: 36px;
height: 36px;
background: rgba(255, 255, 255, 0.1);
border-radius: 8px;
color: var(--text);
text-decoration: none;
font-size: 1.2rem;
transition: all 0.2s ease;
}
.reader-back-btn:hover {
background: rgba(255, 255, 255, 0.2);
}
.reader-title {
margin: 0;
font-size: 1.1rem;
font-weight: 600;
color: var(--text);
}
.reader-page-count {
color: var(--text-muted);
font-size: 0.85rem;
}
.reader-header-right {
display: flex;
align-items: center;
gap: 0.75rem;
}
.reader-jump {
display: flex;
align-items: center;
gap: 0.5rem;
}
.reader-jump label {
color: var(--text-muted);
font-size: 0.85rem;
}
.reader-jump-select {
padding: 0.4rem 0.75rem;
background: var(--surface);
border: 1px solid rgba(255, 255, 255, 0.15);
border-radius: 6px;
color: var(--text);
font-size: 0.85rem;
cursor: pointer;
}
.reader-jump-select option {
background: var(--surface);
color: var(--text);
}
.reader-toggle-nav {
display: flex;
align-items: center;
justify-content: center;
width: 36px;
height: 36px;
background: rgba(255, 255, 255, 0.1);
border: none;
border-radius: 8px;
color: var(--text);
font-size: 1.1rem;
cursor: pointer;
transition: all 0.2s ease;
}
.reader-toggle-nav:hover {
background: rgba(255, 255, 255, 0.2);
}
.reader-body {
display: flex;
flex: 1;
overflow: hidden;
position: relative;
}
/* Navigation Sidebar */
.reader-nav {
position: fixed;
top: 0;
left: 0;
width: 200px;
height: 100vh;
background: var(--panel);
border-right: 1px solid rgba(255, 255, 255, 0.1);
transform: translateX(-100%);
transition: transform 0.3s ease;
z-index: 1000;
display: flex;
flex-direction: column;
}
.reader-nav.open {
transform: translateX(0);
}
.reader-nav-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.reader-nav-header h3 {
margin: 0;
font-size: 1rem;
font-weight: 500;
}
.reader-nav-close {
width: 28px;
height: 28px;
background: rgba(255, 255, 255, 0.1);
border: none;
border-radius: 6px;
color: var(--text);
font-size: 1.2rem;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
}
.reader-nav-close:hover {
background: rgba(255, 255, 255, 0.2);
}
.reader-nav-thumbs {
flex: 1;
overflow-y: auto;
padding: 0.5rem;
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.reader-nav-thumb {
position: relative;
border-radius: 6px;
overflow: hidden;
cursor: pointer;
border: 2px solid transparent;
transition: all 0.2s ease;
}
.reader-nav-thumb:hover {
border-color: rgba(255, 255, 255, 0.3);
}
.reader-nav-thumb.active {
border-color: var(--btn-primary);
}
.reader-nav-thumb img {
width: 100%;
height: auto;
display: block;
}
.thumb-page-num {
position: absolute;
bottom: 4px;
right: 4px;
background: rgba(0, 0, 0, 0.75);
color: white;
padding: 2px 6px;
border-radius: 4px;
font-size: 0.7rem;
font-weight: 600;
}
/* Main Reader Content */
.reader-main {
flex: 1;
display: flex;
flex-direction: column;
position: relative;
}
.reader-content {
flex: 1;
overflow-y: auto;
scroll-behavior: smooth;
padding: 0.25rem;
display: flex;
flex-direction: column;
align-items: center;
gap: 2px;
background: var(--bg);
}
.reader-page {
position: relative;
width: 100%;
display: flex;
justify-content: center;
}
.reader-page img {
max-width: min(100%, 1200px);
height: auto;
display: block;
}
.page-indicator {
position: absolute;
bottom: 0.5rem;
right: 0.5rem;
background: rgba(0, 0, 0, 0.75);
color: white;
padding: 0.25rem 0.6rem;
border-radius: 4px;
font-size: 0.75rem;
opacity: 0;
transition: opacity 0.2s ease;
}
.reader-page:hover .page-indicator {
opacity: 1;
}
.reader-empty {
text-align: center;
padding: 4rem 1rem;
color: var(--text-muted);
}
/* Floating page indicator */
.floating-page-indicator {
position: fixed;
bottom: 1.5rem;
left: 50%;
transform: translateX(-50%);
background: rgba(0, 0, 0, 0.85);
color: white;
padding: 0.5rem 1rem;
border-radius: 999px;
font-size: 0.9rem;
font-weight: 500;
box-shadow: var(--shadow-2);
z-index: 100;
}
/* Quick nav buttons */
.reader-quick-nav {
position: fixed;
right: 1.5rem;
bottom: 1.5rem;
display: flex;
flex-direction: column;
gap: 0.5rem;
z-index: 100;
}
.reader-quick-btn {
padding: 0.5rem 0.75rem;
background: var(--panel);
border: 1px solid rgba(255, 255, 255, 0.15);
border-radius: 6px;
color: var(--text-dim);
font-size: 0.8rem;
cursor: pointer;
transition: all 0.2s ease;
}
.reader-quick-btn:hover {
background: rgba(255, 255, 255, 0.1);
color: var(--text);
}
/* Mobile adjustments */
@media (max-width: 768px) {
.reader-header {
flex-wrap: wrap;
gap: 0.5rem;
}
.reader-header-left {
flex: 1;
}
.reader-title {
font-size: 0.95rem;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 150px;
}
.reader-jump label {
display: none;
}
.reader-nav {
width: 100%;
max-width: 280px;
}
.reader-content {
padding: 0.5rem;
}
.floating-page-indicator {
bottom: 1rem;
font-size: 0.8rem;
}
.reader-quick-nav {
right: 1rem;
bottom: 4rem;
}
}