contacts: ported to static gall

This commit is contained in:
Logan Allen 2019-12-09 15:13:52 -08:00
parent c8020691f8
commit ad64763a8c
4 changed files with 228 additions and 240 deletions

View File

@ -1,13 +1,9 @@
/+ *contact-json
:: contact-store: data store that holds group-based contact data
::
/+ *contact-json, default-agent
|%
+$ move [bone card]
::
+$ card
$% [%diff [%contact-update contact-update]]
[%quit ~]
==
::
+$ state
+$ card card:agent:gall
+$ versioned-state
$% state-zero
==
::
@ -15,70 +11,90 @@
$: %0
=rolodex
==
+$ diff
$% [%contact-update contact-update]
==
--
::
|_ [bol=bowl:gall state-zero]
=| state-zero
=* state -
^- agent:gall
=<
|_ =bowl:gall
+* this .
contact-core +>
cc ~(. contact-core bowl)
def ~(. (default-agent this %|) bowl)
::
++ on-init on-init:def
++ on-save !>(state)
++ on-load
|= old=vase
`this(state !<(state-zero old))
::
++ on-poke
|= [=mark =vase]
^- (quip card _this)
?> (team:title our.bowl src.bowl)
=^ cards state
?+ mark (on-poke:def mark vase)
::%json (poke-json:cc !<(json vase))
%contact-action (poke-contact-action:cc !<(contact-action vase))
==
[cards this]
::
++ on-watch
|= =path
^- (quip card _this)
?> (team:title our.bowl src.bowl)
|^
=/ cards=(list card)
?+ path (on-watch:def path)
[%all ~] (give %contact-update !>([%rolodex rolodex]))
[%updates ~] ~
[%contacts @ *]
%+ give %contact-update
!>([%contacts t.path (~(got by rolodex) t.path)])
==
[cards this]
::
++ give
|= =cage
^- (list card)
[%give %fact ~ cage]~
--
::
++ on-leave on-leave:def
++ on-peek
|= =path
^- (unit (unit cage))
?+ path (on-peek:def path)
[%x %all ~] ``noun+!>(rolodex)
[%x %contacts *]
?~ t.t.path
~
``noun+!>((~(get by rolodex) t.t.path))
::
[%x %contacts *]
:: /:path/:ship
=/ pax `^path`(flop t.t.path)
?~ pax ~
=/ =ship (slav %p i.pax)
?~ t.pax ~
=> .(pax `(list @ta)`(flop t.pax))
=/ contacts=(unit contacts) (~(get by rolodex) pax)
?~ contacts
~
``noun+!>((~(get by u.contacts) ship))
==
::
++ on-agent on-agent:def
++ on-arvo on-arvo:def
++ on-fail on-fail:def
--
::
++ this .
::
++ prep
|= old=(unit state)
^- (quip move _this)
:- ~
?~ old this
?- -.old
%0 this(+<+ u.old)
==
::
++ peek-x-all
|= pax=path
^- (unit (unit [%noun (map path contacts)]))
[~ ~ %noun rolodex]
::
++ peek-x-contacts
|= pax=path
^- (unit (unit [%noun (unit contacts)]))
?~ pax
~
=/ contacts=(unit contacts) (~(get by rolodex) pax)
[~ ~ %noun contacts]
::
++ peek-x-contact
|= pax=path
^- (unit (unit [%noun (unit contact)]))
:: /:path/:ship
=/ pas (flop pax)
?~ pas
~
=/ =ship (slav %p i.pas)
=. pax (scag (dec (lent pax)) `(list @ta)`pax)
=/ contacts=(unit contacts) (~(get by rolodex) pax)
?~ contacts
~
=/ contact=(unit contact) (~(get by u.contacts) ship)
[~ ~ %noun contact]
::
++ peer-all
|= pax=path
^- (quip move _this)
?> (team:title our.bol src.bol)
:: send all updates from now on
:_ this
[ost.bol %diff %contact-update [%rolodex rolodex]]~
::
++ peer-updates
|= pax=path
^- (quip move _this)
?> (team:title our.bol src.bol)
:: send all updates from now on
[~ this]
::
++ peer-contacts
|= pax=path
^- (quip move _this)
?> (team:title our.bol src.bol)
:_ this
[ost.bol %diff %contact-update [%contacts pax (~(got by rolodex) pax)]]~
|_ bol=bowl:gall
::
::++ poke-json
:: |= =json
@ -88,62 +104,57 @@
::
++ poke-contact-action
|= action=contact-action
^- (quip move _this)
^- (quip card _state)
?> (team:title our.bol src.bol)
?- -.action
%create (handle-create action)
%delete (handle-delete action)
%add (handle-add action)
%remove (handle-remove action)
%edit (handle-edit action)
%create (handle-create +.action)
%delete (handle-delete +.action)
%add (handle-add +.action)
%remove (handle-remove +.action)
%edit (handle-edit +.action)
==
::
++ handle-create
|= act=contact-action
^- (quip move _this)
?> ?=(%create -.act)
?< (~(has by rolodex) path.act)
:- (send-diff path.act act)
this(rolodex (~(put by rolodex) path.act *contacts))
|= =path
^- (quip card _state)
?< (~(has by rolodex) path)
:- (send-diff path [%create path])
state(rolodex (~(put by rolodex) path *contacts))
::
++ handle-delete
|= act=contact-action
^- (quip move _this)
?> ?=(%delete -.act)
?> (~(has by rolodex) path.act)
:- (send-diff path.act act)
this(rolodex (~(del by rolodex) path.act))
|= =path
^- (quip card _state)
?> (~(has by rolodex) path)
:- (send-diff path [%delete path])
state(rolodex (~(del by rolodex) path))
::
++ handle-add
|= act=contact-action
^- (quip move _this)
?> ?=(%add -.act)
=/ contacts (~(got by rolodex) path.act)
?< (~(has by contacts) ship.act)
=. contacts (~(put by contacts) ship.act contact.act)
:- (send-diff path.act act)
this(rolodex (~(put by rolodex) path.act contacts))
|= [=path =ship =contact]
^- (quip card _state)
=/ contacts (~(got by rolodex) path)
?< (~(has by contacts) ship)
=. contacts (~(put by contacts) ship contact)
:- (send-diff path [%add path ship contact])
state(rolodex (~(put by rolodex) path contacts))
::
++ handle-remove
|= act=contact-action
^- (quip move _this)
?> ?=(%remove -.act)
=/ contacts (~(got by rolodex) path.act)
?> (~(has by contacts) ship.act)
=. contacts (~(del by contacts) ship.act)
:- (send-diff path.act act)
this(rolodex (~(put by rolodex) path.act contacts))
|= [=path =ship]
^- (quip card _state)
=/ contacts (~(got by rolodex) path)
?> (~(has by contacts) ship)
=. contacts (~(del by contacts) ship)
:- (send-diff path [%remove path ship])
state(rolodex (~(put by rolodex) path contacts))
::
++ handle-edit
|= act=contact-action
^- (quip move _this)
?> ?=(%edit -.act)
=/ contacts (~(got by rolodex) path.act)
=/ contact (~(got by contacts) ship.act)
=. contact (edit-contact contact edit-field.act)
=. contacts (~(put by contacts) ship.act contact)
:- (send-diff path.act act)
this(rolodex (~(put by rolodex) path.act contacts))
|= [=path =ship =edit-field]
^- (quip card _state)
=/ contacts (~(got by rolodex) path)
=/ contact (~(got by contacts) ship)
=. contact (edit-contact contact edit-field)
=. contacts (~(put by contacts) ship contact)
:- (send-diff path [%edit path ship edit-field])
state(rolodex (~(put by rolodex) path contacts))
::
++ edit-contact
|= [con=contact edit=edit-field]
@ -159,15 +170,13 @@
==
::
++ update-subscribers
|= [pax=path upd=contact-update]
^- (list move)
%+ turn (prey:pubsub:userlib pax bol)
|= [=bone *]
[bone %diff %contact-update upd]
|= [pax=path update=contact-update]
^- (list card)
[%give %fact `pax %contact-update !>(update)]~
::
++ send-diff
|= [pax=path upd=contact-update]
^- (list move)
^- (list card)
%- zing
:~ (update-subscribers /all upd)
(update-subscribers /updates upd)

View File

@ -2,7 +2,7 @@
:: into semantic actions for the UI
::
/- *group-store
/+ *server, *contact-json
/+ *server, *contact-json, default-agent
/= index
/^ octs
/; as-octs:mimes:html
@ -36,55 +36,90 @@
/: /===/app/contacts/img /_ /png/
::
|%
::
+$ move [bone card]
::
+$ card
$% [%http-response =http-event:http]
[%connect wire binding:eyre term]
[%quit ~]
[%peer wire dock path]
[%poke wire dock poke]
[%diff %json json]
==
::
+$ poke
$% [%launch-action [@tas path @t]]
[%contact-action contact-action]
[%group-action group-action]
==
+$ card card:agent:gall
--
::
|_ [bol=bowl:gall ?]
::
++ this .
::
++ prep
|= old=(unit ?)
^- (quip move _this)
?~ old
^- agent:gall
=<
|_ =bowl:gall
+* this .
contact-core +>
cc ~(. contact-core bowl)
def ~(. (default-agent this %|) bowl)
::
++ on-init
^- (quip card _this)
:_ this
:~ [ost.bol %peer / [our.bol %contact-store] /updates]
[ost.bol %connect / [~ /'~contacts'] %contact-view]
(launch-poke [/configs '/~contacts/js/tile.js'])
(contact-poke [%create /~/default])
(group-poke [%bundle /~/default])
(contact-poke [%add /~/default our.bol *contact])
(group-poke [%add [our.bol ~ ~] /~/default])
:~ [%pass /updates %agent [our.bowl %contact-store] %watch /updates]
[%pass / %arvo %e %connect [~ /'~contacts'] %contact-view]
(launch-poke:cc [%contact-view /primary '/~contacts/js/tile.js'])
(contact-poke:cc [%create /~/default])
(group-poke:cc [%bundle /~/default])
(contact-poke:cc [%add /~/default our.bowl *contact])
(group-poke:cc [%add [our.bowl ~ ~] /~/default])
==
[~ this(+<+ u.old)]
::
++ on-save on-save:def
++ on-load on-load:def
++ on-poke
|= [=mark =vase]
^- (quip card _this)
?> (team:title our.bowl src.bowl)
?+ mark (on-poke:def mark vase)
%json [(poke-json:cc !<(json vase)) this]
%handle-http-request
=+ !<([eyre-id=@ta =inbound-request:eyre] vase)
:_ this
%+ give-simple-payload:app eyre-id
%+ require-authorization:app inbound-request
poke-handle-http-request:cc
==
::
++ on-watch
|= =path
^- (quip card _this)
?> (team:title our.bowl src.bowl)
?: ?=([%http-response *] path) [~ this]
?. =(/primary path) (on-watch:def path)
[[%give %fact ~ %json !>((rolodex-to-json all-scry:cc))]~ this]
::
++ on-agent
|= [=wire =sign:agent:gall]
^- (quip card _this)
?+ -.sign (on-agent:def wire sign)
%kick
[[%pass / %agent [our.bol %contact-store] %watch /updates]~ this]
::
%fact
?+ p.cage.sign (on-agent:def wire sign)
%contact-update
=/ update=json (update-to-json !<(contact-update q.cage.sign))
[[%give %fact `/primary %json !>(update)]~ this]
==
==
::
++ on-arvo
|= [=wire =sign-arvo]
^- (quip card _this)
?. ?=(%bound +<.sign-arvo)
(on-arvo:def wire sign-arvo)
[~ this]
::
++ on-leave on-leave:def
++ on-peek on-peek:def
++ on-fail on-fail:def
--
::
|_ bol=bowl:gall
++ poke-json
|= jon=json
^- (quip move _this)
^- (list card)
?> (team:title our.bol src.bol)
(poke-contact-view-action (json-to-view-action jon))
::
++ poke-contact-view-action
|= act=contact-view-action
^- (quip move _this)
?> (team:title our.bol src.bol)
:_ this
^- (list card)
?- -.act
%create
:~ (group-poke [%bundle path.act])
@ -106,95 +141,41 @@
(contact-poke [%remove path.act ship.act])
==
==
::
++ peer-primary
|= pax=path
^- (quip move _this)
?> (team:title our.bol src.bol)
:: create inbox with 100 messages max per mailbox and send that along
:: then quit the subscription
:_ this
[ost.bol %diff %json (rolodex-to-json all-scry)]~
::
++ diff-contact-update
|= [wir=wire upd=contact-update]
^- (quip move _this)
=/ updates-json (update-to-json upd)
:_ this
%+ turn (prey:pubsub:userlib /primary bol)
|= [=bone *]
[bone %diff %json updates-json]
::
++ quit
|= wir=wire
^- (quip move _this)
:_ this
[ost.bol %peer / [our.bol %contact-store] /updates]~
::
++ poke-handle-http-request
%- (require-authorization:app ost.bol move this)
|= =inbound-request:eyre
^- (quip move _this)
::
^- simple-payload:http
=+ url=(parse-request-line url.request.inbound-request)
=/ name=@t
=+ back-path=(flop site.url)
?~ back-path
''
i.back-path
?: =(name 'tile')
[[ost.bol %http-response (js-response:app tile-js)]~ this]
?+ site.url
:_ this
[ost.bol %http-response not-found:app]~
::
:: styling
::
[%'~contacts' %css %index ~]
:_ this
[ost.bol %http-response (css-response:app style)]~
::
:: javascript
::
[%'~contacts' %js %index ~]
:_ this
[ost.bol %http-response (js-response:app script)]~
::
:: images
::
?+ site.url not-found:gen
[%'~contacts' %css %index ~] (css-response:gen style)
[%'~contacts' %js %index ~] (js-response:gen script)
[%'~contacts' %js %tile ~] (js-response:gen tile-js)
[%'~contacts' %img *]
=/ img (as-octs:mimes:html (~(got by contact-png) `@ta`name))
:_ this
[ost.bol %http-response (png-response:app img)]~
(png-response:gen (as-octs:mimes:html (~(got by contact-png) `@ta`name)))
::
:: main page
::
[%'~contacts' *]
:_ this
[ost.bol %http-response (html-response:app index)]~
[%'~contacts' *] (html-response:gen index)
==
::
++ bound
|= [wir=wire success=? binding=binding:eyre]
^- (quip move _this)
[~ this]
::
:: +utilities
::
++ contact-poke
|= act=contact-action
^- move
[ost.bol %poke / [our.bol %contact-store] [%contact-action act]]
^- card
[%pass / %agent [our.bol %contact-store] %poke %contact-action !>(act)]
::
++ launch-poke
|= [pax=path =cord]
^- move
[ost.bol %poke / [our.bol %launch] [%launch-action [%contact-view pax cord]]]
|= act=[@tas path @t]
^- card
[%pass / %agent [our.bol %launch] %poke %launch-action !>(act)]
::
++ group-poke
|= act=group-action
^- move
[ost.bol %poke / [our.bol %group-store] [%group-action act]]
^- card
[%pass / %agent [our.bol %group-store] %poke %group-action !>(act)]
::
++ all-scry
^- rolodex

View File

@ -32308,7 +32308,6 @@
global$2[key$1] = "esm";
}
}
//# sourceMappingURL=react-router.js.map
/**
* The public API for a <Router> that uses HTML5 history.
@ -32608,7 +32607,6 @@
style: propTypes.object
});
}
//# sourceMappingURL=react-router-dom.js.map
var classnames = createCommonjsModule(function (module) {
/*!
@ -58761,7 +58759,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
let subscription = new Subscription();
const _jsxFileName = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/lib/icons/icon-home.js";
const _jsxFileName = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/lib/icons/icon-home.js";
class IconHome extends react_1 {
render() {
return (
@ -58770,7 +58768,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
}
}
const _jsxFileName$1 = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/lib/icons/icon-spinner.js";
const _jsxFileName$1 = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/lib/icons/icon-spinner.js";
class IconSpinner extends react_1 {
render() {
return (
@ -58779,7 +58777,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
}
}
const _jsxFileName$2 = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/lib/header-bar.js";
const _jsxFileName$2 = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/lib/header-bar.js";
class HeaderBar extends react_1 {
render() {
let spin = (this.props.spinner)
@ -58807,7 +58805,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
}
}
const _jsxFileName$3 = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/lib/groups-item.js";
const _jsxFileName$3 = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/lib/groups-item.js";
class GroupsItem extends react_1 {
render() {
const { props } = this;
@ -62693,7 +62691,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
var dist_2 = dist.sigil;
var dist_3 = dist.stringRenderer;
const _jsxFileName$4 = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/lib/icons/sigil.js";
const _jsxFileName$4 = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/lib/icons/sigil.js";
class Sigil extends react_1 {
render() {
@ -62719,7 +62717,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
}
}
const _jsxFileName$5 = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/groups.js";
const _jsxFileName$5 = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/groups.js";
class Groups extends react_1 {
// drawer to the left
@ -62790,7 +62788,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
}
}
const _jsxFileName$6 = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/skeleton.js";
const _jsxFileName$6 = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/skeleton.js";
class Skeleton extends react_1 {
render() {
let rightPanelClasses =
@ -62820,7 +62818,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
}
}
const _jsxFileName$7 = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/lib/new.js";
const _jsxFileName$7 = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/lib/new.js";
class NewScreen extends react_1 {
constructor(props) {
super(props);
@ -62919,7 +62917,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
}
}
const _jsxFileName$8 = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/lib/contact-item.js";
const _jsxFileName$8 = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/lib/contact-item.js";
class ContactItem extends react_1 {
render() {
@ -62942,7 +62940,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
}
}
const _jsxFileName$9 = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/contacts.js";
const _jsxFileName$9 = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/contacts.js";
class Contacts extends react_1 {
render() {
const { props } = this;
@ -62979,7 +62977,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
}
}
const _jsxFileName$a = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/lib/card.js";
const _jsxFileName$a = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/lib/card.js";
class ContactCard extends react_1 {
render() {
return (
@ -62992,7 +62990,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
}
}
const _jsxFileName$b = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/js/components/root.js";
const _jsxFileName$b = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/js/components/root.js";
class Root extends react_1 {
constructor(props) {
@ -63109,7 +63107,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
}
}
const _jsxFileName$c = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/src/index.js";
const _jsxFileName$c = "/Users/logan/Dev/urbit/pkg/interface/contacts/src/index.js";
api.setAuthTokens({
ship: window.ship
});

View File

@ -19377,7 +19377,7 @@
}.call(commonjsGlobal));
});
const _jsxFileName = "/Users/matilde/git/tlon/urbit/pkg/interface/contacts/tile/tile.js";
const _jsxFileName = "/Users/logan/Dev/urbit/pkg/interface/contacts/tile/tile.js";
class ContactTile extends react_1 {