From 8516e5d0f5b64c681d31efa2944bb9a9de32dbbc Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sun, 29 Jan 2023 16:23:45 +0000 Subject: document: Inter snippet source text into the xapian index. We store snippet source text in a slot of the class thus interring into the xapian index. This allows us to render search snippets using only the xapian index without referring back to the git repository. * tissue/document.scm ()[snippet-source-text]: New slot. * tissue/document.scm (document-snippet-source-text): Delete method. (document-html-snippet): Remove blank lines from snippet source text before generating a snippet. * tissue/commit.scm (document-snippet-source-text): Delete method. (repository-commits): Initialize snippet-source-text. * tissue/skribilo.scm (fragment-text): New function. (document-fragment): Initialize snippet-source-text. (document-text): Use fragment-text. (document-snippet-source-text): Delete method. * tissue/file-document.scm (file-text): New function. (document-text): Use file-text. (read-gemtext-document): Initialize snippet-source-text. * tissue/issue.scm (read-gemtext-issue): Initialize snippet-source-text. * issues/skribilo-fragment-snippets-need-code-from-repo.gmi: Close issue. --- tissue/commit.scm | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'tissue/commit.scm') diff --git a/tissue/commit.scm b/tissue/commit.scm index c151d3a..b910695 100644 --- a/tissue/commit.scm +++ b/tissue/commit.scm @@ -51,15 +51,6 @@ "Return a date representing the recency of COMMIT." (doc:commit-author-date commit)) -(define-method (document-snippet-source-text (commit )) - "Return the source text for COMMIT from which to extract a search -result snippet." - ;; The snippet source text excludes the first paragraph (i.e., the - ;; summary line) of the commit. Hence, we use commit-body. - (commit-body - (commit-lookup (current-git-repository) - (string->oid (commit-hash commit))))) - (define-method (document-text (commit )) "Return the full text of COMMIT." (commit-message @@ -101,7 +92,14 @@ REPOSITORY." #:hash (oid->string (commit-id commit)) #:author (resolve-alias (signature-name (commit-author commit)) (%aliases)) - #:author-date (commit-author-date commit)) + #:author-date (commit-author-date commit) + ;; The snippet source text excludes the + ;; first paragraph (i.e., the summary line) + ;; of the commit. Hence, we use commit-body. + #:snippet-source-text + (commit-body + (commit-lookup (current-git-repository) + (commit-id commit)))) result)) (list) repository)) -- cgit v1.2.3