Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/py_semantic_taxonomy/adapters/routers/templates/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,14 @@ <h3 class="text-lg font-medium mb-2" style="color: var(--text-color)">Start sear
// Fetch concept details
async function fetchConceptDetails(iri, elementId) {
try {
const response = await fetch(`{{ concept_api_url }}?iri=${encodeURIComponent(iri)}`);
const url = `{{ concept_api_base_url }}${iri}`;
const response = await fetch(url);
const concept = await response.json();

const infoDiv = document.getElementById(elementId);
if (concept) {
if (concept && response.status === 200) {
const schemes = concept['http://www.w3.org/2004/02/skos/core#inScheme'] || [];
const definition = concept['http://www.w3.org/2004/02/skos/core#definition']?.find(d => d['@language'] === 'en')?.['@value'];
const definition = concept['http://www.w3.org/2004/02/skos/core#definition']?.find(d => d['@language'] === '{{ language }}')?.['@value'];

infoDiv.innerHTML = `
<div class="space-y-2">
Expand All @@ -109,7 +110,7 @@ <h3 class="text-lg font-medium mb-2" style="color: var(--text-color)">Start sear
<i class="fas fa-layer-group mr-2" style="color: var(--text-tertiary)"></i>
<div class="flex flex-wrap gap-1">
${schemes.map(scheme => `
<a href="/web/concept_scheme/${scheme['@id']}" class="text-primary hover:text-primary-hover text-xs">
<a href="/web/concept_scheme/${scheme['@id']}?language={{ language }}" class="text-primary hover:text-primary-hover text-xs">
${scheme['@id'].split('/').pop()}
</a>
`).join(', ')}
Expand All @@ -127,9 +128,12 @@ <h3 class="text-lg font-medium mb-2" style="color: var(--text-color)">Start sear

// Render MathJax for dynamically loaded content
if (typeof MathJax !== 'undefined') {
MathJax.typesetPromise([infoDiv.querySelector('.mathjax-content')]).catch(function (err) {
console.log('MathJax rendering error:', err);
});
const mathContent = infoDiv.querySelector('.mathjax-content');
if (mathContent) {
MathJax.typesetPromise([mathContent]).catch(function (err) {
console.log('MathJax rendering error:', err);
});
}
}
} else {
infoDiv.innerHTML = '<span class="text-red-500 text-xs">Failed to load concept details</span>';
Expand Down
2 changes: 1 addition & 1 deletion src/py_semantic_taxonomy/adapters/routers/web_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ async def web_search(
"semantic": semantic,
"results": results,
"suggest_api_url": get_full_api_path("suggest"),
"concept_api_url": get_full_api_path("concept"),
"concept_api_base_url": get_full_api_path("concept_all"),
},
)
except de.SearchNotConfigured:
Expand Down