pull/9/head
Matthew Butterick 11 years ago
parent 79ddd20793
commit 0ad968cd95

@ -51,10 +51,11 @@
;; helper function for ptree ;; helper function for ptree
;; make paths absolute to test whether files exist, ;; make paths absolute to test whether files exist,
;; then convert back to relative ;; then convert back to relative
(define (visible? path)
(not ((->string path) . starts-with? . ".")))
(define/contract (visible-files dir) (define/contract (visible-files dir)
(directory-pathish? . -> . (listof path?)) (directory-pathish? . -> . (listof path?))
(define (visible? relative-path)
(not ((->string relative-path) . starts-with? . ".")))
(filter visible? (filter visible?
(map (λ(p) (find-relative-path dir p)) (map (λ(p) (find-relative-path dir p))
(filter file-exists? (filter file-exists?

@ -0,0 +1,22 @@
#lang racket/base
(require racket/list racket/set)
(require "readability.rkt" "file-tools.rkt" "world.rkt")
(define (pd which)
(->path (format "/Users/MB/git/~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 unique-eligible-paths
(unique-members (map ->output-path
(filter-not ineligible-path? (directory-list dir)))))
unique-eligible-paths)
(route-index (pd "foobar"))

@ -1,7 +1,7 @@
#lang racket/base #lang racket/base
(require racket/system racket/port racket/file (require racket/system racket/port racket/file
racket/string racket/date racket/class racket/list) racket/class racket/list)
(require "debug.rkt" "readability.rkt") (require "debug.rkt" "readability.rkt" "world.rkt")
(provide setup) (provide setup)
@ -49,7 +49,7 @@
(format "#! ~a (format "#! ~a
#lang racket/base #lang racket/base
(require pollen/command) (require pollen/command)
; pollen setup run in ~a on ~a" ;; pollen setup run in ~a on ~a"
racket-path racket-path
cd cd
(format "~a at ~a" (make-datestamp) (make-timestamp)))) (format "~a at ~a" (make-datestamp) (make-timestamp))))
@ -73,27 +73,25 @@
;; task: make polcom file ;; task: make polcom file
(define polcom-filename "polcom")
(define (delete-polcom-file-if-existing) (define (delete-polcom-file-if-existing)
(when (file-exists? polcom-filename) (when (file-exists? POLLEN_COMMAND_FILE)
(begin (begin
(message (format "Deleting existing polcom file in ~a" cd)) (message (format "Deleting existing polcom file in ~a" cd))
(delete-file polcom-filename)))) (delete-file POLLEN_COMMAND_FILE))))
(define (save-polcom-file) (define (save-polcom-file)
(define racket-path (string-trim (with-output-to-string (λ() (system "which racket"))))) (define path-to-racket-exists? (> (len RACKET_PATH) 0))
(define path-to-racket-exists? (> (len racket-path) 0))
(if path-to-racket-exists? (if path-to-racket-exists?
(let ([polcom-data (make-polcom-data racket-path)]) (let ([polcom-data (make-polcom-data RACKET_PATH)])
(message (format "Using ~a as racket path" racket-path)) (message (format "Using ~a as racket path" RACKET_PATH))
(delete-polcom-file-if-existing) (delete-polcom-file-if-existing)
(message (format "Creating new polcom file in ~a" cd)) (message (format "Creating new polcom file in ~a" cd))
(if (not (test-mode)) (if (not (test-mode))
(begin (begin
(display-to-file polcom-data polcom-filename) (display-to-file polcom-data POLLEN_COMMAND_FILE)
(with-output-to-string (λ() (system (format "chmod 755 ~a" polcom-filename))))) (with-output-to-string (λ() (system (format "chmod 755 ~a" POLLEN_COMMAND_FILE)))))
(message "[test mode: file would be saved now]"))) (message "[test mode: file would be saved now]")))
(begin (begin
(message "No path to Racket binary") (message "No path to Racket binary")
@ -113,7 +111,7 @@
(define (success-messages) (define (success-messages)
(message "Setup complete") (message "Setup complete")
(define path-to-polcom (format "~a~a" cd polcom-filename)) (define path-to-polcom (format "~a~a" cd POLLEN_COMMAND_FILE))
(message (format "Run '~a start' to start project server" path-to-polcom)) (message (format "Run '~a start' to start project server" path-to-polcom))
(message (format "Or run '~a help' for a list of commands" path-to-polcom)) (message (format "Or run '~a help' for a list of commands" path-to-polcom))
(when (not (test-mode)) (exit))) (when (not (test-mode)) (exit)))

@ -32,7 +32,9 @@
(define OUTPUT_SUBDIR 'public) (define OUTPUT_SUBDIR 'public)
(define RACKET_PATH "/usr/bin/racket") (require racket/string racket/port racket/system)
;; todo: is path to racket already available as an environment variable?
(define RACKET_PATH (string-trim (with-output-to-string (λ() (system "which racket")))))
(define POLLEN_ROOT 'main) (define POLLEN_ROOT 'main)
(define POLLEN_COMMAND_FILE "polcom") (define POLLEN_COMMAND_FILE "polcom")
@ -46,3 +48,6 @@
dir))) dir)))
(require "readability.rkt")
(define RESERVED_PATHS
(map ->path (list POLLEN_COMMAND_FILE EXTRAS_DIR)))

Loading…
Cancel
Save