[rss: Better special file handling clinton@unknownlamer.org**20110316052503 Ignore-this: 6532ebc5d548027c373580cd9b6888c3 * Permit wild pathnames and more flexible conversion * Take advantage of `directory' and greatly simplify the code generating files to check for changes * Add qbrew recipes to special files ] { hunk ./rss.lisp 30 +;; pathname, pathname -> web accesible page +(defstruct special-file + path + conversion) + hunk ./rss.lisp 36 - '(("book-list.lisp" . "Book List"))) + (list (make-special-file :path (make-pathname :name "book-list" :type "lisp") + :conversion (lambda (path) (declare (ignorable path)) + "Book List.html")) + (make-special-file :path (make-pathname + :name :wild + :type "qbrew" + :directory '(:relative "beer-recipes" :wild)) + :conversion (lambda (path) + (namestring (merge-pathnames + (make-pathname :type "html") + path)))))) + hunk ./rss.lisp 139 - (when-bind basename (or (ppcre:register-groups-bind (basename) - (*muse-file-scanner* potential-muse-path) - basename) - (cdar (member potential-muse-path *special-files* - :key #'car :test #'string=))) - (format nil "http://unknownlamer.org/muse/~A.html" + (when-bind basename (or + (arnesi:aand (ppcre:register-groups-bind (basename) + (*muse-file-scanner* potential-muse-path) + basename) + (format nil "~A.html" arnesi:it)) + (if-bind sf (car (member potential-muse-path *special-files* + :key (compose #'namestring + #'special-file-path) + :test #'pathname-match-p)) + (funcall (special-file-conversion sf) + potential-muse-path))) + (format nil "http://unknownlamer.org/muse/~A" hunk ./rss.lisp 223 - (let ((dirlist (fad:list-directory - *repo-path*)) - (wild-path (make-pathname :type "muse"))) - (mapcan (lambda (path) - (if (pathname-match-p path wild-path) - (list path))) - dirlist)) - (mapcar (lambda (file) - ;; note: assumes only one . in the filename - ;; (this is true ... for now) - (let ((split-file (split-sequence #\. (car file)))) - (merge-pathnames - (make-pathname :name (first split-file) - :type (second split-file)) - *repo-path*))) - *special-files*)))) + (directory (merge-pathnames (make-pathname :type "muse" + :name :wild) + *repo-path*)) + (alexandria:mappend (lambda (special-file) + (directory (merge-pathnames + (special-file-path special-file) + *repo-path*))) + *special-files*)))) + #+nil(break "files = ~A" files) }