add summarization for documents

This commit is contained in:
2025-01-20 20:34:23 +01:00
parent 0594fb8aeb
commit 637a5ebb0c
6 changed files with 270 additions and 9 deletions

View File

@@ -1,7 +1,6 @@
package app
import (
"crowsnest/internal/model"
"html/template"
"net/http"
)
@@ -17,19 +16,13 @@ func (app *App) UpSearch(w http.ResponseWriter, req *http.Request) {
}
// get articles
articles, err := app.articles.Search(searchTerms)
articleVMs, err := app.articles.SearchArticleViewModel(searchTerms)
if err != nil {
// treat as no result
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
// convert to viewmodel
articleVMs := make([]*model.ArticleViewModel, 0, len(articles))
for _, a := range articles {
articleVMs = append(articleVMs, a.ViewModel())
}
// render template
t := template.Must(template.ParseFiles(
"assets/templates/article.html",