Commit 72a4c8f4 authored by Christopher Lemmer Webber's avatar Christopher Lemmer Webber

Restructure things and add homepage

parent 16b4d5f8
......@@ -8,6 +8,9 @@
;;; Utilities
;;; =========
(define-runtime-path cwd ".")
(define (ok body #:content-type [content-type #"application/octet-stream"])
......@@ -22,17 +25,26 @@
(ok (xexp->html-bytes sxml)
#:content-type #"text/html"))
(define (homepage req)
(render-ok '(html (title "It's ok")
(body (p "Everything will be ok")))))
;;; Routing
;;; =======
(define (live-object req obj-id)
(define-values (golem-dispatch golem-url)
[("") homepage]
[("inbox") inbox]
[("outbox") outbox]
[("enc" (string-arg)) serve-encrypted-object]))
;;; Pages
;;; =====
(define (homepage req)
(render-ok (base-tmpl (generic-content-tmpl '(p "Hi there!")))))
(define (live-object-inbox req obj-id)
(define (inbox req)
(define (live-object-outbox req obj-id)
(define (outbox req)
(define (serve-encrypted-object req enc-hash-str)
......@@ -49,13 +61,52 @@
(lambda (out-port)
(write-bytes #"Not found X_X" out-port))))
(define-values (golem-dispatch golem-url)
[("") homepage]
[("live" (string-arg)) live-object]
[("live" (string-arg) "inbox") live-object-inbox]
[("live" (string-arg) "outbox") live-object-outbox]
[("enc" (string-arg)) serve-encrypted-object]))
;;; Templates
;;; =========
(define (base-tmpl body #:title [title #f])
#;(define (header-link link-name link-url)
"[" `(a (@ (href ,link-url))
#;(define username
(and=> (ctx-ref 'user)
(lambda (u)
(asobj-ref u "preferredUsername"))))
`(html (@ (xmlns ""))
(meta (@ (charset "utf-8")))
(title ,(if title
(string-append title " -- Golem")
;; css
(link (@ (rel "stylesheet")
(href "/css/main.css"))))
(div (@ (id "main-wrapper"))
(header (@ (id "site-header"))
;; @@: Not semantic naming!
(span (@ (id "site-header-left-stuff"))
(b (a (@ (href ,(golem-url homepage)))
(div (@ (id "site-main-content"))
(div (@ (id "site-footer"))
(a (@ (href ""))
" is released under the... Apache v2 license? Not sure yet"))))
(define (generic-content-tmpl . content)
`(div (@ (class "generic-content-box"))
(define (centered-content-tmpl . content)
`(div (@ (class "simple-centered-wrap"))
,(apply generic-content-tmpl content)))
;;; Application launching
;;; =====================
(define (main)
(serve/servlet golem-dispatch
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment