a
This commit is contained in:
@@ -23,6 +23,13 @@ class Settings(BaseSettings):
|
|||||||
# CORS
|
# CORS
|
||||||
CORS_ORIGINS: str = '["http://localhost:3000", "http://localhost:8000"]'
|
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:
|
class Config:
|
||||||
env_file = ".env"
|
env_file = ".env"
|
||||||
case_sensitive = False
|
case_sensitive = False
|
||||||
|
|||||||
@@ -224,8 +224,10 @@ document.getElementById('searchInput').addEventListener('input', (e) => {
|
|||||||
allLists = temp;
|
allLists = temp;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Search public lists functionality
|
// Search public lists functionality with debouncing
|
||||||
document.getElementById('publicSearchInput').addEventListener('input', async (e) => {
|
let publicSearchTimeout;
|
||||||
|
document.getElementById('publicSearchInput').addEventListener('input', (e) => {
|
||||||
|
clearTimeout(publicSearchTimeout);
|
||||||
const query = e.target.value.trim();
|
const query = e.target.value.trim();
|
||||||
const publicSection = document.getElementById('publicListsSection');
|
const publicSection = document.getElementById('publicListsSection');
|
||||||
const container = document.getElementById('publicListContainer');
|
const container = document.getElementById('publicListContainer');
|
||||||
@@ -239,25 +241,27 @@ document.getElementById('publicSearchInput').addEventListener('input', async (e)
|
|||||||
publicSection.classList.remove('hidden');
|
publicSection.classList.remove('hidden');
|
||||||
container.innerHTML = `<tr><td colspan="4" class="px-6 py-8 text-center text-slate-400">Searching...</td></tr>`;
|
container.innerHTML = `<tr><td colspan="4" class="px-6 py-8 text-center text-slate-400">Searching...</td></tr>`;
|
||||||
|
|
||||||
try {
|
// Wait 500ms after user stops typing before searching
|
||||||
const response = await fetch(`/api/public-lists/search?domain=${encodeURIComponent(query)}`);
|
publicSearchTimeout = setTimeout(async () => {
|
||||||
const lists = await response.json();
|
try {
|
||||||
|
const response = await fetch(`/api/public-lists/search?domain=${encodeURIComponent(query)}`);
|
||||||
if (lists.length === 0) {
|
const lists = await response.json();
|
||||||
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 += `
|
if (lists.length === 0) {
|
||||||
<tr class="hover:bg-slate-700 transition">
|
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>`;
|
||||||
<td class="px-6 py-4 font-semibold text-slate-100">${escapeHtml(list.name)}</td>
|
return;
|
||||||
<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>
|
|
||||||
|
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">
|
<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">
|
<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);
|
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>`;
|
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) {
|
function editList(listId) {
|
||||||
|
|||||||
+64
-24
@@ -19,9 +19,23 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Recent Public Lists -->
|
<!-- Public Lists Table -->
|
||||||
<div id="publicListsContainer" class="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
|
<div class="bg-slate-800 rounded-lg border border-slate-700 overflow-x-auto">
|
||||||
<div class="col-span-full text-center text-slate-400">Loading public lists...</div>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -59,7 +73,7 @@ function renderPublicLists(lists) {
|
|||||||
const container = document.getElementById('publicListsContainer');
|
const container = document.getElementById('publicListsContainer');
|
||||||
|
|
||||||
if (!lists || lists.length === 0) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,22 +81,43 @@ function renderPublicLists(lists) {
|
|||||||
lists.forEach(list => {
|
lists.forEach(list => {
|
||||||
const urlCount = list.urls.split('\n').filter(u => u.trim()).length;
|
const urlCount = list.urls.split('\n').filter(u => u.trim()).length;
|
||||||
const updatedDate = new Date(list.updated_at).toLocaleDateString();
|
const updatedDate = new Date(list.updated_at).toLocaleDateString();
|
||||||
|
const listUrl = `${window.location.origin}/list-read/${encodeURIComponent(list.unique_slug)}`;
|
||||||
|
|
||||||
html += `
|
html += `
|
||||||
<div class="card p-6 hover:border-sky-500 transition">
|
<tr class="hover:bg-slate-700 transition">
|
||||||
<h3 class="text-lg font-semibold text-sky-400 mb-2 truncate" title="${escapeHtml(list.name)}">${escapeHtml(list.name)}</h3>
|
<td class="px-6 py-4 font-semibold text-slate-100">${escapeHtml(list.name)}</td>
|
||||||
<p class="text-sm text-slate-400 mb-4">${urlCount} URL${urlCount !== 1 ? 's' : ''}</p>
|
<td class="px-6 py-4 text-slate-300">${urlCount} URL${urlCount !== 1 ? 's' : ''}</td>
|
||||||
<p class="text-xs text-slate-500 mb-4">Updated: ${updatedDate}</p>
|
<td class="px-6 py-4 text-slate-400 text-xs">${updatedDate}</td>
|
||||||
<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">
|
<td class="px-6 py-4 text-right">
|
||||||
View List →
|
<div class="flex gap-2 justify-end">
|
||||||
</a>
|
<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">
|
||||||
</div>
|
📋
|
||||||
|
</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;
|
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) {
|
function escapeHtml(text) {
|
||||||
const map = {
|
const map = {
|
||||||
'&': '&',
|
'&': '&',
|
||||||
@@ -94,8 +129,10 @@ function escapeHtml(text) {
|
|||||||
return text.replace(/[&<>"']/g, m => map[m]);
|
return text.replace(/[&<>"']/g, m => map[m]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search public lists
|
// Debounced search for public lists
|
||||||
document.getElementById('publicSearch').addEventListener('input', async (e) => {
|
let searchTimeout;
|
||||||
|
document.getElementById('publicSearch').addEventListener('input', (e) => {
|
||||||
|
clearTimeout(searchTimeout);
|
||||||
const query = e.target.value.trim();
|
const query = e.target.value.trim();
|
||||||
const container = document.getElementById('publicListsContainer');
|
const container = document.getElementById('publicListsContainer');
|
||||||
|
|
||||||
@@ -104,16 +141,19 @@ document.getElementById('publicSearch').addEventListener('input', async (e) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
container.innerHTML = '<div class="col-span-full text-center text-slate-400">Searching...</div>';
|
// Wait 500ms after user stops typing before searching
|
||||||
|
searchTimeout = setTimeout(async () => {
|
||||||
try {
|
container.innerHTML = '<div class="col-span-full text-center text-slate-400">Searching...</div>';
|
||||||
const response = await fetch(`/api/public-lists/search?domain=${encodeURIComponent(query)}`);
|
|
||||||
const results = await response.json();
|
try {
|
||||||
renderPublicLists(results);
|
const response = await fetch(`/api/public-lists/search?domain=${encodeURIComponent(query)}`);
|
||||||
} catch (error) {
|
const results = await response.json();
|
||||||
console.error('Error searching public lists:', error);
|
renderPublicLists(results);
|
||||||
container.innerHTML = '<div class="col-span-full text-center text-red-400">Error searching public lists</div>';
|
} 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
|
// Load public lists on page load
|
||||||
|
|||||||
Reference in New Issue
Block a user