Generate basic actor file
This commit is contained in:
parent
3137913552
commit
438b14d76f
|
@ -2,8 +2,15 @@
|
||||||
|
|
||||||
;; compiler
|
;; compiler
|
||||||
|
|
||||||
|
(provide (struct-out rule)
|
||||||
|
generate-operations
|
||||||
|
execute-rule)
|
||||||
|
|
||||||
|
;; A compiler rule
|
||||||
|
;; Input files, output file, compile function
|
||||||
(struct rule [inputs output compiler] #:transparent)
|
(struct rule [inputs output compiler] #:transparent)
|
||||||
|
|
||||||
|
;; Converts set of rules into ordered list of rules to execute based on current filesystem state
|
||||||
(define (generate-operations rules)
|
(define (generate-operations rules)
|
||||||
(define nodes (mutable-set))
|
(define nodes (mutable-set))
|
||||||
(define edges (make-hash))
|
(define edges (make-hash))
|
||||||
|
@ -92,10 +99,19 @@
|
||||||
(error "self-check failed lmao"))
|
(error "self-check failed lmao"))
|
||||||
dirty-sorted)
|
dirty-sorted)
|
||||||
|
|
||||||
|
;; Executes one rule
|
||||||
(define compiler-rules
|
(define (execute-rule r)
|
||||||
(set
|
(match-define (rule in out func) r)
|
||||||
(rule '("test.o") "my_binary" void)
|
(define cust (make-custodian))
|
||||||
(rule '("test.c") "test.o" void)))
|
(parameterize ([current-custodian cust])
|
||||||
|
(thread-wait
|
||||||
(generate-operations compiler-rules)
|
(thread
|
||||||
|
(lambda ()
|
||||||
|
(call-with-atomic-output-file
|
||||||
|
out
|
||||||
|
(lambda (out-port tmp-path)
|
||||||
|
(func
|
||||||
|
(for/hash ([fn (in-list in)])
|
||||||
|
(values fn (open-input-file fn)))
|
||||||
|
out-port)))))))
|
||||||
|
(custodian-shutdown-all cust))
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
#lang racket
|
||||||
|
|
||||||
|
;; static generation rules
|
||||||
|
|
||||||
|
(require json
|
||||||
|
"compile.rkt")
|
||||||
|
|
||||||
|
(define ACTOR-CONTEXT
|
||||||
|
(list "https://www.w3.org/ns/activitystreams"
|
||||||
|
"https://w3id.org/security/v1"
|
||||||
|
(hash 'manuallyApprovesFollowers "as:manuallyApprovesFollowers"
|
||||||
|
'sensitive "as:sensitive"
|
||||||
|
'movedTo "as:movedTo"
|
||||||
|
'Hashtag "as:Hashtag"
|
||||||
|
'toot "http://joinmastodon.org/ns#"
|
||||||
|
'Emoji "toot:Emoji"
|
||||||
|
'focalPoint (hash '@container "@list"
|
||||||
|
'@id "toot:focalPoint")
|
||||||
|
'featured "toot:featured")))
|
||||||
|
|
||||||
|
(define compile-index-json
|
||||||
|
(rule '("db/actorkey.pub") "public/index.json"
|
||||||
|
(lambda (in out)
|
||||||
|
(define key (port->string (hash-ref in "db/actorkey.pub")))
|
||||||
|
(define actor (hash
|
||||||
|
'@context ACTOR-CONTEXT
|
||||||
|
'Type "Person"
|
||||||
|
'id "https://example.tld/"
|
||||||
|
'name "haskal"
|
||||||
|
'preferredUsername "haskal"
|
||||||
|
'icon (hash 'type "Image"
|
||||||
|
'url "something"
|
||||||
|
'sensitive #f)
|
||||||
|
'image (hash 'type "Image"
|
||||||
|
'url "something"
|
||||||
|
'sensitive #f)
|
||||||
|
'tag (list (hash 'type "Hashtag"
|
||||||
|
'href "https://example.tld/tags/blahaj"
|
||||||
|
'name "#blahaj"))
|
||||||
|
'manuallyApprovesFollowers #f
|
||||||
|
'summary "summary lol"
|
||||||
|
'attachment (list (hash 'type "PropertyValue"
|
||||||
|
'name "pronouns"
|
||||||
|
'value "they/them"))
|
||||||
|
'url "https://example.tld/"
|
||||||
|
'inbox "https://example.tld/inbox"
|
||||||
|
'sharedInbox "https://example.tld/inbox"
|
||||||
|
'endpoints (hash 'sharedInbox "https://example.tld/inbox")
|
||||||
|
'outbox "https://example.tld/outbox"
|
||||||
|
'following 'null
|
||||||
|
'followers "https://example.tld/followers"
|
||||||
|
'liked 'null
|
||||||
|
'publicKey (hash 'id "https://example.tld/#main-key"
|
||||||
|
'type "Key"
|
||||||
|
'owner "https://example.tld/"
|
||||||
|
'publicKeyPem key)))
|
||||||
|
(write-json actor out))))
|
||||||
|
|
||||||
|
(define compiler-rules
|
||||||
|
(set compile-index-json))
|
||||||
|
|
||||||
|
(define ops (generate-operations compiler-rules))
|
||||||
|
(for ([op (in-list ops)])
|
||||||
|
(printf "executing ~s\n" op)
|
||||||
|
(execute-rule op))
|
Loading…
Reference in New Issue