Added current state of all modulo repos from interface monorepo

This commit is contained in:
Logan Allen 2019-06-04 14:29:53 -07:00 committed by Isaac Visintainer
parent 372df74470
commit 64069af56a
75 changed files with 182215 additions and 1004 deletions

527
app/chat.hoon Normal file
View File

@ -0,0 +1,527 @@
/- hall
/+ *server, chat, hall-json
/= index
/^ octs
/; as-octs:mimes:html
/: /===/app/chat/index
/| /html/
/~ ~
==
/= tile-js
/^ octs
/; as-octs:mimes:html
/: /===/app/chat/js/tile
/| /js/
/~ ~
==
/= script
/^ octs
/; as-octs:mimes:html
/: /===/app/chat/js/index
/| /js/
/~ ~
==
/= style
/^ octs
/; as-octs:mimes:html
/: /===/app/chat/css/index
/| /css/
/~ ~
==
/= style
/^ octs
/; as-octs:mimes:html
/: /===/app/chat/css/index
/| /css/
/~ ~
==
/= chat-png
/^ (map knot @)
/: /===/app/chat/img /_ /png/
::
=, chat
::
|_ [bol=bowl:gall sta=state]
::
++ this .
::
:: +prep: set up the app, migrate the state once started
::
++ prep
|= old=(unit state)
^- (quip move _this)
?~ old
=/ inboxpat /circle/inbox/config/group
=/ circlespat /circles/[(scot %p our.bol)]
=/ inboxwir /circle/[(scot %p our.bol)]/inbox/config/group
=/ inboxi/poke
:- %hall-action
[%source %inbox %.y (silt [[our.bol %i] ~]~)]
:_ this
:~ [ost.bol %peer inboxwir [our.bol %hall] inboxpat]
[ost.bol %peer circlespat [our.bol %hall] circlespat]
[ost.bol %connect / [~ /'~chat'] %chat]
[ost.bol %poke /chat [our.bol %hall] inboxi]
[ost.bol %poke /chat [our.bol %launch] [%noun [%chat /chattile]]]
==
:- [ost.bol %poke /chat [our.bol %launch] [%noun [%chat /chattile]]]~
this(sta u.old)
::
::
::
++ peer-chattile
|= wir=wire
^- (quip move _this)
[~ this]
::
:: +peer-messages: subscribe to subset of messages and updates
::
::
++ peer-primary
|= wir=wire
^- (quip move _this)
=/ indices (generate-circle-indices wir)
?~ indices
:_ this
[ost.bol %diff %chat-initial str.sta]~
=* messages messages.str.sta
=/ lisunitmov/(list (unit move))
%+ turn indices
|= [cir=circle:hall start=@ud]
^- (unit move)
=/ wholelist/(unit (list envelope:hall)) (~(get by messages) cir)
?~ wholelist
~
=/ end/@ (lent u.wholelist)
?: (gte start end)
~
:- ~
:* ost.bol
%diff
%chat-update
[%messages cir start end (swag [start end] u.wholelist)]
==
=/ lismov/(list move)
%+ turn
%+ skim lisunitmov
|= umov=(unit move)
^- ?
?~ umov
%.n
%.y
need
:_ this
%+ weld
[ost.bol %diff %chat-config str.sta]~
lismov
::
++ peer-updates
|= wir=wire
^- (quip move _this)
[~ this]
::
++ poke-noun
|= a=*
^- (quip move _this)
~& sta
[~ this]
::
:: +poke-chat: send us an action
::
++ poke-chat-action
|= act=action:chat
^- (quip move _this)
:_ this
%+ turn lis.act
|= hac=action:hall
^- move
:* ost.bol
%poke
/p/[(scot %da now.bol)]
[our.bol %hall]
[%hall-action hac]
==
::
:: +send-chat-update: utility func for sending updates to all our subscribers
::
++ send-chat-update
|= upd=update
^- (list move)
%+ turn (prey:pubsub:userlib /updates bol)
|= [=bone *]
[bone %diff %chat-update upd]
::
::
:: +hall arms
::
::
:: +diff-hall-prize: handle full state initially handed to us by hall
::
++ diff-hall-prize
|= [wir=wire piz=prize:hall]
^- (quip move _this)
?~ wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
?+ i.wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
::
:: %circles wire
::
%circles
?> ?=(%circles -.piz)
:- (send-chat-update [%circles cis.piz])
%= this
circles.str.sta cis.piz
==
::
:: %circle wire
::
%circle
:: ::
:: :: %circle prize
:: ::
:: %circle
?> ?=(%circle -.piz)
=/ circle/circle:hall [our.bol &3:wir]
?: =(circle [our.bol %inbox])
::
:: fill inbox config and remote configs with prize data
::
=/ configs
%- ~(uni in configs.str.sta)
^- (map circle:hall (unit config:hall))
(~(run by rem.cos.piz) |=(a=config:hall `a))
::
=/ circles/(list circle:hall)
%+ turn ~(tap in src.loc.cos.piz)
|= src=source:hall
^- circle:hall
cir.src
::
=/ meslis/(list [circle:hall (list envelope:hall)])
%+ turn circles
|= cir=circle:hall
^- [circle:hall (list envelope:hall)]
[cir ~]
::
=/ localpeers/(set @p)
%- silt %+ turn ~(tap by loc.pes.piz)
|= [shp=@p stat=status:hall]
shp
::
=/ peers/(map circle:hall (set @p))
%- ~(rep by rem.pes.piz)
|= [[cir=circle:hall grp=group:hall] acc=(map circle:hall (set @p))]
^- (map circle:hall (set @p))
=/ newset
%- silt %+ turn ~(tap by grp)
|= [shp=@p stat=status:hall]
shp
(~(put by acc) cir newset)
::
:-
%+ turn ~(tap in (~(del in (silt circles)) [our.bol %inbox]))
|= cir=circle:hall
^- move
=/ wir/wire /circle/[(scot %p our.bol)]/[nom.cir]/config/group
=/ pat/path /circle/[nom.cir]/config/group
[ost.bol %peer wir [our.bol %hall] pat]
::
%= this
inbox.str.sta loc.cos.piz
configs.str.sta configs
messages.str.sta (molt meslis)
peers.str.sta (~(put by peers) [our.bol %inbox] localpeers)
==
::
:: fill remote configs with message data
::
=* messages messages.str.sta
=/ circle/circle:hall [`@p`(slav %p &2:wir) &3:wir]
=/ localpeers/(set @p)
%- silt %+ turn ~(tap by loc.pes.piz)
|= [shp=@p stat=status:hall]
shp
::
=/ peers/(map circle:hall (set @p))
%- ~(rep by rem.pes.piz)
|= [[cir=circle:hall grp=group:hall] acc=(map circle:hall (set @p))]
^- (map circle:hall (set @p))
=/ newset
%- silt %+ turn ~(tap by grp)
|= [shp=@p stat=status:hall]
shp
(~(put by acc) cir newset)
:- ~
%= this
messages.str.sta (~(put by messages) circle nes.piz)
peers.str.sta (~(uni by peers.str.sta) (~(put by peers) circle localpeers))
==
==
::
:: +diff-hall-rumor: handle updates to hall state
::
++ diff-hall-rumor
|= [wir=wire rum=rumor:hall]
^- (quip move _this)
?~ wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
?+ i.wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
::
:: %circles
%circles
?> ?=(%circles -.rum)
?: add.rum
=/ cis (~(put in circles.str.sta) cir.rum)
:- (send-chat-update [%circles cis])
%= this
circles.str.sta cis
peers.str.sta (~(put by peers.str.sta) [our.bol cir.rum] ~)
==
=/ cis (~(del in circles.str.sta) cir.rum)
:- (send-chat-update [%circles cis])
%= this
circles.str.sta cis
peers.str.sta (~(del by peers.str.sta) [our.bol cir.rum])
==
::
::
:: %circle: fill remote configs with message data
::
%circle
?> ?=(%circle -.rum)
=* sto rum.rum
?+ -.sto
[~ this]
::
:: %gram:
::
%gram
?> ?=(%gram -.sto)
=* messages messages.str.sta
=/ circle/circle:hall [`@p`(slav %p &2:wir) &3:wir]
=/ nes/(list envelope:hall) (~(got by messages) circle)
:- (send-chat-update [%message circle nev.sto])
%= this
messages.str.sta (~(put by messages) circle (snoc nes nev.sto))
==
::
:: %status:
::
%status
?> ?=(%status -.sto)
=/ upeers/(unit (set @p)) (~(get by peers.str.sta) cir.sto)
?~ upeers
[~ this]
=/ peers/(set @p)
?: =(%remove -.dif.sto)
(~(del in u.upeers) who.sto)
(~(put in u.upeers) who.sto)
:- (send-chat-update [%peers cir.sto peers])
%= this
peers.str.sta (~(put by peers.str.sta) cir.sto peers)
==
::
:: %config: config has changed
::
%config
=* circ cir.sto
::
?+ -.dif.sto
[~ this]
::
:: %full: set all of config without side effects
::
%full
=* conf cof.dif.sto
:- (send-chat-update [%config circ conf])
%= this
configs.str.sta (~(put by configs.str.sta) circ `conf)
==
::
:: %read: the read count of one of our configs has changed
::
%read
?: =(circ [our.bol %inbox])
:: ignore when circ is inbox
[~ this]
=/ uconf/(unit config:hall) (~(got by configs.str.sta) circ)
?~ uconf
:: should we crash?
[~ this]
=/ conf/config:hall
%= u.uconf
red red.dif.sto
==
:- (send-chat-update [%config circ conf])
%= this
configs.str.sta (~(put by configs.str.sta) circ `conf)
==
::
:: %source: the sources of our inbox have changed
::
%source
?. =(circ [our.bol %inbox])
:: ignore when circ is not inbox
[~ this]
=* affectedcir cir.src.dif.sto
=/ newwir/wire
/circle/[(scot %p hos.affectedcir)]/[nom.affectedcir]/grams/config/group
=/ pat/path /circle/[nom.affectedcir]/grams/config/group
:: we've added a source to our inbox
::
?: add.dif.sto
=/ newinbox %= inbox.str.sta
src (~(put in src.inbox.str.sta) src.dif.sto)
==
:-
%+ weld
[ost.bol %peer newwir [hos.affectedcir %hall] pat]~
(send-chat-update [%inbox newinbox])
%= this
inbox.str.sta newinbox
::src.inbox.str.sta (~(put in src.inbox.str.sta) src.dif.sto)
::
configs.str.sta
?: (~(has by configs.str.sta) affectedcir)
configs.str.sta
(~(put by configs.str.sta) affectedcir ~)
==
=/ newinbox %= inbox.str.sta
src (~(del in src.inbox.str.sta) src.dif.sto)
==
:: we've removed a source from our inbox
::
:-
%+ weld
[ost.bol %pull newwir [hos.affectedcir %hall] ~]~
(send-chat-update [%inbox newinbox])
%= this
src.inbox.str.sta (~(del in src.inbox.str.sta) src.dif.sto)
::
configs.str.sta (~(del by configs.str.sta) affectedcir)
==
==
:: end of branching on dif.sto type
==
:: end of branching on sto type
==
:: end of i.wir branching
::
:: +lient arms
::
::
:: +bound: lient tells us we successfully bound our server to the ~chat url
::
++ bound
|= [wir=wire success=? binding=binding:http-server]
^- (quip move _this)
[~ this]
::
:: +poke-handle-http-request: serve pages from file system based on URl path
::
++ poke-handle-http-request
%- (require-authorization:app ost.bol move this)
|= =inbound-request:http-server
^- (quip move _this)
::
=+ request-line=(parse-request-line url.request.inbound-request)
=/ name=@t
=+ back-path=(flop site.request-line)
?~ back-path
''
i.back-path
?: =(name 'tile')
[[ost.bol %http-response (js-response:app tile-js)]~ this]
?+ site.request-line
:_ this
[ost.bol %http-response not-found:app]~
::
:: styling
::
[%'~chat' %css %index ~]
:_ this
[ost.bol %http-response (css-response:app style)]~
::
:: javascript
::
[%'~chat' %js %index ~]
:_ this
[ost.bol %http-response (js-response:app script)]~
::
:: images
::
[%'~chat' %img *]
=/ img (as-octs:mimes:html (~(got by chat-png) `@ta`name))
:_ this
[ost.bol %http-response (png-response:app img)]~
::
:: inbox page
::
[%'~chat' *]
:_ this
[ost.bol %http-response (html-response:app index)]~
==
::
::
:: +subscription-retry arms
::
::
:: +reap: recieve acknowledgement for peer, retry on failure
::
++ reap
|= [wir=wire err=(unit tang)]
^- (quip move _this)
?~ err
[~ this]
?~ wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
?+ i.wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
::
%circle
=/ shp/@p (slav %p &2:wir)
=/ pat /circle/[&3:wir]/config/group
?: =(&3:wir 'inbox')
:_ this
[ost.bol %peer wir [shp %hall] pat]~
?: (~(has in src.inbox.str.sta) [[shp &3:wir] ~])
:_ this
[ost.bol %peer wir [shp %hall] pat]~
[~ this]
::
%circles
:_ this
[ost.bol %peer wir [our.bol %hall] wir]~
==
::
:: +quit: subscription failed/quit at some point, retry
::
++ quit
|= wir=wire
^- (quip move _this)
?~ wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
?+ i.wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
::
%circle
=/ shp/@p (slav %p &2:wir)
=/ pat /circle/[&3:wir]/config/group
?: =(&3:wir 'inbox')
:_ this
[ost.bol %peer wir [shp %hall] pat]~
?: (~(has in src.inbox.str.sta) [[shp &3:wir] ~])
:_ this
[ost.bol %peer wir [shp %hall] pat]~
[~ this]
::
%circles
:_ this
[ost.bol %peer wir [our.bol %hall] wir]~
==
::
--

2
app/chat/css/index.css Normal file

File diff suppressed because one or more lines are too long

BIN
app/chat/img/Home.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

BIN
app/chat/img/Icon-Home.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

BIN
app/chat/img/Send.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1010 B

BIN
app/chat/img/Tile.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

16
app/chat/index.html Normal file
View File

@ -0,0 +1,16 @@
<!doctype html>
<html>
<head>
<title>Chat</title>
<meta charset="utf-8" />
<meta name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<link rel="stylesheet" href="/~chat/css/index.css" />
</head>
<body>
<div id="root" />
<script src="/~/channel/channel.js"></script>
<script src="/~modulo/session.js"></script>
<script src="/~chat/js/index.js"></script>
</body>
</html>

57863
app/chat/js/index.js Normal file

File diff suppressed because one or more lines are too long

2242
app/chat/js/tile.js Normal file

File diff suppressed because it is too large Load Diff

78
app/clock.hoon Normal file
View File

@ -0,0 +1,78 @@
/+ *server
/= tile-js
/^ octs
/; as-octs:mimes:html
/: /===/app/clock/js/tile
/| /js/
/~ ~
==
=, format
::
|%
:: +move: output effect
::
+$ move [bone card]
:: +card: output effect payload
::
+$ poke
$% [%noun [@tas path]]
==
::
+$ card
$% [%poke wire dock poke]
[%http-response =http-event:http]
[%connect wire binding:http-server term]
[%diff %json json]
==
::
--
::
|_ [bol=bowl:gall ~]
::
++ this .
::
++ bound
|= [wir=wire success=? binding=binding:http-server]
^- (quip move _this)
[~ this]
::
++ prep
|= old=(unit ~)
^- (quip move _this)
=/ lismov/(list move) %+ weld
`(list move)`[ost.bol %connect / [~ /'~clock'] %clock]~
`(list move)`[ost.bol %poke /clock [our.bol %launch] [%noun [%clock /tile]]]~
:- lismov
this
::
++ peer-tile
|= pax=path
^- (quip move _this)
[[ost.bol %diff %json *json]~ this]
::
++ send-tile-diff
|= jon=json
^- (list move)
%+ turn (prey:pubsub:userlib /tile bol)
|= [=bone ^]
[bone %diff %json jon]
::
++ poke-handle-http-request
%- (require-authorization:app ost.bol move this)
|= =inbound-request:http-server
^- (quip move _this)
=+ request-line=(parse-request-line url.request.inbound-request)
=+ back-path=(flop site.request-line)
=/ name=@t
=+ back-path=(flop site.request-line)
?~ back-path
''
i.back-path
::
?~ back-path
[[ost.bol %http-response not-found:app]~ this]
?: =(name 'tile')
[[ost.bol %http-response (js-response:app tile-js)]~ this]
[[ost.bol %http-response not-found:app]~ this]
::
--

2375
app/clock/js/tile.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,260 +0,0 @@
/+ *server, collections
/= index
/: /===/app/landscape/index /!noun/
/= script
/^ octs
/; as-octs:mimes:html
/: /===/app/landscape/js/index-min
/| /js/
/~ ~
==
/= style
/^ octs
/; as-octs:mimes:html
/: /===/app/landscape/css/index
/| /css/
/~ ~
==
/= profile
/: /===/app/landscape/profile /!noun/
/= inbox
/: /===/app/landscape/inbox /!noun/
/= stream
/: /===/app/landscape/stream /!noun/
/= coll-elem
/: /===/app/landscape/collections/elem /!noun/
/= coll-new
/: /===/app/landscape/collections/new /!noun/
::
|%
::
+$ move [bone card]
::
+$ card
$% [%http-response =http-event:http]
[%connect wire binding:http-server term]
[%peer wire dock path]
[%diff diff]
[%quit ~]
==
+$ diff
$% [%hymn manx]
[%json json]
==
::
--
::
|_ [bol=bowl:gall ~]
::
++ this .
::
++ prep
|= old=(unit ~)
^- (quip move _this)
?~ old
:_ this
[ost.bol %connect / [~ /'~landscape'] %landscape]~
[~ this]
::
++ bound
|= [wir=wire success=? binding=binding:http-server]
^- (quip move _this)
[~ this]
::
++ peer-xship
|= wir=wire
^- (quip move _this)
?+ wir
!! :: XX should we really crash on data sent from another ship?
::
[%top @t *]
=/ jon=? =(t.t.wir [%json ~])
=/ dif=diff (coll-elem our.bol (slav %da i.t.wir) ~ jon)
:_ this
:~ [ost.bol %diff dif]
[ost.bol %quit ~]
==
::
[%new @t *]
=/ jon=? =(t.t.wir [%json ~])
=/ pos [*@da %new]
=/ dif=diff (coll-elem our.bol (slav %da i.t.wir) `pos jon)
:_ this
:~ [ost.bol %diff dif]
[ost.bol %quit ~]
==
::
[%view @t @t *]
=/ jon=? =(t.t.t.wir [%json ~])
=/ pos [(slav %da i.t.t.wir) %default]
=/ dif=diff (coll-elem our.bol (slav %da i.t.wir) `pos jon)
:_ this
:~ [ost.bol %diff dif]
[ost.bol %quit ~]
==
::
[%edit @t @t *]
=/ jon=? =(t.t.t.wir [%json ~])
=/ pos [(slav %da i.t.t.wir) %edit]
=/ dif=diff (coll-elem our.bol (slav %da i.t.wir) `pos jon)
:_ this
:~ [ost.bol %diff dif]
[ost.bol %quit ~]
==
==
::
++ diff-hymn
|= [wir=wire hym=manx]
^- (quip move _this)
:_ this
[ost.bol %http-response (html-response:app (manx-to-octs (index hym)))]~
::
++ poke-handle-http-request
%- (require-authorization:app ost.bol move this)
|= =inbound-request:http-server
^- (quip move _this)
::
=+ request-line=(parse-request-line url.request.inbound-request)
?+ site.request-line
:_ this
[ost.bol %http-response not-found:app]~
::
:: inbox page
::
[%'~landscape' ~]
=/ index-html=octs (manx-to-octs (index inbox))
:_ this
[ost.bol %http-response (html-response:app index-html)]~
::
:: styling
::
[%'~landscape' %css ~]
:_ this
[ost.bol %http-response (css-response:app style)]~
::
:: javascript
::
[%'~landscape' %js ~]
:_ this
[ost.bol %http-response (js-response:app script)]~
::
:: profile page
::
[%'~landscape' %profile @t ~]
=/ profile-html=octs
(manx-to-octs (index (profile i.t.t.site.request-line)))
:_ this
[ost.bol %http-response (html-response:app profile-html)]~
::
:: chat page
::
[%'~landscape' %stream ~]
=/ stream-html=octs (manx-to-octs (index stream))
:_ this
[ost.bol %http-response (html-response:app stream-html)]~
::
:: collections top level page
::
[%'~landscape' %collections @t @t ~]
=/ shp=@p (slav %p i.t.t.site.request-line)
=/ col=@da (slav %da i.t.t.t.site.request-line)
?: =(shp our.bol)
:: local request
::
=/ jon=? =(ext.request-line [~ ~.json])
=/ dif=diff (coll-elem shp col ~ jon)
?- -.dif
%hymn
=/ oct=octs (manx-to-octs (index +.dif))
:_ this
[ost.bol %http-response (html-response:app oct)]~
::
%json
=/ oct=octs (json-to-octs +.dif)
:_ this
[ost.bol %http-response (json-response:app oct)]~
==
:: foreign request
::
?: =(ext.request-line [~ ~.json])
:: json format
::
=/ pax=path /xship/top/(scot %da col)/json
:_ this
[ost.bol %peer pax [shp %landscape] pax]~
::
:: html format
=/ pax=path /xship/top/(scot %da col)
:_ this
[ost.bol %peer pax [shp %landscape] pax]~
::
:: collections new post page
::
[%'~landscape' %collections @t @t %new ~]
=/ shp=@p (slav %p i.t.t.site.request-line)
=/ col=@da (slav %da i.t.t.t.site.request-line)
?: =(shp our.bol)
=/ dif=diff (coll-elem shp col `[*@da %new] |)
?> ?=(%hymn -.dif)
=/ new-html=octs
(manx-to-octs (index +.dif))
:_ this
[ost.bol %http-response (html-response:app new-html)]~
=/ pax=path /xship/new/(scot %da col)
:_ this
[ost.bol %peer pax [shp %landscape] pax]~
::
:: collections view post page
::
[%'~landscape' %collections @t @t @t ~]
=/ shp=@p (slav %p i.t.t.site.request-line)
=/ col=@da (slav %da i.t.t.t.site.request-line)
=/ pos=@da (slav %da i.t.t.t.t.site.request-line)
?: =(shp our.bol)
=/ jon=? =(ext.request-line [~ ~.json])
=/ dif=diff (coll-elem shp col `[pos %default] jon)
?- -.dif
%hymn
=/ oct=octs (manx-to-octs (index +.dif))
:_ this
[ost.bol %http-response (html-response:app oct)]~
::
%json
=/ oct=octs (json-to-octs +.dif)
:_ this
[ost.bol %http-response (json-response:app oct)]~
==
:: foreign request
::
?: =(ext.request-line [~ ~.json])
:: json format
::
=/ pax=path /xship/view/(scot %da col)/(scot %da pos)/json
:_ this
[ost.bol %peer pax [shp %landscape] pax]~
::
:: html format
=/ pax=path /xship/view/(scot %da col)/(scot %da pos)
:_ this
[ost.bol %peer pax [shp %landscape] pax]~
::
:: collections edit post page
::
[%'~landscape' %collections @t @t @t %edit ~]
=/ shp=@p (slav %p i.t.t.site.request-line)
=/ col=@da (slav %da i.t.t.t.site.request-line)
=/ pos=@da (slav %da i.t.t.t.t.site.request-line)
?: =(shp our.bol)
=/ dif=diff (coll-elem shp col `[pos %edit] |)
?> ?=(%hymn -.dif)
=/ edit-html=octs
(manx-to-octs (index +.dif))
:_ this
[ost.bol %http-response (html-response:app edit-html)]~
=/ pax=path /xship/edit/(scot %da col)/(scot %da pos)
:_ this
[ost.bol %peer pax [shp %landscape] pax]~
::
==
::
--

View File

@ -1,14 +0,0 @@
::
::::
::
|= [shp=@p col=@da pos=@da dat=@t]
^- manx
;div.container
;div
=urb-component "TopicCreatePage"
=urb-ship "{<shp>}"
=urb-claypath "{<col>}"
=urb-content (trip dat)
;input(type "hidden", name "urb-header", value "collection-write", station "query");
==
==

View File

@ -1,344 +0,0 @@
::
::::
::
/? 309
/+ collections, cram
/= coll-new
/: /===/app/landscape/collections/new /!noun/
/= coll-edit
/: /===/app/landscape/collections/edit /!noun/
/= cols
/^ collection:collections
/; |= a=(map knot item:collections)
[*config:collections a]
/: /===/web/collections /_ /collections-item/
::
::
|%
+$ post-page [p=@da q=?(%default %edit %new)]
--
|= [shp=@p col=@da pos=(unit post-page) json=?]
^- $% [%hymn manx]
[%json ^json]
==
=/ itm=(unit item:collections) (~(get by data.cols) (scot %da col))
?: json
?~ itm [%json ~]
[%json (item-to-json:collections u.itm)]
?~ itm
[%hymn ;div:(Invalid collection)]
=< [%hymn (item-to-elem u.itm)]
|%
++ item-to-elem
!:
|= itm=item:collections
?~ pos
?> ?=(%collection -.itm)
^- manx
;div.container
;div.row
;div.flex-col-2;
;div.flex-col-x
;div.collection-index
;+ (meta-to-elem itm)
;+ (collection-to-elem col.itm)
==
==
;+ ?: =(type.meta.col.itm %blog)
;div.flex-col-5;
?: =(type.meta.col.itm %fora)
;div.flex-col-4;
;div.flex-col-4;
==
==
::
::
?> ?=(%collection -.itm)
=/ posttt=(unit item:collections) (~(get by data.col.itm) (scot %da p.u.pos))
?: ?&(?=(~ posttt) !=(q.u.pos %new))
;div: Invalid collection
^- manx
?- q.u.pos
%default
?< ?=(~ posttt)
?> ?=(%both -.u.posttt)
;div.container
;div.row
;div.flex-col-2;
;div.flex-col-x
;div.collection-index
;+ (meta-to-elem u.posttt)
;+ (both-to-elem col.u.posttt raw.u.posttt)
==
==
;div.flex-col-2;
==
==
::
%edit
?< ?=(~ posttt)
?> ?=(%both -.u.posttt)
=/ dat data.raw.u.posttt
;div.row
;div.flex-col-2;
;div.flex-col-x
;div.collection-index
;+ (meta-to-elem u.posttt)
;+ (coll-edit shp col p.u.pos dat)
==
==
;div.flex-col-2;
==
::
%new
;div.row
;div.flex-col-2;
;div.flex-col-x
;div.collection-index
;+ (meta-to-elem itm)
;+ (coll-new shp col)
==
==
;div.flex-col-2;
==
==
::
++ collection-to-elem
|= col=collection:collections
^- manx
;ul.vanilla
;* %+ roll
%+ sort ~(tap by data.col)
|= [[knot a=item:collections] [knot b=item:collections]]
=/ a-dat (extract-date-created a)
=/ b-dat (extract-date-created b)
(lth a-dat b-dat)
|= [[nom=knot ite=item:collections] out=marl]
^- marl
?: ?=(%error -.ite)
out
:_ out
^- manx
;li.collection-post.mt-6
;+ (item-to-snip nom ite)
==
==
::
++ raw-to-elem
|= raw=raw-item:collections
^- manx
=/ elm elm:(static:cram (ream data.raw))
=/ ht (hedtal:collections +.elm)
=/ title (fall (~(get by meta.raw) %name) /spur)
=/ date (fall (~(get by meta.raw) %date-created) 'missing date')
=/ author (fall (~(get by meta.raw) %author) 'anonymous')
::
;div.mb-18.mt-4
;+ elm
==
::
++ both-to-elem
|= [col=collection:collections raw=raw-item:collections]
^- manx
;div
;+ (raw-to-elem raw)
::
;div
;div.flex.align-center.mb-5
;div(urb-component "IconComment");
;div.ml-2.text-small.text-mono.text-600: {<~(wyt by data.col)>}
==
::
;ul.vanilla
;* %+ turn
%+ sort ~(tap by data.col)
|= [[knot a=item:collections] [knot b=item:collections]]
=/ a-dat (extract-date-created a)
=/ b-dat (extract-date-created b)
(lte a-dat b-dat)
|= [nom=knot ite=item:collections]
^- manx
?> ?=(%raw -.ite)
=/ author (fall (~(get by meta.raw.ite) %author) 'anonymous')
=/ host (fall (~(get by meta.raw.ite) %host) 'anonymous')
=/ date (fall (~(get by meta.raw.ite) %date-created) 'missing date')
;li.mb-6
;div.flex.align-center
;div.mr-2
=urb-component "Sigil"
=urb-ship "{(trip author)}"
=urb-size "18"
=urb-suffix "true";
;div
;a.vanilla.text-mono.text-small.text-700.mr-4
=href "/~~/{(trip host)}/==/web/landscape/profile"
; {(trip author)}
==
==
;div.text-host-breadcrumb
=urb-component "Elapsed"
=urb-timestring "{(trip date)}";
==
;div.collection-comment-content
;+ elm:(static:cram (ream data.raw.ite))
==
==
==
::
;div
=urb-component "CommentCreate"
=urb-pax "{<(flop /spur)>}"
=urb-ship "{<shp>}";
==
==
::
++ extract-date-created
|= i=item:collections
^- @da
?- -.i
%error *@da
%collection date-created.meta.col.i
%both date-created.meta.col.i
%raw (slav %da (~(got by meta.raw.i) %date-created))
==
::
::
::
++ item-to-snip
|= [nom=knot itm=item:collections]
^- manx
?- -.itm
%error
;div: Invalid collection
%collection
(collection-to-snip nom col.itm)
%raw
(raw-to-snip nom raw.itm)
%both
(both-to-snip nom col.itm raw.itm)
==
::
++ collection-to-snip
|= [nom=knot col=collection:collections]
^- manx
=/ lnk=tape
"/~landscape/collections/{<shp>}/{(scow %p p.full-path.meta.col)}/{(spud (flop (slag 1 s.full-path.meta.col)))}"
;div
;div.collection-date: {<date-created.meta.col>}
;h2.mt-0.mb-0
;a(href lnk): {(trip name.meta.col)}
==
;div.who.text-mono.text-600: {<author.meta.col>}
;div.meta-cont
;div.com-count.ml-12
; {(trip (scot %ud ~(wyt by data.col)))} comments
==
==
==
::
++ raw-to-snip
|= [nom=knot raw=raw-item:collections]
^- manx
=/ elm=manx elm:(static:cram (ream data.raw))
=/ ht (hedtal:collections +.elm)
=? tal.ht ?=(~ hed.ht)
(scag 5 c.elm)
=/ title (fall (~(get by meta.raw) %name) nom)
=/ date (fall (~(get by meta.raw) %date-created) 'missing date')
=/ author (fall (~(get by meta.raw) %author) 'anonymous')
=/ lnk=tape
"/~landscape/collections/{<shp>}/{(scow %da col)}/{(trip nom)}"
::
;div
;div.collection-date: {(trip date)}
;h2
;+ ?~ hed.ht
;a(href lnk): {(trip title)}
;a(href lnk): *{hed.ht}
==
;div.who.text-mono.text-600: {(trip author)}
;div.snippet
;* tal.ht
==
==
::
++ both-to-snip
|= [nom=knot col=collection:collections raw=raw-item:collections]
^- manx
=/ elm=manx elm:(static:cram (ream data.raw))
=/ ht (hedtal:collections +.elm)
=? tal.ht ?=(~ hed.ht)
(scag 5 c.elm)
=/ title (fall (~(get by meta.raw) %name) nom)
=/ lnk=tape
"/~landscape/collections/{<shp>}/{(scow %da ^col)}/{(trip nom)}"
::
;div
;div.collection-date: {<date-created.meta.col>}
;h2.mt-0.mb-0.text-500
;+ ?~ hed.ht
;a(href lnk): {(trip title)}
;a(href lnk): *{hed.ht}
==
;div.text-mono.text-small.text-300.mt-1.mb-1: {<author.meta.col>}
;div
;div.icon-label.justify-start
;div(urb-component "IconComment");
;div.ml-2
; {(trip (scot %ud ~(wyt by data.col)))}
==
==
==
==
::
++ meta-to-elem
|= itm=item:collections
^- manx
=/ mat=mart
:~ [%type "hidden"]
[%name "urb-metadata"]
==
:_ ~
:- %input
%+ weld mat
^- mart
?- -.itm
%error ~
%collection
=* met meta.col.itm
:~ [%urb-name (trip name.met)]
[%urb-author (scow %p author.met)]
[%urb-host (scow %p p.full-path.met)]
[%urb-date-created (scow %da date-created.met)]
[%urb-last-modified (scow %da last-modified.met)]
[%urb-content-type (trip type.met)]
[%urb-structure-type "collection-index"]
[%urb-path (spud /web/collections/(scot %da date-created.meta.col.itm))]
[%urb-show "default"]
==
%raw
=/ met ~(got by meta.raw.itm)
:~ [%urb-name (trip (met %name))]
[%urb-author (trip (met %author))]
[%urb-host (trip (met %host))]
[%urb-date-created (trip (met %date-created))]
[%urb-last-modified (trip (met %last-modified))]
[%urb-content-type (trip (met %type))]
[%urb-structure-type "collection-post"]
[%urb-path (spud (flop /web/collections/raw))]
[%urb-show "default"]
==
%both
=/ met ~(got by meta.raw.itm)
:~ [%urb-name (trip (met %name))]
[%urb-author (trip (met %author))]
[%urb-host (trip (met %host))]
[%urb-date-created (trip (met %date-created))]
[%urb-last-modified (trip (met %last-modified))]
[%urb-content-type (trip (met %type))]
[%urb-structure-type "collection-post"]
[%urb-path (spud (flop /web/collections/both))]
[%urb-show "default"]
==
==
--

View File

@ -1,18 +0,0 @@
::
::::
::
|= [shp=@p col=@da]
^- manx
;div.container
;div
=urb-component "TopicCreatePage"
=urb-ship "{<shp>}"
=urb-claypath "{<col>}"
=urb-content "";
;input
=type "hidden"
=name "urb-header"
=value "collection-post-default"
=station "query"
=urb-structure-type "collection-index";
==

File diff suppressed because one or more lines are too long

View File

@ -1,5 +0,0 @@
^- manx
;div
;div(urb-component "InboxPage");
;input(type "hidden", name "urb-metadata", urb-structure-type "header-inbox");
==

View File

@ -1,22 +0,0 @@
|= inner=manx
^- manx
;html
::
;head
;title: Landscape
;meta(charset "utf-8");
;meta
=name "viewport"
=content "width=device-width, initial-scale=1, shrink-to-fit=no";
;link(rel "stylesheet", href "/~landscape/css.css");
;script@"/~/channel/channel.js";
;script@"/session.js";
==
::
;body
;div#root
;+ inner
==
;script@"/~landscape/js.js";
==
==

File diff suppressed because one or more lines are too long

View File

@ -1,26 +0,0 @@
|= who=@t
^- manx
;div
;input(type "hidden", name "urb-metadata", urb-structure-type "header-profile", urb-author "{(trip who)}");
;div.container
;div.row
;div.flex-col-2;
;div.flex-col-x
;div.profile-avatar
;div(urb-component "Sigil", urb-size "320", urb-ship "{(trip who)}", urb-suffix "false");
;div(urb-component "ProfileMsgBtn", urb-ship "{(trip who)}");
==
==
==
;div.row.mt-9
;div.flex-offset-2.flex-col-x
;h2.text-500: Meta
==
==
;div.row.mt-4.align-center
;div.flex-col-2;
;h3.text-500.flex-col-1.mt-0: Started:
;div.flex-col-x.text-mono: ~2018.4.12..6.45.12
==
==
==

View File

@ -1,6 +0,0 @@
^- manx
;div.chat-container
;div.chat-container-inner(urb-component "ChatPage");
;input(type "hidden", name "urb-metadata", urb-structure-type "stream-chat");
==

View File

@ -1,6 +0,0 @@
^- manx
;div
;div(urb-component "WelcomePage");
;input(type "hidden", name "urb-metadata", urb-structure-type "welcome");
==

129
app/launch.hoon Normal file
View File

@ -0,0 +1,129 @@
/+ *server, collections
/= index
/^ octs
/; as-octs:mimes:html
/: /===/app/launch/index
/| /html/
/~ ~
==
/= script
/^ octs
/; as-octs:mimes:html
/: /===/app/launch/js/index
/| /js/
/~ ~
==
/= style
/^ octs
/; as-octs:mimes:html
/: /===/app/launch/css/index
/| /css/
/~ ~
==
/= launch-png
/^ (map knot @)
/: /===/app/launch/img /_ /png/
::
|%
::
+$ move [bone card]
::
+$ card
$% [%http-response =http-event:http]
[%connect wire binding:http-server term]
[%peer wire dock path]
[%diff %json json]
==
+$ tile [name=@tas subscribe=path]
+$ tile-data (map @tas json)
+$ state
$% [%0 tiles=(set tile) data=tile-data path-to-tile=(map path @tas)]
==
::
--
::
|_ [bol=bowl:gall sta=state]
::
++ this .
::
++ prep
|= old=(unit state)
^- (quip move _this)
?~ old
:_ this
[ost.bol %connect / [~ /] %launch]~
[~ this(sta u.old)]
::
++ bound
|= [wir=wire success=? binding=binding:http-server]
^- (quip move _this)
[~ this]
::
++ poke-noun
|= [name=@tas subscribe=path]
^- (quip move _this)
:- [ost.bol %peer subscribe [our.bol name] subscribe]~
%= this
tiles.sta (~(put in tiles.sta) [name subscribe])
data.sta (~(put by data.sta) name *json)
path-to-tile.sta (~(put by path-to-tile.sta) subscribe name)
==
::
++ diff-json
|= [pax=path jon=json]
=/ name/@tas (~(got by path-to-tile.sta) pax)
:-
%+ turn (prey:pubsub:userlib /main bol)
|= [=bone *]
[bone %diff %json (frond:enjs:format name jon)]
%= this
data.sta (~(put by data.sta) name jon)
==
::
++ peer-main
|= [pax=path]
^- (quip move _this)
=/ data/json %- pairs:enjs:format ~(tap by data.sta)
:_ this
[ost.bol %diff %json data]~
::
++ poke-handle-http-request
%- (require-authorization:app ost.bol move this)
|= =inbound-request:http-server
^- (quip move _this)
::
=+ request-line=(parse-request-line url.request.inbound-request)
=/ name=@t
=+ back-path=(flop site.request-line)
?~ back-path
''
i.back-path
=/ site (flop site.request-line)
?~ site
:_ this
[ost.bol %http-response (html-response:app index)]~
?+ site.request-line
:_ this
[ost.bol %http-response not-found:app]~
::
:: styling
::
[%'~launch' %css %index ~]
:_ this
[ost.bol %http-response (css-response:app style)]~
::
:: javascript
::
[%'~launch' %js %index ~]
:_ this
[ost.bol %http-response (js-response:app script)]~
::
:: images
::
[%'~launch' %img *]
=/ img (as-octs:mimes:html (~(got by launch-png) `@ta`name))
:_ this
[ost.bol %http-response (png-response:app img)]~
==
::
--

2
app/launch/css/index.css Normal file

File diff suppressed because one or more lines are too long

BIN
app/launch/img/Home.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

16
app/launch/index.html Normal file
View File

@ -0,0 +1,16 @@
<!doctype html>
<html>
<head>
<title>Home</title>
<meta charset="utf-8" />
<meta name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<link rel="stylesheet" href="/~launch/css/index.css" />
</head>
<body>
<div id="root" />
<script src="/~/channel/channel.js"></script>
<script src="/~modulo/session.js"></script>
<script src="/~launch/js/index.js"></script>
</body>
</html>

49241
app/launch/js/index.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +1,4 @@
/- *modulo
/+ *server /+ *server
/= index
/^ octs
/; as-octs:mimes:html
/: /===/app/modulo/index
/| /html/
/~ ~
==
/= modulo-js
/^ octs
/; as-octs:mimes:html
/: /===/app/modulo/script
/| /js/
/~ ~
==
=, format
|% |%
:: +move: output effect :: +move: output effect
:: ::
@ -23,44 +7,13 @@
:: ::
+$ card +$ card
$% [%connect wire binding:http-server term] $% [%connect wire binding:http-server term]
[%serve wire binding:http-server generator:http-server]
[%disconnect wire binding:http-server] [%disconnect wire binding:http-server]
[%http-response =http-event:http] [%http-response =http-event:http]
[%poke wire dock poke]
[%diff %json json]
==
+$ poke
$% [%modulo-bind app=term]
[%modulo-unbind app=term]
==
::
+$ state
$% $: %0
session=(map term @t)
order=(list term)
cur=(unit [term @])
==
==
::
++ session-as-json
|= [cur=(unit [term @]) session=(map term @t) order=(list term)]
^- json
?~ cur
*json
%- pairs:enjs
:~ [%app %s -.u.cur]
[%url %s (~(got by session) -.u.cur)]
:- %list
:- %a
%+ turn order
|= [a=term]
[%s a]
== ==
:: ::
-- --
:: ::
|_ [bow=bowl:gall sta=state] |_ [bow=bowl:gall ~]
:: ::
++ this . ++ this .
:: ::
@ -69,7 +22,7 @@
^- (quip move _this) ^- (quip move _this)
?~ old ?~ old
:_ this :_ this
[ost.bow %connect / [~ /] %modulo]~ [ost.bow %connect / [~ /'~modulo'] %modulo]~
[~ this] [~ this]
:: ::
:: alerts us that we were bound. we need this because the vane calls back. :: alerts us that we were bound. we need this because the vane calls back.
@ -79,34 +32,13 @@
^- (quip move _this) ^- (quip move _this)
[~ this] [~ this]
:: ::
++ peer-applist
|= [pax=path]
^- (quip move _this)
:_ this
[ost.bow %diff %json (session-as-json cur.sta session.sta order.sta)]~
::
++ session-js ++ session-js
^- octs ^- octs
:: ?~ cur.sta
:: *octs
%- as-octt:mimes:html %- as-octt:mimes:html
;: weld ;: weld
:: (trip 'window.onload = function() {')
"window.ship = '{+:(scow %p our.bow)}';" "window.ship = '{+:(scow %p our.bow)}';"
"window.urb = new Channel();" "window.urb = new Channel();"
== ==
:: (trip '};')
:: ==
:: " window.state = "
:: (en-json:html (session-as-json cur.sta session.sta order.sta))
:: (trip '}();')
:: %- trip
:: '''
:: document.onkeydown = (event) => {
:: if (!event.metaKey || event.keyCode !== 75) { return; }
:: window.parent.postMessage("commandPalette", "*");
:: };
:: '''
:: ::
:: +poke-handle-http-request: received on a new connection established :: +poke-handle-http-request: received on a new connection established
:: ::
@ -114,99 +46,6 @@
%- (require-authorization:app ost.bow move this) %- (require-authorization:app ost.bow move this)
|= =inbound-request:http-server |= =inbound-request:http-server
^- (quip move _this) ^- (quip move _this)
::
=/ request-line (parse-request-line url.request.inbound-request)
=/ site (flop site.request-line)
?~ site
[[ost.bow %http-response (redirect:app '~landscape')]~ this]
?+ site
[[ost.bow %http-response (html-response:app index)]~ this]
[%session *]
[[ost.bow %http-response (js-response:app session-js)]~ this] [[ost.bow %http-response (js-response:app session-js)]~ this]
[%script *]
[[ost.bow %http-response (js-response:app modulo-js)]~ this]
==
:: +poke-handle-http-cancel: received when a connection was killed
::
++ poke-handle-http-cancel
|= =inbound-request:http-server
^- (quip move _this)
:: the only long lived connections we keep state about are the stream ones.
::
[~ this]
::
++ poke-modulo-bind
|= bin=term
^- (quip move _this)
=/ url (crip "~{(scow %tas bin)}")
?: (~(has by session.sta) bin)
[~ this]
:- [`move`[ost.bow %connect / [~ /[url]] bin] ~]
%= this
session.sta
(~(put by session.sta) bin url)
::
order.sta
(weld order.sta ~[bin])
::
cur.sta
?~ cur.sta `[bin 0]
cur.sta
==
::
++ poke-modulo-unbind
|= bin=term
^- (quip move _this)
=/ url (crip "~{(scow %tas bin)}")
?. (~(has by session.sta) bin)
[~ this]
=/ ind (need (find ~[bin] order.sta))
=/ neworder (oust [ind 1] order.sta)
:- [`move`[ost.bow %disconnect / [~ /(crip "~{(scow %tas bin)}")]] ~]
%= this
session.sta (~(del by session.sta) bin)
order.sta neworder
cur.sta
::
?: =(1 (lent order.sta))
~
?: (lth ind +:(need cur.sta))
`[-:(need cur.sta) (dec +:(need cur.sta))]
?: =(ind +:(need cur.sta))
`[(snag 0 neworder) 0]
cur.sta
==
::
++ poke-modulo-command
|= com=command
^- (quip move _this)
=/ length (lent order.sta)
?~ cur.sta
[~ this]
?: =(length 1)
[~ this]
=/ new-cur=(unit [term @])
?- -.com
%forward
?: =((dec length) +.u.cur.sta)
`[(snag 0 order.sta) 0]
=/ ind +(+.u.cur.sta)
`[(snag ind order.sta) ind]
%back
?: =(0 +.u.cur.sta)
=/ ind (dec length)
`[(snag ind order.sta) ind]
=/ ind (dec +.u.cur.sta)
`[(snag ind order.sta) ind]
%go
=/ ind (find [app.com]~ order.sta)
?~ ind
cur.sta
`[app.com u.ind]
==
:_ this(cur.sta new-cur)
%+ turn (prey:pubsub:userlib /applist bow)
|= [=bone ^]
[bone %diff %json (session-as-json new-cur session.sta order.sta)]
:: ::
-- --

View File

@ -1,28 +0,0 @@
<!doctype html>
<html>
<head>
<script type="application/javascript" src="~/channel/channel.js"></script>
<script type="application/javascript" src="/session.js"></script>
<style type="text/css">
.command-palette {
position: relative;
background-color: #f6f6f6;
top:10%;
left:10%;
width: 80%;
border: none;
outline: none;
height: 48px;
font-size: 20px;
line-height: 48px;
}
</style>
</head>
<body>
<div id="frame"></div>
<div id="popup" style="display:hidden;">
<input id="input" class="command-palette" type="text" style="visibility:hidden !important;" />
</div>
<script type="application/javascript" src="/script.js"></script>
</body>
</html>

View File

@ -1,69 +0,0 @@
function setFrame() {
let iframe = document.createElement('iframe');
iframe.setAttribute('src', window.state.url);
iframe.setAttribute('width', '100%;');
iframe.setAttribute('height', '100%;');
iframe.setAttribute('style', 'border-style: none !important;');
let inner = document.getElementById("frame");
inner.innerHTML = "";
inner.appendChild(iframe);
iframe.focus();
}
function doSub() {
window.urb.subscribe(window.ship, "modulo", "/applist",
(err) => {
console.log(err);
},
(event) => {
console.log(event);
window.state = event;
setFrame();
},
() => {
doSub();
}
);
}
var palette = false;
window.addEventListener("message", (event) => {
let popup = document.getElementById("popup");
let input = document.getElementById("input");
if (palette) {
palette = false;
popup.style = "display:hidden;";
input.style = "visibility:hidden !important;";
input.value = "";
} else {
palette = true;
popup.style = "position:absolute; left: 0; top: 0; display:block; width: 100%; height: 100%; margin: 0 0; background-color:white;";
input.style = "";
input.focus();
input.addEventListener("keyup", (e) => {
if (e.keyCode !== 13) { return; }
popup.style = "display:hidden;";
popup.style = "visibility:hidden !important;";
window.urb.poke(window.ship, "modulo", "modulo-command",
{
go: input.value
},
(json) => {
console.log(json);
},
(err) => {
console.log(err);
}
);
});
}
});
setFrame();
doSub();

126
app/timer.hoon Normal file
View File

@ -0,0 +1,126 @@
/+ *server
/= tile-js
/^ octs
/; as-octs:mimes:html
/: /===/app/timer/js/tile
/| /js/
/~ ~
==
/= timer-png
/^ (map knot @)
/: /===/app/timer/img /_ /png/
=, format
::
|%
:: +move: output effect
::
+$ move [bone card]
:: +card: output effect payload
::
+$ poke
$% [%noun [@tas path]]
==
::
+$ card
$% [%poke wire dock poke]
[%http-response =http-event:http]
[%connect wire binding:http-server term]
[%diff %json json]
[%wait wire @da]
[%rest wire @da]
==
::
--
::
|_ [bol=bowl:gall tim=@da]
::
++ this .
::
++ bound
|= [wir=wire success=? binding=binding:http-server]
^- (quip move _this)
[~ this]
::
++ prep
|= old=(unit tim=@da)
^- (quip move _this)
=/ lismov/(list move) %+ weld
`(list move)`[ost.bol %connect / [~ /'~timer'] %timer]~
`(list move)`[ost.bol %poke /timer [our.bol %launch] [%noun [%timer /tile]]]~
:- lismov
?~ old
this
%= this
tim tim.u.old
==
::
++ peer-tile
|= pax=path
^- (quip move _this)
?: =(tim *@da)
[[ost.bol %diff %json [%s '']]~ this]
[[ost.bol %diff %json [%s (scot %da tim)]]~ this]
::
++ send-tile-diff
|= jon=json
^- (list move)
%+ turn (prey:pubsub:userlib /tile bol)
|= [=bone ^]
[bone %diff %json jon]
::
++ poke-json
|= jon=json
^- (quip move _this)
~& jon
?. ?=(%s -.jon)
[~ this]
=/ str/@t +.jon
?: =(str 'start')
=/ data/@da (add now.bol ~s10)
:- %+ weld
`(list move)`(send-tile-diff [%s (scot %da data)])
`(list move)`[ost.bol %wait /timer data]~
this(tim data)
?: =(str 'stop')
:- %+ weld
`(list move)`(send-tile-diff [%s ''])
`(list move)`[ost.bol %rest /timer tim]~
this(tim *@da)
[~ this]
::
++ poke-handle-http-request
%- (require-authorization:app ost.bol move this)
|= =inbound-request:http-server
^- (quip move _this)
=+ request-line=(parse-request-line url.request.inbound-request)
=+ back-path=(flop site.request-line)
=/ name=@t
=+ back-path=(flop site.request-line)
?~ back-path
''
i.back-path
::
~& site.request-line
?+ site.request-line
[[ost.bol %http-response not-found:app]~ this]
::
:: tile
::
[%'~timer' %tile ~]
[[ost.bol %http-response (js-response:app tile-js)]~ this]
::
:: images
::
[%'~timer' %img *]
=/ img (as-octs:mimes:html (~(got by timer-png) `@ta`name))
:_ this
[ost.bol %http-response (png-response:app img)]~
==
::
++ wake
|= [wir=wire err=(unit tang)]
^- (quip move _this)
:- (send-tile-diff [%s 'alarm'])
this(tim *@da)
::
--

BIN
app/timer/img/example.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

2588
app/timer/js/tile.js Normal file

File diff suppressed because it is too large Load Diff

160
app/weather.hoon Normal file
View File

@ -0,0 +1,160 @@
/+ *server
/= tile-js
/^ octs
/; as-octs:mimes:html
/: /===/app/weather/js/tile
/| /js/
/~ ~
==
/= weather-png
/^ (map knot @)
/: /===/app/weather/img /_ /png/
=, format
::
|%
:: +move: output effect
::
+$ move [bone card]
:: +card: output effect payload
::
+$ card
$% [%poke wire dock poke]
[%http-response =http-event:http]
[%diff %json json]
[%connect wire binding:http-server term]
[%request wire request:http outbound-config:http-client]
[%wait wire @da]
==
+$ poke
$% [%noun [@tas path]]
==
+$ state
$% [%0 data=json time=@da location=@t timer=(unit @da)]
==
--
::
|_ [bol=bowl:gall state]
::
++ this .
::
++ bound
|= [wir=wire success=? binding=binding:http-server]
^- (quip move _this)
[~ this]
::
++ prep
|= old=(unit state)
^- (quip move _this)
=/ lismov/(list move) %+ weld
`(list move)`[ost.bol %connect / [~ /'~weather'] %weather]~
`(list move)`[ost.bol %poke /weather [our.bol %launch] [%noun [%weather /weathertile]]]~
:- lismov
?~ old
this
%= this
data data.u.old
time time.u.old
==
::
++ peer-weathertile
|= pax=path
^- (quip move _this)
[[ost.bol %diff %json data]~ this]
::
++ poke-json
|= jon=json
^- (quip move _this)
?. ?=(%s -.jon)
[~ this]
=/ str/@t +.jon
=/ req/request:http (request-darksky str)
=/ out *outbound-config:http-client
?~ timer
:- %+ weld
`(list move)`[ost.bol %wait /timer (add now.bol ~d1)]~
`(list move)`[ost.bol %request /[(scot %da now.bol)] req out]~
%= this
location str
timer `(add now.bol ~d1)
==
:- [ost.bol %request /[(scot %da now.bol)] req out]~
%= this
location str
==
::
++ request-darksky
|= location=@t
^- request:http
=/ url/@t
%- crip %+ weld
(trip 'https://api.darksky.net/forecast/634639c10670c7376dc66b6692fe57ca/')
(trip location)
=/ hed [['Accept' 'application/json']]~
[%'GET' url hed *(unit octs)]
::
++ send-tile-diff
|= jon=json
^- (list move)
%+ turn (prey:pubsub:userlib /weathertile bol)
|= [=bone ^]
[bone %diff %json jon]
::
++ http-response
|= [=wire response=client-response:http-client]
^- (quip move _this)
:: ignore all but %finished
?. ?=(%finished -.response)
[~ this]
=/ data/(unit mime-data:http-client) full-file.response
?~ data
:: data is null
[~ this]
=/ jon/(unit json) (de-json:html q.data.u.data)
?~ jon
[~ this]
?> ?=(%o -.u.jon)
=/ ayyy/json %- pairs:enjs:format :~
currently+(~(got by p.u.jon) 'currently')
daily+(~(got by p.u.jon) 'daily')
==
:- (send-tile-diff ayyy)
%= this
data ayyy
time now.bol
==
::
++ poke-handle-http-request
%- (require-authorization:app ost.bol move this)
|= =inbound-request:http-server
^- (quip move _this)
=+ request-line=(parse-request-line url.request.inbound-request)
=+ back-path=(flop site.request-line)
=/ name=@t
=+ back-path=(flop site.request-line)
?~ back-path
''
i.back-path
::
?~ back-path
:_ this ~
?: =(name 'tile')
[[ost.bol %http-response (js-response:app tile-js)]~ this]
?: (lte (lent back-path) 1)
[[ost.bol %http-response not-found:app]~ this]
?: =(&2:site.request-line 'img')
=/ img (as-octs:mimes:html (~(got by weather-png) `@ta`name))
[[ost.bol %http-response (png-response:app img)]~ this]
[~ this]
::
++ wake
|= [wir=wire ~]
^- (quip move _this)
=/ req/request:http (request-darksky location)
=/ lismov/(list move)
`(list move)`[ost.bol %request /[(scot %da now.bol)] req *outbound-config:http-client]~
?~ timer
:- (weld lismov `(list move)`[ost.bol %wait /timer (add now.bol ~d1)]~)
this(timer `(add now.bol ~d1))
[lismov this]
::
--

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
app/weather/img/cloudy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
app/weather/img/fog.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

BIN
app/weather/img/high.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 960 B

BIN
app/weather/img/low.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 897 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
app/weather/img/rain.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
app/weather/img/sleet.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 B

BIN
app/weather/img/snow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
app/weather/img/sunset.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

BIN
app/weather/img/wind.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

6938
app/weather/js/tile.js Normal file

File diff suppressed because it is too large Load Diff

959
app/write.hoon Normal file
View File

@ -0,0 +1,959 @@
::
:: /app/write.hoon
::
/- hall, *write
/+ *server, *write
::
/= index
/^ $-(json manx)
/: /===/app/write/index /!noun/
::
/= js
/^ octs
/; as-octs:mimes:html
/| /: /===/app/write/js/index /js/
/~ ~
==
::
/= css
/^ octs
/; as-octs:mimes:html
/| /: /===/app/write/css/index /css/
/~ ~
==
::
|%
::
+$ move [bone card]
::
+$ card
$% [%info wire toro:clay]
[%poke wire dock poke]
[%perm wire desk path rite:clay]
[%peer wire dock path]
[%pull wire dock ~]
[%quit ~]
[%diff diff]
[%build wire ? schematic:ford]
[%kill wire ~]
[%connect wire binding:http-server term]
[%http-response http-event:http]
[%disconnect binding:http-server]
==
::
+$ poke
$% [%hall-action action:hall]
[%write-action action]
==
::
+$ diff
$% [%hall-rumor rumor:hall]
[%json json]
[%write-collection collection]
[%write-rumor rumor]
==
::
--
::
|_ [bol=bowl:gall sat=state]
::
++ this .
:: +our-beak: beak for this app, with case set to current invocation date
::
++ our-beak /(scot %p our.bol)/[q.byk.bol]/(scot %da now.bol)
:: +allowed-by: checks if ship :who is allowed by the permission rules in :dic
::
++ allowed-by
|= [who=@p dic=dict:clay]
^- ?
?: =(who our.bol) &
=/ in-list=?
?| (~(has in p.who.rul.dic) who)
::
%- ~(rep by q.who.rul.dic)
|= [[@ta cru=crew:clay] out=_|]
?: out &
(~(has in cru) who)
==
?: =(%black mod.rul.dic)
!in-list
in-list
:: +write-file: write file at path
::
++ write-file
=, space:userlib
|= [pax=path cay=cage]
^- move
=. pax (weld our-beak pax)
[ost.bol %info (weld /write-file pax) (foal pax cay)]
::
++ update-udon-front
|= [fro=(map knot cord) udon=@t]
^- @t
%- of-wain:format
=/ tum (trip udon)
=/ id (find ";>" tum)
?~ id
%+ weld (front-to-wain fro)
(to-wain:format (crip (weld ";>\0a" tum)))
%+ weld (front-to-wain fro)
(to-wain:format (crip (slag u.id tum)))
::
++ front-to-wain
|= a=(map knot cord)
^- wain
=/ entries=wain
%+ turn ~(tap by a)
|= b=[knot cord]
=/ c=[term cord] (,[term cord] b)
(crip " [{<-.c>} {<+.c>}]")
::
?~ entries ~
;: weld
[':- :~' ~]
entries
[' ==' ~]
==
::
++ prep
|= old=(unit *)
^- (quip move _this)
~& write-prep+act.bol
?~ old
:_ this
[ost.bol %connect / [~ /'~publish'] %write]~
[~ this(sat (state u.old))]
::
++ poke-noun
|= a=*
^- (quip move _this)
?. =(src.bol our.bol)
[~ this]
?+ a
[~ this]
::
%test-build
=/ schema=schematic:ford
:-
:*
%bake
%write-info
*coin
[[our.bol q.byk.bol] /fora/write/web]
==
:*
%bake
%write-post
*coin
[[our.bol q.byk.bol] /post-1/fora/write/web]
==
:_ this
[ost.bol %build /test/build %.n schema]~
::
%print-subs
~& sup.bol
[~ this]
::
%kill-all-builds
:_ this
:~ [ost.bol %kill /collection/fora ~]
[ost.bol %kill /post/fora/post-1 ~]
[ost.bol %kill /comments/fora/post-1 ~]
[ost.bol %kill /post/fora/post-2 ~]
[ost.bol %kill /comments/fora/post-2 ~]
[ost.bol %kill /post/fora/post-3 ~]
[ost.bol %kill /comments/fora/post-3 ~]
==
::
::
%send-diff
=/ rum=json (frond:enjs:format %poke-noun ~)
=/ mov=(list move)
%+ turn (prey:pubsub:userlib /primary bol)
|= [=bone *]
[bone %diff %json rum]
~& mov+mov
[mov this]
::
%peer
~& %peer
:_ this
[ost.bol %peer /collection/fora [~zod %write] /collection/fora]~
::
%pull
~& %pull
=/ wir=wire /collection/fora
:_ this
[ost.bol %pull wir [~zod %write] ~]~
::
%flush-state
[~ this(sat *state)]
::
%print-state
~& sat
[~ this]
::
==
::
++ da
|_ moves=(list move)
::
++ da-this .
::
++ da-done
^- (quip move _this)
[(flop moves) this]
::
++ da-emit
|= mov=move
%_ da-this
moves [mov moves]
==
::
++ da-emil
|= mov=(list move)
%_ da-this
moves (welp (flop mov) moves)
==
::
++ da-change
|= del=delta
^+ da-this
?- -.del
::
%collection
=/ old=(unit collection)
?: =(our.bol who.del)
(~(get by pubs.sat) col.del)
(~(get by subs.sat) who.del col.del)
=/ new=collection
?~ old
[dat.del ~ ~ ~ ~]
[dat.del pos.u.old com.u.old order.u.old]
=? pubs.sat =(our.bol who.del)
(~(put by pubs.sat) col.del new)
=? subs.sat !=(our.bol who.del)
(~(put by subs.sat) [who.del col.del] new)
(da-emil (affection del))
::
%post
=/ old=(unit collection)
?: =(our.bol who.del)
(~(get by pubs.sat) col.del)
(~(get by subs.sat) who.del col.del)
=/ new=collection
?~ old
[[%.n ~] (my [pos.del dat.del] ~) ~ ~ ~]
[col.u.old (~(put by pos.u.old) pos.del dat.del) com.u.old order.u.old]
=? pubs.sat =(our.bol who.del)
(~(put by pubs.sat) col.del new)
=? subs.sat !=(our.bol who.del)
(~(put by subs.sat) [who.del col.del] new)
=? da-this ?=(~ old)
(da-insert who.del col.del pos.del)
(da-emil (affection del))
::
%comments
=/ old=(unit collection)
?: =(our.bol who.del)
(~(get by pubs.sat) col.del)
(~(get by subs.sat) who.del col.del)
=/ new=collection
?~ old
[[%.n ~] ~ (my [pos.del dat.del] ~) ~ ~]
[col.u.old pos.u.old (~(put by com.u.old) pos.del dat.del) order.u.old]
=? pubs.sat =(our.bol who.del)
(~(put by pubs.sat) col.del new)
=? subs.sat !=(our.bol who.del)
(~(put by subs.sat) [who.del col.del] new)
(da-emil (affection del))
::
%total
=? pubs.sat =(our.bol who.del)
(~(put by pubs.sat) col.del dat.del)
=? subs.sat !=(our.bol who.del)
(~(put by subs.sat) [who.del col.del] dat.del)
::
=/ posts=(list @tas) ~(tap in ~(key by pos.dat.del))
=. da-this
|-
?~ posts
da-this
%= $
da-this (da-insert who.del col.del i.posts)
posts t.posts
==
(da-emil (affection del))
::
==
::
++ da-insert
|= [who=@p coll=@tas post=@tas]
^+ da-this
:: assume we've read our own posts
::
=? unread.sat !=(who our.bol)
(~(put in unread.sat) who coll post)
:: insertion sort into latest
::
=/ new-date=@da date-created:(need (get-post-by-index who coll post))
=/ pre=(list [@p @tas @tas]) ~
=/ suf=(list [@p @tas @tas]) latest.sat
=. latest.sat
|-
?~ suf
(weld pre [who coll post]~)
=/ i-date=@da date-created:(need (get-post-by-index i.suf))
?: (gte new-date i-date)
(weld pre [[who coll post] suf])
%= $
suf t.suf
pre (snoc pre i.suf)
==
:: insertion sort into order
::
=/ new-post=post-info (need (get-post-by-index who coll post))
=/ col=collection (need (get-coll-by-index who coll))
::
=/ pre=(list @tas) ~
=/ suf=(list @tas)
?: pinned.new-post
pin.order.col
unpin.order.col
::
=/ new-list=(list @tas)
|-
?~ suf
(snoc pre post)
=/ i-date=@da date-created:(need (get-post-by-index who coll i.suf))
?: (gte date-created.new-post i-date)
(weld pre [post suf])
%= $
suf t.suf
pre (snoc pre i.suf)
==
::
=. order.col
?: pinned.new-post
[new-list unpin.order.col]
[pin.order.col new-list]
::
=? pubs.sat =(our.bol who)
(~(put by pubs.sat) coll col)
=? subs.sat !=(our.bol who)
(~(put by subs.sat) [who coll] col)
da-this
--
:: +bake: apply delta
::
++ bake
|= del=delta
^- (quip move _this)
da-done:(da-change:da del)
:: +affection: rumors to interested
::
++ affection
|= del=delta
^- (list move)
%- zing
%+ turn ~(tap by sup.bol)
|= [b=bone s=ship p=path]
^- (list move)
=/ rum=(unit rumor) (feel p del)
?~ rum
~
[b %diff %write-rumor u.rum]~
:: +feel: delta to rumor
::
++ feel
|= [query=wire del=delta]
^- (unit rumor)
?+ query
~
[%primary ~]
[~ del]
::
[%collection @t ~]
=/ coll=@tas i.t.query
?: =(coll col.del)
[~ del]
~
::
==
::
++ get-post-by-index
|= [who=@p coll=@tas post=@tas]
^- (unit post-info)
=/ col=(unit collection)
?: =(our.bol who)
(~(get by pubs.sat) coll)
(~(get by subs.sat) who coll)
?~ col ~
=/ pos=(unit (each [post-info manx] tang))
(~(get by pos.u.col) post)
?~ pos ~
?: ?=(%.n -.u.pos) ~
[~ -.p.u.pos]
::
++ get-coll-by-index
|= [who=@p coll=@tas]
^- (unit collection)
?: =(our.bol who)
(~(get by pubs.sat) coll)
(~(get by subs.sat) coll)
::
++ made
|= [wir=wire wen=@da mad=made-result:ford]
^- (quip move _this)
?+ wir
[~ this]
::
[%collection @t ~]
=/ col=@tas i.t.wir
=/ awa (~(get by awaiting.sat) col)
::
=/ dat=(each collection-info tang)
?: ?=([%incomplete *] mad)
[%.n tang.mad]
?: ?=([%error *] build-result.mad)
[%.n message.build-result.mad]
?> ?=(%bake +<.build-result.mad)
?> ?=(%write-info p.cage.build-result.mad)
[%.y (collection-info q.q.cage.build-result.mad)]
::
?~ awa
(bake [%collection our.bol col dat])
=. builds.u.awa (~(del in builds.u.awa) wir)
?~ partial.u.awa
?~ builds.u.awa
:: one-off build, make delta and process it
::
=. awaiting.sat (~(del by awaiting.sat) col)
(bake [%collection our.bol col dat])
:: 1st part of multi-part, store partial delta and don't process it
::
=/ del=delta [%total our.bol col dat ~ ~ ~ ~]
=. awaiting.sat (~(put by awaiting.sat) col builds.u.awa `del)
[~ this]
::
?~ builds.u.awa
:: last part of multipart, update partial delta and process it
::
?> ?=(%total -.u.partial.u.awa)
=/ del=delta
:* %total
our.bol
col
dat
pos.dat.u.partial.u.awa
com.dat.u.partial.u.awa
[~ ~]
==
=. awaiting.sat (~(del by awaiting.sat) col)
(bake del)
:: nth part of multi-part, update partial delta and don't process it
::
?> ?=(%total -.u.partial.u.awa)
=/ del=delta
:* %total
our.bol
col
dat
pos.dat.u.partial.u.awa
com.dat.u.partial.u.awa
[~ ~]
==
=. awaiting.sat (~(put by awaiting.sat) col builds.u.awa `del)
[~ this]
::
[%post @t @t ~]
=/ col=@tas i.t.wir
=/ pos=@tas i.t.t.wir
=/ awa (~(get by awaiting.sat) col)
::
=/ dat=(each [post-info manx] tang)
?: ?=([%incomplete *] mad)
[%.n tang.mad]
?: ?=([%error *] build-result.mad)
[%.n message.build-result.mad]
?> ?=(%bake +<.build-result.mad)
?> ?=(%write-post p.cage.build-result.mad)
[%.y (,[post-info manx] q.q.cage.build-result.mad)]
::
?~ awa
(bake [%post our.bol col pos dat])
=. builds.u.awa (~(del in builds.u.awa) wir)
?~ partial.u.awa
?~ builds.u.awa
:: one-off build, make delta and process it
::
=. awaiting.sat (~(del by awaiting.sat) col)
(bake [%post our.bol col pos dat])
:: 1st part of multi-part, store partial delta and don't process it
::
=/ del=delta [%total our.bol col [%.n ~] (my [pos dat] ~) ~ ~ ~]
=. awaiting.sat (~(put by awaiting.sat) col builds.u.awa `del)
[~ this]
::
?~ builds.u.awa
:: last part of multipart, update partial delta and process it
::
?> ?=(%total -.u.partial.u.awa)
=/ del=delta
:* %total
our.bol
col
col.dat.u.partial.u.awa
(~(put by pos.dat.u.partial.u.awa) pos dat)
com.dat.u.partial.u.awa
[~ ~]
==
=. awaiting.sat (~(del by awaiting.sat) col)
(bake del)
:: nth part of multi-part, update partial delta and don't process it
::
?> ?=(%total -.u.partial.u.awa)
=/ del=delta
:* %total
our.bol
col
col.dat.u.partial.u.awa
(~(put by pos.dat.u.partial.u.awa) pos dat)
com.dat.u.partial.u.awa
[~ ~]
==
=. awaiting.sat (~(put by awaiting.sat) col builds.u.awa `del)
[~ this]
::
[%comments @t @t ~]
=/ col=@tas i.t.wir
=/ pos=@tas i.t.t.wir
=/ awa (~(get by awaiting.sat) col)
::
=/ dat=(each (list [comment-info manx]) tang)
?: ?=([%incomplete *] mad)
[%.n tang.mad]
?: ?=([%error *] build-result.mad)
[%.n message.build-result.mad]
?> ?=(%bake +<.build-result.mad)
?> ?=(%write-comments p.cage.build-result.mad)
[%.y (,(list [comment-info manx]) q.q.cage.build-result.mad)]
::
?~ awa
(bake [%comments our.bol col pos dat])
=. builds.u.awa (~(del in builds.u.awa) wir)
?~ partial.u.awa
?~ builds.u.awa
:: one-off build, make delta and process it
::
=. awaiting.sat (~(del by awaiting.sat) col)
(bake [%comments our.bol col pos dat])
:: 1st part of multi-part, store partial delta and don't process it
::
=/ del=delta [%total our.bol col [%.n ~] ~ (my [pos dat] ~) ~ ~]
=. awaiting.sat (~(put by awaiting.sat) col builds.u.awa `del)
[~ this]
::
?~ builds.u.awa
:: last part of multipart, update partial delta and process it
::
?> ?=(%total -.u.partial.u.awa)
=/ del=delta
:* %total
our.bol
col
col.dat.u.partial.u.awa
pos.dat.u.partial.u.awa
(~(put by com.dat.u.partial.u.awa) pos dat)
[~ ~]
==
=. awaiting.sat (~(del by awaiting.sat) col)
(bake del)
:: nth part of multi-part, update partial delta and don't process it
::
?> ?=(%total -.u.partial.u.awa)
=/ del=delta
:* %total
our.bol
col
col.dat.u.partial.u.awa
pos.dat.u.partial.u.awa
(~(put by com.dat.u.partial.u.awa) pos dat)
[~ ~]
==
=. awaiting.sat (~(put by awaiting.sat) col builds.u.awa `del)
[~ this]
==
::
++ poke-write-action
|= act=action
^- (quip move _this)
?- -.act
::
%new-collection
:: XX check permissions of src.bol
:: XX check if file already exists
=/ conf=collection-info
:* our.bol
title.act
name.act
com.act
edit.act
now.bol
now.bol
==
:: XX set permissions
:: XX automatically serve collection
:: (add to set of builds)
=/ pax=path /web/write/[name.act]/write-info
::
=/ wir=wire /collection/[name.act]
=/ schema=schematic:ford
:* %bake
%write-info
*coin
[[our.bol q.byk.bol] /[name.act]/write/web]
==
:_ this
:~ (write-file pax %write-info !>(conf))
[ost.bol %build wir %.y schema]
==
::
%new-post
:: XX check permissions of src.bol
:: XX check if file already exists
:: XX check if coll doesn't exist
=. content.act (cat 3 content.act '\0a') :: XX fix udon parser
=/ front=(map knot cord)
%- my
:~ [%creator (scot %p src.bol)]
[%title title.act]
[%collection coll.act]
[%filename name.act]
[%comments com.act]
[%date-created (scot %da now.bol)]
[%last-modified (scot %da now.bol)]
[%pinned %false]
==
:: XX set permissions
:: XX add to set of builds
=/ pax=path /web/write/[coll.act]/[name.act]/udon
=/ out=@t (update-udon-front front content.act)
::
=/ post-wir=wire /post/[coll.act]/[name.act]
=/ post-schema=schematic:ford
:* %bake
%write-post
*coin
[[our.bol q.byk.bol] /[name.act]/[coll.act]/write/web]
==
::
=/ comments-wir=wire /comments/[coll.act]/[name.act]
=/ comments-schema=schematic:ford
:* %bake
%write-comments
*coin
[[our.bol q.byk.bol] /[name.act]/[coll.act]/write/web]
==
:_ this
:~ (write-file pax %udon !>(out))
[ost.bol %build comments-wir %.y comments-schema]
[ost.bol %build post-wir %.y post-schema]
==
::
%new-comment
:: XX check permissions of src.bol
:: XX check if file already exists
=. content.act (cat 3 content.act '\0a') :: XX fix udon parser
=/ front=(map knot cord)
%- my
:~ [%creator (scot %p src.bol)]
[%collection coll.act]
[%post post.act]
[%date-created (scot %da now.bol)]
[%last-modified (scot %da now.bol)]
==
:: XX set permissions
:: XX add to set of builds
=/ pax=path /web/write/[coll.act]/[post.act]/(scot %da now.bol)/udon
=/ out=@t (update-udon-front front content.act)
:_ this
[(write-file pax %udon !>(out))]~
::
%delete
[~ this]
::
%edit-collection
[~ this]
::
%edit-post
[~ this]
::
%edit-comment
[~ this]
::
%invite
[~ this]
::
:: %serve:
::
%serve
:: XX specialize this check for subfiles
?: (~(has by pubs.sat) coll.act)
[~ this]
=/ files=(list path)
.^((list path) %ct (weld our-beak /web/write/[coll.act]))
=/ all=[moves=(list move) builds=(set wire)]
%+ roll files
|= [pax=path out=[moves=(list move) builds=(set wire)]]
?+ pax
out
::
[%web %write @tas %write-info ~]
?> =(coll.act i.t.t.pax)
=/ wir=wire /collection/[coll.act]
=/ schema=schematic:ford
:* %bake
%write-info
*coin
[[our.bol q.byk.bol] /[coll.act]/write/web]
==
%= out
moves [[ost.bol %build wir %.y schema] moves.out]
builds (~(put in builds.out) wir)
==
::
[%web %write @tas @tas %udon ~]
?> =(coll.act i.t.t.pax)
=/ post i.t.t.t.pax
=/ post-wir=wire /post/[coll.act]/[post]
=/ post-schema=schematic:ford
:* %bake
%write-post
*coin
[[our.bol q.byk.bol] /[post]/[coll.act]/write/web]
==
::
=/ comments-wir=wire /comments/[coll.act]/[post]
=/ comments-schema=schematic:ford
:* %bake
%write-comments
*coin
[[our.bol q.byk.bol] /[post]/[coll.act]/write/web]
==
%= out
moves
:* [ost.bol %build post-wir %.y post-schema]
[ost.bol %build comments-wir %.y comments-schema]
moves.out
==
::
builds
(~(uni in builds.out) (sy post-wir comments-wir ~))
==
::
==
:- moves.all
%= this
awaiting.sat (~(put by awaiting.sat) coll.act builds.all ~)
==
::
:: %unserve:
::
%unserve
:: XX pull subscriptions for unserved collections
::
=/ col=(unit collection) (~(get by pubs.sat) coll.act)
?~ col
~| [%non-existent-collection coll.act] !!
=/ kills=(list move)
%+ roll ~(tap by pos.u.col)
|= [[post=@tas *] out=(list move)]
:* [ost.bol %kill /post/[coll.act]/[post] ~]
[ost.bol %kill /comments/[coll.act]/[post] ~]
out
==
::
=/ new-latest=(list [@p @tas @tas])
%+ skip latest.sat
|= [who=@p coll=@tas post=@tas]
?& =(who our.bol)
=(coll coll.act)
==
::
=/ new-unread=(set [@p @tas @tas])
%- sy
%+ skip ~(tap in unread.sat)
|= [who=@p coll=@tas post=@tas]
?& =(who our.bol)
=(coll coll.act)
==
::
:- [[ost.bol %kill /collection/[coll.act] ~] kills]
%= this
pubs.sat (~(del by pubs.sat) coll.act)
awaiting.sat (~(del by awaiting.sat) coll.act)
latest.sat new-latest
unread.sat new-unread
==
::
:: %subscribe:
::
%subscribe
=/ wir=wire /collection/[coll.act]
:_ this
[ost.bol %peer wir [who.act %write] wir]~
::
:: %unsubscribe:
::
%unsubscribe
=/ new-latest=(list [@p @tas @tas])
%+ skim latest.sat
|= [who=@p coll=@tas post=@tas]
?& =(who our.bol)
=(coll coll.act)
==
::
=/ new-unread=(set [@p @tas @tas])
%- sy
%+ skim ~(tap in unread.sat)
|= [who=@p coll=@tas post=@tas]
?& =(who our.bol)
=(coll coll.act)
==
=/ wir=wire /collection/[coll.act]
:- [ost.bol %pull wir [who.act %write] ~]~
%= this
subs.sat (~(del by subs.sat) who.act coll.act)
latest.sat new-latest
unread.sat new-unread
==
::
==
::
++ bound
|= [wir=wire success=? binding=binding:http-server]
^- (quip move _this)
[~ this]
::
:: +poke-handle-http-request: received on a new connection established
::
++ poke-handle-http-request
%- (require-authorization:app ost.bol move this)
|= =inbound-request:http-server
^- (quip move _this)
::
=/ request-line (parse-request-line url.request.inbound-request)
?+ request-line
:_ this
[ost.bol %http-response not-found:app]~
:: styling
::
[[[~ %css] [%'~publish' %index ~]] ~]
:_ this
[ost.bol %http-response (css-response:app css)]~
:: scripting
::
[[[~ %js] [%'~publish' %index ~]] ~]
:_ this
[ost.bol %http-response (js-response:app js)]~
:: home page; redirect to recent
::
[[~ [%'~publish' ~]] ~]
=/ hym=manx (index (state-to-json sat))
:_ this
[ost.bol %http-response (redirect:app '/~publish/recent')]~
:: recent page
::
[[~ [%'~publish' %recent ~]] ~]
=/ hym=manx (index (state-to-json sat))
:_ this
[ost.bol %http-response (manx-response:app hym)]~
:: subscriptions
::
[[~ [%'~publish' %subs ~]] ~]
=/ hym=manx (index (state-to-json sat))
:_ this
[ost.bol %http-response (manx-response:app hym)]~
:: published
::
[[~ [%'~publish' %pubs ~]] ~]
=/ hym=manx (index (state-to-json sat))
:_ this
[ost.bol %http-response (manx-response:app hym)]~
:: blog
::
[[~ [%'~publish' @t @t ~]] ~]
=/ who=(unit @p) (slaw %p i.t.site.request-line)
=/ blog=@tas i.t.t.site.request-line
=/ hym=manx (index (state-to-json sat))
:_ this
[ost.bol %http-response (manx-response:app hym)]~
:: blog post
::
[[~ [%'~publish' @t @t @t ~]] ~]
=/ who=(unit @p) (slaw %p i.t.site.request-line)
=/ blog=@tas i.t.t.site.request-line
=/ post=@tas i.t.t.t.site.request-line
::
?~ who [[ost.bol %http-response not-found:app]~ this]
=/ col=(unit collection)
?: =(u.who our.bol)
(~(get by pubs.sat) blog)
(~(get by subs.sat) u.who blog)
?~ col [[ost.bol %http-response not-found:app]~ this]
=/ pos (~(get by pos.u.col) post)
?~ pos [[ost.bol %http-response not-found:app]~ this]
=/ hym=manx (index (state-to-json sat))
:_ this
[ost.bol %http-response (manx-response:app hym)]~
::
==
::
++ peer-primary
|= wir=wire
^- (quip move _this)
?. =(our.bol src.bol)
:: only we are allowed to subscribe on primary
::
:_ this
[ost.bol %quit ~]~
[~ this]
::
++ pull
|= wir=wire
^- (quip move _this)
[~ this]
::
++ peer-collection
|= wir=wire
^- (quip move _this)
?. ?=([@tas ~] wir)
[~ this]
:: XX handle permissions for foreign subscriptions
::
=/ coll=@tas i.wir
=/ col=(unit collection) (~(get by pubs.sat) coll)
?~ col
[~ this]
=/ rum=rumor
[%total our.bol coll u.col]
:_ this
[ost.bol %diff %write-rumor rum]~
::
++ diff-write-rumor
|= [wir=wire rum=rumor]
^- (quip move _this)
(bake rum)
::
:: +poke-handle-http-cancel: received when a connection was killed
::
++ poke-handle-http-cancel
|= =inbound-request:http-server
^- (quip move _this)
[~ this]
::
--

2
app/write/css/index.css Normal file

File diff suppressed because one or more lines are too long

21
app/write/index.hoon Normal file
View File

@ -0,0 +1,21 @@
|= inject=json
^- manx
;html
::
;head
;title: Write
;meta(charset "utf-8");
;meta
=name "viewport"
=content "width=device-width, initial-scale=1, shrink-to-fit=no";
;link(rel "stylesheet", href "/~publish/index.css");
;script@"/~/channel/channel.js";
;script@"/~modulo/session.js";
;script: window.injectedState = {(en-json:html inject)}
==
::
;body
;div#root;
;script@"/~publish/index.js";
==
==

57858
app/write/js/index.js Normal file

File diff suppressed because it is too large Load Diff

121
lib/chat.hoon Normal file
View File

@ -0,0 +1,121 @@
/- hall
|%
::
+$ move [bone card]
::
+$ card
$% [%http-response =http-event:http]
[%connect wire binding:http-server term]
[%peer wire dock path]
[%quit ~]
[%poke wire dock poke]
[%peer wire dock path]
[%pull wire dock ~]
[%diff diff]
==
::
+$ diff
$% [%hall-rumor rumor:hall]
[%chat-initial streams]
[%chat-update update]
[%chat-config streams]
==
::
+$ poke
$% [%hall-action action:hall]
[%noun [@tas path]]
==
::
+$ state
$% [%0 str=streams]
==
::
+$ streams
$: :: inbox config
::
inbox=config:hall
:: names and configs of all circles we know about
::
configs=(map circle:hall (unit config:hall))
:: messages for all circles we know about
::
messages=(map circle:hall (list envelope:hall))
::
::
circles=(set name:hall)
::
::
peers=(map circle:hall (set @p))
==
::
+$ update
$% [%inbox con=config:hall]
[%message cir=circle:hall env=envelope:hall]
[%messages cir=circle:hall start=@ud end=@ud env=(list envelope:hall)]
[%config cir=circle:hall con=config:hall]
[%circles cir=(set name:hall)]
[%peers cir=circle:hall per=(set @p)]
==
::
+$ action [%actions lis=(list action:hall)]
+$ pareto-mark
$%
[%json pax=path name=@t jon=json]
[%path name=@t obj=(map @t json)]
==
::
::
::
:: +utilities
::
+$ indices-internal-state
$:
lis=(list [circle:hall @])
item=[cir=circle:hall count=@ud]
index=@
==
::
++ generate-circle-indices
|= wir=wire
^- (list [circle:hall @])
=/ data
%^ spin (swag [0 (lent wir)] wir) *indices-internal-state
|= [a=@ta b=indices-internal-state]
^- [* out=indices-internal-state]
=/ switch (dvr index.b 3)
?: =(q.switch 0) :: remainder 0, should be a ship
?: =(index.b 0) :: if item is null, don't add to list
:- 0
%= b
hos.cir.item (slav %p a)
index +(index.b)
==
:: if item is not null, add to list
:- 0
%= b
hos.cir.item (slav %p a)
nom.cir.item *name:hall
count.item 0
lis (snoc lis.b item.b)
index +(index.b)
==
?: =(q.switch 1) :: remainder 1, should be a circle name
:- 0
%= b
nom.cir.item a
index +(index.b)
==
?: =(q.switch 2) :: remainder 2, should be a number
:- 0
%= b
count.item (need (rush a dem))
index +(index.b)
==
!! :: impossible
?: =(index.q.data 0)
~
(snoc lis.q.data item.q.data)
::
--
::

View File

@ -79,23 +79,25 @@
=+ myr=(clan:title our) =+ myr=(clan:title our)
:: ::
?: ?=($pawn myr) ?: ?=($pawn myr)
:~ [%base %collections] :~ [%home %lens]
[%home %lens]
[%base %hall] [%base %hall]
[%base %talk] [%base %talk]
[%base %dojo] [%base %dojo]
[%base %landscape]
[%base %modulo] [%base %modulo]
== ==
:~ [%home %collections] :~ [%home %lens]
[%home %lens]
[%home %acme] [%home %acme]
[%home %dns] [%home %dns]
[%home %dojo] [%home %dojo]
[%home %hall] [%home %hall]
[%home %talk] [%home %talk]
[%home %landscape]
[%home %modulo] [%home %modulo]
[%home %launch]
[%home %chat]
[%home %write]
[%home %timer]
[%home %clock]
[%home %weather]
== ==
:: ::
++ deft-fish :: default connects ++ deft-fish :: default connects

View File

@ -59,6 +59,11 @@
^- http-event:http ^- http-event:http
[%start [200 ['content-type' 'text/css']~] [~ oct-css] %.y] [%start [200 ['content-type' 'text/css']~] [~ oct-css] %.y]
:: ::
++ manx-response
|= man=manx
^- http-event:http
[%start [200 ['content-type' 'text/html']~] [~ (manx-to-octs man)] %.y]
::
++ png-response ++ png-response
|= oct-png=octs |= oct-png=octs
^- http-event:http ^- http-event:http

203
lib/write.hoon Normal file
View File

@ -0,0 +1,203 @@
/- *write
/+ elem-to-react-json
|%
::
++ front-to-post-info
|= fro=(map knot cord)
^- post-info
=/ got ~(got by fro)
~| %invalid-frontmatter
:* (slav %p (got %creator))
(got %title)
(got %collection)
(got %filename)
(comment-config (got %comments))
(slav %da (got %date-created))
(slav %da (got %last-modified))
(rash (got %pinned) (fuss %true %false))
==
::
++ front-to-comment-info
|= fro=(map knot cord)
^- comment-info
=/ got ~(got by fro)
~| %invalid-frontmatter
:* (slav %p (got %creator))
(got %collection)
(got %post)
(slav %da (got %date-created))
(slav %da (got %last-modified))
==
::
++ collection-info-to-json
|= con=collection-info
^- json
%- pairs:enjs:format
:~ :- %owner [%s (scot %p owner.con)]
:- %title [%s title.con]
:- %comments [%s comments.con]
:- %allow-edit [%s allow-edit.con]
:- %date-created (time:enjs:format date-created.con)
:- %last-modified (time:enjs:format last-modified.con)
:- %filename [%s filename.con]
==
::
++ post-info-to-json
|= info=post-info
^- json
%- pairs:enjs:format
:~ :- %creator [%s (scot %p creator.info)]
:- %title [%s title.info]
:- %comments [%s comments.info]
:- %date-created (time:enjs:format date-created.info)
:- %last-modified (time:enjs:format last-modified.info)
:- %pinned [%b pinned.info]
:- %filename [%s filename.info]
:- %collection [%s collection.info]
==
::
++ comment-info-to-json
|= info=comment-info
^- json
%- pairs:enjs:format
:~ :- %creator [%s (scot %p creator.info)]
:- %date-created (time:enjs:format date-created.info)
:- %last-modified (time:enjs:format last-modified.info)
:- %post [%s post.info]
:- %collection [%s collection.info]
==
::
++ tang-to-json
|= tan=tang
%- wall:enjs:format
%- zing
%+ turn tan
|= a=tank
(wash [0 80] a)
::
++ string-to-symbol
|= tap=tape
^- @tas
%- crip
%+ turn tap
|= a=@
?: ?| &((gte a 'a') (lte a 'z'))
&((gte a '0') (lte a '9'))
==
a
?: &((gte a 'A') (lte a 'Z'))
(add 32 a)
'-'
::
++ collection-build-to-json
|= bud=(each collection-info tang)
^- json
?: ?=(%.y -.bud)
(collection-info-to-json +.bud)
(tang-to-json +.bud)
::
++ post-build-to-json
|= bud=(each [post-info manx] tang)
^- json
?: ?=(%.y -.bud)
%- pairs:enjs:format
:~ info+(post-info-to-json +<.bud)
body+(elem-to-react-json +>.bud)
==
(tang-to-json +.bud)
::
++ comment-build-to-json
|= bud=(each (list [comment-info manx]) tang)
^- json
?: ?=(%.y -.bud)
:- %a
%+ turn p.bud
|= [com=comment-info man=manx]
^- json
%- pairs:enjs:format
:~ info+(comment-info-to-json com)
body+(elem-to-react-json man)
==
(tang-to-json +.bud)
::
++ total-build-to-json
|= col=collection
^- json
%- pairs:enjs:format
:~ info+(collection-build-to-json col.col)
::
:+ %posts
%o
%+ roll ~(tap in ~(key by pos.col))
|= [post=@tas out=(map @t json)]
=/ post-build (~(got by pos.col) post)
=/ comm-build (~(got by com.col) post)
%+ ~(put by out)
post
%- pairs:enjs:format
:~ post+(post-build-to-json post-build)
comments+(comment-build-to-json comm-build)
==
::
:- %order
%- pairs:enjs:format
:~ pin+a+(turn pin.order.col |=(s=@tas [%s s]))
unpin+a+(turn unpin.order.col |=(s=@tas [%s s]))
==
==
::
++ state-to-json
|= sat=state
^- json
%- pairs:enjs:format
:~ :+ %pubs
%o
%+ roll ~(tap by pubs.sat)
|= [[nom=@tas col=collection] out=(map @t json)]
%+ ~(put by out)
nom
(total-build-to-json col)
::
:+ %subs
%o
%- ~(rep by subs.sat)
|= $: [[who=@p nom=@tas] col=collection]
out=(map @t [%o (map @t json)])
==
=/ shp=@t (rsh 3 1 (scot %p who))
?: (~(has by out) shp)
%+ ~(put by out)
shp
:- %o
%+ ~(put by +:(~(got by out) shp))
nom
(total-build-to-json col)
%+ ~(put by out)
shp
:- %o
(my [nom (total-build-to-json col)] ~)
::
:+ %latest
%a
%+ turn latest.sat
|= [who=@p coll=@tas post=@tas]
%- pairs:enjs:format
:~ who+(ship:enjs:format who)
coll+s+coll
post+s+post
==
::
:+ %unread
%a
%+ turn ~(tap in unread.sat)
|= [who=@p coll=@tas post=@tas]
%- pairs:enjs:format
:~ who+(ship:enjs:format who)
coll+s+coll
post+s+post
==
==
::
--

58
mar/chat/action.hoon Normal file
View File

@ -0,0 +1,58 @@
::
::
/- hall
/+ chat, hall-json
::
|_ act=action:chat
++ grow
|%
++ tank !!
--
::
++ grab
|%
++ noun streams:chat
++ json
|= jon=^json
=< (parse-chat-action jon)
|%
::
++ hall-action
=, dejs:hall-json
=, dejs-soft:format
|= a=^json
^- action:hall
=- (need ((of -) a))
:~ create+(ot nom+so des+so sec+secu ~)
design+(ot nom+so cof+conf ~)
delete+(ot nom+so why+(mu so) ~)
depict+(ot nom+so des+so ~)
filter+(ot nom+so fit+filt ~)
permit+(ot nom+so inv+bo sis+(as (su fed:ag)) ~)
source+(ot nom+so sub+bo srs+(as sorc) ~)
read+(ot nom+so red+ni ~)
usage+(ot nom+so add+bo tas+(as so) ~)
newdm+(ot sis+(as (su fed:ag)) ~)
::
convey+(ar thot)
phrase+(ot aud+audi ses+(ar spec:dejs:hall-json) ~)
::
notify+(ot aud+audi pes+(mu pres) ~)
naming+(ot aud+audi man+huma ~)
::
glyph+(ot gyf+so aud+audi bin+bo ~)
nick+(ot who+(su fed:ag) nic+so ~)
::
public+(ot add+bo cir+circ ~)
==
::
++ parse-chat-action
=, dejs:format
%- of
:~
[%actions (ot lis+(ar hall-action) ~)]
==
::
--
--
--

48
mar/chat/config.hoon Normal file
View File

@ -0,0 +1,48 @@
::
::
/? 309
::
/- hall
/+ chat, hall-json
::
|_ str=streams:chat
++ grow
|%
++ json
=, enjs:format
^- ^json
%+ frond %chat
%- pairs
:~
::
[%inbox (conf:enjs:hall-json inbox.str)]
::
:- %configs
%- pairs
%+ turn ~(tap by configs.str)
|= [cir=circle:hall con=(unit config:hall)]
^- [@t ^json]
:- (crip (circ:en-tape:hall-json cir))
?~(con ~ (conf:enjs:hall-json u.con))
::
:- %circles :- %a
%+ turn ~(tap in circles.str)
|= nom=name:hall
[%s nom]
::
:- %peers
%- pairs
%+ turn ~(tap by peers.str)
|= [cir=circle:hall per=(set @p)]
^- [@t ^json]
:- (crip (circ:en-tape:hall-json cir))
[%a (turn ~(tap in per) ship)]
::
==
--
::
++ grab
|%
++ noun streams:chat
--
--

56
mar/chat/initial.hoon Normal file
View File

@ -0,0 +1,56 @@
::
::
/? 309
::
/- hall
/+ chat, hall-json
::
|_ str=streams:chat
++ grow
|%
++ json
=, enjs:format
^- ^json
%+ frond %initial
%- pairs
:~
::
[%inbox (conf:enjs:hall-json inbox.str)]
::
:- %configs
%- pairs
%+ turn ~(tap by configs.str)
|= [cir=circle:hall con=(unit config:hall)]
^- [@t ^json]
:- (crip (circ:en-tape:hall-json cir))
?~(con ~ (conf:enjs:hall-json u.con))
::
:- %messages
%- pairs
%+ turn ~(tap by messages.str)
|= [cir=circle:hall lis=(list envelope:hall)]
^- [@t ^json]
:- (crip (circ:en-tape:hall-json cir))
[%a (turn lis enve:enjs:hall-json)]
::
:- %circles :- %a
%+ turn ~(tap in circles.str)
|= nom=name:hall
[%s nom]
::
:- %peers
%- pairs
%+ turn ~(tap by peers.str)
|= [cir=circle:hall per=(set @p)]
^- [@t ^json]
:- (crip (circ:en-tape:hall-json cir))
[%a (turn ~(tap in per) ship)]
::
==
--
::
++ grab
|%
++ noun streams:chat
--
--

87
mar/chat/update.hoon Normal file
View File

@ -0,0 +1,87 @@
::
::
/? 309
::
/- hall
/+ chat, hall-json
::
|_ upd=update:chat
++ grow
|%
++ json
=, enjs:format
^- ^json
%+ frond %update
%- pairs
:~
::
:: %inbox
?: =(%inbox -.upd)
?> ?=(%inbox -.upd)
[%inbox (conf:enjs:hall-json con.upd)]
::
:: %message
?: =(%message -.upd)
?> ?=(%message -.upd)
:- %message
%- pairs
:~
[%circle (circ:enjs:hall-json cir.upd)]
[%envelope (enve:enjs:hall-json env.upd)]
==
::
:: %messages
?: =(%messages -.upd)
?> ?=(%messages -.upd)
:- %messages
%- pairs
:~
[%circle (circ:enjs:hall-json cir.upd)]
[%start (numb start.upd)]
[%end (numb end.upd)]
[%envelopes [%a (turn env.upd enve:enjs:hall-json)]]
==
::
:: %config
?: =(%config -.upd)
?> ?=(%config -.upd)
:- %config
%- pairs
:~
[%circle (circ:enjs:hall-json cir.upd)]
[%config (conf:enjs:hall-json con.upd)]
==
::
:: %circles
?: =(%circles -.upd)
?> ?=(%circles -.upd)
:- %circles
%- pairs
:~
:- %circles
:- %a
%+ turn ~(tap in cir.upd)
|= nom=name:hall
[%s nom]
==
::
:: %peers
?: =(%peers -.upd)
?> ?=(%peers -.upd)
:- %peers
%- pairs
:~
[%circle (circ:enjs:hall-json cir.upd)]
[%peers [%a (turn ~(tap in per.upd) ship:enjs:format)]]
==
::
:: %noop
[*@t *^json]
==
--
::
++ grab
|%
++ noun update:chat
--
--

View File

@ -1,6 +0,0 @@
|_ ter=term
++ grab
|%
++ noun term
--
--

View File

@ -1,14 +0,0 @@
/- *modulo
=, format
|_ com=command
++ grab
|%
++ noun command
++ json
%- of:dejs
:~ forward+ul:dejs
back+ul:dejs
go+(su:dejs sym)
==
--
--

View File

@ -1,6 +0,0 @@
|_ ter=term
++ grab
|%
++ noun term
--
--

187
mar/write/action.hoon Normal file
View File

@ -0,0 +1,187 @@
::
:::: /hoon/action/write/mar
::
/? 309
/- write
=, format
::
|_ act=action:write
::
++ grow
|%
++ tank >act<
--
::
++ grab
|%
++ noun action:write
++ json
|= jon=^json
%- action:write
=< (action jon)
|%
++ action
%- of:dejs
:~ new-collection+new-collection
new-post+new-post
new-comment+new-comment
::
delete+item-id
::
edit-collection+edit-collection
edit-post+edit-post
edit-comment+edit-comment
::
invite+invite
::
serve+serve
unserve+unserve
::
subscribe+subscribe
unsubscribe+unsubscribe
::
==
::
++ new-collection
%- ot:dejs
:~ name+(su:dejs sym)
title+so:dejs
comments+comment-config
allow-edit+edit-config
perm+perm-config
==
::
++ new-post
%- ot:dejs
:~ coll+(su:dejs sym)
name+(su:dejs sym)
title+so:dejs
comments+comment-config
perm+perm-config
content+so:dejs
==
::
++ new-comment
%- ot:dejs
:~ coll+(su:dejs sym)
name+(su:dejs sym)
content+so:dejs
==
::
++ edit-collection
%- ot:dejs
:~ name+(su:dejs sym)
title+so:dejs
comments+comment-config
allow-edit+edit-config
perm+perm-config
==
::
++ edit-post
%- ot:dejs
:~ coll+(su:dejs sym)
name+(su:dejs sym)
title+so:dejs
comments+comment-config
perm+perm-config
content+so:dejs
==
::
++ edit-comment
%- ot:dejs
:~ coll+(su:dejs sym)
name+(su:dejs sym)
id+(su:dejs sym)
content+so:dejs
==
::
++ comment-config
%- su:dejs
;~(pose (jest %open) (jest %closed) (jest %none))
::
++ edit-config
%- su:dejs
;~(pose (jest %post) (jest %comment) (jest %all) (jest %none))
::
++ perm-config
%- ot:dejs
:~ :- %read
%- ot:dejs
:~ mod+(su:dejs ;~(pose (jest %black) (jest %white)))
who+whoms
==
:- %write
%- ot:dejs
:~ mod+(su:dejs ;~(pose (jest %black) (jest %white)))
who+whoms
== ==
::
++ whoms
|= jon=^json
^- (set whom:clay)
=/ x ((ar:dejs (su:dejs fed:ag)) jon)
%- (set whom:clay)
%- ~(run in (sy x))
|=(w=@ [& w])
::
++ item-id
|= jon=^json
^- item-id:write
?> ?=(%a -.jon) :: must be array
?< ?=(~ +.jon) :: must have at least one item
?> ?=([%s @t] -.+.jon) :: first item must be string
=/ coll=@tas (slav %tas +.-.+.jon) :: get first item as @tas
?~ +.+.jon :: if only one item, return it
coll
?> ?=([%s @t] -.+.+.jon) :: second item must be string
=/ post=@tas (slav %tas +.-.+.+.jon) :: get second item as @tas
?~ +.+.+.jon :: if two items, return them
[coll post]
?> ?=([%s @t] -.+.+.+.jon) :: third item must be string
=/ comm=@tas (slav %tas +.-.+.+.+.jon) :: get third item as @tas
?> ?=(~ +.+.+.+.jon) :: no fourth item
[coll post comm]
::
++ invite
%- ot:dejs
:~ coll+(su:dejs sym)
who+(ar:dejs (su:dejs fed:ag))
==
::
++ serve
%- ot:dejs
:~ coll+(su:dejs sym)
==
::
++ unserve
%- ot:dejs
:~ coll+(su:dejs sym)
==
::
++ subscribe
%- ot:dejs
:~ who+(su:dejs fed:ag)
coll+(su:dejs sym)
==
::
++ unsubscribe
%- ot:dejs
:~ who+(su:dejs fed:ag)
coll+(su:dejs sym)
==
::
--
--
--

84
mar/write/info.hoon Normal file
View File

@ -0,0 +1,84 @@
::
:::: /hoon/info/write/mar
::
/- write
!:
|_ con=collection-info:write
::
::
++ grow
|%
++ mime
:- /text/x-write-info
(as-octs:mimes:html (of-wain:format txt))
++ txt
^- wain
:~ (cat 3 'owner: ' (scot %p owner.con))
(cat 3 'title: ' title.con)
(cat 3 'filename: ' filename.con)
(cat 3 'comments: ' comments.con)
(cat 3 'allow-edit: ' allow-edit.con)
(cat 3 'date-created: ' (scot %da date-created.con))
(cat 3 'last-modified: ' (scot %da last-modified.con))
==
--
++ grab
|%
++ mime
|= [mite:eyre p=octs:eyre]
(txt (to-wain:format q.p))
++ txt
|= txs=(pole @t)
^- collection-info:write
:: TODO: putting ~ instead of * breaks this but shouldn't
::
?> ?= $: owner=@t
title=@t
filename=@t
comments=@t
allow-edit=@t
date-created=@t
last-modified=@t
*
==
txs
::
:* %+ rash owner.txs
;~(pfix (jest 'owner: ~') fed:ag)
::
%+ rash title.txs
;~(pfix (jest 'title: ') (cook crip (star next)))
::
%+ rash filename.txs
;~(pfix (jest 'filename: ') (cook crip (star next)))
::
%+ rash comments.txs
;~ pfix
(jest 'comments: ')
%+ cook comment-config:write
;~(pose (jest %open) (jest %closed) (jest %none))
==
::
%+ rash allow-edit.txs
;~ pfix
(jest 'allow-edit: ')
%+ cook edit-config:write
;~(pose (jest %post) (jest %comment) (jest %all) (jest %none))
==
::
%+ rash date-created.txs
;~ pfix
(jest 'date-created: ~')
(cook year when:so)
==
::
%+ rash last-modified.txs
;~ pfix
(jest 'last-modified: ~')
(cook year when:so)
==
==
++ noun collection-info:write
--
++ grad %mime
--

47
mar/write/rumor.hoon Normal file
View File

@ -0,0 +1,47 @@
/- *write
/+ *write, elem-to-react-json
|_ rum=rumor
++ grab
|%
++ noun rumor
--
++ grow
|%
++ noun rum
++ json
=, enjs:format
%+ frond -.rum
?- -.rum
%collection
%- pairs
:~ [%coll s+col.rum]
[%who (ship who.rum)]
[%data (collection-build-to-json dat.rum)]
==
::
%post
%- pairs
:~ [%coll s+col.rum]
[%post s+pos.rum]
[%who (ship who.rum)]
[%data (post-build-to-json dat.rum)]
==
::
%comments
%- pairs
:~ [%coll s+col.rum]
[%post s+pos.rum]
[%who (ship who.rum)]
[%data (comment-build-to-json dat.rum)]
==
::
%total
%- pairs
:~ [%coll s+col.rum]
[%who (ship who.rum)]
[%data (total-build-to-json dat.rum)]
==
==
::
--
--

24
ren/write/comments.hoon Normal file
View File

@ -0,0 +1,24 @@
/- write
/+ write, cram, elem-to-react-json
/= args /$ ,[beam *]
/= result
/^ (list [comment-info:write manx])
/;
|= $= comments
%+ map knot
$: comment-front=(map knot cord)
comment-content=manx
~
==
^- (list [comment-info:write manx])
:: XX sort this list
%+ turn ~(tap by comments)
|= [fil=knot front=(map knot cord) content=manx ~]
^- [comment-info:write manx]
[(front-to-comment-info:write front) content]
::
/_
/. /&front&/udon/
/&elem&/udon/
==
result

17
ren/write/post.hoon Normal file
View File

@ -0,0 +1,17 @@
/- write
/+ write, cram, elem-to-react-json
/= args /$ ,[beam *]
/= result
/^ [post-info:write manx]
/;
|= $: post-front=(map knot cord)
post-content=manx
~
==
:- (front-to-post-info:write post-front)
post-content
::
/. /&front&/udon/
/&elem&/udon/
==
result

View File

@ -1,7 +0,0 @@
|%
+$ command
$% [%forward ~]
[%back ~]
[%go app=term]
==
--

124
sur/write.hoon Normal file
View File

@ -0,0 +1,124 @@
|%
+$ item-id
$? coll=@tas
[coll=@tas post=@tas]
[coll=@tas post=@tas comment=@tas]
==
::
+$ action
$% $: %new-collection
name=@tas
title=@t
com=comment-config
edit=edit-config
perm=perm-config
==
::
$: %new-post
coll=@tas
name=@tas
title=@t
com=comment-config
perm=perm-config
content=@t
==
::
[%new-comment coll=@tas post=@tas content=@t]
::
[%delete item-id]
::
$: %edit-collection
name=@tas
title=@t
com=comment-config
edit=edit-config
perm=perm-config
==
::
$: %edit-post
coll=@tas
name=@tas
title=@t
com=comment-config
perm=perm-config
content=@t
==
::
[%edit-comment coll=@tas post=@tas id=@tas content=@t]
::
[%invite coll=@tas who=(list ship)]
::
[%serve coll=@tas]
[%unserve coll=@tas]
::
[%subscribe who=@p coll=@tas]
[%unsubscribe who=@p coll=@tas]
::
==
::
+$ collection-info
$: owner=@p
title=@t
filename=@tas
comments=comment-config
allow-edit=edit-config
date-created=@da
last-modified=@da
==
::
+$ post-info
$: creator=@p
title=@t
collection=@tas
filename=@tas
comments=comment-config
date-created=@da
last-modified=@da
pinned=?
==
::
+$ comment-info
$: creator=@p
collection=@tas
post=@tas
date-created=@da
last-modified=@da
==
::
+$ perm-config [read=rule:clay write=rule:clay]
::
::
+$ comment-config $?(%open %closed %none)
::
::
+$ edit-config $?(%post %comment %all %none)
::
+$ rumor delta
:: $% [%collection who=@p col=@tas dat=(each collection-info tang)]
:: [%post who=@p col=@tas pos=@tas dat=(each [post-info manx] tang)]
:: [%comments who=@p col=@tas pos=@tas dat=(each (list [comment-info manx]) tang)]
:: [%serve who=@p nom=@tas col=collection]
:: ==
::
+$ collection
$: col=(each collection-info tang)
pos=(map @tas (each [post-info manx] tang))
com=(map @tas (each (list [comment-info manx]) tang))
order=[pin=(list @tas) unpin=(list @tas)]
==
::
+$ state
$: pubs=(map @tas collection)
subs=(map [ship @tas] collection)
awaiting=(map @tas [builds=(set wire) partial=(unit delta)])
latest=(list [who=ship coll=@tas post=@tas])
unread=(set [who=ship coll=@tas post=@tas])
==
::
+$ delta
$% [%collection who=@p col=@tas dat=(each collection-info tang)]
[%post who=@p col=@tas pos=@tas dat=(each [post-info manx] tang)]
[%comments who=@p col=@tas pos=@tas dat=(each (list [comment-info manx]) tang)]
[%total who=@p col=@tas dat=collection]
==
--