Create basic settings and build webfinger
This commit is contained in:
parent
e162a531bc
commit
3cf3db8db2
1
NOTES.md
1
NOTES.md
|
@ -3,6 +3,7 @@
|
||||||
- crypto-lib
|
- crypto-lib
|
||||||
- markdown
|
- markdown
|
||||||
- sass (submodule, needed modifications)
|
- sass (submodule, needed modifications)
|
||||||
|
- http
|
||||||
|
|
||||||
## Disk structure
|
## Disk structure
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,14 @@
|
||||||
;; static generation rules
|
;; static generation rules
|
||||||
|
|
||||||
(require json
|
(require json
|
||||||
|
net/url-string
|
||||||
"compile.rkt")
|
"compile.rkt")
|
||||||
|
|
||||||
|
(define (get-pref prefs what)
|
||||||
|
(match prefs
|
||||||
|
[(list _ ... (list (? (curry symbol=? what)) value) _ ...) value]
|
||||||
|
[_ (error "no such pref" prefs what)]))
|
||||||
|
|
||||||
(define ACTOR-CONTEXT
|
(define ACTOR-CONTEXT
|
||||||
(list "https://www.w3.org/ns/activitystreams"
|
(list "https://www.w3.org/ns/activitystreams"
|
||||||
"https://w3id.org/security/v1"
|
"https://w3id.org/security/v1"
|
||||||
|
@ -19,15 +25,20 @@
|
||||||
'featured "toot:featured")))
|
'featured "toot:featured")))
|
||||||
|
|
||||||
(define compile-index-json
|
(define compile-index-json
|
||||||
(rule '("db/actorkey.pub") "public/index.json"
|
(rule '("db/actorkey.pub" "src/instance.rktd" "src/bio.md") "public/index.json"
|
||||||
(lambda (in out)
|
(lambda (in out)
|
||||||
(define key (port->string (hash-ref in "db/actorkey.pub")))
|
(define key (port->string (hash-ref in "db/actorkey.pub")))
|
||||||
|
(define prefs (read (hash-ref in "src/instance.rktd")))
|
||||||
|
(define instance-url (get-pref prefs 'shonks:instance-url))
|
||||||
|
(define display-name (get-pref prefs 'shonks:display-name))
|
||||||
|
(define name (get-pref prefs 'shonks:name))
|
||||||
|
(define bio (port->string (hash-ref in "src/bio.md")))
|
||||||
(define actor (hash
|
(define actor (hash
|
||||||
'@context ACTOR-CONTEXT
|
'@context ACTOR-CONTEXT
|
||||||
'Type "Person"
|
'Type "Person"
|
||||||
'id "https://example.tld/"
|
'id instance-url
|
||||||
'name "haskal"
|
'name display-name
|
||||||
'preferredUsername "haskal"
|
'preferredUsername name
|
||||||
'icon (hash 'type "Image"
|
'icon (hash 'type "Image"
|
||||||
'url "something"
|
'url "something"
|
||||||
'sensitive #f)
|
'sensitive #f)
|
||||||
|
@ -35,29 +46,46 @@
|
||||||
'url "something"
|
'url "something"
|
||||||
'sensitive #f)
|
'sensitive #f)
|
||||||
'tag (list (hash 'type "Hashtag"
|
'tag (list (hash 'type "Hashtag"
|
||||||
'href "https://example.tld/tags/blahaj"
|
'href (string-append instance-url "tags/blahaj")
|
||||||
'name "#blahaj"))
|
'name "#blahaj"))
|
||||||
'manuallyApprovesFollowers #f
|
'manuallyApprovesFollowers #f
|
||||||
'summary "summary lol"
|
'summary bio
|
||||||
'attachment (list (hash 'type "PropertyValue"
|
'attachment (list (hash 'type "PropertyValue"
|
||||||
'name "pronouns"
|
'name "pronouns"
|
||||||
'value "they/them"))
|
'value "they/them"))
|
||||||
'url "https://example.tld/"
|
'url instance-url
|
||||||
'inbox "https://example.tld/inbox"
|
'inbox (string-append instance-url "inbox")
|
||||||
'sharedInbox "https://example.tld/inbox"
|
'sharedInbox (string-append instance-url "inbox")
|
||||||
'endpoints (hash 'sharedInbox "https://example.tld/inbox")
|
'endpoints (hash 'sharedInbox (string-append instance-url "inbox"))
|
||||||
'outbox "https://example.tld/outbox"
|
'outbox (string-append instance-url "outbox")
|
||||||
'following 'null
|
'following 'null
|
||||||
'followers "https://example.tld/followers"
|
'followers (string-append instance-url "followers")
|
||||||
'liked 'null
|
'liked 'null
|
||||||
'publicKey (hash 'id "https://example.tld/#main-key"
|
'publicKey (hash 'id (string-append instance-url "#main-key")
|
||||||
'type "Key"
|
'type "Key"
|
||||||
'owner "https://example.tld/"
|
'owner instance-url
|
||||||
'publicKeyPem key)))
|
'publicKeyPem key)))
|
||||||
(write-json actor out))))
|
(write-json actor out))))
|
||||||
|
|
||||||
|
(define compile-webfinger
|
||||||
|
(rule '("src/instance.rktd") "public/webfinger.json"
|
||||||
|
(lambda (in out)
|
||||||
|
(define prefs (read (hash-ref in "src/instance.rktd")))
|
||||||
|
(define instance-url (get-pref prefs 'shonks:instance-url))
|
||||||
|
(define host (url-host (string->url instance-url)))
|
||||||
|
(define name (get-pref prefs 'shonks:name))
|
||||||
|
(define webfinger
|
||||||
|
(hash
|
||||||
|
'subject (format "acct:~a@~a" name host)
|
||||||
|
'links (list (hash
|
||||||
|
'rel "self"
|
||||||
|
'type "application/activity+json"
|
||||||
|
'href instance-url))))
|
||||||
|
(write-json webfinger out))))
|
||||||
|
|
||||||
(define compiler-rules
|
(define compiler-rules
|
||||||
(set compile-index-json))
|
(set compile-index-json
|
||||||
|
compile-webfinger))
|
||||||
|
|
||||||
(define ops (generate-operations compiler-rules))
|
(define ops (generate-operations compiler-rules))
|
||||||
(for ([op (in-list ops)])
|
(for ([op (in-list ops)])
|
||||||
|
|
20
scripts/init
20
scripts/init
|
@ -43,10 +43,14 @@
|
||||||
|
|
||||||
; src and public
|
; src and public
|
||||||
(make-directory "src")
|
(make-directory "src")
|
||||||
(put-preferences '(shonks:instance-url shonks:display-name shonks:name)
|
;; TODO
|
||||||
'("https://myinstance.tld/" "Display Name(tm)" "username")
|
;; don't rly like preferences, so this is custom because i said so :P
|
||||||
#f
|
(define DEFAULT-PREFS
|
||||||
"src/instance.rktd")
|
'((shonks:instance-url "https://myinstance.tld/")
|
||||||
|
(shonks:display-name "Display Name(tm)")
|
||||||
|
(shonks:name "username")))
|
||||||
|
(with-output-to-file "src/instance.rktd"
|
||||||
|
(lambda () (pretty-write DEFAULT-PREFS) (void)))
|
||||||
(with-output-to-file "src/bio.md"
|
(with-output-to-file "src/bio.md"
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(write-string "this section left intentionally blank")
|
(write-string "this section left intentionally blank")
|
||||||
|
@ -55,11 +59,13 @@
|
||||||
|
|
||||||
(make-directory "public")
|
(make-directory "public")
|
||||||
(make-directory "public/posts")
|
(make-directory "public/posts")
|
||||||
|
(make-directory "public/tags")
|
||||||
|
|
||||||
|
(make-directory "nginx")
|
||||||
|
|
||||||
; task queue
|
; task queue
|
||||||
(define c (sqlite3-connect #:database "taskq.sqlite3" #:mode 'create))
|
(require "../private/taskq.rkt")
|
||||||
(query-exec c "create table taskq (id blob(16) primary key, task blob, state integer)")
|
(taskq-close (make-taskq "taskq.sqlite3" #t))
|
||||||
(disconnect c)
|
|
||||||
|
|
||||||
(with-output-to-file "version" (lambda () (write-string "1.0") (void)))
|
(with-output-to-file "version" (lambda () (write-string "1.0") (void)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue