feat: add Stack Overflow search engine

Uses the Stack Exchange API v3 (/search/advanced) to find questions
sorted by relevance. No API key required (300 req/day); optionally
configure via STACKOVERFLOW_KEY env var or [engines.stackoverflow].

Results include score, answer count, view count, and tags in the
snippet. Assigned to the 'it' category, triggered by the IT category
tab or explicit engine selection.

6 tests covering parsing, edge cases, and helpers.
This commit is contained in:
Franz Kafka 2026-03-22 22:29:34 +00:00
parent e96040ef35
commit df67492602
5 changed files with 440 additions and 7 deletions

View file

@ -26,7 +26,7 @@ import (
var defaultPortedEngines = []string{
"wikipedia", "arxiv", "crossref", "braveapi",
"brave", "qwant", "duckduckgo", "github", "reddit",
"bing", "google", "youtube",
"bing", "google", "youtube", "stackoverflow",
// Image engines
"bing_images", "ddg_images", "qwant_images",
}
@ -116,6 +116,7 @@ func inferFromCategories(categories []string) []string {
set["crossref"] = true
case "it":
set["github"] = true
set["stackoverflow"] = true
case "social media":
set["reddit"] = true
case "videos":
@ -134,8 +135,8 @@ func inferFromCategories(categories []string) []string {
// stable order
order := map[string]int{
"wikipedia": 0, "braveapi": 1, "brave": 2, "qwant": 3, "duckduckgo": 4, "bing": 5, "google": 6,
"arxiv": 7, "crossref": 8, "github": 9, "reddit": 10, "youtube": 11,
"bing_images": 12, "ddg_images": 13, "qwant_images": 14,
"arxiv": 7, "crossref": 8, "github": 9, "stackoverflow": 10, "reddit": 11, "youtube": 12,
"bing_images": 13, "ddg_images": 14, "qwant_images": 15,
}
sortByOrder(out, order)
return out