Skip to content

Commit a5464d3

Browse files
Fixing concept display in search results (#81)
* Fix ModuleNotFoundError for url_utils in PyPI distribution * Fixed search not working respecting languages * IRI in search doesn't use search but goes directly to concept * formatting * Fixing concept not shown in search results --------- Co-authored-by: Valentin Starlinger <[email protected]>
1 parent 29aa870 commit a5464d3

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/py_semantic_taxonomy/adapters/routers/templates/search.html

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,14 @@ <h3 class="text-lg font-medium mb-2" style="color: var(--text-color)">Start sear
9494
// Fetch concept details
9595
async function fetchConceptDetails(iri, elementId) {
9696
try {
97-
const response = await fetch(`{{ concept_api_url }}?iri=${encodeURIComponent(iri)}`);
97+
const url = `{{ concept_api_base_url }}${iri}`;
98+
const response = await fetch(url);
9899
const concept = await response.json();
99100

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

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

128129
// Render MathJax for dynamically loaded content
129130
if (typeof MathJax !== 'undefined') {
130-
MathJax.typesetPromise([infoDiv.querySelector('.mathjax-content')]).catch(function (err) {
131-
console.log('MathJax rendering error:', err);
132-
});
131+
const mathContent = infoDiv.querySelector('.mathjax-content');
132+
if (mathContent) {
133+
MathJax.typesetPromise([mathContent]).catch(function (err) {
134+
console.log('MathJax rendering error:', err);
135+
});
136+
}
133137
}
134138
} else {
135139
infoDiv.innerHTML = '<span class="text-red-500 text-xs">Failed to load concept details</span>';

src/py_semantic_taxonomy/adapters/routers/web_router.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ async def web_search(
434434
"semantic": semantic,
435435
"results": results,
436436
"suggest_api_url": get_full_api_path("suggest"),
437-
"concept_api_url": get_full_api_path("concept"),
437+
"concept_api_base_url": get_full_api_path("concept_all"),
438438
},
439439
)
440440
except de.SearchNotConfigured:

0 commit comments

Comments
 (0)