- Search can be narrowed by space, author and last change; the index records a mapping version and rebuilds when it changes. - Editors can pin up to 12 pages to a space's home. - Find and replace in the editor (Ctrl+F), with match case. - Pages can be set to full width and a serif or mono font. - Tailwind now scans the editor package, so its classes are generated. - Fix golangci-lint findings, including push device names that were saved before being trimmed and capped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
31 lines
938 B
Go
31 lines
938 B
Go
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
package httpapi
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"docwell/server/internal/access"
|
|
"docwell/server/internal/directory"
|
|
)
|
|
|
|
// SearchService is the part of directory.Service that searches pages.
|
|
type SearchService interface {
|
|
Search(ctx context.Context, c access.Caller, wsID string, q directory.SearchQuery) (directory.SearchResult, error)
|
|
}
|
|
|
|
func (a *api) searchRoutes(mux *routeMux) {
|
|
mux.HandleFunc("GET /api/v1/workspaces/{id}/search", a.requireUser(func(w http.ResponseWriter, r *http.Request) {
|
|
q := r.URL.Query()
|
|
limit, _ := strconv.Atoi(q.Get("limit"))
|
|
res, err := a.dir.Search(r.Context(), caller(r), r.PathValue("id"), directory.SearchQuery{
|
|
Text: q.Get("q"), Space: q.Get("space"), Author: q.Get("author"),
|
|
UpdatedAfter: q.Get("updatedAfter"), UpdatedBefore: q.Get("updatedBefore"),
|
|
Limit: min(max(limit, 0), 50),
|
|
})
|
|
a.respond(w, res, err)
|
|
}))
|
|
}
|