Skip to content

Commit

Permalink
Further cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
svera committed Dec 9, 2024
1 parent 4b69283 commit cda158d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion internal/webserver/controller/author/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Sender interface {
From() string
}

// IdxReader defines a set of reading and writing operations over an index
// IdxReader defines a set of author reading operations over an index
type IdxReader interface {
SearchByAuthor(authorSlug string, page, resultsPerPage int) (result.Paginated[[]index.Document], error)
Author(slug string) (index.Author, error)
Expand Down
16 changes: 8 additions & 8 deletions internal/webserver/controller/author/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"github.com/svera/coreander/v4/internal/webserver/view"
)

func (d *Controller) Search(c *fiber.Ctx) error {
func (a *Controller) Search(c *fiber.Ctx) error {
emailSendingConfigured := true
if _, ok := d.sender.(*infrastructure.NoEmail); ok {
if _, ok := a.sender.(*infrastructure.NoEmail); ok {
emailSendingConfigured = false
}

Expand All @@ -25,7 +25,7 @@ func (d *Controller) Search(c *fiber.Ctx) error {
}

if session.WordsPerMinute > 0 {
d.config.WordsPerMinute = session.WordsPerMinute
a.config.WordsPerMinute = session.WordsPerMinute
}

var searchResults result.Paginated[[]index.Document]
Expand All @@ -40,14 +40,14 @@ func (d *Controller) Search(c *fiber.Ctx) error {
page = 1
}

author, _ := d.idx.Author(authorSlug)
if searchResults, err = d.idx.SearchByAuthor(authorSlug, page, model.ResultsPerPage); err != nil {
author, _ := a.idx.Author(authorSlug)
if searchResults, err = a.idx.SearchByAuthor(authorSlug, page, model.ResultsPerPage); err != nil {
log.Println(err)
return fiber.ErrInternalServerError
}

if session.ID > 0 {
searchResults = d.hlRepository.HighlightedPaginatedResult(int(session.ID), searchResults)
searchResults = a.hlRepository.HighlightedPaginatedResult(int(session.ID), searchResults)
}

err = c.Render("author/results", fiber.Map{
Expand All @@ -56,8 +56,8 @@ func (d *Controller) Search(c *fiber.Ctx) error {
"Paginator": view.Pagination(model.MaxPagesNavigator, searchResults, map[string]string{}),
"Title": fmt.Sprintf("Coreander - %s", author.Name),
"EmailSendingConfigured": emailSendingConfigured,
"EmailFrom": d.sender.From(),
"WordsPerMinute": d.config.WordsPerMinute,
"EmailFrom": a.sender.From(),
"WordsPerMinute": a.config.WordsPerMinute,
}, "layout")

if err != nil {
Expand Down
8 changes: 1 addition & 7 deletions internal/webserver/controller/document/detail.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,8 @@ func (d *Controller) Detail(c *fiber.Ctx) error {
}

title := fmt.Sprintf("%s | Coreander", document.Title)
authorsString := ""
if len(document.Authors) > 0 {
authors := make([]string, len(document.Authors))
for i, author := range document.Authors {
authors[i] = author
}
authorsString = strings.Join(authors, ", ")
title = fmt.Sprintf("%s - %s | Coreander", authorsString, document.Title)
title = fmt.Sprintf("%s - %s | Coreander", strings.Join(document.Authors, ", "), document.Title)
}

sameSubjects, err := d.idx.SameSubjects(document.Slug, relatedDocuments)
Expand Down

0 comments on commit cda158d

Please sign in to comment.