◊(Local Yarn Code "Check-in [1e45b119]")

Overview
Comment:Utility scripts use (main)
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1e45b1198323c68403801c625494a261612917a38e64b355c776a9925f4d2bc8
User & Date: joel on 2019-04-27 19:08:24
Other Links: manifest | tags
Context
2019-04-27
19:49
Add scribble tag for repo files check-in: 8b79fa0d user: joel tags: trunk
19:08
Utility scripts use (main) check-in: 1e45b119 user: joel tags: trunk
19:06
Flesh out makefile and build workflow (closes [aca89051]) check-in: 61bc0732 user: joel tags: trunk
Changes

Modified makefile from [604071f7] to [01d09963].

92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
	fossil uv sync

# 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

.PHONY: all scribble help spritz article publish check-env

.DEFAULT_GOAL := help

check-env:
ifndef LOCALYARN_SRV
	$(error LOCALYARN_SRV env variable not set, should be a destination valid for rsync)
endif
ifndef WEB_SRV_PORT
	$(error WEB_SRV_PORT env variable not set, should be SSH port number for web server)
endif







|












92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
	fossil uv sync

# 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 -tm util/newpost.rkt

.PHONY: all scribble help spritz article publish check-env

.DEFAULT_GOAL := help

check-env:
ifndef LOCALYARN_SRV
	$(error LOCALYARN_SRV env variable not set, should be a destination valid for rsync)
endif
ifndef WEB_SRV_PORT
	$(error WEB_SRV_PORT env variable not set, should be SSH port number for web server)
endif

Modified util/newpost.rkt from [08f6dade] to [88a7503d].

22
23
24
25
26
27
28


29
30
31
32
33
34
35
..
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
;; -------------------------------------------------------------------------

(require racket/date
         racket/string
         racket/file
         racket/system
         "../dust.rkt")



(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)
................................................................................

(define date-string
  (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))])







>
>







 







|

|

|
|

|

|

>
|
|
|
|
|
|
|

|
|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
..
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)
................................................................................

(define date-string
  (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!})

(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))]))