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

Restructure things and add homepage

parent 16b4d5f8
......@@ -8,6 +8,9 @@
racket/runtime-path
magenc/install-factory)
;;; 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)
'TODO)
(define-values (golem-dispatch golem-url)
(dispatch-rules
[("") 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)
'TODO)
(define (live-object-outbox req obj-id)
(define (outbox req)
'TODO)
(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)
(dispatch-rules
[("") 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)
(list
"[" `(a (@ (href ,link-url))
,link-name)
"]"))
#;(define username
(and=> (ctx-ref 'user)
(lambda (u)
(asobj-ref u "preferredUsername"))))
`(html (@ (xmlns "http://www.w3.org/1999/xhtml"))
(head
(meta (@ (charset "utf-8")))
(title ,(if title
(string-append title " -- Golem")
"Golem"))
;; css
(link (@ (rel "stylesheet")
(href "/css/main.css"))))
(body
(div (@ (id "main-wrapper"))
(header (@ (id "site-header"))
;; @@: Not semantic naming!
(span (@ (id "site-header-left-stuff"))
(b (a (@ (href ,(golem-url homepage)))
"*golem*"))))
(div (@ (id "site-main-content"))
,body))
(div (@ (id "site-footer"))
(a (@ (href "https://gitlab.com/spritely/golem"))
"Golem")
" is released under the... Apache v2 license? Not sure yet"))))
(define (generic-content-tmpl . content)
`(div (@ (class "generic-content-box"))
,@content))
(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