pull/9/head
Matthew Butterick 11 years ago
parent 139af0a22f
commit db44ef7eff

@ -61,6 +61,12 @@
(define (make-debug-timestamp) (define (make-debug-timestamp)
(format "[~a ∆~as]" (make-timestamp) (seconds-since-last-message))) (format "[~a ∆~as]" (make-timestamp) (seconds-since-last-message)))
;; todo: consolidate these two message functions
(define (basic-message . items)
(displayln (string-join `(,@(map (λ(x)(if (string? x) x (~v x))) items))) (current-error-port)))
(define (message . items) (define (message . items)
(displayln (string-join `(,(make-debug-timestamp) ,@(map (λ(x)(if (string? x) x (~v x))) items))) (current-error-port))) (displayln (string-join `(,(make-debug-timestamp) ,@(map (λ(x)(if (string? x) x (~v x))) items))) (current-error-port)))
@ -68,5 +74,5 @@
; report the current value of the variable, then return it ; report the current value of the variable, then return it
(define-syntax-rule (report var) (define-syntax-rule (report var)
(begin (begin
(message 'var "=" var) (basic-message 'var "=" var)
var)) var))

@ -45,7 +45,7 @@
(module+ test (module+ test
(check-true (directory-pathish? "/Users/")) (check-true (directory-pathish? "/Users/"))
(check-false (directory-pathish? "foobar"))) (check-false (directory-pathish? "foobarzooblish")))
;; helper function for ptree ;; helper function for ptree
@ -70,7 +70,7 @@
(module+ test (module+ test
(define foo-path-strings '("foo" "foo.txt" "foo.bar" "foo.bar.txt")) (define foo-path-strings '("foo" "foo.txt" "foo.bar" "foo.bar.txt"))
(define-values (foo-path foo.txt-path foo.bar-path foo.bar.txt-path) (define-values (foo-path foo.txt-path foo.bar-path foo.bar.txt-path)
(apply values (map string->path foo-path-strings))) (apply values (map ->path foo-path-strings)))
;; test the sample paths before using them for other tests ;; test the sample paths before using them for other tests
(define foo-paths (list foo-path foo.txt-path foo.bar-path foo.bar.txt-path)) (define foo-paths (list foo-path foo.txt-path foo.bar-path foo.bar.txt-path))
(for-each check-equal? (map ->string foo-paths) foo-path-strings)) (for-each check-equal? (map ->string foo-paths) foo-path-strings))

@ -0,0 +1 @@
world 10201

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

@ -1,22 +1,36 @@
#lang racket/base #lang racket/base
(require racket/list racket/set) (require racket/list racket/set)
(require "readability.rkt" "file-tools.rkt" "world.rkt") (require "readability.rkt" "file-tools.rkt" "world.rkt" "debug.rkt")
(define (pd which) (define (pd which)
(->path (format "/Users/MB/git/~a" which))) (->path (format "/Users/MB/git/pollen/~a" which)))
(define (ineligible-path? f)
(or (not (visible? f)) (member f RESERVED_PATHS)))
(define (unique-members xs)
(set->list (list->set xs)))
(define (route-index [dir pollen-project-directory]) (define (route-index [dir pollen-project-directory])
(define unique-eligible-paths (define (make-link-cell [href+text (cons #f #f)])
(unique-members (map ->output-path (define href (car href+text))
(filter-not ineligible-path? (directory-list dir))))) (define text (cdr href+text))
unique-eligible-paths) (filter-not void? `(td ,(when (and href text)
`(a ((href ,href)) ,text)))))
(define (make-path-row p)
(define pstring (->string p))
(define (file-in-dir? p) (file-exists? (apply build-path (map ->path (list dir p)))))
(define sources (filter file-in-dir? (list (->preproc-source-path pstring) (->pollen-source-path pstring))))
`(tr ,@(map make-link-cell (list
(cons pstring pstring)
(cons (format "raw/~a" pstring) "raw")
(if (not (empty? sources))
(cons (->string (car sources)) "source")
(cons #f #f))))))
(define (unique-sorted-paths xs)
(sort (set->list (list->set (map ->output-path xs))) #:key ->string string<?))
(define (ineligible-path? x) (or (not (visible? x)) (member x RESERVED_PATHS)))
(define project-paths (filter-not ineligible-path? (directory-list dir)))
`(table ,@(map make-path-row (unique-sorted-paths project-paths))))
(route-index (pd "foobar")) (route-index (pd "foobar"))

@ -34,7 +34,9 @@
(require racket/string racket/port racket/system) (require racket/string racket/port racket/system)
;; todo: is path to racket already available as an environment variable? ;; todo: is path to racket already available as an environment variable?
(define RACKET_PATH (string-trim (with-output-to-string (λ() (system "which racket"))))) ;; e.g., (find-system-path 'xxx)?
;;(define RACKET_PATH (string-trim (with-output-to-string (λ() (system "which racket")))))
(define RACKET_PATH "/usr/bin/racket")
(define POLLEN_ROOT 'main) (define POLLEN_ROOT 'main)
(define POLLEN_COMMAND_FILE "polcom") (define POLLEN_COMMAND_FILE "polcom")
@ -51,3 +53,5 @@
(require "readability.rkt") (require "readability.rkt")
(define RESERVED_PATHS (define RESERVED_PATHS
(map ->path (list POLLEN_COMMAND_FILE EXTRAS_DIR))) (map ->path (list POLLEN_COMMAND_FILE EXTRAS_DIR)))

Loading…
Cancel
Save