summaryrefslogtreecommitdiff
path: root/tissue/document.scm
diff options
context:
space:
mode:
authorArun Isaac2023-01-29 16:23:45 +0000
committerArun Isaac2023-01-29 16:46:38 +0000
commit8516e5d0f5b64c681d31efa2944bb9a9de32dbbc (patch)
treee8def557954f95796cb419ada71a7ed5346533c2 /tissue/document.scm
parentd5adbcf983bb2d83fd46041ad3226dd8912266a6 (diff)
downloadtissue-8516e5d0f5b64c681d31efa2944bb9a9de32dbbc.tar.gz
tissue-8516e5d0f5b64c681d31efa2944bb9a9de32dbbc.tar.lz
tissue-8516e5d0f5b64c681d31efa2944bb9a9de32dbbc.zip
document: Inter snippet source text into the xapian index.
We store snippet source text in a slot of the <document> 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 (<document>)[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.
Diffstat (limited to 'tissue/document.scm')
-rw-r--r--tissue/document.scm22
1 files changed, 10 insertions, 12 deletions
diff --git a/tissue/document.scm b/tissue/document.scm
index c05e40f..1e55e67 100644
--- a/tissue/document.scm
+++ b/tissue/document.scm
@@ -133,7 +133,9 @@ mutate @var{object}."
(define-class <document> ()
(title #:accessor document-title #:init-keyword #:title)
- (web-uri #:accessor document-web-uri #:init-keyword #:web-uri))
+ (web-uri #:accessor document-web-uri #:init-keyword #:web-uri)
+ (snippet-source-text #:accessor document-snippet-source-text
+ #:init-keyword #:snippet-source-text))
(define-generic document-id-term)
(define-generic document-text)
@@ -173,21 +175,17 @@ and further text, increase-termpos! must be called before indexing."
(index-text! term-generator (document-text document))
term-generator))
-(define-method (document-snippet-source-text (document <document>))
- "Return the source text for DOCUMENT from which to extract a search
-result snippet."
- ;; Remove blank lines from document text.
- (string-join
- (remove string-blank?
- (string-split (document-text document)
- #\newline))
- "\n"))
-
(define (document-html-snippet document mset)
"Return snippet for DOCUMENT. MSET is the xapian MSet object
representing a list of search results."
(mset-snippet mset
- (document-snippet-source-text document)
+ ;; Remove blank lines from text.
+ (string-join
+ (remove string-blank?
+ (string-split
+ (document-snippet-source-text document)
+ #\newline))
+ "\n")
#:length 200
#:highlight-start "<b>"
#:highlight-end "</b>"