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

Overview
Comment:Small fixes in dust
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e18e8fa4d53834196e5b8b8f5175d7e487f8db1416decc4224c86750b6b555a2
User & Date: joel on 2019-03-09 04:00:30
Other Links: manifest | tags
Context
2019-03-09
04:02
Small fixes in crystalize check-in: 0e2c0e7e user: joel tags: trunk
04:00
Small fixes in dust check-in: e18e8fa4 user: joel tags: trunk
03:59
Allow to take zero SQL parameters check-in: 0d3df679 user: joel tags: trunk
Changes

Modified dust.rkt from [c1bae001] to [402b4b9e].

19
20
21
22
23
24
25

26
27
28
29
30
31
32
;; Author contact information:
;;   joel@jdueck.net
;;   https://joeldueck.com
;; -------------------------------------------------------------------------

(require pollen/core
         pollen/pagetree

         net/uri-codec
         gregor
         txexpr
         racket/list
         racket/string)

;; Provides common helper functions used throughout the project







>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
;; Author contact information:
;;   joel@jdueck.net
;;   https://joeldueck.com
;; -------------------------------------------------------------------------

(require pollen/core
         pollen/pagetree
         pollen/setup
         net/uri-codec
         gregor
         txexpr
         racket/list
         racket/string)

;; Provides common helper functions used throughout the project
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77

;; 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 (string-append series-path "/" maybe-series ".html"))]
    [else '||]))

(define (series-noun)
  (define series-pnode (series-pagenode)) 
  (case series-pnode
    ['|| ""] ; no series specified
    [else (or (select-from-metas 'noun-singular series-pnode) "")]))







|







64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

;; 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))]
    [else '||]))

(define (series-noun)
  (define series-pnode (series-pagenode)) 
  (case series-pnode
    ['|| ""] ; no series specified
    [else (or (select-from-metas 'noun-singular series-pnode) "")]))
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
;; ~~~ Project-wide Pagetrees ~~~

(define (include-in-pagetree folder extension)
  (define (matching-file? f)
    (string-suffix? f extension))
  (define (file->output-pagenode f)
    (string->symbol (format "~a/~a" folder (string-replace f extension ".html"))))

  (define file-strs (map path->string (directory-list folder)))
  (map file->output-pagenode (filter matching-file? file-strs)))

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

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

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

(define (attr-present? name attrs)
  (for/or ([attr-pair (in-list attrs)])
          (equal? name (car attr-pair))))







|
|


|


|







86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
;; ~~~ Project-wide Pagetrees ~~~

(define (include-in-pagetree folder extension)
  (define (matching-file? f)
    (string-suffix? f extension))
  (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")))

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

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

(define (attr-present? name attrs)
  (for/or ([attr-pair (in-list attrs)])
          (equal? name (car attr-pair))))