coming together

This commit is contained in:
HotSwapp
2025-08-13 18:53:35 -05:00
parent acc5155bf7
commit 5111079149
51 changed files with 14457 additions and 588 deletions

View File

@@ -441,6 +441,8 @@ function initializeAdvancedSearch() {
});
}
// Use shared highlight utilities
async function loadSearchFacets() {
try {
const response = await window.http.wrappedFetch('/api/search/facets');
@@ -744,6 +746,9 @@ function displaySearchResults(data) {
const resultsContainer = document.getElementById('searchResults');
const statusElement = document.getElementById('searchStatus');
const facetsCard = document.getElementById('facetsCard');
const tokens = (window.highlightUtils && typeof window.highlightUtils.buildTokens === 'function')
? window.highlightUtils.buildTokens(currentSearchCriteria.query || '')
: [];
// Update status
const executionTime = data.stats?.search_execution_time || 0;
@@ -777,6 +782,9 @@ function displaySearchResults(data) {
data.results.forEach(result => {
const typeIcon = getTypeIcon(result.type);
const typeBadge = getTypeBadge(result.type);
const matchHtml = (window.highlightUtils && typeof window.highlightUtils.formatSnippet === 'function')
? window.highlightUtils.formatSnippet(result.highlight, tokens)
: (result.highlight || '');
resultsHTML += `
<div class="search-result-item border-b py-3">
@@ -787,7 +795,7 @@ function displaySearchResults(data) {
<div class="flex-1">
<div class="flex justify-between items-start mb-1">
<h6 class="mb-1">
<a href="${result.url}" class="hover:underline">${result.title}</a>
<a href="${result.url}" class="hover:underline">${window.highlightUtils ? window.highlightUtils.highlight(result.title || '', tokens) : (result.title || '')}</a>
${typeBadge}
</h6>
<div class="text-right">
@@ -795,16 +803,20 @@ function displaySearchResults(data) {
${result.updated_at ? `<br><small class="text-neutral-500">${formatDate(result.updated_at)}</small>` : ''}
</div>
</div>
<p class="mb-1 text-neutral-500">${result.description}</p>
${result.highlight ? `<div class="text-sm text-info-600"><strong>Match:</strong> ${result.highlight}</div>` : ''}
${displayResultMetadata(result.metadata)}
<p class="mb-1 text-neutral-500">${window.highlightUtils ? window.highlightUtils.highlight(result.description || '', tokens) : (result.description || '')}</p>
${matchHtml ? `<div class="text-sm text-info-600"><strong>Match:</strong> ${matchHtml}</div>` : ''}
${displayResultMetadata(result.metadata, tokens)}
</div>
</div>
</div>
`;
});
resultsContainer.innerHTML = resultsHTML;
if (window.setSafeHTML) {
window.setSafeHTML(resultsContainer, resultsHTML);
} else {
resultsContainer.innerHTML = resultsHTML;
}
// Display pagination
if (data.page_info.total_pages > 1) {
@@ -903,14 +915,23 @@ function getTypeBadge(type) {
return badges[type] || '';
}
function displayResultMetadata(metadata) {
function displayResultMetadata(metadata, tokens) {
if (!metadata) return '';
let metadataHTML = '<div class="text-sm text-neutral-500 mt-1">';
Object.entries(metadata).forEach(([key, value]) => {
if (value && key !== 'phones') { // Skip complex objects
metadataHTML += `<span class="mr-3"><strong>${key.replace('_', ' ')}:</strong> ${value}</span>`;
const label = (window.highlightUtils && window.highlightUtils.escape)
? window.highlightUtils.escape(String(key).replace('_', ' '))
: String(key).replace('_', ' ');
const valStr = typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean'
? String(value)
: '';
const valueHtml = (window.highlightUtils && typeof window.highlightUtils.highlight === 'function')
? window.highlightUtils.highlight(valStr, Array.isArray(tokens) ? tokens : [])
: valStr;
metadataHTML += `<span class="mr-3"><strong>${label}:</strong> ${valueHtml}</span>`;
}
});