◊(Local Yarn Code "Diff")

Differences From Artifact [c19af359]:

To Artifact [7a13118b]:


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










































































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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155







+
+
+
+
-
+

-
+
+
+
+
+
+
+
+
+
+

-
-
-
-
-
-
-
+
+
+
+
+
+
+
+

-
-
-
-
-
-
+
+
+
+
+
+

-
+
-

-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+

-
+

-
-
-
+
+
+

-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
;; Author contact information:
;;   joel@jdueck.net
;;   https://joeldueck.com
;; -------------------------------------------------------------------------

;; Provides functions for displaying content in HTML templates.
(require pollen/core
         pollen/template
         racket/string
         txexpr
         openssl/sha1
         "dates.rkt")
         "dust.rkt")

(provide (all-defined-out))
(provide html$-page-head
         html$-page-body-open
         html$-article-open
         html$-article-close
         html$-page-body-close
         html$-note-title
         html$-note-contents
         html$-note-listing-full
         html$-note-in-article
         html$-notes-section)

(define (html-head [title #f])
  ◊@{<head>
     <title>The Local Yarn◊when/splice[title]{: ◊title}</title>
     <meta charset="utf-8" />
     <meta name="viewport" content="width=device-width, initial-scale=1">
     <link rel="stylesheet" type="text/css" href="/web-extra/martin.css">
     </head>})
(define (html$-page-head [title #f])
  (define title-part (if title (format ": ~a" title) ""))string-append{<head>
 <title>The Local Yarn◊|title|</title>
 <meta charset="utf-8" />
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <link rel="stylesheet" type="text/css" href="/web-extra/martin.css">
 </head>})

(define (html-page-top)
  ◊@{<body><main>
     <a href="/"><header>
     <img src="/web-extra/logo.png" height="103" width="129" class="logo">
     <h1>The Local Yarn</h1>
     </header></a>})
(define (html$-page-body-open)
  ◊string-append{<body><main>
 <a href="/"><header>
 <img src="/web-extra/logo.png" height="103" width="129" class="logo">
 <h1>The Local Yarn</h1>
 </header></a>})

(define (html-article-header)
(define (html$-article-open title-html-flow published)
  (define title (select-from-metas 'title (current-metas)))
  (define published (select-from-metas 'published (current-metas)))
    (cond
      [title
       ◊string-append{<article class="with-title hentry">
          <h1 class="entry-title">◊|title|</h1>
          <p class="time"><a href="#" class="rel-bookmark">
          <time datetime="◊published" class="published">◊ymd->english[published]</time>
          </a></p>
          <section class="entry-content">}]
      [else
       ◊string-append{<article class="no-title hentry">
          <h1><a href="#" class="rel-bookmark">
          <time datetime="◊published" class="entry-title">◊ymd->english[published]</time>
          </a></h1>
          <section class="entry-content">}]))
  (cond
    [title-html-flow
     ◊string-append{<article class="with-title hentry">
      <h1 class="entry-title">◊|title-html-flow|</h1>
      <p class="time"><a href="#" class="rel-bookmark">
      <time datetime="◊published" class="published">◊ymd->english[published]</time>
      </a></p>
      <section class="entry-content">}]
    [else
     ◊string-append{<article class="no-title hentry">
      <h1><a href="#" class="rel-bookmark">
      <time datetime="◊published" class="entry-title">◊ymd->english[published]</time>
      </a></h1>
      <section class="entry-content">}]))

(define (html-article-footer)
(define (html$-article-close)
  ◊string-append{</section>
     <footer class="article-info"><span class="x">(</span>Part of ‘Talking About Poetry’. Once I threw a mudball at a birdhouse. I’m not exactly proud of it, though.<span class="x">)</span></footer>
     </article>})

 <footer class="article-info"><span class="x">(</span>Part of ‘Talking About Poetry’. Once I threw a mudball at a birdhouse. I’m not exactly proud of it, though.<span class="x">)</span></footer>
 </article>})
 

(define (html-page-bottom)
  ◊@{<footer>By Joel Dueck</footer>
     </main></body>})
(define (html$-page-body-close)
  ◊string-append{<footer>By Joel Dueck</footer>
 </main></body>})

;; Notes
;;
(define (html$-note-title author pagenode parent-title)
  (define author-part
    (cond [(and (non-empty-string? author)
                (not (string-ci=? author default-authorname)))
           (format "A note from ~a, " author)]
          [else ""]))
  (define article-part
    (format "Re: <a class=\"cross-reference\" href=\"/~a\">~a</a>"
            pagenode
            parent-title))
  (string-append author-part article-part))

(define (html$-note-contents disposition-mark elems)
  (define-values (first-tag first-attrs first-elems) (txexpr->values (car elems)))
  (define disposition
    (cond [(non-empty-string? disposition-mark)
           `(span [[class "disposition-mark"]] ,disposition-mark)]
          [else ""]))
  (define body-elems
    (cond
      [(equal? 'p first-tag)
       (cons (txexpr 'p first-attrs (cons disposition first-elems)) (cdr elems))]
      [else
       (cons disposition elems)]))
  (string-append* (map ->html body-elems)))

(define (html$-note-listing-full pagenode note-id title-html-flow date author author-url contents)
  (define author-part
    (cond [(non-empty-string? author)
           ◊string-append{
            <div class="note-meta">
            &mdash;<a class="u-author h-card" href="◊|author-url|">◊|author|</a>
            </div>}]
          [else ◊string-append{
            <div class="note-meta">
            &mdash;<a class="u-author h-card" href="https://thelocalyarn.com">◊|default-authorname|</a>
            </div>}]))
  
  ◊string-append{
 <article class="with-title hentry">
 <h1 class="entry-title">◊|title-html-flow|</h1>
 <p class="time"><a href="◊|pagenode|◊note-id" class="rel-bookmark note-permlink">
 <time datetime="◊date">◊ymd->english[date]</time>
 </a></p>
 <section class="entry-content">
 <div class="p-content p-name">◊|contents|</div>
 ◊author-part
 </section>
 </article>})

(define (html$-note-in-article id date author author-url contents)
  ◊string-append{
 <div class="note u-comment" id="◊|id|">
 <h3><a href="◊|id|"><time class="dt-published" datetime="◊date">◊ymd->english[date]</time>
 </a></h3>
 <div class="p-content p-name">
 ◊contents
 </div>
 <div class="note-meta">
 &mdash;<a class="u-author h-card" href="◊|author-url|">◊|author|</a>
 </div>
 </div>})

(define (html$-notes-section note-htmls)
  ◊string-append{<div class="further-notes">
 <h2>Further Notes</h2>
 ◊(apply string-append note-htmls)
 </div>})