asset: Filter out assets that do not pass the site file filter.
* haunt/asset.scm (directory-assets): Add 'keep?' argument. (static-directory): Use site file filter.
This commit is contained in:
		@@ -55,9 +55,9 @@ PREFIX."
 | 
				
			|||||||
       (mkdir-p (dirname target*))
 | 
					       (mkdir-p (dirname target*))
 | 
				
			||||||
       (copy-file source target*)))))
 | 
					       (copy-file source target*)))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(define (directory-assets directory dest)
 | 
					(define (directory-assets directory keep? dest)
 | 
				
			||||||
  "Create a list of asset objects to be stored within DEST for all
 | 
					  "Create a list of asset objects to be stored within DEST for all
 | 
				
			||||||
files in DIRECTORY, recursively."
 | 
					files in DIRECTORY that match KEEP?, recursively."
 | 
				
			||||||
  (define enter? (const #t))
 | 
					  (define enter? (const #t))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ;; In order to do accurate file name manipulation, every file name
 | 
					  ;; In order to do accurate file name manipulation, every file name
 | 
				
			||||||
@@ -67,10 +67,12 @@ files in DIRECTORY, recursively."
 | 
				
			|||||||
    (let ((base-length (length (file-name-components directory)))
 | 
					    (let ((base-length (length (file-name-components directory)))
 | 
				
			||||||
          (dest* (file-name-components dest)))
 | 
					          (dest* (file-name-components dest)))
 | 
				
			||||||
      (lambda (file-name stat memo)
 | 
					      (lambda (file-name stat memo)
 | 
				
			||||||
 | 
					        (if (keep? file-name)
 | 
				
			||||||
            (let* ((file-name* (file-name-components file-name))
 | 
					            (let* ((file-name* (file-name-components file-name))
 | 
				
			||||||
                   (target (join-file-name-components
 | 
					                   (target (join-file-name-components
 | 
				
			||||||
                            (append dest* (drop file-name* base-length)))))
 | 
					                            (append dest* (drop file-name* base-length)))))
 | 
				
			||||||
          (cons (make-asset file-name target) memo)))))
 | 
					              (cons (make-asset file-name target) memo))
 | 
				
			||||||
 | 
					            memo))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  (define (noop file-name stat memo) memo)
 | 
					  (define (noop file-name stat memo) memo)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,7 @@
 | 
				
			|||||||
  #:use-module (ice-9 ftw)
 | 
					  #:use-module (ice-9 ftw)
 | 
				
			||||||
  #:use-module (ice-9 match)
 | 
					  #:use-module (ice-9 match)
 | 
				
			||||||
  #:use-module (haunt asset)
 | 
					  #:use-module (haunt asset)
 | 
				
			||||||
 | 
					  #:use-module (haunt site)
 | 
				
			||||||
  #:export (static-directory))
 | 
					  #:export (static-directory))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(define* (static-directory directory #:optional (dest directory))
 | 
					(define* (static-directory directory #:optional (dest directory))
 | 
				
			||||||
@@ -35,5 +36,5 @@
 | 
				
			|||||||
in DIRECTORY, a file names relative to a site's source directory, and
 | 
					in DIRECTORY, a file names relative to a site's source directory, and
 | 
				
			||||||
copies them into DEST, a prefix relative to a site's target output
 | 
					copies them into DEST, a prefix relative to a site's target output
 | 
				
			||||||
directory.  By default, DEST is DIRECTORY."
 | 
					directory.  By default, DEST is DIRECTORY."
 | 
				
			||||||
  (lambda _
 | 
					  (lambda (site posts)
 | 
				
			||||||
    (directory-assets directory dest)))
 | 
					    (directory-assets directory (site-file-filter site) dest)))
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user