@@ -24,10 +24,12 @@ (require racket/date racket/string racket/file racket/system "../dust.rkt") + +(provide main) (define (normalize str) (define alphanum-only (regexp-replace* #rx"[^A-Za-z0-9 ]" str "")) (string-normalize-spaces (string-downcase alphanum-only) #px"\\s+" "-")) @@ -42,26 +44,27 @@ (parameterize [(date-display-format 'iso-8601)] (date->string (current-date)))) (define (make-template-contents title) ◊string-append{ -#lang pollen - -◊comment{Copyright ◊(substring date-string 0 4) by ◊|default-authorname|. All Rights Reserved.} - -◊"◊"(define-meta published "◊date-string") -◊"◊"(define-meta series "seriesname") - -◊"◊"title{◊title} - -Write here!}) - -(display "Enter title: ") -(define title (read-line)) -(cond [(non-empty-string? title) - (define post-file (make-filename (normalize title))) - (define post-contents (make-template-contents title)) - (display-to-file post-contents post-file) - (displayln (format "Saved to ~a" post-file)) - - ; the + argument tells vim to place the cursor at the last line of the file. - (system (format "mvim + ~a" post-file))]) + #lang pollen + + ◊comment{Copyright ◊(substring date-string 0 4) by ◊|default-authorname|. All Rights Reserved.} + + ◊"◊"(define-meta published "◊date-string") + ◊"◊"(define-meta series "seriesname") + + ◊"◊"title{◊title} + + Write here!}) + +(define (main) + (display "Enter title: ") + (define title (read-line)) + (cond [(non-empty-string? title) + (define post-file (make-filename (normalize title))) + (define post-contents (make-template-contents title)) + (display-to-file post-contents post-file) + (displayln (format "Saved to ~a" post-file)) + + ; the + argument tells vim to place the cursor at the last line of the file. + (system (format "mvim + ~a" post-file))]))