urbit-browser-manager/gall-app/urbit/app/browsermanager.hoon

93 lines
2.1 KiB
Plaintext
Raw Normal View History

2020-11-29 02:54:20 -08:00
/- browsermanager
2020-11-28 00:12:21 -08:00
/+ *server, default-agent
::
|%
2020-11-29 12:02:52 -08:00
+$ versioned-state
2020-12-03 03:19:10 -08:00
$% [%0 state-0]
2020-11-29 12:02:52 -08:00
==
2020-12-03 03:19:10 -08:00
+$ state-0 $:
2021-01-02 04:10:24 -08:00
access-counts=@
seen-urls=(set @t)
2020-12-03 03:19:10 -08:00
==
2020-11-28 00:12:21 -08:00
+$ card card:agent:gall
--
^- agent:gall
2021-01-02 04:10:24 -08:00
=| state-0
=* state -
2021-01-02 03:23:43 -08:00
|^
:: Main gall core
2020-11-28 00:12:21 -08:00
|_ bol=bowl:gall
+* this .
def ~(. (default-agent this %|) bol)
::
++ on-init
^- (quip card _this)
2020-11-29 22:17:13 -08:00
=/ launcha [%launch-action !>([%add %browsermanager [[%basic 'Browser Manager' '/~browsermanager/img/tile.png' '/~browsermanager'] %.y]])]
2020-11-28 00:12:21 -08:00
=/ filea [%file-server-action !>([%serve-dir /'~browsermanager' /app/browsermanager %.n %.n])]
:_ this
:~ [%pass /srv %agent [our.bol %file-server] %poke filea]
[%pass /browsermanager %agent [our.bol %launch] %poke launcha]
==
::
++ on-watch
|= =path
^- (quip card _this)
?: ?=([%http-response *] path)
`this
?. =(/ path)
(on-watch:def path)
[[%give %fact ~ %json !>(*json)]~ this]
::
++ on-agent on-agent:def
::
++ on-arvo
|= [=wire =sign-arvo]
^- (quip card _this)
?. ?=(%bound +<.sign-arvo)
(on-arvo:def wire sign-arvo)
[~ this]
::
2020-11-29 02:54:20 -08:00
::
++ on-poke
|= [=mark =vase]
^- (quip card _this)
?+ mark
(on-poke:def mark vase)
2020-12-03 03:19:10 -08:00
%noun ~& 'Browser Manager state'
~& state
2020-11-29 02:54:20 -08:00
`this
%browsermanager-action
=/ action !<(action:browsermanager vase)
2021-01-03 01:52:58 -08:00
=/ output (handle-action action state)
=/ new-actions=(list card) +2:output
=/ new-state=state-0 +3:output
[new-actions this(state new-state)]
2020-11-29 02:54:20 -08:00
==
2021-01-02 03:04:31 -08:00
++ on-save
~& 'on-save'
on-save:def
++ on-load
~& 'on-load'
on-load:def
2020-11-28 00:12:21 -08:00
++ on-leave on-leave:def
2021-01-03 03:42:18 -08:00
++ on-peek
|= pax=path
^- (unit (unit cage))
~
2020-11-28 00:12:21 -08:00
++ on-fail on-fail:def
--
2020-11-29 03:16:07 -08:00
:: Helper core
++ handle-action
2021-01-03 01:52:58 -08:00
|= [action=action:browsermanager state=state-0]
^- [(list card) state-0]
2020-11-29 03:16:07 -08:00
~& 'Browser Manager action'
~& >> action
2021-01-03 03:00:39 -08:00
=/ new-state
?- -.action
%ping state
%submit-url ~& 'got submit-url' state(seen-urls (~(put in seen-urls.state) url.action))
==
=/ new-state new-state(access-counts (add 1 access-counts.state))
2021-01-03 01:52:58 -08:00
[~ new-state]
2020-11-29 03:16:07 -08:00
--