Skip to content

Commit

Permalink
URI-encode topic names in anchor IDs. Closes #8
Browse files Browse the repository at this point in the history
  • Loading branch information
otherjoel committed Mar 30, 2019
1 parent 8e54641 commit efe005c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
10 changes: 8 additions & 2 deletions topics.html.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#lang pollen

◊(local-require "util-topics.rkt" pollen/template pollen/pagetree pollen/private/version pollen/cache)
◊(require "util-topics.rkt"
pollen/template
pollen/pagetree
pollen/private/version
pollen/cache
net/uri-codec)

◊(define main-pagetree (cached-doc (string->path "index.ptree")))

<!DOCTYPE html>
Expand All @@ -27,7 +33,7 @@
<table>
◊for/s[topic (topic-list)]{
<tr>
<td><a name="◊(car topic)">◊(car topic)</a></td>
<td><a id="◊(uri-encode (car topic))">◊(car topic)</a></td>
<td><ul>
◊for/s[post (cdr topic)]{
<li><a href="/◊(list-ref post 0)">◊(list-ref post 1)</a></li>
Expand Down
8 changes: 2 additions & 6 deletions util-template.rkt
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#lang racket

(require
racket/date
pollen/template
pollen/core
pollen/cache
pollen/pagetree
pollen/file
net/uri-codec
"util-date.rkt"
txexpr)

Expand All @@ -31,7 +27,7 @@
(define topics-xexpr
(cond [topics
(define topic-listitems
(map (λ(t) `(li (a [[href ,(string-append "/topics.html#" t)]] ,t)))
(map (λ(t) `(li (a [[href ,(string-append "/topics.html#" (uri-encode t))]] ,t)))
(string-split (regexp-replace* #px"\\s*,\\s*" topics ",") ",")))
`(ul ,@topic-listitems)]
[else ""]))
Expand Down

0 comments on commit efe005c

Please sign in to comment.