Overview
| Comment: | Add quick templating for new articles |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
1afe7e9748833b46675ea93b5e76c58e |
| User & Date: | joel on 2019-04-11 04:16:52 |
| Other Links: | manifest | tags |
Context
|
2019-04-11
| ||
| 17:11 | Fix display of titles in poetry check-in: a4a69244 user: joel tags: trunk | |
| 04:16 | Add quick templating for new articles check-in: 1afe7e97 user: joel tags: trunk | |
| 03:23 | Fix paragraph decoding inside notes check-in: 40ecb212 user: joel tags: trunk | |
Changes
Modified makefile from [81b0b22c] to [3dd8fa71].
| ︙ | ︙ | |||
22 23 24 25 26 27 28 |
fossil uv add scribbled/*
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}'
| > > > | | 22 23 24 25 26 27 28 29 30 31 32 33 34 |
fossil uv add scribbled/*
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: scribble help spritz article
.DEFAULT_GOAL := help
|
Added util/newpost.rkt version [08f6dade].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 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 |
#lang pollen/mode racket/base
;; Copyright (c) 2018 Joel Dueck.
;;
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; A copy of the License is included with this source code, in the
;; file "LICENSE.txt".
;; You may also obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;;
;; Author contact information:
;; joel@jdueck.net
;; https://joeldueck.com
;; -------------------------------------------------------------------------
(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)
(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
◊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))])
|