this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: include quotes in web UI search results

Search handler only queried links, ignoring quotes entirely.
Now fetches both links and quotes, merges them sorted by
timestamp descending, and renders with date grouping.

+60 -3
+60 -3
internal/handler/handlers.go
··· 553 553 return 554 554 } 555 555 556 + quotes, err := h.Store.SearchQuotes(ctx, query, data.ClientFilter{}) 557 + if err != nil { 558 + h.ServerError(w, r, err) 559 + return 560 + } 561 + 556 562 containerHTML := "" 557 - if len(links) > 0 { 563 + if len(links) > 0 || len(quotes) > 0 { 564 + // Process all items into DisplayItems 565 + var allItems []service.DisplayItem 558 566 for _, item := range links { 559 - d := h.Service.ProcessIRCLink(item) 560 - s, _ := h.Renderer.RenderToString("tumble_item_ircLink.html", d) 567 + allItems = append(allItems, h.Service.ProcessIRCLink(item)) 568 + } 569 + for _, item := range quotes { 570 + allItems = append(allItems, h.Service.ProcessQuote(item)) 571 + } 572 + 573 + // Sort by timestamp descending (newest first) 574 + sort.Slice(allItems, func(i, j int) bool { 575 + return allItems[i].Timestamp.After(allItems[j].Timestamp) 576 + }) 577 + 578 + // Render items with date grouping 579 + lastDate := "" 580 + sectionOpen := false 581 + for _, item := range allItems { 582 + var tmplName string 583 + switch item.Type { 584 + case "ircLink": 585 + tmplName = "tumble_item_ircLink.html" 586 + case "quote": 587 + tmplName = "tumble_item_quote.html" 588 + } 589 + 590 + if item.FullDate != lastDate { 591 + if sectionOpen { 592 + containerHTML += "</div>" 593 + } 594 + containerHTML += fmt.Sprintf(`<div class="date-section" data-date="%s">`, item.FullDate) 595 + sectionOpen = true 596 + 597 + dateData := map[string]string{ 598 + "Date": item.DateRawDay, 599 + "Day": item.DateDay, 600 + "Month": item.DateMonth, 601 + "Year": item.DateYear, 602 + } 603 + dateHTML, err := h.Renderer.RenderToString("tumble_date.html", dateData) 604 + if err == nil { 605 + containerHTML += dateHTML 606 + } 607 + lastDate = item.FullDate 608 + } 609 + 610 + s, err := h.Renderer.RenderToString(tmplName, item) 611 + if err != nil { 612 + slog.Debug("Render Error", "type", item.Type, "id", item.ID, "error", err) 613 + continue 614 + } 561 615 containerHTML += s 616 + } 617 + if sectionOpen { 618 + containerHTML += "</div>" 562 619 } 563 620 } else { 564 621 // Use the new no_search_results template