mirror of
https://github.com/urbit/shrub.git
synced 2024-11-30 22:15:47 +03:00
neo: self hosting chat
This commit is contained in:
parent
cbc36f52aa
commit
7b95a245bc
50
pkg/arvo/neo/src/std/imp/message.hoon
Normal file
50
pkg/arvo/neo/src/std/imp/message.hoon
Normal file
@ -0,0 +1,50 @@
|
||||
/@ message
|
||||
:: sender ship namesapce (~bus)
|
||||
:: /messages/1
|
||||
:: host ship namespace
|
||||
:: /chat/foo
|
||||
:: /chat/foo/messages/1 :: symlink to /+bus/messages/1
|
||||
::
|
||||
:: /~zod/chat/foo/messages/1 <- []
|
||||
:: /~zod/chat/foo/messages/1 <-
|
||||
:: /~zod/chat/foo/messages/1 <-
|
||||
::
|
||||
:: /~bus/subs/foo -> /~zod/chat/foo
|
||||
::
|
||||
:: [/~bus/subs/foo/messages/1 %make ]
|
||||
:: possibly optimisticaly update, then forward note to foreign ship
|
||||
::
|
||||
:: %make
|
||||
:: ^- firm:neo
|
||||
|%
|
||||
+$ state %message
|
||||
+$ poke ~
|
||||
++ kids *kids:neo
|
||||
++ deps *deps:neo
|
||||
++ form
|
||||
^- form:neo
|
||||
|_ [=bowl:neo case=@ud vase-state=vase *]
|
||||
++ call
|
||||
|= [old-state=* act=*]
|
||||
:: =+ ;;(=action act)
|
||||
:: ~& call/act
|
||||
*(list card:neo)
|
||||
++ reduce
|
||||
|= act=*
|
||||
^- vase
|
||||
vase-state
|
||||
++ init
|
||||
|= vas=(unit vase)
|
||||
?> ?=(^ vas)
|
||||
=+ !<(state=message u.vas)
|
||||
!>(state)
|
||||
++ echo
|
||||
|= [=pith val=*]
|
||||
*(list card:neo)
|
||||
++ born
|
||||
*(list card:neo)
|
||||
++ take
|
||||
|= =sign:neo
|
||||
*(list card:neo)
|
||||
--
|
||||
--
|
7
pkg/arvo/neo/src/std/pro/chat-diff.hoon
Normal file
7
pkg/arvo/neo/src/std/pro/chat-diff.hoon
Normal file
@ -0,0 +1,7 @@
|
||||
/@ message
|
||||
$% [%title title=@t] :: update
|
||||
[%add =ship]
|
||||
[%del =ship]
|
||||
[%msg pro=pith message]
|
||||
[%dbug ~]
|
||||
==
|
@ -1,91 +1 @@
|
||||
/@ message
|
||||
=>
|
||||
|%
|
||||
++ card card:neo
|
||||
++ msg-loc
|
||||
|= =bowl:neo
|
||||
^- path
|
||||
/(scot %p our.bowl)/base/(scot %da now.bowl)/lib/message/hoon
|
||||
--
|
||||
^- firm:neo
|
||||
|%
|
||||
:: $state: state for chat container
|
||||
:: .who: set of ships allowed to poke
|
||||
:: .title: human-readable title of chat
|
||||
::
|
||||
+$ state [%0 who=(set ship) title=@t]
|
||||
:: $poke: update for chat container
|
||||
::
|
||||
:: %title:
|
||||
:: %add: add .ship to .who in $state
|
||||
:: %del: remove .ship from .who in $state
|
||||
::
|
||||
+$ poke
|
||||
$% [%title title=@t] :: update
|
||||
[%add =ship]
|
||||
[%del =ship]
|
||||
[%msg msg=state:message]
|
||||
[%dbug ~]
|
||||
==
|
||||
++ kids
|
||||
=< apex
|
||||
|%
|
||||
++ apex
|
||||
%- ~(gas by *kids:neo)
|
||||
:~ messages
|
||||
==
|
||||
++ messages
|
||||
:- ~[&/%messages |/%da]
|
||||
[state:message poke:message]
|
||||
--
|
||||
++ deps
|
||||
=< apex
|
||||
|%
|
||||
++ apex
|
||||
%- ~(gas by *deps:neo)
|
||||
:~ open/open
|
||||
==
|
||||
++ open
|
||||
[| ,? ,?]
|
||||
--
|
||||
++ form
|
||||
^- form:neo
|
||||
|_ [=bowl:neo case=@ud state-vase=vase *]
|
||||
+* sta !<(state state-vase)
|
||||
++ call
|
||||
|= [old-state=vase act=*]
|
||||
=+ ;;(=poke act)
|
||||
?: ?=(%dbug -.poke)
|
||||
~& dbug/bowl
|
||||
*(list card)
|
||||
?. ?=(%msg -.poke)
|
||||
*(list card)
|
||||
[%neo (welp were.bowl ~[da/now.bowl]) %make %message `!>(msg.poke) ~]^~
|
||||
++ reduce
|
||||
|= pok=*
|
||||
^- vase
|
||||
=+ ;;(=poke pok)
|
||||
=/ sta sta
|
||||
?. ;;(? +:(~(gut by deps.bowl) %open [*pith &]))
|
||||
~&(dropping-poke/poke !>(sta))
|
||||
?> |(=(our src):bowl (~(has in who.sta) src.bowl))
|
||||
=- !>(-)
|
||||
^- state
|
||||
?- -.poke
|
||||
%title !! :: sta(title title.poke)
|
||||
%add sta(who (~(put in who.sta) ship.poke))
|
||||
%del sta(who (~(del in who.sta) ship.poke))
|
||||
?(%dbug %msg) sta
|
||||
==
|
||||
++ init
|
||||
|= old=(unit vase)
|
||||
!>(*state)
|
||||
++ born *(list card:neo)
|
||||
++ echo
|
||||
|= [=pith val=*]
|
||||
*(list card:neo)
|
||||
++ take
|
||||
|= =sign:neo
|
||||
*(list card:neo)
|
||||
--
|
||||
--
|
||||
,[%0 who=(set ship) title=@t]
|
||||
|
1
pkg/arvo/neo/src/std/pro/ford-hoon.hoon
Normal file
1
pkg/arvo/neo/src/std/pro/ford-hoon.hoon
Normal file
@ -0,0 +1 @@
|
||||
[cache=(unit vase) =hoon]
|
1
pkg/arvo/neo/src/std/pro/ford-poke.hoon
Normal file
1
pkg/arvo/neo/src/std/pro/ford-poke.hoon
Normal file
@ -0,0 +1 @@
|
||||
[%dep ~]
|
1
pkg/arvo/neo/src/std/pro/ford-state.hoon
Normal file
1
pkg/arvo/neo/src/std/pro/ford-state.hoon
Normal file
@ -0,0 +1 @@
|
||||
[cache=(unit vase) ~]
|
@ -1,50 +1 @@
|
||||
:: sender ship namesapce (~bus)
|
||||
:: /messages/1
|
||||
:: host ship namespace
|
||||
:: /chat/foo
|
||||
:: /chat/foo/messages/1 :: symlink to /+bus/messages/1
|
||||
::
|
||||
:: /~zod/chat/foo/messages/1 <- []
|
||||
:: /~zod/chat/foo/messages/1 <-
|
||||
:: /~zod/chat/foo/messages/1 <-
|
||||
::
|
||||
:: /~bus/subs/foo -> /~zod/chat/foo
|
||||
::
|
||||
:: [/~bus/subs/foo/messages/1 %make ]
|
||||
:: possibly optimisticaly update, then forward note to foreign ship
|
||||
::
|
||||
:: %make
|
||||
:: ^- firm:neo
|
||||
|%
|
||||
+$ state [from=ship now=time message=@t]
|
||||
+$ poke ~
|
||||
++ kids *kids:neo
|
||||
++ deps *deps:neo
|
||||
++ form
|
||||
^- form:neo
|
||||
|_ [=bowl:neo case=@ud vase-state=vase *]
|
||||
+* sta !<(state vase-state)
|
||||
++ call
|
||||
|= [old-state=* act=*]
|
||||
:: =+ ;;(=action act)
|
||||
:: ~& call/act
|
||||
*(list card:neo)
|
||||
++ reduce
|
||||
|= act=*
|
||||
^- vase
|
||||
!>(sta)
|
||||
++ init
|
||||
|= vas=(unit vase)
|
||||
?> ?=(^ vas)
|
||||
=+ !<(=state u.vas)
|
||||
!>(state)
|
||||
++ echo
|
||||
|= [=pith val=*]
|
||||
*(list card:neo)
|
||||
++ born
|
||||
*(list card:neo)
|
||||
++ take
|
||||
|= =sign:neo
|
||||
*(list card:neo)
|
||||
--
|
||||
--
|
||||
,[from=ship now=time contents=@t]
|
||||
|
Loading…
Reference in New Issue
Block a user