This commit is contained in:
2025-11-30 12:53:36 +00:00
parent 349c21ec8a
commit 4a4ae4548b
3 changed files with 96 additions and 44 deletions

View File

@@ -23,6 +23,13 @@ class Settings(BaseSettings):
# CORS
CORS_ORIGINS: str = '["http://localhost:3000", "http://localhost:8000"]'
# Registration
REGISTRATION_ENABLED: bool = False
# MFA
MFA_ENABLED: bool = True
MFA_ISSUER: str = "URL List Manager"
class Config:
env_file = ".env"
case_sensitive = False

View File

@@ -224,8 +224,10 @@ document.getElementById('searchInput').addEventListener('input', (e) => {
allLists = temp;
});
// Search public lists functionality
document.getElementById('publicSearchInput').addEventListener('input', async (e) => {
// Search public lists functionality with debouncing
let publicSearchTimeout;
document.getElementById('publicSearchInput').addEventListener('input', (e) => {
clearTimeout(publicSearchTimeout);
const query = e.target.value.trim();
const publicSection = document.getElementById('publicListsSection');
const container = document.getElementById('publicListContainer');
@@ -239,25 +241,27 @@ document.getElementById('publicSearchInput').addEventListener('input', async (e)
publicSection.classList.remove('hidden');
container.innerHTML = `<tr><td colspan="4" class="px-6 py-8 text-center text-slate-400">Searching...</td></tr>`;
try {
const response = await fetch(`/api/public-lists/search?domain=${encodeURIComponent(query)}`);
const lists = await response.json();
if (lists.length === 0) {
container.innerHTML = `<tr><td colspan="4" class="px-6 py-8 text-center text-slate-400">No public lists found containing "${escapeHtml(query)}"</td></tr>`;
return;
}
let html = '';
lists.forEach(list => {
const urlCount = list.urls.split('\n').filter(u => u.trim()).length;
const updatedDate = new Date(list.updated_at).toLocaleDateString();
// Wait 500ms after user stops typing before searching
publicSearchTimeout = setTimeout(async () => {
try {
const response = await fetch(`/api/public-lists/search?domain=${encodeURIComponent(query)}`);
const lists = await response.json();
html += `
<tr class="hover:bg-slate-700 transition">
<td class="px-6 py-4 font-semibold text-slate-100">${escapeHtml(list.name)}</td>
<td class="px-6 py-4 text-slate-300">${urlCount} URL${urlCount !== 1 ? 's' : ''}</td>
<td class="px-6 py-4 text-slate-400 text-xs">${updatedDate}</td>
if (lists.length === 0) {
container.innerHTML = `<tr><td colspan="4" class="px-6 py-8 text-center text-slate-400">No public lists found containing "${escapeHtml(query)}"</td></tr>`;
return;
}
let html = '';
lists.forEach(list => {
const urlCount = list.urls.split('\n').filter(u => u.trim()).length;
const updatedDate = new Date(list.updated_at).toLocaleDateString();
html += `
<tr class="hover:bg-slate-700 transition">
<td class="px-6 py-4 font-semibold text-slate-100">${escapeHtml(list.name)}</td>
<td class="px-6 py-4 text-slate-300">${urlCount} URL${urlCount !== 1 ? 's' : ''}</td>
<td class="px-6 py-4 text-slate-400 text-xs">${updatedDate}</td>
<td class="px-6 py-4 text-right">
<a href="{{ url_for('list_read', slug='') }}${encodeURIComponent(list.unique_slug)}" target="_blank" class="inline-flex items-center justify-center w-8 h-8 bg-slate-700 hover:bg-sky-600 rounded transition duration-200 text-sm" title="View">
👁️
@@ -272,6 +276,7 @@ document.getElementById('publicSearchInput').addEventListener('input', async (e)
console.error('Error searching public lists:', error);
container.innerHTML = `<tr><td colspan="4" class="px-6 py-8 text-center text-red-400">Error searching public lists</td></tr>`;
}
}, 500);
});
function editList(listId) {

View File

@@ -19,9 +19,23 @@
</div>
</div>
<!-- Recent Public Lists -->
<div id="publicListsContainer" class="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
<div class="col-span-full text-center text-slate-400">Loading public lists...</div>
<!-- Public Lists Table -->
<div class="bg-slate-800 rounded-lg border border-slate-700 overflow-x-auto">
<table class="w-full text-sm">
<thead>
<tr class="border-b border-slate-700 bg-slate-900">
<th class="px-6 py-3 text-left font-semibold text-slate-300">Name</th>
<th class="px-6 py-3 text-left font-semibold text-slate-300">URLs</th>
<th class="px-6 py-3 text-left font-semibold text-slate-300">Updated</th>
<th class="px-6 py-3 text-right font-semibold text-slate-300">Actions</th>
</tr>
</thead>
<tbody id="publicListsContainer" class="divide-y divide-slate-700">
<tr>
<td colspan="4" class="px-6 py-8 text-center text-slate-400">Loading public lists...</td>
</tr>
</tbody>
</table>
</div>
</div>
@@ -59,7 +73,7 @@ function renderPublicLists(lists) {
const container = document.getElementById('publicListsContainer');
if (!lists || lists.length === 0) {
container.innerHTML = '<div class="col-span-full text-center text-slate-400">No public lists yet. Create one to share!</div>';
container.innerHTML = '<tr><td colspan="4" class="px-6 py-8 text-center text-slate-400">No public lists found</td></tr>';
return;
}
@@ -67,22 +81,43 @@ function renderPublicLists(lists) {
lists.forEach(list => {
const urlCount = list.urls.split('\n').filter(u => u.trim()).length;
const updatedDate = new Date(list.updated_at).toLocaleDateString();
const listUrl = `${window.location.origin}/list-read/${encodeURIComponent(list.unique_slug)}`;
html += `
<div class="card p-6 hover:border-sky-500 transition">
<h3 class="text-lg font-semibold text-sky-400 mb-2 truncate" title="${escapeHtml(list.name)}">${escapeHtml(list.name)}</h3>
<p class="text-sm text-slate-400 mb-4">${urlCount} URL${urlCount !== 1 ? 's' : ''}</p>
<p class="text-xs text-slate-500 mb-4">Updated: ${updatedDate}</p>
<a href="{{ url_for('list_read', slug='') }}${encodeURIComponent(list.unique_slug)}" class="inline-block bg-sky-600 hover:bg-sky-700 text-white text-sm font-semibold py-2 px-4 rounded transition duration-200">
View List →
</a>
</div>
<tr class="hover:bg-slate-700 transition">
<td class="px-6 py-4 font-semibold text-slate-100">${escapeHtml(list.name)}</td>
<td class="px-6 py-4 text-slate-300">${urlCount} URL${urlCount !== 1 ? 's' : ''}</td>
<td class="px-6 py-4 text-slate-400 text-xs">${updatedDate}</td>
<td class="px-6 py-4 text-right">
<div class="flex gap-2 justify-end">
<button onclick="copyListLink('${listUrl}')" class="inline-flex items-center justify-center w-8 h-8 bg-slate-700 hover:bg-slate-600 rounded transition duration-200 text-sm" title="Copy link">
📋
</button>
<a href="${listUrl}" target="_blank" class="inline-flex items-center justify-center w-8 h-8 bg-slate-700 hover:bg-sky-600 rounded transition duration-200 text-sm" title="Open in new window">
👁️
</a>
</div>
</td>
</tr>
`;
});
container.innerHTML = html;
}
function copyListLink(url) {
navigator.clipboard.writeText(url).then(() => {
// Show feedback
const feedback = document.createElement('div');
feedback.textContent = 'Link copied!';
feedback.style.cssText = 'position: fixed; top: 20px; right: 20px; background: #10b981; color: white; padding: 12px 20px; border-radius: 6px; z-index: 1000; font-size: 14px;';
document.body.appendChild(feedback);
setTimeout(() => feedback.remove(), 2000);
}).catch(() => {
alert('Failed to copy link');
});
}
function escapeHtml(text) {
const map = {
'&': '&amp;',
@@ -94,8 +129,10 @@ function escapeHtml(text) {
return text.replace(/[&<>"']/g, m => map[m]);
}
// Search public lists
document.getElementById('publicSearch').addEventListener('input', async (e) => {
// Debounced search for public lists
let searchTimeout;
document.getElementById('publicSearch').addEventListener('input', (e) => {
clearTimeout(searchTimeout);
const query = e.target.value.trim();
const container = document.getElementById('publicListsContainer');
@@ -104,16 +141,19 @@ document.getElementById('publicSearch').addEventListener('input', async (e) => {
return;
}
container.innerHTML = '<div class="col-span-full text-center text-slate-400">Searching...</div>';
try {
const response = await fetch(`/api/public-lists/search?domain=${encodeURIComponent(query)}`);
const results = await response.json();
renderPublicLists(results);
} catch (error) {
console.error('Error searching public lists:', error);
container.innerHTML = '<div class="col-span-full text-center text-red-400">Error searching public lists</div>';
}
// Wait 500ms after user stops typing before searching
searchTimeout = setTimeout(async () => {
container.innerHTML = '<div class="col-span-full text-center text-slate-400">Searching...</div>';
try {
const response = await fetch(`/api/public-lists/search?domain=${encodeURIComponent(query)}`);
const results = await response.json();
renderPublicLists(results);
} catch (error) {
console.error('Error searching public lists:', error);
container.innerHTML = '<div class="col-span-full text-center text-red-400">Error searching public lists</div>';
}
}, 500);
});
// Load public lists on page load