JoelDueck.com Source

Check-in [86818268e6]
Login

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

Overview
Comment:Use HTML5 printer instead of tidy
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 86818268e68f1c22ab8f7be21016a2c5323222eec1c635d458abe6dafbe7e554
User & Date: joel 2024-07-18 00:29:50
Context
2024-07-18
15:57
Update readme check-in: c920590bcd user: joel tags: trunk
00:29
Use HTML5 printer instead of tidy check-in: 86818268e6 user: joel tags: trunk
00:28
Home page edits check-in: ab4f5ed986 user: joel tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to makefile.

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
web: ## Rebuild all web pages

$(core-modules): compiled/%_rkt.zo: %.rkt
	raco make $<

$(pages-html): $(core-modules)
$(pages-html): publish/%.html: writing/compiled/%.page_rkt.zo
	racket -t render-page.rkt -- $(patsubst publish/%.html, writing/%.page.rkt, $@) \
	| tidy -quiet -indent --wrap 100 --new-inline-tags footer --wrap-attributes no --tidy-mark no > $@ || true

$(pages-compiled): writing/compiled/%.page_rkt.zo: writing/%.page.rkt
	raco make $<

publish/feed.atom: $(pages-html) feed.rkt
	racket -tm feed.rkt

$(webpages): render-page.rkt
$(webpages): publish/%.html: web-pages/%.rkt
	racket $< | tidy -quiet -indent --wrap 100 --new-inline-tags footer --wrap-attributes no --tidy-mark no > $@ || true

publish/res/style.css: $(static-sources) 
	rm -rf publish && cp -R static publish

zap: ## Clear Racket compile cache, and remove all HTML output
	rm -rf compiled || true
	rm -rf writing/compiled || true







|
<









|







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
web: ## Rebuild all web pages

$(core-modules): compiled/%_rkt.zo: %.rkt
	raco make $<

$(pages-html): $(core-modules)
$(pages-html): publish/%.html: writing/compiled/%.page_rkt.zo
	racket -t render-page.rkt -- $(patsubst publish/%.html, writing/%.page.rkt, $@) > $@


$(pages-compiled): writing/compiled/%.page_rkt.zo: writing/%.page.rkt
	raco make $<

publish/feed.atom: $(pages-html) feed.rkt
	racket -tm feed.rkt

$(webpages): render-page.rkt
$(webpages): publish/%.html: web-pages/%.rkt
	racket $< > $@

publish/res/style.css: $(static-sources) 
	rm -rf publish && cp -R static publish

zap: ## Clear Racket compile cache, and remove all HTML output
	rm -rf compiled || true
	rm -rf writing/compiled || true

Changes to render-page.rkt.

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
68

69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#lang at-exp racket/base

(require jdcom
         punct/doc
         punct/fetch
         punct/render/html
         racket/format
         racket/match
         racket/path
         "tools.rkt"

         (only-in xml xexpr->string))

(provide display-html-page/dropin
         display-html-page)

;; Render a Punct source file to HTML and display to the current output port.

(define (time-tag date-str)
  @~a{<time datetime="@date-str">@(date-fmt date-str)</time>})

(define (display-html-page/dropin html-xexprs metas)
  (display-html-page (document metas 
                               (xexpr->string `(article ,@html-xexprs)) 
                               '()) 
                     #:dropin-html? #t))  

(define (display-html-page src #:dropin-html? [dropin-html? #f])
  (define doc (if (or (document? src) dropin-html?) src (get-doc src)))
  (display @~a{
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>@(or (meta-ref doc 'title) "Web page") — Joel Dueck dot com</title>
    <link rel="alternate" type="application/atom+xml" href="http://joeldueck.com/feed.atom">
    <meta http-equiv="Content-Security-Policy" content="default-src 'self' https://joeldueck.com data:; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' https://plausible.io; connect-src https://plausible.io https://api.weather.gov  https://joeldueck.com;" /> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
    <meta name="theme-color" content="hsl(var(--base-temp),50%,96%);">
    <link rel="stylesheet" href="res/block.css" type="text/css">
    <link rel="stylesheet" href="res/style.css?@(date-fmt #:format "d-MMM-y-hms")" type="text/css">
    <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
    <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
    <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"></script>
</head>
<body>
    <main>
      <header class="small-caps">
            <h1><a href="index.html">Joel Dueck</a>
            @(match (meta-ref doc 'date)
              [#f ""]
              [(var d) @~a{&middot; @(time-tag d)}]) </h1>
      </header>
    





















    @(cond
      [dropin-html? (document-body doc)]
      [else 
        (parameterize ([current-directory (path->directory-path (path-only src))])
        (doc->html doc jd-tags->html))])

    </main>
    <footer>
        <div id="weather"><noscript>You don’t have javascript. How droll!</noscript></div>
        <div id="tempslider">
            <input type="range" min="-40" max="110" value="72" class="slider" id="myRange">
            <button class="small-caps" onclick="updateWeatherDiv()" style="margin-left: 0.5rem;">Reset</button>
        </div>

        <script src='res/windfinger.js'></script>
    </footer>
    <!--
       Generated on @(date-fmt #:format "EEEE, d MMMM yyyy h:ma z")
       Built with Punct: https://github.com/otherjoel/punct
       Source: https://joeldueck.com/code/jdcom
    -->
    @(match (meta-ref doc 'web-script) [(? string? s) @~a{<script src="@s"></script>}] [_ ""])
</body>
</html>
}))

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


|



<
<


>
|







|



|
|
|



|
|
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
|
<
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
<
<
|
|
|
|
|
<
>
|
<
<
<
<
<
<
|
<
<
<





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






68



69
70
71
72
73
#lang at-exp racket/base

(require jdcomls
         punct/doc
         punct/fetch
         punct/render/html


         racket/path
         "tools.rkt"
         html-printer
         (only-in xml comment))

(provide display-html-page/dropin
         display-html-page)

;; Render a Punct source file to HTML and display to the current output port.

(define (time-tag date-str)
  `(time [[datetime ,date-str]] ,(date-fmt date-str)))

(define (display-html-page/dropin html-xexprs metas)
  (display-html-page (document metas 
                               `(article ,@html-xexprs)
                               '())
                     #:dropin-html? #t))

(define (display-html-page src #:dropin-html? [dropin-html? #f])
  (define doc (if (or (document? src) dropin-html?) src (get-doc src)))
  (display
   (xexpr->html5

    #:add-breaks? #t

















    `(html

      [[lang "en"]]

      (head
       ,(comment (string-append "Generated on " (date-fmt #:format "EEEE, d MMMM yyyy h:ma z")))
       ,(comment "Built with Racket + Punct + HTML5 Writer")
       (meta [[charset "UTF-8"]])
       (title ,(or (meta-ref doc 'title) "Web page") " — Joel Dueck dot com")
       (meta [[name "viewport"]
              [content "width=device-width, initial-scale=1.0, viewport-fit=cover"]])
       (meta [[http-equiv "Content-Security-Policy"]
              [content "default-src 'self' https://joeldueck.com data:; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' https://plausible.io; connect-src https://plausible.io https://api.weather.gov  https://joeldueck.com;"]])
       (meta [[name "theme-color"]
              [content "hsl(var(--base-temp),50%,96%);"]])
       (link [[rel "stylesheet"] [href "/res/block.css"]])
       (link [[rel "stylesheet"] [href ,(format "/res/style.css?~a" (date-fmt #:format "d-MMM-y-hms"))]])
       (link [[rel "apple-touch-icon"] [sizes "180x180"] [href "/apple-touch-icon.png"]])
       (link [[rel "icon"] [type "image/png"] [sizes "32x32"] [href "/favicon-32x32.png"]])
       (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))