2021-08-23 04:47:08 +03:00
|
|
|
/- *docket, hood, treaty
|
2021-09-06 22:37:13 +03:00
|
|
|
/+ *server, agentio, default-agent, multipart, dbug, verb
|
2021-08-11 06:50:44 +03:00
|
|
|
|%
|
|
|
|
+$ card card:agent:gall
|
|
|
|
+$ state-0
|
2021-08-23 04:47:08 +03:00
|
|
|
$: :: local
|
2021-08-11 06:50:44 +03:00
|
|
|
charges=(map desk charge)
|
|
|
|
==
|
|
|
|
:: $cache: impermanent state
|
|
|
|
+$ cache
|
|
|
|
by-base=(map term desk)
|
|
|
|
::
|
|
|
|
+$ inflated-state
|
|
|
|
[state-0 cache]
|
|
|
|
:: +lac: toggle verbosity
|
|
|
|
++ lac &
|
2021-08-26 03:45:42 +03:00
|
|
|
::
|
2021-08-23 04:47:08 +03:00
|
|
|
++ ver
|
|
|
|
|%
|
|
|
|
++ poke 1
|
|
|
|
++ scry 1
|
|
|
|
++ peer 1
|
|
|
|
--
|
2021-08-11 06:50:44 +03:00
|
|
|
::
|
|
|
|
--
|
|
|
|
^- agent:gall
|
|
|
|
%- agent:dbug
|
2021-09-17 03:44:35 +03:00
|
|
|
%+ verb |
|
2021-08-11 06:50:44 +03:00
|
|
|
=| inflated-state
|
|
|
|
=* state -
|
|
|
|
=<
|
|
|
|
|_ =bowl:gall
|
|
|
|
+* this .
|
|
|
|
io ~(. agentio bowl)
|
|
|
|
pass pass:io
|
|
|
|
def ~(. (default-agent this %|) bowl)
|
|
|
|
cc ~(. +> bowl)
|
2021-08-23 04:47:08 +03:00
|
|
|
ch ch:cc
|
2021-08-11 06:50:44 +03:00
|
|
|
::
|
|
|
|
++ on-init
|
|
|
|
^- (quip card _this)
|
|
|
|
:_ this
|
|
|
|
:~ (~(watch-our pass /kiln) %hood /kiln/vats)
|
|
|
|
(~(connect pass /eyre) [~ /] %docket)
|
2021-08-23 04:47:08 +03:00
|
|
|
(~(wait pass /init) (add 1 now.bowl))
|
2021-08-11 06:50:44 +03:00
|
|
|
(~(connect pass /eyre) [~ /apps] %docket)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ on-load
|
|
|
|
|= =vase
|
|
|
|
^- (quip card _this)
|
|
|
|
=+ !<(old=state-0 vase)
|
2021-08-23 04:47:08 +03:00
|
|
|
=* cha ~(. ch q.byk.bowl)
|
2021-09-06 22:37:13 +03:00
|
|
|
|^
|
2021-08-11 06:50:44 +03:00
|
|
|
=. -.state old
|
|
|
|
=. +.state inflate-cache
|
|
|
|
`this
|
2021-09-06 22:37:13 +03:00
|
|
|
::
|
2021-08-11 06:50:44 +03:00
|
|
|
++ inflate-cache
|
|
|
|
^- cache
|
|
|
|
%- ~(gas by *(map term desk))
|
2021-08-23 04:47:08 +03:00
|
|
|
%+ murn ~(tap by charges)
|
2021-08-11 06:50:44 +03:00
|
|
|
|= [=desk =charge]
|
2021-08-23 04:47:08 +03:00
|
|
|
?. ?=(%glob -.href.docket.charge) ~
|
|
|
|
`:_(desk base.href.docket.charge)
|
2021-08-11 06:50:44 +03:00
|
|
|
--
|
|
|
|
::
|
|
|
|
++ on-save !>(-.state)
|
|
|
|
++ on-poke
|
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
2021-09-06 22:37:13 +03:00
|
|
|
|^
|
2021-08-11 06:50:44 +03:00
|
|
|
=^ cards state
|
|
|
|
?+ mark (on-poke:def:cc mark vase)
|
2021-08-23 04:47:08 +03:00
|
|
|
%docket-install (install !<([ship desk] vase))
|
|
|
|
%docket-uninstall (uninstall !<(desk vase))
|
2021-08-11 06:50:44 +03:00
|
|
|
::
|
|
|
|
%noun
|
|
|
|
=+ ;;([%kick =desk] q.vase)
|
2021-08-23 04:47:08 +03:00
|
|
|
:_(state ~(fetch-glob ch desk))
|
2021-08-11 06:50:44 +03:00
|
|
|
::
|
|
|
|
%handle-http-request
|
|
|
|
=+ !<([id=@ta req=inbound-request:eyre] vase)
|
2021-09-06 22:37:13 +03:00
|
|
|
(handle-http-request:cc id req)
|
2021-08-11 06:50:44 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
2021-08-23 04:47:08 +03:00
|
|
|
::
|
|
|
|
++ install
|
|
|
|
|= [=ship =desk]
|
|
|
|
^- (quip card _state)
|
|
|
|
=+ .^(=treaty:treaty %gx (scry:io %treaty /treaty/(scot %p ship)/[desk]/noun))
|
2021-09-06 22:37:13 +03:00
|
|
|
?: (~(has by charges) desk)
|
|
|
|
~| bad-install-desk/desk
|
|
|
|
!!
|
2021-08-23 04:47:08 +03:00
|
|
|
=. charges
|
|
|
|
(~(put by charges) desk docket.treaty %install ~)
|
|
|
|
=* cha ~(. ch desk)
|
|
|
|
:_ state
|
|
|
|
~[add-fact:cha (install:cha ship desk)]
|
|
|
|
::
|
|
|
|
++ uninstall
|
|
|
|
|= =desk
|
|
|
|
^- (quip card _state)
|
2021-09-06 21:59:24 +03:00
|
|
|
=/ =charge ~|(no-charge-installed+desk (~(got by charges) desk))
|
2021-08-23 04:47:08 +03:00
|
|
|
=. charges (~(del by charges) desk)
|
|
|
|
=? by-base ?=(%glob -.href.docket.charge)
|
|
|
|
(~(del by by-base) base.href.docket)
|
|
|
|
=* cha ~(. ch desk)
|
|
|
|
:_ state
|
|
|
|
~[del-fact:cha uninstall:cha]
|
|
|
|
--
|
2021-08-11 06:50:44 +03:00
|
|
|
::
|
|
|
|
++ on-watch
|
|
|
|
|= =path
|
|
|
|
^- (quip card _this)
|
|
|
|
=^ cards state
|
|
|
|
?+ path (on-watch:def path)
|
2021-09-06 22:37:13 +03:00
|
|
|
[%http-response *]
|
2021-08-11 06:50:44 +03:00
|
|
|
?> (team:title [our src]:bowl)
|
|
|
|
`state
|
|
|
|
::
|
|
|
|
[%charges ~]
|
|
|
|
?> (team:title [our src]:bowl)
|
|
|
|
`state
|
2021-08-26 03:30:35 +03:00
|
|
|
::
|
2021-09-21 17:15:57 +03:00
|
|
|
[%glob @ @ ~]
|
|
|
|
=* base i.t.path
|
2021-09-26 11:49:27 +03:00
|
|
|
=/ hash (slav %uv i.t.t.path)
|
2021-09-06 21:59:24 +03:00
|
|
|
=/ desk ~|(path/path (~(got by by-base) i.t.path))
|
|
|
|
=/ =charge ~|(desk/desk (~(got by charges) desk))
|
2021-08-26 03:30:35 +03:00
|
|
|
?> ?=(%glob -.chad.charge)
|
2021-09-26 11:49:27 +03:00
|
|
|
=/ have (hash-glob:cc glob.chad.charge)
|
|
|
|
~| [%glob-unavailable requested=hash have=have]
|
|
|
|
?> =(hash have)
|
2021-08-26 03:30:35 +03:00
|
|
|
:_ state
|
2021-09-06 21:59:24 +03:00
|
|
|
:~ [%give %fact ~[path] %glob !>(`glob`glob.chad.charge)]
|
2021-08-26 03:30:35 +03:00
|
|
|
[%give %kick ~[path] ~]
|
|
|
|
==
|
2021-08-11 06:50:44 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
|
|
|
++ on-peek
|
|
|
|
|= =path
|
|
|
|
^- (unit (unit cage))
|
|
|
|
?+ path [~ ~]
|
2021-08-23 04:47:08 +03:00
|
|
|
[%x %ver %poke ~] ``noun+!>(poke:ver)
|
|
|
|
[%x %ver %peer ~] ``noun+!>(peer:ver)
|
|
|
|
[%x %ver %scry ~] ``noun+!>(scry:ver)
|
2021-08-11 06:50:44 +03:00
|
|
|
[%x %our ~] ``json+!>(s+(scot %p our.bowl))
|
2021-08-23 07:10:22 +03:00
|
|
|
::
|
|
|
|
[%x %dbug %state ~]
|
|
|
|
=- ``noun+!>(-)
|
|
|
|
%_ state
|
|
|
|
charges
|
|
|
|
%- ~(run by charges)
|
|
|
|
|= =charge
|
|
|
|
=? chad.charge ?=(%glob -.chad.charge)
|
2021-09-17 16:00:00 +03:00
|
|
|
:- %glob
|
|
|
|
%- ~(run by glob.chad.charge)
|
|
|
|
|=(=mime mime(q.q 1.337))
|
2021-08-23 07:10:22 +03:00
|
|
|
charge
|
|
|
|
==
|
2021-08-11 06:50:44 +03:00
|
|
|
::
|
|
|
|
[%x %charges ~]
|
|
|
|
:- ~ :- ~
|
2021-08-23 04:47:08 +03:00
|
|
|
:- %charge-update
|
|
|
|
!> ^- charge-update
|
2021-08-11 06:50:44 +03:00
|
|
|
:- %initial
|
2021-08-23 04:47:08 +03:00
|
|
|
%- ~(gas by *(map desk charge))
|
2021-08-11 06:50:44 +03:00
|
|
|
%+ turn ~(tap by charges)
|
|
|
|
|= [=desk =charge]
|
2021-08-23 04:47:08 +03:00
|
|
|
[desk (get-light-charge charge)]
|
2021-08-11 06:50:44 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ on-agent
|
|
|
|
|= [=wire =sign:agent:gall]
|
|
|
|
^- (quip card _this)
|
|
|
|
|^
|
|
|
|
=^ cards state
|
2021-08-23 04:47:08 +03:00
|
|
|
?+ wire ~&(bad-docket-take+wire `state)
|
2021-08-11 06:50:44 +03:00
|
|
|
~ `state
|
|
|
|
[%kiln ~] take-kiln
|
2021-08-23 04:47:08 +03:00
|
|
|
[%charge @ *] (take-charge i.t.wire t.t.wire)
|
2021-08-11 06:50:44 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
|
|
|
++ take-kiln
|
|
|
|
^- (quip card _state)
|
|
|
|
?+ -.sign (on-agent:def:cc wire sign)
|
|
|
|
%kick [(~(watch-our pass /kiln) %hood /kiln/vats)^~ state]
|
|
|
|
::
|
|
|
|
%fact
|
|
|
|
?. ?=(%kiln-vats-diff p.cage.sign) `state
|
2021-08-23 06:32:22 +03:00
|
|
|
=+ !<(=diff:hood q.cage.sign)
|
|
|
|
=* cha ~(. ch desk.diff)
|
|
|
|
?+ -.diff `state
|
2021-08-26 03:45:42 +03:00
|
|
|
::
|
2021-09-20 20:30:26 +03:00
|
|
|
%commit
|
2021-08-26 03:45:42 +03:00
|
|
|
=* cha ~(. ch desk.diff)
|
|
|
|
?. docket-exists:cha `state
|
2021-09-21 19:19:38 +03:00
|
|
|
:: always update the docket in state to match clay's
|
|
|
|
::
|
|
|
|
=/ =docket docket:cha
|
|
|
|
=/ pre=(unit charge) (~(get by charges) desk.diff)
|
|
|
|
=. charges (new-docket:cha docket)
|
2021-09-21 17:15:57 +03:00
|
|
|
:: if the new chad is a site, we're instantly done
|
|
|
|
::
|
2021-08-26 03:45:42 +03:00
|
|
|
?: ?=(%site -.href.docket)
|
2021-09-21 17:15:57 +03:00
|
|
|
:- ~[add-fact:cha]
|
2021-09-21 19:19:38 +03:00
|
|
|
=. charges (new-chad:cha %site ~)
|
|
|
|
state
|
|
|
|
::
|
|
|
|
=. by-base (~(put by by-base) base.href.docket desk.diff)
|
|
|
|
:: if the glob specification is unchanged, keep it
|
2021-09-21 17:15:57 +03:00
|
|
|
::
|
2021-09-26 20:55:22 +03:00
|
|
|
::
|
|
|
|
?: &(?=(^ pre) =(href.docket.u.pre href.docket))
|
2021-09-21 19:19:38 +03:00
|
|
|
[~[add-fact:cha] state]
|
|
|
|
:: if the glob spec changed, but we already host it, keep it
|
|
|
|
:: (this is the "just locally uploaded" case)
|
|
|
|
::
|
|
|
|
?: ?& ?=(^ pre)
|
|
|
|
?=(%glob -.chad.u.pre)
|
|
|
|
::
|
2021-09-23 08:45:13 +03:00
|
|
|
.= [(sham glob.chad.u.pre) %ames our.bowl]
|
|
|
|
glob-reference.href.docket
|
2021-09-21 19:19:38 +03:00
|
|
|
==
|
2021-09-21 17:15:57 +03:00
|
|
|
[~[add-fact:cha] state]
|
|
|
|
:: if the glob changed, forget the old and fetch the new
|
|
|
|
::
|
2021-09-21 19:19:38 +03:00
|
|
|
=. charges (new-chad:cha %install ~)
|
|
|
|
[[add-fact:cha fetch-glob:cha] state]
|
2021-08-23 06:32:22 +03:00
|
|
|
::
|
|
|
|
%suspend
|
2021-08-26 03:45:42 +03:00
|
|
|
?. (~(has by charges) desk.diff) `state
|
2021-09-21 17:15:57 +03:00
|
|
|
=/ glob=(unit glob)
|
|
|
|
=/ =chad
|
|
|
|
chad:(~(got by charges) desk.diff)
|
|
|
|
?:(?=(%glob -.chad) `glob.chad ~)
|
|
|
|
=. charges (new-chad:cha %suspend glob)
|
2021-08-23 06:32:22 +03:00
|
|
|
:_(state ~[add-fact:cha])
|
|
|
|
::
|
|
|
|
%revive
|
2021-08-26 03:45:42 +03:00
|
|
|
?. (~(has by charges) desk.diff) `state
|
2021-08-23 06:32:22 +03:00
|
|
|
=/ =charge (~(got by charges) desk.diff)
|
|
|
|
?. ?=(%glob -.href.docket.charge)
|
|
|
|
=. charges (new-chad:cha %site ~)
|
|
|
|
:_(state ~[add-fact:cha])
|
2021-09-21 17:15:57 +03:00
|
|
|
=. charges
|
|
|
|
%- new-chad:cha
|
|
|
|
?. ?=([%suspend ~ *] chad.charge)
|
|
|
|
[%install ~]
|
|
|
|
[%glob u.glob.chad.charge]
|
2021-08-23 06:32:22 +03:00
|
|
|
:_(state [add-fact fetch-glob]:cha)
|
|
|
|
==
|
2021-08-23 04:47:08 +03:00
|
|
|
==
|
|
|
|
++ take-charge
|
|
|
|
|= [=desk =^wire]
|
|
|
|
^- (quip card _state)
|
2021-09-26 20:55:22 +03:00
|
|
|
~| [%took-for-nonexistent-charge desk]
|
2021-08-23 04:47:08 +03:00
|
|
|
?> (~(has by charges) desk)
|
|
|
|
=* cha ~(. ch desk)
|
|
|
|
?+ wire ~|(%bad-charge-wire !!)
|
|
|
|
::
|
|
|
|
[%install ~]
|
|
|
|
?> ?=(%poke-ack -.sign)
|
2021-09-06 22:37:13 +03:00
|
|
|
?~ p.sign
|
2021-08-26 03:45:42 +03:00
|
|
|
`state
|
2021-08-23 04:47:08 +03:00
|
|
|
=. charges (new-chad:cha hung+'Failed install')
|
|
|
|
((slog leaf+"Failed installing %{(trip desk)}" u.p.sign) `state)
|
|
|
|
::
|
2021-09-06 22:37:13 +03:00
|
|
|
[%uninstall ~]
|
2021-08-23 04:47:08 +03:00
|
|
|
?> ?=(%poke-ack -.sign)
|
|
|
|
?~ p.sign `state
|
|
|
|
((slog leaf+"Failed to uninstall %{(trip desk)}" u.p.sign) `state)
|
|
|
|
::
|
2021-09-26 02:45:05 +03:00
|
|
|
?([%glob @ %http @ ~] [%glob @ %ames @ ~])
|
2021-08-23 04:47:08 +03:00
|
|
|
?- -.sign
|
|
|
|
%kick `state
|
|
|
|
::
|
|
|
|
?(%poke-ack %watch-ack)
|
|
|
|
?~ p.sign `state
|
2021-09-26 02:45:05 +03:00
|
|
|
=/ err
|
2021-08-23 04:47:08 +03:00
|
|
|
=/ act=tape ?:(?=(%poke-ack -.sign) "start" "listen")
|
2021-09-26 02:45:05 +03:00
|
|
|
=. charges %- new-chad:cha
|
|
|
|
?: ?=(i.t.t.wire %http) hung+'glob-failed'
|
|
|
|
hung+'failed to fetch glob via ames'
|
2021-08-23 04:47:08 +03:00
|
|
|
:- ~[add-fact:cha]
|
|
|
|
((slog leaf+"docket: couldn't {act} thread; will retry" u.p.sign) state)
|
|
|
|
::
|
|
|
|
%fact
|
|
|
|
?+ p.cage.sign `state
|
|
|
|
%thread-fail
|
|
|
|
=+ !<([=term =tang] q.cage.sign)
|
2021-09-27 21:50:58 +03:00
|
|
|
?. =(term %cancelled)
|
|
|
|
=. charges (new-chad:cha hung+'glob-failed')
|
|
|
|
:- ~[add-fact:cha]
|
|
|
|
((slog leaf+"docket: thread failed;" leaf+<term> tang) state)
|
|
|
|
%- (slog leaf+"docket: thread cancelled; retrying" leaf+<term> tang)
|
|
|
|
=. charges (new-chad:cha %install ~)
|
|
|
|
:_ state
|
2021-09-27 22:57:39 +03:00
|
|
|
[leave-glob:cha add-fact:cha fetch-glob:cha]
|
2021-08-23 04:47:08 +03:00
|
|
|
::
|
|
|
|
%thread-done
|
|
|
|
=+ !<(=glob q.cage.sign)
|
2021-09-26 20:53:13 +03:00
|
|
|
=/ =charge (~(got by charges) desk)
|
|
|
|
?. ?=(%glob -.href.docket.charge)
|
|
|
|
`state
|
|
|
|
=* want=@uv hash.glob-reference.href.docket.charge
|
|
|
|
=/ plea=@uv (slav %uv i.t.wire)
|
|
|
|
?. =(want plea)
|
|
|
|
:: we requested this at some point but no longer want it
|
|
|
|
::
|
|
|
|
`state
|
|
|
|
=/ have=@uv (hash-glob glob)
|
|
|
|
?. =(want have)
|
|
|
|
%. `state
|
|
|
|
=/ url=@t (fall (slaw %t i.t.t.t.wire) '???')
|
|
|
|
%- slog
|
|
|
|
:~ leaf+"docket: glob hash mismatch on {<desk>} from {(trip url)}"
|
|
|
|
leaf+"expected: {<want>}"
|
|
|
|
leaf+"received: {<have>}"
|
|
|
|
==
|
|
|
|
=. charges (new-chad:cha glob+glob)
|
|
|
|
=. by-base (~(put by by-base) base.href.docket.charge desk)
|
2021-08-23 04:47:08 +03:00
|
|
|
:_(state ~[add-fact:cha])
|
|
|
|
==
|
|
|
|
==
|
2021-08-11 06:50:44 +03:00
|
|
|
==
|
|
|
|
--
|
|
|
|
::
|
|
|
|
++ on-arvo
|
2021-08-23 04:47:08 +03:00
|
|
|
|= [=wire sign=sign-arvo]
|
2021-08-11 06:50:44 +03:00
|
|
|
=^ cards state
|
2021-08-23 04:47:08 +03:00
|
|
|
?+ wire (on-arvo:def wire sign)
|
2021-09-06 22:37:13 +03:00
|
|
|
[%init ~]
|
2021-08-23 04:47:08 +03:00
|
|
|
=* cha ~(. ch q.byk.bowl)
|
|
|
|
=. charges (~(put by charges) q.byk.bowl [docket:cha %install ~])
|
|
|
|
[fetch-glob:cha state]
|
2021-08-11 06:50:44 +03:00
|
|
|
::
|
|
|
|
[%eyre ~]
|
2021-08-23 04:47:08 +03:00
|
|
|
?> ?=([%eyre %bound *] sign)
|
2021-09-06 22:37:13 +03:00
|
|
|
?: accepted.sign `state
|
2021-08-23 04:47:08 +03:00
|
|
|
~& [dap.bowl %failed-to-bind path.binding.sign]
|
2021-08-11 06:50:44 +03:00
|
|
|
`state
|
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
|
|
|
++ on-fail on-fail:def
|
|
|
|
++ on-leave on-leave:def
|
|
|
|
--
|
|
|
|
|_ =bowl:gall
|
2021-08-23 04:47:08 +03:00
|
|
|
++ io ~(. agentio bowl)
|
|
|
|
++ pass pass:io
|
2021-08-11 06:50:44 +03:00
|
|
|
++ def ~(. (default-agent state %|) bowl)
|
|
|
|
::
|
2021-09-21 17:15:57 +03:00
|
|
|
++ hash-glob sham
|
|
|
|
::
|
2021-08-11 06:50:44 +03:00
|
|
|
++ handle-http-request
|
2021-09-06 22:37:13 +03:00
|
|
|
|= [eyre-id=@ta inbound-request:eyre]
|
|
|
|
^- (quip card _state)
|
|
|
|
::
|
|
|
|
=; [payload=simple-payload:http caz=(list card) =_state]
|
|
|
|
:_ state
|
|
|
|
%+ weld caz
|
|
|
|
(give-simple-payload:app eyre-id payload)
|
|
|
|
::
|
|
|
|
::NOTE we don't use +require-authorization-simple here because we want
|
|
|
|
:: to short-circuit all the below logic for the unauthenticated case.
|
|
|
|
?. authenticated
|
|
|
|
:_ [~ state]
|
|
|
|
=- [[307 ['location' -]~] ~]
|
|
|
|
(cat 3 '/~/login?redirect=' url.request)
|
|
|
|
::
|
|
|
|
=* headers header-list.request
|
|
|
|
=/ req-line (parse-request-line url.request)
|
|
|
|
::
|
|
|
|
|^ ?+ method.request [[405^~ ~] ~ state]
|
|
|
|
%'GET' [handle-get-request ~ state]
|
|
|
|
%'POST' handle-upload
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ handle-get-request
|
|
|
|
^- simple-payload:http
|
|
|
|
?+ [site ext]:req-line (redirect:gen '/apps/grid/')
|
|
|
|
[[%session ~] [~ %js]]
|
|
|
|
%- inline-js-response
|
|
|
|
(rap 3 'window.ship = "' (rsh 3 (scot %p our.bowl)) '";' ~)
|
|
|
|
::
|
|
|
|
[[%docket %upload ~] ?(~ [~ %html])]
|
|
|
|
[[200 ~] `(upload-page ~)]
|
|
|
|
::
|
|
|
|
[[%apps @ *] *]
|
|
|
|
%+ payload-from-glob
|
|
|
|
(snag 1 site.req-line)
|
|
|
|
req-line(site (slag 2 site.req-line))
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ upload-page
|
|
|
|
|= msg=(list @t)
|
|
|
|
^- octs
|
|
|
|
%- as-octt:mimes:html
|
|
|
|
%- en-xml:html
|
|
|
|
^- manx
|
2021-09-14 17:38:20 +03:00
|
|
|
:: desks: with local globs, eligible for upload
|
|
|
|
::
|
|
|
|
=/ desks=(list desk)
|
|
|
|
%+ murn ~(tap by charges)
|
|
|
|
|= [d=desk [docket *]]
|
|
|
|
^- (unit desk)
|
2021-09-15 00:29:07 +03:00
|
|
|
?:(?=(%glob -.href) `d ~)
|
2021-09-14 17:38:20 +03:00
|
|
|
::
|
2021-09-06 22:37:13 +03:00
|
|
|
;html
|
|
|
|
;head
|
|
|
|
;title:"%docket globulator"
|
|
|
|
;meta(charset "utf-8");
|
2021-09-14 17:38:20 +03:00
|
|
|
;style:'''
|
|
|
|
* { font-family: monospace; margin-top: 1em; }
|
|
|
|
li { margin-top: 0.5em; }
|
|
|
|
'''
|
2021-09-06 22:37:13 +03:00
|
|
|
==
|
|
|
|
;body
|
|
|
|
;h2:"%docket globulator"
|
|
|
|
;+ ?. =(~ msg)
|
|
|
|
:- [%p ~]
|
|
|
|
(join `manx`;br; (turn msg |=(m=@t `manx`:/"{(trip m)}")))
|
2021-09-14 17:38:20 +03:00
|
|
|
;ol(start "0")
|
|
|
|
;li:"""
|
2021-09-15 00:29:07 +03:00
|
|
|
make sure the desk you want to upload a glob for has a
|
|
|
|
desk.docket with %base and %glob- entries.
|
2021-09-14 17:38:20 +03:00
|
|
|
"""
|
|
|
|
;li:"select the desk you want to upload the glob for."
|
|
|
|
;li:"""
|
|
|
|
select a directory containing the glob contents.
|
|
|
|
usually contains at least an /index.html.
|
|
|
|
"""
|
|
|
|
;li:"glob!"
|
|
|
|
==
|
|
|
|
;+ ?: =(~ desks)
|
|
|
|
;p:"no desks eligible for glob upload"
|
|
|
|
;form(method "post", enctype "multipart/form-data")
|
|
|
|
;label
|
|
|
|
;+ :/"desk: "
|
|
|
|
;select(name "desk")
|
|
|
|
;* %+ turn desks
|
|
|
|
|=(d=desk =+((trip d) ;option(value -):"{-}"))
|
|
|
|
==
|
|
|
|
==
|
|
|
|
;br;
|
|
|
|
;label
|
|
|
|
;+ :/"data: "
|
|
|
|
;input
|
|
|
|
=type "file"
|
|
|
|
=name "glob"
|
|
|
|
=directory ""
|
|
|
|
=webkitdirectory ""
|
|
|
|
=mozdirectory "";
|
|
|
|
==
|
|
|
|
;br;
|
|
|
|
;button(type "submit"):"glob!"
|
|
|
|
==
|
2021-09-06 22:37:13 +03:00
|
|
|
==
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ handle-upload
|
|
|
|
^- [simple-payload:http (list card) _state]
|
|
|
|
?. ?=([[%docket %upload ~] ?(~ [~ %html])] [site ext]:req-line)
|
|
|
|
[[404^~ ~] [~ state]]
|
|
|
|
::
|
|
|
|
=; [desk=@ta =glob err=(list @t)]
|
|
|
|
=* cha ~(. ch desk)
|
|
|
|
=/ =charge (~(got by charges) desk)
|
|
|
|
::
|
|
|
|
=? err =(~ glob)
|
2021-09-14 17:38:20 +03:00
|
|
|
['no files in glob' err]
|
|
|
|
=? err !?=(%glob -.href.docket.charge)
|
2021-09-06 22:37:13 +03:00
|
|
|
['desk does not use glob' err]
|
|
|
|
::
|
|
|
|
?. =(~ err)
|
|
|
|
:_ [~ state]
|
|
|
|
[[400 ~] `(upload-page err)]
|
|
|
|
:- [[200 ~] `(upload-page 'successfully globbed' ~)]
|
2021-09-21 18:42:45 +03:00
|
|
|
?> ?=(%glob -.href.docket.charge)
|
2021-09-06 22:37:13 +03:00
|
|
|
::
|
|
|
|
=. charges (new-chad:cha glob+glob)
|
|
|
|
=. by-base
|
|
|
|
=- (~(put by by-base) - desk)
|
|
|
|
base.href.docket.charge
|
2021-09-21 18:42:45 +03:00
|
|
|
::
|
|
|
|
:_ state
|
|
|
|
::
|
|
|
|
=/ ours=?
|
2021-09-23 08:45:13 +03:00
|
|
|
=/ loc location.glob-reference.href.docket.charge
|
2021-09-21 18:42:45 +03:00
|
|
|
?& ?=(%ames -.loc)
|
|
|
|
=(our.bowl ship.loc)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
:* add-fact:cha
|
|
|
|
::
|
|
|
|
?. ours ~
|
|
|
|
^- (list card)
|
|
|
|
=- [%pass /write/[desk] %arvo %c %info -]~
|
|
|
|
%+ foal:space:userlib
|
|
|
|
/(scot %p our.bowl)/[desk]/(scot %da now.bowl)/desk/docket
|
|
|
|
=- [%docket !>(`docket`-)]
|
2021-09-23 08:45:13 +03:00
|
|
|
docket.charge(glob-reference.href [(hash-glob glob) %ames our.bowl])
|
2021-09-21 18:42:45 +03:00
|
|
|
==
|
2021-09-06 22:37:13 +03:00
|
|
|
::
|
|
|
|
?~ parts=(de-request:multipart [header-list body]:request)
|
|
|
|
~& headers=header-list.request
|
|
|
|
[*@ta *glob 'failed to parse submitted data' ~]
|
|
|
|
::
|
|
|
|
%+ roll u.parts
|
|
|
|
|= [[name=@t part:multipart] desk=@ta =glob err=(list @t)]
|
|
|
|
^+ [desk glob err]
|
|
|
|
?: =('desk' name)
|
|
|
|
:: must be a desk with existing charge
|
|
|
|
::
|
|
|
|
?. ((sane %ta) body)
|
|
|
|
[desk glob (cat 3 'invalid desk: ' body) err]
|
|
|
|
?. (~(has by charges) body)
|
|
|
|
[desk glob (cat 3 'unknown desk: ' body) err]
|
|
|
|
[body glob err]
|
|
|
|
:- desk
|
|
|
|
:: all submitted files must be complete
|
|
|
|
::
|
|
|
|
?. =('glob' name) [glob (cat 3 'weird part: ' name) err]
|
|
|
|
?~ file [glob 'file without filename' err]
|
|
|
|
?~ type [glob (cat 3 'file without type: ' u.file) err]
|
|
|
|
?^ code [glob (cat 3 'strange encoding: ' u.code) err]
|
|
|
|
=/ filp (rush u.file fip)
|
|
|
|
?~ filp [glob (cat 3 'strange filename: ' u.file) err]
|
|
|
|
:: ignore metadata files and other "junk"
|
|
|
|
::TODO consider expanding coverage
|
|
|
|
::
|
|
|
|
?: =('.DS_Store' (rear `path`u.filp))
|
|
|
|
[glob err]
|
|
|
|
:: make sure to exclude the top-level dir from the path
|
|
|
|
::
|
|
|
|
:_ err
|
|
|
|
%+ ~(put by glob) (slag 1 `path`u.filp)
|
|
|
|
[u.type (as-octs:mimes:html body)]
|
|
|
|
::
|
|
|
|
++ fip
|
|
|
|
=, de-purl:html
|
|
|
|
%+ cook
|
|
|
|
|=(pork (weld q (drop p)))
|
|
|
|
(cook deft (more fas smeg))
|
|
|
|
::
|
|
|
|
++ inline-js-response
|
|
|
|
|= js=cord
|
|
|
|
^- simple-payload:http
|
|
|
|
%. (as-octs:mimes:html js)
|
|
|
|
%* . js-response:gen
|
|
|
|
cache %.n
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ payload-from-glob
|
|
|
|
|= [from=@ta what=request-line]
|
|
|
|
^- simple-payload:http
|
|
|
|
=/ des=(unit desk)
|
|
|
|
(~(get by by-base) from)
|
|
|
|
?~ des not-found:gen
|
|
|
|
=/ cha=(unit charge)
|
|
|
|
(~(get by charges) u.des)
|
|
|
|
?~ cha not-found:gen
|
|
|
|
?. ?=(%glob -.chad.u.cha) not-found:gen
|
|
|
|
=* glob glob.chad.u.cha
|
|
|
|
=/ suffix=^path
|
|
|
|
(weld site.what (drop ext.what))
|
|
|
|
?: =(suffix /desk/js)
|
|
|
|
%- inline-js-response
|
|
|
|
(rap 3 'window.desk = "' u.des '";' ~)
|
2021-09-22 03:11:31 +03:00
|
|
|
=/ requested
|
|
|
|
?: (~(has by glob) suffix) suffix
|
|
|
|
/index/html
|
2021-09-06 22:37:13 +03:00
|
|
|
=/ data=mime
|
2021-09-22 03:11:31 +03:00
|
|
|
(~(got by glob) requested)
|
2021-09-06 22:37:13 +03:00
|
|
|
=/ mime-type=@t (rsh 3 (crip <p.data>))
|
|
|
|
=; headers
|
|
|
|
[[200 headers] `q.data]
|
2021-09-22 03:11:31 +03:00
|
|
|
:- content-type+mime-type
|
|
|
|
?: =(/index/html requested) ~
|
|
|
|
~[max-1-wk:gen]
|
2021-09-06 22:37:13 +03:00
|
|
|
--
|
2021-08-23 04:47:08 +03:00
|
|
|
::
|
|
|
|
++ get-light-charge
|
|
|
|
|= =charge
|
|
|
|
?. ?=(%glob -.chad.charge) charge
|
|
|
|
charge(glob.chad *glob)
|
|
|
|
:: +ch: Charge engine
|
|
|
|
++ ch
|
|
|
|
|_ =desk
|
2021-09-26 20:53:13 +03:00
|
|
|
++ pass |=(=wire ~(. ^pass [%charge desk wire]))
|
|
|
|
++ glob-wire
|
|
|
|
|= glob-reference
|
|
|
|
^- wire
|
|
|
|
:+ %glob
|
|
|
|
(scot %uv hash)
|
|
|
|
?- -.location
|
|
|
|
%http /http/(scot %t url.location)
|
|
|
|
%ames /ames/(scot %p ship.location)
|
|
|
|
==
|
2021-08-23 04:47:08 +03:00
|
|
|
++ add-fact
|
|
|
|
=/ =charge (~(got by charges) desk)
|
|
|
|
(fact:io charge-update+!>([%add-charge desk (get-light-charge charge)]) /charges ~)
|
|
|
|
++ del-fact (fact:io charge-update+!>([%del-charge desk]) /charges ~)
|
|
|
|
++ install
|
|
|
|
|= [=ship remote=^desk]
|
2021-09-26 20:53:13 +03:00
|
|
|
(poke-our:(pass /install) %hood kiln-install+!>([desk ship remote]))
|
2021-08-23 04:47:08 +03:00
|
|
|
++ uninstall
|
2021-09-26 20:53:13 +03:00
|
|
|
(poke-our:(pass /uninstall) %hood kiln-uninstall+!>(desk))
|
2021-09-25 17:27:14 +03:00
|
|
|
++ new-docket
|
|
|
|
|= d=^docket
|
|
|
|
%+ ~(put by charges) desk
|
|
|
|
[d chad:(~(gut by charges) desk *charge)]
|
2021-08-23 04:47:08 +03:00
|
|
|
++ new-chad |=(c=chad (~(jab by charges) desk |=(charge +<(chad c))))
|
2021-09-27 22:57:39 +03:00
|
|
|
++ leave-glob
|
|
|
|
^- card
|
|
|
|
=/ =charge
|
|
|
|
~| desk/desk
|
|
|
|
(~(got by charges) desk)
|
|
|
|
?> ?=(%glob -.href.docket.charge)
|
|
|
|
=/ ref glob-reference.href.docket.charge
|
|
|
|
(leave-our:(pass (glob-wire ref)) %spider)
|
2021-08-23 04:47:08 +03:00
|
|
|
++ fetch-glob
|
2021-09-21 17:15:57 +03:00
|
|
|
^- (list card)
|
2021-09-06 21:59:24 +03:00
|
|
|
=/ =charge
|
|
|
|
~| desk/desk
|
|
|
|
(~(got by charges) desk)
|
2021-08-11 06:50:44 +03:00
|
|
|
=/ tid=@t (cat 3 'docket-' (scot %uv (sham (mix eny.bowl desk))))
|
2021-08-23 04:47:08 +03:00
|
|
|
?> ?=(%glob -.href.docket.charge)
|
2021-09-23 08:45:13 +03:00
|
|
|
=/ ref glob-reference.href.docket.charge
|
|
|
|
?: ?=(%ames -.location.ref)
|
|
|
|
?: =(our.bowl ship.location.ref)
|
2021-09-21 17:15:57 +03:00
|
|
|
~> %slog.0^leaf/"docket: awaiting manual glob for {<desk>} desk"
|
|
|
|
~
|
2021-09-26 02:45:05 +03:00
|
|
|
~> %slog.0^leaf/"docket: fetching {<-.location.ref>} glob for {<desk>} desk"
|
2021-09-23 08:45:13 +03:00
|
|
|
=/ =cage spider-start+!>([~ `tid byk.bowl(r da+now.bowl) %glob !>(`[ref desk])])
|
2021-09-26 20:53:13 +03:00
|
|
|
:~ (watch-our:(pass (glob-wire ref)) %spider /thread-result/[tid])
|
|
|
|
(poke-our:(pass (glob-wire ref)) %spider cage)
|
2021-08-11 06:50:44 +03:00
|
|
|
==
|
2021-08-26 03:45:42 +03:00
|
|
|
++ docket-exists .^(? %cu (scry:io desk /desk/docket))
|
|
|
|
++ docket .^(^docket %cx (scry:io desk /desk/docket))
|
2021-08-11 06:50:44 +03:00
|
|
|
--
|
|
|
|
--
|
2021-08-23 04:47:08 +03:00
|
|
|
|