From ed0eca8f766f24f63cc43a39289fd56fc9617588 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 10 Dec 2025 09:07:07 +0000 Subject: [PATCH 1/4] Fix search output format and remove dead secrets code - Updated `GetBibleSearch` in `pkg/app/search.go` to return HTML anchor tags for verses. - Updated `pkg/app/search_test.go` to verify the new HTML format. - Removed `secrets.yaml` generation in `.github/workflows/deployment.yml`. - Removed `secrets.yaml` copy instruction in `Dockerfile`. --- .github/workflows/deployment.yml | 2 -- Dockerfile | 1 - pkg/app/search.go | 7 +++++-- pkg/app/search_test.go | 5 +++++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index fbd2195..9341dce 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -37,8 +37,6 @@ jobs: - name: Docker Build and Stage run: | - printf "TELEGRAM_ID: \"$TELEGRAM_ID\"\nADMIN_ID: \"$ADMIN_ID\"\nGCLOUD_PROJECT_ID: \"$GCLOUD_PROJECT_ID\"\n" >> secrets.yaml - cat secrets.yaml docker build --build-arg GCLOUD_PROJECT_ID=$GCLOUD_PROJECT_ID -f Dockerfile -t $GCLOUD_REGION-docker.pkg.dev/$GCLOUD_PROJECT_ID/$ARTIFACT_ID/root:latest . docker push $GCLOUD_REGION-docker.pkg.dev/$GCLOUD_PROJECT_ID/$ARTIFACT_ID/root:latest diff --git a/Dockerfile b/Dockerfile index a91057b..678b4da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,6 @@ FROM scratch AS runner ARG GCLOUD_PROJECT_ID ENV GCLOUD_PROJECT_ID=$GCLOUD_PROJECT_ID -COPY --from=builder /go/src/app/secrets.yaml /go/bin/secrets.yaml COPY --from=builder /go/src/app/resource/* /go/bin/ COPY --from=builder /go/bin/main /go/bin/main COPY --from=certificates /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt diff --git a/pkg/app/search.go b/pkg/app/search.go index 383d410..c3f68db 100644 --- a/pkg/app/search.go +++ b/pkg/app/search.go @@ -49,8 +49,11 @@ func GetBibleSearch(env def.SessionData) def.SessionData { var sb strings.Builder sb.WriteString(fmt.Sprintf("Found %d results for '%s':\n", len(resp), env.Msg.Message)) for _, res := range resp { - // Format: - Verse (URL) - sb.WriteString(fmt.Sprintf("- %s\n", res.Verse)) + if res.URL != "" { + sb.WriteString(fmt.Sprintf("- %s\n", res.URL, res.Verse)) + } else { + sb.WriteString(fmt.Sprintf("- %s\n", res.Verse)) + } } env.Res.Message = sb.String() } else { diff --git a/pkg/app/search_test.go b/pkg/app/search_test.go index acbf405..b37c842 100644 --- a/pkg/app/search_test.go +++ b/pkg/app/search_test.go @@ -67,5 +67,10 @@ func TestGetBibleSearch(t *testing.T) { if !strings.Contains(env.Res.Message, "Found") && !strings.Contains(env.Res.Message, "No results") { t.Errorf("Expected result count, got: %s", env.Res.Message) } + + expected := `- John 3:16` + if !strings.Contains(env.Res.Message, expected) { + t.Errorf("Expected HTML link in response, got: %s", env.Res.Message) + } }) } From 77d13506b7a5899b54242d7657591c4df66b2ba3 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 10 Dec 2025 09:17:36 +0000 Subject: [PATCH 2/4] Fix search output format and remove dead secrets code - Updated `GetBibleSearch` in `pkg/app/search.go` to return HTML anchor tags for verses. - Updated `pkg/app/search_test.go` and `pkg/app/ask_test.go` to verify the new HTML format. - Removed `secrets.yaml` generation in `.github/workflows/deployment.yml`. - Removed `secrets.yaml` copy instruction in `Dockerfile`. --- pkg/app/ask_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/app/ask_test.go b/pkg/app/ask_test.go index 7630c4b..f1858fd 100644 --- a/pkg/app/ask_test.go +++ b/pkg/app/ask_test.go @@ -90,7 +90,7 @@ func TestGetBibleAsk(t *testing.T) { env = GetBibleAsk(env) // Expect fallback to search - expected := "Found 1 results for 'Question':\n- John 3:16\n" + expected := "Found 1 results for 'Question':\n- John 3:16\n" if env.Res.Message != expected { t.Errorf("Expected search result message, got: %s", env.Res.Message) } From e6f95f580708b9b8ae161dd4e12076965fb8adc7 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 10 Dec 2025 09:32:03 +0000 Subject: [PATCH 3/4] Fix double newlines in poetry and restore search links - Update `pkg/app/passage.go` to prevent extra newlines after spans when followed by `
`. - Update `pkg/app/passage_test.go` with reproduction cases and updated expectations. - Update `pkg/app/search.go` to return HTML links for search results. - Update `pkg/app/search_test.go` and `pkg/app/ask_test.go` to match new search output. - Remove `secrets.yaml` related code from `deployment.yml` and `Dockerfile`. --- pkg/app/passage.go | 21 ++++++++++++++++++++- pkg/app/passage_test.go | 10 +++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/pkg/app/passage.go b/pkg/app/passage.go index c3065db..8699041 100644 --- a/pkg/app/passage.go +++ b/pkg/app/passage.go @@ -54,7 +54,26 @@ func ParseNodesForPassage(node *html.Node) string { childText := ParseNodesForPassage(child) parts = append(parts, childText) if len(strings.TrimSpace(childText)) > 0 { - parts = append(parts, "\n") + isNextBr := false + next := child.NextSibling + for next != nil { + if next.Type == html.TextNode { + if len(strings.TrimSpace(next.Data)) == 0 { + next = next.NextSibling + continue + } else { + break + } + } + if next.Data == "br" { + isNextBr = true + } + break + } + + if !isNextBr { + parts = append(parts, "\n") + } } case "sup": isFootnote := func(node *html.Node) bool { diff --git a/pkg/app/passage_test.go b/pkg/app/passage_test.go index 8496fce..13b8662 100644 --- a/pkg/app/passage_test.go +++ b/pkg/app/passage_test.go @@ -141,12 +141,20 @@ func TestParsePassageFromHtml(t *testing.T) { t.Run("HTML with spans", func(t *testing.T) { html := `

Line 1.
Line 2.

` - expected := "Line 1.\n\n Line 2." + expected := "Line 1.\n Line 2." if got := ParsePassageFromHtml("", html, ""); got != expected { t.Errorf("ParsePassageFromHtml() = %v, want %v", got, expected) } }) + t.Run("Poetry double newline check", func(t *testing.T) { + html := `

Line 1
Line 2

` + expected := "Line 1\nLine 2" + if got := ParsePassageFromHtml("", html, ""); got != expected { + t.Errorf("ParsePassageFromHtml() = %q, want %q", got, expected) + } + }) + t.Run("HTML with line breaks", func(t *testing.T) { html := `

Line 1.
Line 2.

` expected := "Line 1.\nLine 2." From 1df5bd939311d95c5e135dea98c0b63a4df1cda1 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 10 Dec 2025 09:40:32 +0000 Subject: [PATCH 4/4] Refactor poetry formatting logic to be stateless - Extracted `isNextSiblingBr` helper function in `pkg/app/passage.go`. - Simplified `ParseNodesForPassage` to use the helper function instead of inline boolean state. - Verified all tests in `pkg/app` pass. --- pkg/app/passage.go | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/pkg/app/passage.go b/pkg/app/passage.go index 8699041..963c6f1 100644 --- a/pkg/app/passage.go +++ b/pkg/app/passage.go @@ -42,6 +42,22 @@ func GetReference(doc *html.Node) string { } +func isNextSiblingBr(node *html.Node) bool { + for next := node.NextSibling; next != nil; next = next.NextSibling { + if next.Type == html.TextNode { + if len(strings.TrimSpace(next.Data)) == 0 { + continue + } + return false + } + if next.Type == html.ElementNode && next.Data == "br" { + return true + } + return false + } + return false +} + func ParseNodesForPassage(node *html.Node) string { var text string var parts []string @@ -53,27 +69,8 @@ func ParseNodesForPassage(node *html.Node) string { case "span": childText := ParseNodesForPassage(child) parts = append(parts, childText) - if len(strings.TrimSpace(childText)) > 0 { - isNextBr := false - next := child.NextSibling - for next != nil { - if next.Type == html.TextNode { - if len(strings.TrimSpace(next.Data)) == 0 { - next = next.NextSibling - continue - } else { - break - } - } - if next.Data == "br" { - isNextBr = true - } - break - } - - if !isNextBr { - parts = append(parts, "\n") - } + if len(strings.TrimSpace(childText)) > 0 && !isNextSiblingBr(child) { + parts = append(parts, "\n") } case "sup": isFootnote := func(node *html.Node) bool {