22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
+
+
-
+
-
+
-
-
+
+
-
+
-
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
+
+
|
;; -------------------------------------------------------------------------
(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+" "-"))
(define (make-filename basename)
(build-path (current-directory) articles-folder (string-append basename ".poly.pm")))
(define (comment . strs)
(format "◊; ~a" (apply string-append strs)))
(define date-string
(parameterize [(date-display-format 'iso-8601)]
(date->string (current-date))))
(define (make-template-contents title)
◊string-append{
#lang pollen
#lang pollen
◊comment{Copyright ◊(substring date-string 0 4) by ◊|default-authorname|. All Rights Reserved.}
◊comment{Copyright ◊(substring date-string 0 4) by ◊|default-authorname|. All Rights Reserved.}
◊"◊"(define-meta published "◊date-string")
◊"◊"(define-meta series "seriesname")
◊"◊"(define-meta published "◊date-string")
◊"◊"(define-meta series "seriesname")
◊"◊"title{◊title}
◊"◊"title{◊title}
Write here!})
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))
(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))])
; the + argument tells vim to place the cursor at the last line of the file.
(system (format "mvim + ~a" post-file))]))
|