diff options
Diffstat (limited to 'backupdesk/sur')
-rw-r--r-- | backupdesk/sur/docket.hoon | 82 | ||||
-rw-r--r-- | backupdesk/sur/markdown.hoon | 157 | ||||
-rw-r--r-- | backupdesk/sur/nostr.hoon | 103 | ||||
-rw-r--r-- | backupdesk/sur/nostrill.hoon | 51 | ||||
-rw-r--r-- | backupdesk/sur/spider.hoon | 27 | ||||
-rw-r--r-- | backupdesk/sur/trill/feed.hoon | 16 | ||||
-rw-r--r-- | backupdesk/sur/trill/gate.hoon | 26 | ||||
-rw-r--r-- | backupdesk/sur/trill/post.hoon | 121 |
8 files changed, 583 insertions, 0 deletions
diff --git a/backupdesk/sur/docket.hoon b/backupdesk/sur/docket.hoon new file mode 100644 index 0000000..091c8c9 --- /dev/null +++ b/backupdesk/sur/docket.hoon @@ -0,0 +1,82 @@ +|% +:: ++$ version + [major=@ud minor=@ud patch=@ud] +:: ++$ glob (map path mime) +:: ++$ url cord +:: $glob-location: How to retrieve a glob +:: ++$ glob-reference + [hash=@uvH location=glob-location] +:: ++$ glob-location + $% [%http =url] + [%ames =ship] + == +:: $href: Where a tile links to +:: ++$ href + $% [%glob base=term =glob-reference] + [%site =path] + == +:: $chad: State of a docket +:: ++$ chad + $~ [%install ~] + $% :: Done + [%glob =glob] + [%site ~] + :: Waiting + [%install ~] + [%suspend glob=(unit glob)] + :: Error + [%hung err=cord] + == +:: +:: $charge: A realized $docket +:: ++$ charge + $: =docket + =chad + == +:: +:: $clause: A key and value, as part of a docket +:: +:: Only used to parse $docket +:: ++$ clause + $% [%title title=@t] + [%info info=@t] + [%color color=@ux] + [%glob-http url=cord hash=@uvH] + [%glob-ames =ship hash=@uvH] + [%image =url] + [%site =path] + [%base base=term] + [%version =version] + [%website website=url] + [%license license=cord] + == +:: +:: $docket: A description of JS bundles for a desk +:: ++$ docket + $: %1 + title=@t + info=@t + color=@ux + =href + image=(unit url) + =version + website=url + license=cord + == +:: ++$ charge-update + $% [%initial initial=(map desk charge)] + [%add-charge =desk =charge] + [%del-charge =desk] + == +-- diff --git a/backupdesk/sur/markdown.hoon b/backupdesk/sur/markdown.hoon new file mode 100644 index 0000000..baf266e --- /dev/null +++ b/backupdesk/sur/markdown.hoon @@ -0,0 +1,157 @@ +=> |% + ++ ln + |% + :: + :: Url: optionally enclosed in triangle brackets + :: A link destination consists of either + :: - a sequence of zero or more characters between an opening < and a closing > that + :: contains no line breaks or unescaped < or > characters, or + :: - a nonempty sequence of characters that does not start with <, does not include + :: ASCII space or control characters, and includes parentheses only if (a) they are + :: backslash-escaped or (b) they are part of a balanced pair of unescaped parentheses. + :: (Implementations may impose limits on parentheses nesting to avoid performance + :: issues, but at least three levels of nesting should be supported.) + +$ url [text=@t has-triangle-brackets=?] + :: + :: Url with optional title-text + +$ urlt [=url title-text=(unit @t)] + :: + :: Link target: the part of a link after the display text. can be direct or reference + :: A reference link is in square brackets, and refers to a named link elsewhere. + :: - full => [Display][foo] + :: - collapsed => [Display][] + :: - shortcut => [Display] + :: Collapsed and shortcut links have a `label` equal to the display text. + +$ target $% [%direct =urlt] + [%ref type=?(%full %collapsed %shortcut) label=@t] + == + -- + -- +:: +|% + :: + :: Markdown document or fragment: a list of nodes + ++ markdown =< $+ markdown + (list node) + |% + +$ node $+ markdown-node + $@ ~ :: `$@ ~` is magic that makes recursive structures work + $% [%leaf node:leaf] + [%container node:container] + == + -- + :: + ++ inline + |% + :: A single inline element + ++ element $+ inline-element + $@ ~ + $%(escape entity code hardbrk softbrk text emphasis strong link image autolink html) + :: + :: Any amount of elements + ++ contents (list element) + :: + :: ----------------------- + :: List of inline elements + :: ----------------------- + :: + :: Backslash-escaped character + +$ escape [%escape char=@t] + :: + :: HTML-entity + +$ entity [%entity code=@t] + :: + :: Code span (inline code). Interpreted literally, cannot have nested elements. + :: Can be enclosed by any amount of backticks on each side, >= 1. Must be balanced. + +$ code [%code-span num-backticks=@ text=@t] + :: + :: Line break + +$ hardbrk [%line-break ~] + :: + :: Soft line break: a newline in the source code, will be rendered as a single space + +$ softbrk [%soft-line-break ~] + :: + :: Text: Just text + +$ text [%text text=@t] + :: + :: Emphasis and strong emphasis + :: Can use either tar "*" or cab "_" as the emphasis character. + :: Can have nested inline elements. + +$ emphasis [%emphasis emphasis-char=@t =contents] + +$ strong [%strong emphasis-char=@t =contents] + :: + :: Link + +$ link [%link =contents =target:ln] + :: + :: Images + +$ image [%image alt-text=@t =target:ln] + :: + :: Autolink: a link that's just itself, surrounded by "<...>" + +$ autolink [%autolink text=@t] + :: + :: HTML + +$ html [%html text=@t] + -- + :: + :: Leaf nodes: non-nested (i.e., terminal) nodes + ++ leaf + |% + ++ node $+ leaf-node + $@ ~ + $%(heading break codeblk-indent codeblk-fenced html link-ref-def table paragraph blank-line) + :: + :: Heading, either setext or ATX style + +$ heading [%heading style=?(%setext %atx) level=@ =contents:inline] + :: + :: Thematic break (horizontal line) + :: Consists of at least 3 repetitions of either hep '-', cab '_', or tar '*' + +$ break [%break char=@t char-count=@] + :: + :: Indentation-based code block: indented 4 spaces. Can include newlines and blank lines. + +$ codeblk-indent [%indent-codeblock text=@t] + :: + :: Fenced code block: begins and ends with 3+ repetitions of tic (`) or sig (~). + :: Can be indented up to 3 spaces. + +$ codeblk-fenced [%fenced-codeblock char=@t char-count=@ info-string=@t indent-level=@ text=@t] + :: + :: HTML + +$ html [%html text=@t] + :: + :: Link reference definition (defines a named link which can be referenced elsewhere) + +$ link-ref-def [%link-ref-definition label=@t =urlt:ln] + :: + :: Paragraph + +$ paragraph [%paragraph =contents:inline] + :: + :: Blank lines (not rendered, but lets user control aethetic layout of the source code) + +$ blank-line [%blank-line ~] + :: + :: Table (alignments: [l]eft, [r]ight, [c]enter, [n]one) + +$ table [%table widths=(list @) head=(list contents:inline) align=(list ?(%l %c %r %n)) rows=(list (list contents:inline))] + -- + :: + :: Container node: can contain other nodes (either container or leaf). + ++ container + |% + ++ node $+ container-node + $@ ~ + $%(block-quote ol ul tl) + :: + :: Block quote. Can be nested. + +$ block-quote [%block-quote =markdown] + :: + :: Ordered list: numbered based on first list item marker. + :: Marker char can be either dot '1. asdf' or par '1) asdf' + :: Can be indented up to 3 spaces + +$ ol [%ol indent-level=@ marker-char=@t start-num=@ contents=(list markdown)] :: is-tight=? + :: + :: Unordered list: bullet point list + :: Marker char can be either hep (-), lus (+) or tar (*) + :: Can be indented up to 3 spaces + +$ ul [%ul indent-level=@ marker-char=@t contents=(list markdown)] :: is-tight=? + :: + :: Task list: unordered list of tasks + :: Can be indented up to 3 spaces + +$ tl [%tl indent-level=@ marker-char=@t contents=(list [is-checked=? =markdown])] :: is-tight=? + -- +-- diff --git a/backupdesk/sur/nostr.hoon b/backupdesk/sur/nostr.hoon new file mode 100644 index 0000000..652a106 --- /dev/null +++ b/backupdesk/sur/nostr.hoon @@ -0,0 +1,103 @@ +|% ++$ keys [pub=@ priv=@] ++$ event +$: id=@ux :: 32bytes + pubkey=@ux :: 32bytes + created-at=@ud :: seconds + kind=@ud + tags=(list tag) + content=@t + sig=@ux :: 64bytes +== ++$ raw-event +$: pubkey=@ux :: 32bytes + created-at=@ud :: seconds + kind=@ud + tags=(list tag) + content=@t +== ++$ tag (list @t) +:: $: key=@t +:: value=@t +:: rest=(list @t) +:: == ++$ user-meta :: NIP-1 +$: name=@t + about=@t + picture=@t + other=(map @t json) +== ++$ relay-stats +$: connected=(unit @da) + reqs=(map sub-id event-stats) +== ++$ event-stats + [filters=(list filter) received=event-count] ++$ sub-id @t ++$ event-count @ud + ++$ relay-req +$: sub-id=@t + filters=(list filter) +== +:: Relay comms ++$ filter +$: ids=(unit (set @ux)) + authors=(unit (set @ux)) + kinds=(unit (set @ud)) + tags=(unit (map @t (set @t))) + since=(unit @da) + until=(unit @da) + limit=(unit @ud) +== +:: messages from relay +++ relay-msg +$% [%event sub-id=@t =event] + [%ok id=@ux accepted=? msg=@t] + [%eose sub-id=@t] + [%closed sub-id=@t msg=@t] + [%notice msg=@t] + [%auth challenge=@t] + :: from our shim + [%error msg=@t] +== +++ shim + |% + ++ url 'http://localhost:8888/shim' + +$ req + $% [%req relay-req] + [%event =event] + [%auth =event] + [%close sub-id=@t] + == + +$ bulk-req [relays=(list @t) =req] + -- + +:: https://github.com/sesseor/nostr-relays-list/blob/main/relays.txt +++ public-relays ^- (list @t) + :~ 'wss://nos.lol' + :: 'wss://relay.damus.io' + :: 'wss://nostr.wine' + :: 'wss://offchain.pub' + == + :: 'wss://knostr.neutrine.com' +-- +:: event: { +:: content: "😂", +:: created_at: 1758049319, +:: id: "36c8a0bb6a9a1ff3ca3e6868fdf2c055a09aea39b1c078b75c38f5a7b580da87", +:: kind: 7, +:: pubkey: "26d6a946675e603f8de4bf6f9cef442037b70c7eee170ff06ed7673fc34c98f1", +:: sig: "7b5a9c799776935f959eccfd311af6152db6a1360296c9790b35544d0b83a8d75f8937ad1ad6f5da3e0d3e2bdb1bfb92686adbde42c3ef53ca06771080d08153", +:: tags: [ +:: [ "e", "091d00811bb9a57088ab7c1d39697b0ed9bbbe05dae135b406f3560290fba311", +:: "wss://relay.nostr.band/", "root", "26d6a946675e603f8de4bf6f9cef442037b70c7eee170ff06ed7673fc34c98f1" +:: ], [ "e", "1cd926b58a1bac70adcedf38212d72ee1380e17dad1aef6bbc18782c5c540236", +:: "wss://relay.nostr.band/", "reply", "3252715543f6e43be086465129b030d47d76cf8cead4798e48864563c3375083" +:: ], [ "p", "26d6a946675e603f8de4bf6f9cef442037b70c7eee170ff06ed7673fc34c98f1", +:: "wss://nostr.bitcoiner.social/" +:: ], [ "p", "3252715543f6e43be086465129b030d47d76cf8cead4798e48864563c3375083", +:: "ws://relay.snort.social/" +:: ], [ "e", "b9a0c3b28a291d80bcb41ee730f2c48366fd2fefba0e68f9fb928bb9ca96f757" ], [ "p", "3252715543f6e43be086465129b030d47d76cf8cead4798e48864563c3375083" ] +:: ], +:: }, diff --git a/backupdesk/sur/nostrill.hoon b/backupdesk/sur/nostrill.hoon new file mode 100644 index 0000000..a0d270f --- /dev/null +++ b/backupdesk/sur/nostrill.hoon @@ -0,0 +1,51 @@ +/- trill=trill-feed, nostr +|% ++$ state state-0 ++$ state-0 + $: %0 + :: nostr config + relays=(map @t relay-stats:nostr) + keys=(lest keys:nostr) :: cycled, i.keys is current one + :: own feed + feed=feed:trill + :: nostr feed from relays + =nostr-feed + :: profiles + profiles=(map @ux user-meta:nostr) + following=(map @ux =feed:trill) + follow-graph=(map @ux (set follow)) + :: TODO global feed somehow? + + == ++$ nostr-feed ((mop @ud event:nostr) gth) +++ norm ((on @ud event:nostr) gth) ++$ follow [pubkey=@ux name=@t relay=(unit @t)] ++$ shim-msg +++ ui + |% + +$ poke + $% [%fols fols-poke] + [%post post-poke] + :: [%reac reac-poke] + [%prof prof-poke] + [%keys ~] :: cycle-keys + [%rela relay-poke] + == + +$ post-poke + $% [%add pubkey=@ux content=@t] + [%rt id=@ux pubkey=@ux relay=@t] :: NIP-18 + [%del pubkey=@ux] + == + +$ fols-poke + $% [%add pubkey=@ux] + [%del pubkey=@ux] + == + +$ prof-poke + $% [%add pubkey=@ux meta=user-meta:nostr] + [%del pubkey=@ux] + == + +$ relay-poke + $% [%send host=@p id=@ relays=(list @t)] + == + -- +-- diff --git a/backupdesk/sur/spider.hoon b/backupdesk/sur/spider.hoon new file mode 100644 index 0000000..7c21268 --- /dev/null +++ b/backupdesk/sur/spider.hoon @@ -0,0 +1,27 @@ +/+ libstrand=strand +=, strand=strand:libstrand +|% ++$ thread $-(vase shed:khan) ++$ input [=tid =cage] ++$ tid tid:strand ++$ bowl bowl:strand ++$ http-error + $? %bad-request :: 400 + %forbidden :: 403 + %nonexistent :: 404 + %offline :: 504 + == ++$ start-args + $: parent=(unit tid) + use=(unit tid) + =beak + file=term + =vase + == ++$ inline-args + $: parent=(unit tid) + use=(unit tid) + =beak + =shed:khan + == +-- diff --git a/backupdesk/sur/trill/feed.hoon b/backupdesk/sur/trill/feed.hoon new file mode 100644 index 0000000..be7abb5 --- /dev/null +++ b/backupdesk/sur/trill/feed.hoon @@ -0,0 +1,16 @@ +/- post=trill-post +|% ++$ feeds (map ship feed) ++$ feed ((mop id:post post:post) gth) ++$ index (map @t (set pid:post)) +++ orm ((on id:post post:post) gth) ++$ full-graph ((mop id:post full-node:post) gth) +++ form ((on id:post full-node:post) gth) ++$ global ((mop pid:post post:post) ggth) +++ ggth |=([[ship a=time] [ship b=time]] (gth a b)) +++ gorm ((on pid:post post:post) ggth) + ++$ cursor (unit @da) ++$ fc [=feed:feed start=cursor end=cursor] ++$ gc [mix=global:feed start=cursor end=cursor] +-- diff --git a/backupdesk/sur/trill/gate.hoon b/backupdesk/sur/trill/gate.hoon new file mode 100644 index 0000000..ddc0adb --- /dev/null +++ b/backupdesk/sur/trill/gate.hoon @@ -0,0 +1,26 @@ +|% ++$ gate +$: =lock + begs=(set @p) :: follow requests + post-begs=(set post-beg) :: read requests for specific posts + :: TODO include whole thread? + mute=lock :: mute list to prevent request spamming + backlog=$~(50 @) :: size of backlog sent to followers by default +== ++$ post-beg [=ship id=@da] + ++$ lock +$: rank=[caveats=(set rank:title) locked=_| public=?] + luk=[caveats=(set ship) locked=_| public=?] + ship=[caveats=(set ship) locked=_| public=?] + tags=[caveats=(set @t) locked=_| public=?] + custom=[fn=(unit $-(@p ?)) public=?] +== ++$ change +$% [%set-rank set=(set rank:title) locked=? public=?] + [%set-luk set=(set ship) locked=? public=?] + [%set-ship set=(set ship) locked=? public=?] + [%set-tags set=(set @t) locked=? public=?] + [%set-custom term] :: Handle this and set in hoon +== +-- diff --git a/backupdesk/sur/trill/post.hoon b/backupdesk/sur/trill/post.hoon new file mode 100644 index 0000000..97912ce --- /dev/null +++ b/backupdesk/sur/trill/post.hoon @@ -0,0 +1,121 @@ +/- gate=trill-gate +|% ++$ id @da ++$ pid [=ship =id] +:: anon post type? ++$ tag @t ++$ post + $: =id + host=ship + author=ship + thread=id + parent=(unit id) + children=(set id) + contents=content-map + read=lock:gate + write=lock:gate + =engagement + =hash :: We'll reuse this for the Nostr pubkey + =signature + tags=(set tag) ::TODO make sure it's not infinite + == ++$ sent-post + $: host=ship + author=ship + thread=(unit id) + parent=(unit id) + contents=content-list + read=lock:gate + write=lock:gate + tags=(set tag) + == ++$ full-node + $: =id + host=ship + author=ship + thread=id + parent=(unit id) + children=internal-graph + contents=content-map + read=lock:gate + write=lock:gate + =engagement + =hash + =signature + tags=(set tag) + == +:: recursive types crash ++$ internal-graph + $~ [%empty ~] + $% [%full p=full-graph] + [%empty ~] + == ++$ full-graph ((mop id full-node) gth) +++ form ((on id full-node) gth) +:: from post:graph-store +:: +sham (half sha-256) hash of +validated-portion ++$ hash @uvH +:: ++$ signature [p=@uvH q=ship r=life] ++$ engagement + $: + =reacts + quoted=(set signed-pid) + shared=(set signed-pid) + == ++$ signed-pid [=signature =pid] ++$ react @t ++$ reacts (map ship signed-react-2) ++$ signed-react [=pid author=ship =react =signature] ++$ signed-react-2 [p=react q=signature] + + ++$ content-map ((mop time content-list) gth) +++ corm ((on time content-list) gth) +:: +$ content-list contents:contents-1 ++$ content-list contents ++$ li content-list ++$ contents (list block) ++$ paragraph (list inline) ++$ heading $?(%h1 %h2 %h3 %h4 %h5 %h6) ++$ block + $% [%paragraph p=(list inline)] + [%blockquote p=(list inline)] + [%table rows=(list (list contents))] + [%heading p=cord q=heading] + [%list p=(list inline) ordered=?] + [%media =media] + [%codeblock code=cord lang=cord] + [%eval hoon=cord] + :: + [%ref type=term =ship =path] + :: + [%json origin=term content=@t] + :: TODO get rid of this. should be a ref + [%poll id=@da] + == ++$ poll-opt [option=cord votes=@] ++$ media + $% [%images p=(list cord)] + [%video p=cord] + [%audio p=cord] + == ++$ inline + $% [%text p=cord] + [%italic p=cord] + [%bold p=cord] + [%strike p=cord] + [%codespan p=cord] + [%link href=cord show=cord] + [%break ~] + :: not strictly markdown + [%underline p=cord] + [%sup p=cord] + [%sub p=cord] + [%ruby p=cord q=cord] + :: custom types + [%ship p=ship] + :: TODO + :: [%date p=@da] + == +-- |