94 lines
2.5 KiB
Racket
Executable File
94 lines
2.5 KiB
Racket
Executable File
#!/usr/bin/env racket
|
|
#lang racket
|
|
; vim: ft=racket
|
|
|
|
(require db
|
|
crypto
|
|
crypto/libcrypto
|
|
net/base64
|
|
"../private/prefs.rkt"
|
|
"../private/taskq.rkt")
|
|
|
|
(when (file-exists? "version")
|
|
(displayln "current directory contains data")
|
|
(exit))
|
|
|
|
; cache dirs
|
|
(make-directory "cache")
|
|
(make-directory "cache/actors")
|
|
(make-directory "cache/posts")
|
|
|
|
; db dirs
|
|
(make-directory "db")
|
|
(make-directory "db/followers")
|
|
(make-directory "db/comments")
|
|
(make-directory "db/posted")
|
|
|
|
; actor keys
|
|
(define PK-BEGIN "-----BEGIN PUBLIC KEY-----")
|
|
(define PK-END "-----END PUBLIC KEY-----")
|
|
(crypto-factories (list libcrypto-factory))
|
|
(define actor-key (generate-private-key 'rsa '((nbits 4096))))
|
|
(with-output-to-file
|
|
"db/actorkey"
|
|
(lambda ()
|
|
(write-bytes (pk-key->datum actor-key 'PrivateKeyInfo))
|
|
(void)))
|
|
(with-output-to-file
|
|
"db/actorkey.pub"
|
|
(lambda ()
|
|
(write-bytes (string->bytes/utf-8 PK-BEGIN))
|
|
(write-bytes #"\n")
|
|
(define pem (pk-key->datum actor-key 'SubjectPublicKeyInfo))
|
|
(write-bytes (base64-encode pem))
|
|
(write-bytes (string->bytes/utf-8 PK-END))
|
|
(void)))
|
|
|
|
; src and public
|
|
(make-directory "src")
|
|
|
|
(with-output-to-file "src/instance.rktd"
|
|
(lambda () (prefs-save DEFAULT-PREFS) (void)))
|
|
(with-output-to-file "src/bio.md"
|
|
(lambda ()
|
|
(write-string "this section left intentionally blank")
|
|
(void)))
|
|
(with-output-to-file "src/style.sass"
|
|
(lambda () (write-string "// styles go here :P\n") (void)))
|
|
;; TODO index template
|
|
(with-output-to-file "src/template-post.html"
|
|
(lambda ()
|
|
(write-string ;; TODO add more meta elements / semantic web type stuff
|
|
;; add an embedded json-LD object maybe
|
|
"<!DOCTYPE html>
|
|
<html lang='{{prefs.lang}}'>
|
|
<head>
|
|
<meta charset='UTF-8' />
|
|
<meta name='viewport' content='width=device-width, initial-scale=1' />
|
|
<meta name='description' content='{{post.summary}}'>
|
|
<title>{{post.title}} &em; {{prefs.title}}</title>
|
|
</head>
|
|
<body>
|
|
<article>
|
|
{{post.content}}
|
|
</article>
|
|
</body>
|
|
</html>"
|
|
) (void)))
|
|
|
|
(make-directory "src/posts")
|
|
(make-directory "src/drafts")
|
|
|
|
(make-directory "public")
|
|
(make-directory "public/posts")
|
|
(make-directory "public/tags")
|
|
|
|
(make-directory "nginx")
|
|
|
|
; task queue
|
|
(taskq-shutdown (make-taskq "taskq.sqlite3" #t))
|
|
|
|
(with-output-to-file "version" (lambda () (write-string "1.0") (void)))
|
|
|
|
(displayln "done")
|