Latest stable branch includes sermon analysis endpoint, but not required for new installations

This commit is contained in:
2024-11-12 17:25:56 -08:00
parent 0ab32bf4e2
commit 87f0dc54c5
16 changed files with 376 additions and 70 deletions
+115
View File
@@ -0,0 +1,115 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Search</title>
<style>
#search-box {
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
width: 100%;
margin-bottom: 10px;
}
#results {
list-style: none;
padding: 0;
}
#results li {
margin-bottom: 10px;
border-bottom: 1px solid #eee;
padding: 5px;
}
</style>
</head>
<body>
<h1>Bible Semantic Search</h1>
<p>This is NOT a keyword search. This means searching single words will not have the results you expect. For that, use the normal keyword search at <a href='/'>api.1611.social</a></p>
<p>Use a sentence like "The Lord will kill his enemies without mercy" - you are supposed to search an idea, not individual words.</p>
<h3>Recent searches:</h3>
<ul id="last-searched"></ul>
<input type="text" id="search-box" placeholder="The lord god is a man of war, just in all his dealings">
<button id="search-button">Search</button>
<ul id="results"></ul>
<script>
const searchButton = document.getElementById('search-button');
const searchBox = document.getElementById('search-box');
const resultsList = document.getElementById('results');
const lastSearched = document.getElementById('last-searched');
window.addEventListener('DOMContentLoaded', async () => {
const lastSearchedURL = `https://api.1611.social/natural`;
const data = {
token: 'testing',
query: '__last_searched__'
};
const response = await fetch(lastSearchedURL, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
if (response.ok) {
const results = await response.json();
lastSearched.innerHTML = ''; // Clear previous results
results.forEach(result => {
const listItem = document.createElement('li');
listItem.innerHTML = `
${result.query}<br>
`;
lastSearched.appendChild(listItem);
});
} else {
console.error('Error fetching data:', response.statusText);
}
});
searchButton.addEventListener('click', async () => {
const query = searchBox.value;
if (query.length >= 100){
alert("Query too long");
return;}
const url = `https://api.1611.social/natural`; // Replace with your actual URL
const data = {
token: 'testing',
query: query
};
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
if (response.ok) {
const results = await response.json();
resultsList.innerHTML = ''; // Clear previous results
results.forEach(result => {
const listItem = document.createElement('li');
const uriRef = encodeURIComponent(result.ref);
listItem.innerHTML = `
<strong>Verse ID:</strong> ${result.verse_id}<br>
<strong>Text:</strong> ${result.text}<br>
<strong>Ref:</strong> <a href=/find?kw=${uriRef}>${result.ref}</a><br>
<strong>Score:</strong> ${result.score}
`;
resultsList.appendChild(listItem);
});
} else {
console.error('Error fetching data:', response.statusText);
alert('An error occurred while searching. Please try again later.');
}
});
</script>
</body>
</html>