diff options
Diffstat (limited to 'tissue/document.scm')
-rw-r--r-- | tissue/document.scm | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/tissue/document.scm b/tissue/document.scm index 48d82cc..1e55e67 100644 --- a/tissue/document.scm +++ b/tissue/document.scm @@ -43,12 +43,12 @@ document-snippet-source-text document-snippet print - document-sxml-snippet - document->sxml)) + document-sxml-snippet)) (define (slot-set object slot-name value) - "Set SLOT-NAME in OBJECT to VALUE. This is a purely functional setter -that operates on a copy of OBJECT. It does not mutate OBJECT." + "Set @var{slot-name} in @var{object} to @var{value}. This is a purely +functional setter that operates on a copy of @var{object}. It does not +mutate @var{object}." (let ((clone (shallow-clone object))) (slot-set! clone slot-name value) clone)) @@ -87,7 +87,8 @@ that operates on a copy of OBJECT. It does not mutate OBJECT." (define (object->scm object) "Convert GOOPS OBJECT to a serializable object." (cond - ((or (string? object) + ((or (symbol? object) + (string? object) (number? object) (boolean? object)) object) @@ -107,7 +108,8 @@ that operates on a copy of OBJECT. It does not mutate OBJECT." (define (scm->object scm) "Convert serializable object SCM to a GOOPS object." (cond - ((or (string? scm) + ((or (symbol? scm) + (string? scm) (number? scm) (boolean? scm)) scm) @@ -131,13 +133,14 @@ that operates on a copy of OBJECT. It does not mutate 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) (define-generic document-recency-date) (define-generic print) -(define-generic document->sxml) (define-method (document-type (document <document>)) (string-trim-both (symbol->string (class-name (class-of document))) @@ -172,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>" |