Index: makefile ================================================================== --- makefile +++ makefile @@ -94,11 +94,11 @@ # Self-documenting makefile (http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html) help: ## Displays this help screen @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}' article: ## Start a new article from a template - racket util/newpost.rkt + racket -tm util/newpost.rkt .PHONY: all scribble help spritz article publish check-env .DEFAULT_GOAL := help Index: util/newpost.rkt ================================================================== --- util/newpost.rkt +++ util/newpost.rkt @@ -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))]))