JoelDueck.com Source

Check-in [3efe57fb2e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add when/list convenience macro for template
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3efe57fb2e809f36cb70ec166d8fae2a92ac2f68f7cb9d93488a71cd0549dec5
User & Date: joel 2024-07-18 16:19:45
Context
2024-08-02
14:47
Add HTML5 Printer to projects list Leaf check-in: 8dfd9a4e84 user: joel tags: trunk
2024-07-18
16:19
Add when/list convenience macro for template check-in: 3efe57fb2e user: joel tags: trunk
15:58
typed in the wrong window once and now I'm eternally sad check-in: dcc823bcb3 user: joel tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to render-page.rkt.

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
       (link [[rel "icon"] [type "image/png"] [sizes "16x16"] [href "/favicon-16x16.png"]])
       (link [[rel "manifest"] [href "/site.webmanifest"]])
       (script [[defer ""] [data-domain "joeldueck.com"] [src "https//plausible.io/js/script.js"]]))
      (body
       (main
        (header [[class "small-caps"]]
                (h1 (a [[href "/index.html"]] "Joel Dueck")
                    ,@(if (meta-ref doc 'date) (list 'middot " " (time-tag (meta-ref doc 'date))) '())))
        ,(cond
           [dropin-html? (document-body doc)]
           [else 
            (parameterize ([current-directory (path->directory-path (path-only src))])
              (doc->html-xexpr doc jd-tags->html))]))
       (footer
        (div [[id "weather"]] (noscript "You don’t have javascript. How droll!"))
        (div [[id "tempslider"]]
             (input [[id "myRange"] [class "slider"] [type "range"] [min "-40"] [max "110"] [value "72"]])
             (button [[class "small-caps"] [onclick "updateWeatherDiv()"] [style "margin-left: 0.5rem;"]]
                     "Reset"))
        (script [[src "res/windfinger.js"]]))
       ,@(if (meta-ref doc 'web-script) `((script [[src ,(meta-ref doc 'web-script)]])) '()))))))

(module+ main
  (require racket/cmdline)
  (define src (command-line #:args (filename) filename))
  (display-html-page src))







|












|





48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
       (link [[rel "icon"] [type "image/png"] [sizes "16x16"] [href "/favicon-16x16.png"]])
       (link [[rel "manifest"] [href "/site.webmanifest"]])
       (script [[defer ""] [data-domain "joeldueck.com"] [src "https//plausible.io/js/script.js"]]))
      (body
       (main
        (header [[class "small-caps"]]
                (h1 (a [[href "/index.html"]] "Joel Dueck")
                    ,@(when/list [(meta-ref doc 'date) d] 'middot " " (time-tag d))))
        ,(cond
           [dropin-html? (document-body doc)]
           [else 
            (parameterize ([current-directory (path->directory-path (path-only src))])
              (doc->html-xexpr doc jd-tags->html))]))
       (footer
        (div [[id "weather"]] (noscript "You don’t have javascript. How droll!"))
        (div [[id "tempslider"]]
             (input [[id "myRange"] [class "slider"] [type "range"] [min "-40"] [max "110"] [value "72"]])
             (button [[class "small-caps"] [onclick "updateWeatherDiv()"] [style "margin-left: 0.5rem;"]]
                     "Reset"))
        (script [[src "res/windfinger.js"]]))
       ,@(when/list [(meta-ref doc 'web-script) ws] `(script [[src ,ws]])))))))

(module+ main
  (require racket/cmdline)
  (define src (command-line #:args (filename) filename))
  (display-html-page src))

Changes to tools.rkt.

1
2
3

4

5
6
7
8
9







#lang racket/base

(require gregor

         splitflap)


(provide (all-defined-out))

(define (date-fmt [date-str ""] #:format [fmt "d MMM y"])
  (if date-str (~t (infer-moment date-str) fmt) #f))










>
|
>





>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#lang racket/base

(require gregor
         racket/match
         splitflap
         [for-syntax racket/base])

(provide (all-defined-out))

(define (date-fmt [date-str ""] #:format [fmt "d MMM y"])
  (if date-str (~t (infer-moment date-str) fmt) #f))

(define-syntax (when/list stx)
    (syntax-case stx ()
      [(_ (EXPR ID) BODY ...)
       #'(match EXPR [#f '()] [(var ID) (list BODY ...)])]
      [(_ EXPR BODY ...)
       #'(if EXPR (list BODY ...) '())]))