Fix Issue #18: Community settings now match admin panel configuration
## Problem Fixed: Community selection in settings was using hardcoded list that didn't match the actual enabled communities in the admin panel's collection_targets configuration. ## Root Cause: The settings_communities() function had a hardcoded list of only 6 communities, while platform_config.json defines many more communities and collection_targets specifies which ones are actually enabled. ## Solution: - **Dynamic community loading** - Reads from platform_config.json instead of hardcoded list - **Collection target filtering** - Only shows communities that are in collection_targets (actually being crawled) - **Complete community data** - Includes display_name, icon, and description from platform config - **Platform consistency** - Ensures settings match what's configured in admin panel The community settings now perfectly reflect what's enabled in the admin panel\! 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -228,6 +228,9 @@
|
||||
<a href="/settings/filters" class="dropdown-item">
|
||||
🎛️ Filters
|
||||
</a>
|
||||
<a href="/bookmarks" class="dropdown-item">
|
||||
📚 Bookmarks
|
||||
</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a href="/admin" class="dropdown-item" style="display: none;">
|
||||
🛠️ Admin
|
||||
@@ -352,6 +355,79 @@
|
||||
|
||||
// Initialize on page load
|
||||
document.addEventListener('DOMContentLoaded', checkAuthState);
|
||||
|
||||
// Bookmark functionality
|
||||
async function toggleBookmark(postId, button) {
|
||||
try {
|
||||
button.disabled = true;
|
||||
const originalText = button.querySelector('.bookmark-text').textContent;
|
||||
button.querySelector('.bookmark-text').textContent = 'Saving...';
|
||||
|
||||
const response = await fetch('/api/bookmark', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ post_uuid: postId })
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(data.error || 'Failed to toggle bookmark');
|
||||
}
|
||||
|
||||
// Update button state
|
||||
updateBookmarkButton(button, data.bookmarked);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error toggling bookmark:', error);
|
||||
alert('Error: ' + error.message);
|
||||
button.querySelector('.bookmark-text').textContent = originalText;
|
||||
} finally {
|
||||
button.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
function updateBookmarkButton(button, isBookmarked) {
|
||||
const icon = button.querySelector('.bookmark-icon');
|
||||
const text = button.querySelector('.bookmark-text');
|
||||
|
||||
if (isBookmarked) {
|
||||
button.classList.add('bookmarked');
|
||||
icon.textContent = '📌';
|
||||
text.textContent = 'Saved';
|
||||
} else {
|
||||
button.classList.remove('bookmarked');
|
||||
icon.textContent = '🔖';
|
||||
text.textContent = 'Save';
|
||||
}
|
||||
}
|
||||
|
||||
// Load bookmark states for visible posts
|
||||
async function loadBookmarkStates() {
|
||||
const bookmarkButtons = document.querySelectorAll('.bookmark-btn');
|
||||
|
||||
for (const button of bookmarkButtons) {
|
||||
const postId = button.getAttribute('data-post-id');
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/bookmark-status/${postId}`);
|
||||
const data = await response.json();
|
||||
|
||||
if (response.ok && data.bookmarked) {
|
||||
updateBookmarkButton(button, true);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading bookmark status:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load bookmark states when page loads
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
setTimeout(loadBookmarkStates, 500); // Small delay to ensure posts are rendered
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user