(define-module (web view doc) #:use-module (json) #:use-module (ice-9 match) #:use-module (ice-9 format) #:use-module (ice-9 iconv) #:use-module (ice-9 receive) #:use-module (ice-9 string-fun) #:use-module (sxml simple) #:use-module (web sxml) #:export (view-doc)) (define (parse-html buf) (car (cdr (xml->sxml buf)))) (define* (layout #:key (head '()) (body '()) (title "GeneNetwork.org API") (info "") (meta "") (data "") (back "") ) `((doctype "html") (html (@ (lang "en")) (head (title ,title) (meta (@ (http-equiv "Content-Type") (content "text/html; charset=UTF-8"))) (meta (@ (name "author") (content "GeneNetwork team"))) (meta (@ (name "viewport") (content "width=device-width, initial-scale=1"))) (link (@ (rel "stylesheet") (media "screen") (type "text/css") (href "./css/gn-doc.css"))) ,@head) (body (h1 ,title) (p ,info) (p "JSON API: " (a (@ (href ,meta)) "meta") " | " (a (@ (href ,data)) "data") " | " (a (@ (href ,back)) "back")) (pre ,(scm->json-string body #:pretty #t)) ; (p ,(parse-html "some raw really text here")) (footer (p "Copyright © 2005—2023 by the GeneNetwork community with a touch of " (span (@ (class "lambda")) "λ") "!") (p "This is free software. Download the " (a (@ (href "https://ci.genenetwork.org/")) "source code") ".")) )))) (define* (view-doc path page #:optional rec) (layout #:title page #:info (assoc-ref rec "info") #:meta (assoc-ref rec "meta") #:data (assoc-ref rec "data") #:back (assoc-ref rec "up") #:body rec))