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

Overview
Comment:Rename constants. Closes [fc2fc68]
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 74055398039c37c3a566008d9e60c8dafd272681a87e5662db66ac5d5aa89d85
User & Date: joel on 2019-04-07 21:32:02
Other Links: manifest | tags
References
2019-04-07
21:32 Closed ticket [fc2fc682]: Constants named “path” should be Racket paths plus 4 other changes artifact: 66a349e6 user: joel
Context
2019-04-07
22:23
Implement permlinks in article markup check-in: d3d5e894 user: joel tags: trunk
21:32
Rename constants. Closes [fc2fc68] check-in: 74055398 user: joel tags: trunk
21:11
Simplify a couple of HTML conversions check-in: e54b3c52 user: joel tags: trunk
Changes

Modified code-docs/dust.scrbl from [1d7645f5] to [31c02e8b].

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
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







-
-
+
+

-
+






-
-
+
+







@section{Constants}

@defthing[default-authorname string? #:value "Joel Dueck"]

Used as the default author name for @code{note}s, and (possibly in the future) for articles
generally.

@deftogether[(@defthing[articles-path path-string? #:value "articles"]
              @defthing[series-path   path-string? #:value "series"])]
@deftogether[(@defthing[articles-folder path-string? #:value "articles"]
              @defthing[series-folder   path-string? #:value "series"])]

The path of the folder that contains the Pollen source documents for Articles and Series
The names of the folders that contain the Pollen source documents for Articles and Series
respectively, relative to the project’s document root.

@deftogether[(@defproc[(articles-pagetree) pagetree?]
              @defproc[(series-pagetree) pagetree?])]

These are project-wide pagetrees: @racket[articles-pagetree] contains a pagenode for every Pollen
document contained in @racket[articles-path], and @racket[series-pagetree] contains a pagenode for
every Pollen document in @racket[series-path]. The pagenodes themselves point to the rendered
document contained in @racket[articles-folder], and @racket[series-pagetree] contains a pagenode for
every Pollen document in @racket[series-folder]. The pagenodes themselves point to the rendered
@tt{.html} targets of the source documents.

@defproc[(here-output-path) path?]

Returns the path to the current output file, relative to @racket[current-project-root]. If no metas
are available, raises an error. This is like what you can get from the @tt{here} variable that Pollen
provides, except it is available outside templates.

Modified crystalize.rkt from [f6a60f0d] to [ce57f9ce].

164
165
166
167
168
169
170
171

172
173
174

175
176
177
178
179
180
181
164
165
166
167
168
169
170

171
172
173

174
175
176
177
178
179
180
181







-
+


-
+








;; ~~~ Retrieve listings of articles and notes ~~~
;; ~~~ (Mainly for use on Series pages         ~~~

;; (private) Create a WHERE clause matching a single series or list of series
(define (where/series s)
  (cond [(list? s)
         (let ([series (map (curry (format "~a/~a.html" series-path)) s)])
         (let ([series (map (curry (format "~a/~a.html" series-folder)) s)])
           (format "WHERE `series_pagenode` IN ~a" (list->sql-values series)))]
        [(string? s)
         (format "WHERE `series_pagenode` IS \"~a/~a.html\"" series-path s)]
         (format "WHERE `series_pagenode` IS \"~a/~a.html\"" series-folder s)]
        [(equal? s #t)
         (format "WHERE `series_pagenode` IS \"~a\"" (here-output-path))]
        [else ""]))

;; (private) Return a combined list of articles and notes sorted by date
(define (list/articles+notes type #:series [s #t] #:limit [limit -1] [order "DESC"])
  (define select #<<@@@@@

Modified dust.rkt from [86d18cd5] to [4a46ea1e].

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
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







-
-
+
+









-
-
+
+







         series-pagenode
         make-tag-predicate
         tx-strs
         ymd->english
         ymd->dateformat
         default-authorname
         default-title
         articles-path
         series-path
         articles-folder
         series-folder
         articles-pagetree
         series-pagetree
         first-words
         build-note-id
         notes->last-disposition-values
         disposition-values
         )

(define default-authorname "Joel Dueck")
(define series-path "series")
(define articles-path "articles")
(define series-folder "series")
(define articles-folder "articles")

(define (default-title body-txprs)
  (format "“~a…”" (first-words body-txprs 5)))

(define (maybe-meta m [missing ""])
  (or (select-from-metas m (current-metas)) missing))

78
79
80
81
82
83
84
85

86
87
88
89
90
91
92
78
79
80
81
82
83
84

85
86
87
88
89
90
91
92







-
+








;; Checks current-metas for a 'series meta and returns the pagenode of that series,
;; or '|| if no series is specified.
(define (series-pagenode)
  (define maybe-series (or (select-from-metas 'series (current-metas)) ""))
  (cond
    [(non-empty-string? maybe-series)
     (->pagenode (format "~a/~a.html" series-path maybe-series))]
     (->pagenode (format "~a/~a.html" series-folder maybe-series))]
    [else '||]))

(define (series-noun)
  (define series-pnode (series-pagenode)) 
  (case series-pnode
    ['|| ""] ; no series specified
    [else (or (select-from-metas 'noun-singular series-pnode) "")]))
105
106
107
108
109
110
111
112

113
114
115

116
117
118
119
120
121
122
105
106
107
108
109
110
111

112
113
114

115
116
117
118
119
120
121
122







-
+


-
+







  (define (file->output-pagenode f)
    (string->symbol (format "~a/~a" folder (string-replace f extension ".html"))))
  (define folder-path (build-path (current-project-root) folder))
  (define file-strs (map path->string (directory-list folder-path)))
  (map file->output-pagenode (filter matching-file? file-strs)))

(define (articles-pagetree)
  `(root ,@(include-in-pagetree articles-path ".poly.pm")))
  `(root ,@(include-in-pagetree articles-folder ".poly.pm")))

(define (series-pagetree)
  `(root ,@(include-in-pagetree series-path ".poly.pm")))
  `(root ,@(include-in-pagetree series-folder ".poly.pm")))

;; ~~~ Convenience functions for tagged x-expressions ~~~

(define (maybe-attr name attrs [missing ""])
  (define result (assoc name attrs))
  (cond
    [(pair? result) (cadr result)]