Compare commits
3 commits
6be10ed319
...
1f302b3a9e
Author | SHA1 | Date | |
---|---|---|---|
1f302b3a9e | |||
9b3cd6dbe7 | |||
44906015a5 |
3 changed files with 18 additions and 6 deletions
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
(define examples
|
(define examples
|
||||||
'(("crosscode" "CrossCode_Wiki")
|
'(("crosscode" "CrossCode_Wiki")
|
||||||
|
("pokemon" "Eevee")
|
||||||
("minecraft" "Bricks")
|
("minecraft" "Bricks")
|
||||||
("undertale" "Hot_Dog...%3F")
|
("undertale" "Hot_Dog...%3F")
|
||||||
("tardis" "Eleanor_Blake")
|
("tardis" "Eleanor_Blake")
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
web-server/http
|
web-server/http
|
||||||
web-server/dispatchers/dispatch
|
web-server/dispatchers/dispatch
|
||||||
; my libs
|
; my libs
|
||||||
|
"config.rkt"
|
||||||
"pure-utils.rkt"
|
"pure-utils.rkt"
|
||||||
"xexpr-utils.rkt"
|
"xexpr-utils.rkt"
|
||||||
"url-utils.rkt"
|
"url-utils.rkt"
|
||||||
|
@ -231,12 +232,17 @@
|
||||||
(define body
|
(define body
|
||||||
(generate-wiki-page source-url wikiname title (update-tree-wiki page wikiname)))
|
(generate-wiki-page source-url wikiname title (update-tree-wiki page wikiname)))
|
||||||
(define redirect-msg ((query-selector (attribute-selector 'class "redirectMsg") body)))
|
(define redirect-msg ((query-selector (attribute-selector 'class "redirectMsg") body)))
|
||||||
(response/output
|
(define headers (if redirect-msg
|
||||||
#:code 200
|
|
||||||
#:headers (if redirect-msg
|
|
||||||
(let* ([dest (get-attribute 'href (bits->attributes ((query-selector (λ (t a c) (eq? t 'a)) redirect-msg))))]
|
(let* ([dest (get-attribute 'href (bits->attributes ((query-selector (λ (t a c) (eq? t 'a)) redirect-msg))))]
|
||||||
[value (bytes-append #"0;url=" (string->bytes/utf-8 dest))])
|
[value (bytes-append #"0;url=" (string->bytes/utf-8 dest))])
|
||||||
(list (header #"Refresh" value)))
|
(list (header #"Refresh" value)))
|
||||||
(list))
|
(list)))
|
||||||
|
(when (config-true? 'debug)
|
||||||
|
; used for its side effects
|
||||||
|
; convert to string with error checking, error will be raised if xexp is invalid
|
||||||
|
(xexp->html body))
|
||||||
|
(response/output
|
||||||
|
#:code 200
|
||||||
|
#:headers headers
|
||||||
(λ (out)
|
(λ (out)
|
||||||
(write-html body out))))))]))
|
(write-html body out))))))]))
|
||||||
|
|
|
@ -158,7 +158,8 @@
|
||||||
(define attributes (bits->attributes (cdr element)))
|
(define attributes (bits->attributes (cdr element)))
|
||||||
(define contents (filter element-is-content? (cdr element))) ; provide elements and strings
|
(define contents (filter element-is-content? (cdr element))) ; provide elements and strings
|
||||||
(if (or (equal? element-type '*DECL)
|
(if (or (equal? element-type '*DECL)
|
||||||
(equal? element-type '@))
|
(equal? element-type '@)
|
||||||
|
(equal? element-type '&))
|
||||||
; special element, do nothing
|
; special element, do nothing
|
||||||
element
|
element
|
||||||
; regular element, transform it
|
; regular element, transform it
|
||||||
|
@ -169,6 +170,10 @@
|
||||||
(map (λ (content)
|
(map (λ (content)
|
||||||
(if (element-is-element? content) (loop content) content))
|
(if (element-is-element? content) (loop content) content))
|
||||||
contents))]))))
|
contents))]))))
|
||||||
|
(module+ test
|
||||||
|
; check (& x) sequences are preserved
|
||||||
|
(check-equal? (update-tree (λ (e t a c) (list t a c)) '(body "Hey" (& nbsp) (a (@ (href "/")))))
|
||||||
|
'(body "Hey" (& nbsp) (a (@ (href "/"))))))
|
||||||
|
|
||||||
(define (has-class? name attributes)
|
(define (has-class? name attributes)
|
||||||
(and (member name (string-split (or (get-attribute 'class attributes) "") " ")) #t))
|
(and (member name (string-split (or (get-attribute 'class attributes) "") " ")) #t))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue