rename: kafka → samsa
Full project rename from kafka to samsa (after Gregor Samsa, who woke one morning from uneasy dreams to find himself transformed). - Module: github.com/metamorphosis-dev/kafka → samsa - Binary: cmd/kafka/ → cmd/samsa/ - CSS: kafka.css → samsa.css - UI: all 'kafka' product names, titles, localStorage keys → samsa - localStorage keys: kafka-theme → samsa-theme, kafka-engines → samsa-engines - OpenSearch: ShortName, LongName, description, URLs updated - AGPL headers: 'kafka' → 'samsa' - Docs, configs, examples updated - Cache key prefix: kafka: → samsa:
This commit is contained in:
parent
c91908a427
commit
8e9aae062b
70 changed files with 185 additions and 184 deletions
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -102,7 +102,7 @@ func (s *Service) wikipediaSuggestions(ctx context.Context, query string) ([]str
|
|||
}
|
||||
req.Header.Set(
|
||||
"User-Agent",
|
||||
"gosearch-go/0.1 (compatible; +https://github.com/metamorphosis-dev/kafka)",
|
||||
"gosearch-go/0.1 (compatible; +https://github.com/metamorphosis-dev/samsa)",
|
||||
)
|
||||
|
||||
resp, err := s.http.Do(req)
|
||||
|
|
|
|||
10
internal/cache/cache.go
vendored
10
internal/cache/cache.go
vendored
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -25,7 +25,7 @@ import (
|
|||
"log/slog"
|
||||
"time"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ func (c *Cache) Get(ctx context.Context, key string) (contracts.SearchResponse,
|
|||
return contracts.SearchResponse{}, false
|
||||
}
|
||||
|
||||
fullKey := "kafka:" + key
|
||||
fullKey := "samsa:" + key
|
||||
|
||||
data, err := c.client.Get(ctx, fullKey).Bytes()
|
||||
if err != nil {
|
||||
|
|
@ -129,7 +129,7 @@ func (c *Cache) Set(ctx context.Context, key string, resp contracts.SearchRespon
|
|||
return
|
||||
}
|
||||
|
||||
fullKey := "kafka:" + key
|
||||
fullKey := "samsa:" + key
|
||||
if err := c.client.Set(ctx, fullKey, data, c.ttl).Err(); err != nil {
|
||||
c.logger.Warn("cache set failed", "key", fullKey, "error", err)
|
||||
}
|
||||
|
|
@ -140,7 +140,7 @@ func (c *Cache) Invalidate(ctx context.Context, key string) {
|
|||
if !c.Enabled() {
|
||||
return
|
||||
}
|
||||
fullKey := "kafka:" + key
|
||||
fullKey := "samsa:" + key
|
||||
c.client.Del(ctx, fullKey)
|
||||
}
|
||||
|
||||
|
|
|
|||
6
internal/cache/cache_test.go
vendored
6
internal/cache/cache_test.go
vendored
|
|
@ -3,13 +3,13 @@ package cache
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
func TestKey_Deterministic(t *testing.T) {
|
||||
req := contracts.SearchRequest{
|
||||
Format: contracts.FormatJSON,
|
||||
Query: "kafka metamorphosis",
|
||||
Query: "samsa metamorphosis",
|
||||
Pageno: 1,
|
||||
Safesearch: 0,
|
||||
Language: "auto",
|
||||
|
|
@ -29,7 +29,7 @@ func TestKey_Deterministic(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestKey_DifferentQueries(t *testing.T) {
|
||||
reqA := contracts.SearchRequest{Query: "kafka", Format: contracts.FormatJSON}
|
||||
reqA := contracts.SearchRequest{Query: "samsa", Format: contracts.FormatJSON}
|
||||
reqB := contracts.SearchRequest{Query: "orwell", Format: contracts.FormatJSON}
|
||||
|
||||
if Key(reqA) == Key(reqB) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -23,10 +23,10 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/metamorphosis-dev/kafka/internal/util"
|
||||
"github.com/metamorphosis-dev/samsa/internal/util"
|
||||
)
|
||||
|
||||
// Config is the top-level configuration for the kafka service.
|
||||
// Config is the top-level configuration for the samsa service.
|
||||
type Config struct {
|
||||
Server ServerConfig `toml:"server"`
|
||||
Upstream UpstreamConfig `toml:"upstream"`
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -28,7 +28,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
func TestArxivEngine_Search(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -28,7 +28,7 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
// BingEngine searches Bing via the public Bing API.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -18,7 +18,7 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
// BingImagesEngine searches Bing Images via their public RSS endpoint.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
func TestBingEngine_EmptyQuery(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
type BraveEngine struct {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -27,7 +27,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
// BraveEngine implements the Brave Web Search API.
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
func TestBraveEngine_GatingAndHeader(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -27,7 +27,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
type CrossrefEngine struct {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
func TestCrossrefEngine_Search(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -19,7 +19,7 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
// DuckDuckGoImagesEngine searches DuckDuckGo Images via their vql API.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -25,7 +25,7 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
// DuckDuckGoEngine searches DuckDuckGo's Lite/HTML endpoint.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -21,7 +21,7 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
// parseDuckDuckGoHTML parses DuckDuckGo Lite's HTML response for search results.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
func TestDuckDuckGoEngine_EmptyQuery(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -19,7 +19,7 @@ package engines
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
// Engine is a Go-native implementation of a search engine.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -21,7 +21,7 @@ import (
|
|||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/config"
|
||||
"github.com/metamorphosis-dev/samsa/internal/config"
|
||||
)
|
||||
|
||||
// NewDefaultPortedEngines returns the Go-native engine registry.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -27,7 +27,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
// GitHubEngine searches GitHub repositories and code via the public search API.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
func TestGitHubEngine_EmptyQuery(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -25,13 +25,13 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
// googleUserAgent is an honest User-Agent identifying the metasearch engine.
|
||||
// Using a spoofed GSA User-Agent violates Google's Terms of Service and
|
||||
// risks permanent IP blocking.
|
||||
var googleUserAgent = "Kafka/0.1 (compatible; +https://github.com/metamorphosis-dev/kafka)"
|
||||
var googleUserAgent = "Kafka/0.1 (compatible; +https://github.com/metamorphosis-dev/samsa)"
|
||||
|
||||
type GoogleEngine struct {
|
||||
client *http.Client
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -20,7 +20,7 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
var defaultPortedEngines = []string{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -26,7 +26,7 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -18,7 +18,7 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
// QwantImagesEngine searches Qwant Images via the v3 search API.
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
func TestQwantEngine_WebLite(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
func TestQwantEngine_Web(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -26,7 +26,7 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
// RedditEngine searches Reddit posts via the public JSON API.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
func TestRedditEngine_EmptyQuery(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -27,7 +27,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
const stackOverflowAPIBase = "https://api.stackexchange.com/2.3"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -23,7 +23,7 @@ import (
|
|||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
func TestStackOverflow_Name(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -26,7 +26,7 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
type WikipediaEngine struct {
|
||||
|
|
@ -108,7 +108,7 @@ func (e *WikipediaEngine) Search(ctx context.Context, req contracts.SearchReques
|
|||
// Wikimedia APIs require a descriptive User-Agent.
|
||||
httpReq.Header.Set(
|
||||
"User-Agent",
|
||||
"gosearch-go/0.1 (compatible; +https://github.com/metamorphosis-dev/kafka)",
|
||||
"gosearch-go/0.1 (compatible; +https://github.com/metamorphosis-dev/samsa)",
|
||||
)
|
||||
// Best-effort: hint content language.
|
||||
if req.Language != "" && req.Language != "auto" {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
func TestWikipediaEngine_Search(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -27,7 +27,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
type YouTubeEngine struct {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -22,9 +22,9 @@ import (
|
|||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/kafka/internal/search"
|
||||
"github.com/metamorphosis-dev/kafka/internal/views"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/search"
|
||||
"github.com/metamorphosis-dev/samsa/internal/views"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -24,9 +24,9 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/kafka/internal/httpapi"
|
||||
"github.com/metamorphosis-dev/kafka/internal/search"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/httpapi"
|
||||
"github.com/metamorphosis-dev/samsa/internal/search"
|
||||
)
|
||||
|
||||
// mockUpstreamHandler returns controlled JSON responses.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -21,7 +21,7 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
// MergeResponses merges multiple compatible JSON responses.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
func TestMergeResponses_DedupResultsAndSets(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -127,7 +127,7 @@ func writeCSV(w http.ResponseWriter, resp SearchResponse) error {
|
|||
|
||||
func writeRSS(w http.ResponseWriter, resp SearchResponse) error {
|
||||
q := resp.Query
|
||||
escapedTitle := xmlEscape("kafka search: " + q)
|
||||
escapedTitle := xmlEscape("samsa search: " + q)
|
||||
escapedDesc := xmlEscape("Search results for \"" + q + "\" - kafka")
|
||||
escapedQueryTerms := xmlEscape(q)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -22,11 +22,11 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/cache"
|
||||
"github.com/metamorphosis-dev/kafka/internal/config"
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/kafka/internal/engines"
|
||||
"github.com/metamorphosis-dev/kafka/internal/upstream"
|
||||
"github.com/metamorphosis-dev/samsa/internal/cache"
|
||||
"github.com/metamorphosis-dev/samsa/internal/config"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/engines"
|
||||
"github.com/metamorphosis-dev/samsa/internal/upstream"
|
||||
)
|
||||
|
||||
type ServiceConfig struct {
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/kafka/internal/engines"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/engines"
|
||||
)
|
||||
|
||||
// mockEngine is a test engine that returns a predefined response or error.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package search
|
||||
|
||||
import "github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
import "github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
|
||||
// Re-export the JSON contract types so the rest of the code can stay in the
|
||||
// `internal/search` namespace without creating an import cycle.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -27,7 +27,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="referrer" content="no-referrer">
|
||||
<meta name="robots" content="noarchive">
|
||||
<meta name="description" content="kafka — a privacy-respecting, open metasearch engine">
|
||||
<title>{{if .Query}}{{.Query}} — {{end}}kafka</title>
|
||||
<link rel="stylesheet" href="/static/css/kafka.css">
|
||||
<meta name="description" content="samsa — a privacy-respecting, open metasearch engine">
|
||||
<title>{{if .Query}}{{.Query}} — {{end}}samsa</title>
|
||||
<link rel="stylesheet" href="/static/css/samsa.css">
|
||||
<link rel="icon" href="/static/img/favicon.svg" type="image/svg+xml">
|
||||
<link title="kafka" type="application/opensearchdescription+xml" rel="search" href="/opensearch.xml">
|
||||
<script>var s=document.documentElement;s.setAttribute('data-theme',localStorage.getItem('kafka-theme')||'light');</script>
|
||||
<link title="samsa" type="application/opensearchdescription+xml" rel="search" href="/opensearch.xml">
|
||||
<meta name="samsa" content="samsa">
|
||||
<script>var s=document.documentElement;s.setAttribute('data-theme',localStorage.getItem('samsa-theme')||'light');</script>
|
||||
</head>
|
||||
<body>
|
||||
<header class="site-header">
|
||||
|
|
@ -20,7 +21,7 @@
|
|||
<circle cx="11" cy="11" r="8"/>
|
||||
<path d="m21 21-4.35-4.35"/>
|
||||
</svg>
|
||||
<span class="site-name">kafka</span>
|
||||
<span class="site-name">samsa</span>
|
||||
</a>
|
||||
<a href="/preferences" class="settings-link" title="Preferences">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
|
|
@ -35,7 +36,7 @@
|
|||
</main>
|
||||
|
||||
<footer>
|
||||
<p>Powered by <a href="https://git.ashisgreat.xyz/penal-colony/kafka">kafka</a> — a privacy-respecting, open metasearch engine{{if .SourceURL}} · <a href="{{.SourceURL}}">Source</a>{{end}} · <a href="https://www.gnu.org/licenses/agpl-3.0.html">AGPLv3</a></p>
|
||||
<p>Powered by <a href="https://git.ashisgreat.xyz/penal-colony/samsa">samsa</a> — a privacy-respecting, open metasearch engine{{if .SourceURL}} · <a href="{{.SourceURL}}">Source</a>{{end}} · <a href="https://www.gnu.org/licenses/agpl-3.0.html">AGPLv3</a></p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<circle cx="11" cy="11" r="8"/>
|
||||
<path d="m21 21-4.35-4.35"/>
|
||||
</svg>
|
||||
<span class="home-logo-text">kafka</span>
|
||||
<span class="home-logo-text">samsa</span>
|
||||
</a>
|
||||
<p class="home-tagline">Private meta-search, powered by open source.</p>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
|
||||
<ShortName>kafka</ShortName>
|
||||
<ShortName>samsa</ShortName>
|
||||
<Description>A privacy-respecting, open metasearch engine</Description>
|
||||
<InputEncoding>UTF-8</InputEncoding>
|
||||
<OutputEncoding>UTF-8</OutputEncoding>
|
||||
<LongName>kafka — Privacy-respecting metasearch</LongName>
|
||||
<LongName>samsa — Privacy-respecting metasearch</LongName>
|
||||
<Image width="16" height="16" type="image/svg+xml">/static/img/favicon.svg</Image>
|
||||
<Contact>https://git.ashisgreat.xyz/penal-colony/kafka</Contact>
|
||||
<Contact>https://git.ashisgreat.xyz/penal-colony/samsa</Contact>
|
||||
<Url type="text/html" method="GET" template="{baseUrl}/search?q={searchTerms}&format=html">
|
||||
<Param name="pageno" value="{startPage?}" />
|
||||
<Param name="language" value="{language?}" />
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@
|
|||
var themeButtons = document.querySelectorAll('.theme-btn');
|
||||
|
||||
// Load saved theme
|
||||
var savedTheme = localStorage.getItem('kafka-theme') || 'light';
|
||||
var savedTheme = localStorage.getItem('samsa-theme') || 'light';
|
||||
themeInput.value = savedTheme;
|
||||
document.querySelectorAll('.theme-btn').forEach(function(btn) {
|
||||
btn.classList.toggle('active', btn.dataset.theme === savedTheme);
|
||||
|
|
@ -116,12 +116,12 @@
|
|||
themeButtons.forEach(function(b) { b.classList.remove('active'); });
|
||||
btn.classList.add('active');
|
||||
document.documentElement.setAttribute('data-theme', theme);
|
||||
localStorage.setItem('kafka-theme', theme);
|
||||
localStorage.setItem('samsa-theme', theme);
|
||||
});
|
||||
});
|
||||
|
||||
// Load saved engine preferences
|
||||
var savedEngines = JSON.parse(localStorage.getItem('kafka-engines') || 'null');
|
||||
var savedEngines = JSON.parse(localStorage.getItem('samsa-engines') || 'null');
|
||||
if (savedEngines) {
|
||||
savedEngines.forEach(function(engine) {
|
||||
var checkbox = document.querySelector('input[name="engine"][value="' + engine.id + '"]');
|
||||
|
|
@ -135,7 +135,7 @@
|
|||
document.querySelectorAll('input[name="engine"]').forEach(function(cb) {
|
||||
engines.push({ id: cb.value, enabled: cb.checked });
|
||||
});
|
||||
localStorage.setItem('kafka-engines', JSON.stringify(engines));
|
||||
localStorage.setItem('samsa-engines', JSON.stringify(engines));
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<circle cx="11" cy="11" r="8"/>
|
||||
<path d="m21 21-4.35-4.35"/>
|
||||
</svg>
|
||||
<span>kafka</span>
|
||||
<span>samsa</span>
|
||||
</a>
|
||||
|
||||
<form class="header-search" method="GET" action="/search" role="search">
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// kafka — a privacy-respecting metasearch engine
|
||||
// samsa — a privacy-respecting metasearch engine
|
||||
// Copyright (C) 2026-present metamorphosis-dev
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -26,8 +26,8 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/kafka/internal/util"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/util"
|
||||
)
|
||||
|
||||
//go:embed all:templates
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package views
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/metamorphosis-dev/kafka/internal/contracts"
|
||||
"github.com/metamorphosis-dev/samsa/internal/contracts"
|
||||
)
|
||||
|
||||
func mockSearchResponse(query string, numResults int) contracts.SearchResponse {
|
||||
|
|
@ -36,10 +36,10 @@ func mockEmptyResponse() contracts.SearchResponse {
|
|||
}
|
||||
|
||||
func TestFromResponse_Basic(t *testing.T) {
|
||||
resp := mockSearchResponse("kafka trial", 42)
|
||||
data := FromResponse(resp, "kafka trial", 1, "", "", "")
|
||||
resp := mockSearchResponse("samsa trial", 42)
|
||||
data := FromResponse(resp, "samsa trial", 1, "", "", "")
|
||||
|
||||
if data.Query != "kafka trial" {
|
||||
if data.Query != "samsa trial" {
|
||||
t.Errorf("expected query 'kafka trial', got %q", data.Query)
|
||||
}
|
||||
if data.NumberOfResults != 42 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue