From 4fa2378e67300cfb868c3b38555ba04f4ceba015 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Wed, 29 Apr 2020 15:01:31 -0400 Subject: [PATCH] apps: stop serving webpages from all apps except publish --- pkg/arvo/app/chat-view.hoon | 73 +++++--------------------- pkg/arvo/app/clock.hoon | 96 +++------------------------------- pkg/arvo/app/contact-view.hoon | 55 ++++--------------- pkg/arvo/app/launch.hoon | 10 ++-- pkg/arvo/app/link-view.hoon | 76 ++------------------------- pkg/arvo/app/soto.hoon | 92 +++----------------------------- pkg/arvo/app/weather.hoon | 67 ++++-------------------- pkg/arvo/lib/contact-json.hoon | 2 +- 8 files changed, 57 insertions(+), 414 deletions(-) diff --git a/pkg/arvo/app/chat-view.hoon b/pkg/arvo/app/chat-view.hoon index 880fd713e..67fef4c9f 100644 --- a/pkg/arvo/app/chat-view.hoon +++ b/pkg/arvo/app/chat-view.hoon @@ -8,51 +8,15 @@ *metadata-store, *permission-group-hook, *chat-hook, - *metadata-hook, - *rw-security, - hook=chat-hook -/+ *server, default-agent, verb, dbug, - store=chat-store, - view=chat-view -/= 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/ - /~ ~ - == -/= chat-png - /^ (map knot @) - /: /===/app/chat/img /_ /png/ + *metadata-hook +/+ *server, *chat-json, default-agent, verb, dbug :: ~% %chat-view-top ..is ~ |% +$ card card:agent:gall :: +$ poke - $% [%launch-action [@tas path @t]] - [%chat-action action:store] + $% [%chat-action chat-action] [%group-action group-action] [%chat-hook-action action:hook] [%permission-hook-action permission-hook-action] @@ -72,12 +36,9 @@ :: ++ on-init ^- (quip card _this) - =/ launcha [%launch-action !>([%add %chat-view /configs '/~chat/js/tile.js'])] :_ this - :~ [%pass /updates %agent [our.bol %chat-store] %watch /updates] - [%pass / %arvo %e %connect [~ /'~chat'] %chat-view] - [%pass /chat-view %agent [our.bol %launch] %poke launcha] - == + [%pass /updates %agent [our.bol %chat-store] %watch /updates]~ + :: ++ on-poke ~/ %chat-view-poke |= [=mark =vase] @@ -155,7 +116,14 @@ [~ this] :: ++ on-save on-save:def - ++ on-load on-load:def + ++ on-load + |= old=* + ^- (quip card _this) + :_ this + :~ [%pass / %arvo %e %disconnect [~ /'~chat']] + [%pass / %arvo %e %connect [~ /'chat-view'] %chat-view] + == + :: ++ on-leave on-leave:def ++ on-peek on-peek:def ++ on-fail on-fail:def @@ -170,18 +138,7 @@ ^- simple-payload:http =+ url=(parse-request-line url.request.inbound-request) ?+ site.url not-found:gen - [%'~chat' %css %index ~] (css-response:gen style) - [%'~chat' %js %tile ~] (js-response:gen tile-js) - [%'~chat' %js %index ~] (js-response:gen script) - :: - [%'~chat' %img @t *] - =/ name=@t i.t.t.site.url - =/ img (~(get by chat-png) name) - ?~ img - not-found:gen - (png-response:gen (as-octs:mimes:html u.img)) - :: - [%'~chat' %paginate @t @t *] + [%'chat-view' %paginate @t @t *] =/ start (need (rush i.t.t.site.url dem)) =/ end (need (rush i.t.t.t.site.url dem)) =/ pax t.t.t.t.site.url @@ -190,8 +147,6 @@ %- json-to-octs %- update:enjs:store [%messages pax start end envelopes] - :: - [%'~chat' *] (html-response:gen index) == :: ++ poke-json diff --git a/pkg/arvo/app/clock.hoon b/pkg/arvo/app/clock.hoon index 43c10dcdd..74af06098 100644 --- a/pkg/arvo/app/clock.hoon +++ b/pkg/arvo/app/clock.hoon @@ -1,11 +1,6 @@ +:: clock: deprecated, should be removed +:: /+ *server, default-agent, verb, dbug -/= tile-js - /^ octs - /; as-octs:mimes:html - /: /===/app/clock/js/tile - /| /js/ - /~ ~ - == =, format :: |% @@ -25,96 +20,19 @@ +* this . def ~(. (default-agent this %|) bowl) :: -++ on-init - ^- (quip card:agent:gall _this) - =/ launcha - [%launch-action !>([%add %clock /clocktile '/~clock/js/tile.js'])] - :_ this - :~ [%pass / %arvo %e %connect [~ /'~clock'] %clock] - [%pass /clock %agent [our.bowl %launch] %poke launcha] - == -:: bootstrapping to get %goad started OTA -:: +++ on-init on-init:def ++ on-save !>(%3) ++ on-load |= old-state=vase ^- (quip card _this) - =/ old !<(?(~ %1 %2 %3) old-state) - =^ cards this - ?: ?=(%3 old) - `this - ?: ?=(%2 old) - :: ensure launch is set up to listen to us correctly - :: - =/ launcha - [%launch-action !>([%add %clock /clocktile '/~clock/js/tile.js'])] - :_ this - [%pass /clock %agent [our.bowl %launch] %poke launcha]~ - :_ this :_ ~ - [%pass /behn %arvo %b %wait +(now.bowl)] - :: - [cards this] -:: -++ on-poke - |= [=mark =vase] - ^- (quip card:agent:gall _this) - |^ - ?: ?=(%json mark) - (poke-json !<(json vase)) - ?. ?=(%handle-http-request mark) - (on-poke:def mark vase) - =+ !<([eyre-id=@ta =inbound-request:eyre] vase) :_ this - %+ give-simple-payload:app eyre-id - %+ require-authorization:app inbound-request - |= =inbound-request:eyre - =/ 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 - not-found:gen - ?: =(name 'tile') - (js-response:gen tile-js) - not-found:gen - :: - ++ poke-json - |= jon=json - ^- (quip card:agent:gall _this) - =. data.state jon - :_ this - [%give %fact ~[/clocktile] %json !>(jon)]~ - -- -:: -++ on-watch - |= =path - ^- (quip card:agent:gall _this) - ?: ?=([%http-response *] path) - `this - ?. =(/clocktile path) - (on-watch:def path) - [[%give %fact ~ %json !>(data.state)]~ this] + [%pass / %arvo %e %disconnect [~ /'~clock']]~ :: +++ on-poke on-poke:def +++ on-watch on-watch:def ++ on-leave on-leave:def ++ on-peek on-peek:def ++ on-agent on-agent:def -++ on-arvo - |= [=wire =sign-arvo] - ^- (quip card:agent:gall _this) - ?: ?=(%wake +<.sign-arvo) - ?^ error.sign-arvo - :_ this :_ ~ - [%pass /dill %arvo %d %flog %crud %clock-fail u.error.sign-arvo] - :_ this :_ ~ - [%pass /gall %arvo %g %goad | `%hood] - :: - ?. ?=(%bound +<.sign-arvo) - (on-arvo:def wire sign-arvo) - [~ this] -:: +++ on-arvo on-arvo:def ++ on-fail on-fail:def -- diff --git a/pkg/arvo/app/contact-view.hoon b/pkg/arvo/app/contact-view.hoon index 97aa15729..5467c51c7 100644 --- a/pkg/arvo/app/contact-view.hoon +++ b/pkg/arvo/app/contact-view.hoon @@ -10,38 +10,6 @@ *permission-group-hook, *permission-hook /+ *server, *contact-json, default-agent, dbug -/= index - /^ octs - /; as-octs:mimes:html - /: /===/app/contacts/index - /| /html/ - /~ ~ - == -/= tile-js - /^ octs - /; as-octs:mimes:html - /: /===/app/contacts/js/tile - /| /js/ - /~ ~ - == -/= script - /^ octs - /; as-octs:mimes:html - /: /===/app/contacts/js/index - /| /js/ - /~ ~ - == -/= style - /^ octs - /; as-octs:mimes:html - /: /===/app/contacts/css/index - /| /css/ - /~ ~ - == -/= contact-png - /^ (map knot @) - /: /===/app/contacts/img /_ /png/ -:: |% +$ card card:agent:gall -- @@ -60,7 +28,7 @@ ^- (quip card _this) :_ this :~ [%pass /updates %agent [our.bowl %contact-store] %watch /updates] - [%pass / %arvo %e %connect [~ /'~groups'] %contact-view] + (contact-poke:cc [%create /~/default]) (group-poke:cc [%bundle /~/default]) (contact-poke:cc [%add /~/default our.bowl *contact]) @@ -68,7 +36,14 @@ == :: ++ on-save on-save:def - ++ on-load on-load:def + ++ on-load + |= old=* + ^- (quip card _this) + :_ this + :~ [%pass / %arvo %e %disconnect [~ /'~groups']] + [%pass / %arvo %e %connect [~ /'contact-view'] %contact-view] + == + :: ++ on-poke |= [=mark =vase] ^- (quip card _this) @@ -173,15 +148,7 @@ '' i.back-path ?+ site.url not-found:gen - [%'~groups' %css %index ~] (css-response:gen style) - [%'~groups' %js %index ~] (js-response:gen script) - [%'~groups' %js %tile ~] (js-response:gen tile-js) - [%'~groups' %img *] - (png-response:gen (as-octs:mimes:html (~(got by contact-png) `@ta`name))) - :: - :: avatar images - :: - [%'~groups' %avatar @ *] + [%'contact-view' @ *] =/ =path (flop t.t.site.url) ?~ path not-found:gen =/ contact (contact-scry `^path`(snoc (flop t.path) name)) @@ -194,8 +161,6 @@ =/ content-type ['content-type' content-type.u.avatar.u.contact] [[200 [content-type max-3-days ~]] `octs.u.avatar.u.contact] == - :: - [%'~groups' *] (html-response:gen index) == :: :: +utilities diff --git a/pkg/arvo/app/launch.hoon b/pkg/arvo/app/launch.hoon index 31c82dfa2..8c8666830 100644 --- a/pkg/arvo/app/launch.hoon +++ b/pkg/arvo/app/launch.hoon @@ -64,9 +64,7 @@ ++ on-init ^- (quip card _this) :_ this(state *[%3 state-two]) - :~ (launch-who q.byk.bol) - [%pass / %arvo %e %connect [~ /] %launch] - == + [(launch-who q.byk.bol)]~ :: ++ on-save !>(state) :: @@ -94,7 +92,11 @@ $(old-state [%3 +.old-state], cards [(launch-who q.byk.bol) cards]) :: %3 - [(flop cards) this(state old-state)] + :_ this(state old-state) + %- zing + :~ (flop cards) + [%pass / %arvo %e %disconnect [~ /]]~ + == == :: ++ on-poke diff --git a/pkg/arvo/app/link-view.hoon b/pkg/arvo/app/link-view.hoon index b7c46a00f..dd55e50ed 100644 --- a/pkg/arvo/app/link-view.hoon +++ b/pkg/arvo/app/link-view.hoon @@ -42,13 +42,9 @@ ++ on-init ^- (quip card _this) :_ this - :~ [%pass /connect %arvo %e %connect [~ /'~link'] dap.bowl] - [%pass /submissions %agent [our.bowl %link-store] %watch /submissions] + :~ [%pass /submissions %agent [our.bowl %link-store] %watch /submissions] [%pass /discussions %agent [our.bowl %link-store] %watch /discussions] [%pass /seen %agent [our.bowl %link-store] %watch /seen] - :: - =+ [%add dap.bowl /tile '/~link/js/tile.js'] - [%pass /launch %agent [our.bowl %launch] %poke %launch-action !>(-)] :: =+ [%invite-action !>([%create /link])] [%pass /invitatory/create %agent [our.bowl %invite-store] %poke -] @@ -62,7 +58,8 @@ ++ on-load |= old=vase ^- (quip card _this) - [~ this(state !<(state-0 old))] + :_ this(state !<(state-0 old)) + [%pass /connect %arvo %e %disconnect [~ /'~link']]~ :: ++ on-poke |= [=mark =vase] @@ -70,12 +67,6 @@ ?> (team:title our.bowl src.bowl) :_ this ?+ mark (on-poke:def mark vase) - %handle-http-request - =+ !<([eyre-id=@ta =inbound-request:eyre] vase) - %+ give-simple-payload:app eyre-id - %+ require-authorization:app inbound-request - handle-http-request:do - :: %link-action [(handle-action:do !<(action vase)) ~] :: @@ -86,9 +77,7 @@ ++ on-watch |= =path ^- (quip card _this) - ?: ?| ?=([%http-response *] path) - ?=([%json %seen ~] path) - == + ?: ?=([%json %seen ~] path) [~ this] ?: ?=([%tile ~] path) :_ this @@ -185,63 +174,6 @@ 'pageNumber'^(numb page-number) 'page'^a+(turn page item-to-json) == -:: -++ handle-http-request - |= =inbound-request:eyre - ^- simple-payload:http - ?. =(src.bowl our.bowl) - [[403 ~] ~] - :: request-line: parsed url + params - :: - =/ =request-line - %- parse-request-line - url.request.inbound-request - =* req-head header-list.request.inbound-request - ?+ method.request.inbound-request not-found:gen - %'GET' - (handle-get req-head request-line) - == -:: -++ handle-get - |= [request-headers=header-list:http =request-line] - ^- simple-payload:http - :: try to load file from clay - :: - ?~ ext.request-line - :: for extension-less requests, always just serve the index.html. - :: that way the js can load and figure out how to deal with that route. - :: - $(request-line [[`%html ~[%'~link' 'index']] args.request-line]) - =/ file=(unit octs) - ?. ?=([%'~link' *] site.request-line) ~ - (get-file-at /app/link [t.site u.ext]:request-line) - ?~ file not-found:gen - ?+ u.ext.request-line not-found:gen - %html (html-response:gen u.file) - %js (js-response:gen u.file) - %css (css-response:gen u.file) - %png (png-response:gen u.file) - == -:: -++ get-file-at - |= [base=path file=path ext=@ta] - ^- (unit octs) - :: only expose html, css and js files for now - :: - ?. ?=(?(%html %css %js %png) ext) - ~ - =/ =path - :* (scot %p our.bowl) - q.byk.bowl - (scot %da now.bowl) - (snoc (weld base file) ext) - == - ?. .^(? %cu path) - ~ - %- some - %- as-octs:mimes:html - .^(@ %cx path) -:: ++ do-poke |= [app=term =mark =vase] ^- card diff --git a/pkg/arvo/app/soto.hoon b/pkg/arvo/app/soto.hoon index 2e5007f7f..42207b818 100644 --- a/pkg/arvo/app/soto.hoon +++ b/pkg/arvo/app/soto.hoon @@ -3,39 +3,7 @@ :: Relays sole-effects to subscribers and forwards sole-action pokes :: /- sole -/+ *server, *soto, default-agent -/= index - /^ octs - /; as-octs:mimes:html - /: /===/app/soto/index - /| /html/ - /~ ~ - == -/= tile-js - /^ octs - /; as-octs:mimes:html - /: /===/app/soto/js/tile - /| /js/ - /~ ~ - == -/= script - /^ octs - /; as-octs:mimes:html - /: /===/app/soto/js/index - /| /js/ - /~ ~ - == -/= style - /^ octs - /; as-octs:mimes:html - /: /===/app/soto/css/index - /| /css/ - /~ ~ - == -/= soto-png - /^ (map knot @) - /: /===/app/soto/img /_ /png/ -:: +/+ *soto, default-agent |% +$ card card:agent:gall +$ state-zero ~ @@ -50,67 +18,19 @@ sc ~(. soto-core bol) def ~(. (default-agent this %|) bol) :: -++ on-init - :_ this - :~ [%pass /bind/soto %arvo %e %connect [~ /'~dojo'] %soto] - :* %pass /launch/soto %agent [our.bol %launch] %poke - %launch-action !>([%add %soto /sototile '/~dojo/js/tile.js']) - == - == +++ on-init [~ this] ++ on-save !>(state) :: ++ on-load |= old=vase - [~ this(state !<(state-zero old))] -:: -++ on-poke - |= [mar=mark vas=vase] - ^- (quip card _this) - ?> (team:title our.bol src.bol) - ?. ?=(%handle-http-request mar) - (on-poke:def mar vas) - =+ !<([id=@ta req=inbound-request:eyre] vas) - :_ this - %+ give-simple-payload:app id - %+ require-authorization:app req - |= =inbound-request:eyre - ^- simple-payload:http - =/ request-line (parse-request-line url.request.inbound-request) - ?+ request-line - not-found:gen - :: main page - :: - [[~ [%'~dojo' *]] *] - (html-response:gen index) - :: main js - :: - [[[~ %js] [%'~dojo' %js %index ~]] ~] - (js-response:gen script) - :: tile js - :: - [[[~ %js] [%'~dojo' %js %tile ~]] ~] - (js-response:gen tile-js) - :: styling - :: - [[[~ %css] [%'~dojo' %css %index ~]] ~] - (css-response:gen style) - :: images - :: - [[[~ %png] [%'~dojo' %img @t ~]] ~] - =/ filename=@t i.t.t.site.request-line - =/ img (~(get by soto-png) filename) - ?~ img - not-found:gen - (png-response:gen (as-octs:mimes:html u.img)) - == + :_ this(state !<(state-zero old)) + [%pass /bind/soto %arvo %e %disconnect [~ /'~dojo']]~ :: +++ on-poke on-poke:def ++ on-watch |= pax=path ^- (quip card _this) - ?+ pax (on-watch:def pax) - [%http-response *] - [~ this] - :: + ?+ pax (on-watch:def pax) [%sototile ~] :_ this [%give %fact ~ %json !>(~)]~ diff --git a/pkg/arvo/app/weather.hoon b/pkg/arvo/app/weather.hoon index dfa254cec..f50872443 100644 --- a/pkg/arvo/app/weather.hoon +++ b/pkg/arvo/app/weather.hoon @@ -1,14 +1,4 @@ -/+ *server, *server, default-agent, verb, dbug -/= tile-js - /^ octs - /; as-octs:mimes:html - /: /===/app/weather/js/tile - /| /js/ - /~ ~ - == -/= weather-png - /^ (map knot @) - /: /===/app/weather/img /_ /png/ +/+ *server, default-agent, verb, dbug =, format :: |% @@ -30,43 +20,28 @@ weather-core +> wc ~(. weather-core bol) def ~(. (default-agent this %|) bol) - ++ on-init - :_ this - :~ [%pass /bind/weather %arvo %e %connect [~ /'~weather'] %weather] - :* %pass /launch/weather %agent [our.bol %launch] %poke - %launch-action !>([%add %weather /weathertile '/~weather/js/tile.js']) - == - == + ++ on-init [~ this] ++ on-save !>(state) ++ on-load |= old=vase - `this(state !<(state-zero old)) + :_ this(state !<(state-zero old)) + [%pass /bind/weather %arvo %e %disconnect [~ /'~weather']]~ :: ++ on-poke |= [=mark =vase] ^- (quip card _this) =^ cards state - ?+ mark (on-poke:def mark vase) - %json - (poke-json:wc !<(json vase)) - %handle-http-request - =+ !<([eyre-id=@ta =inbound-request:eyre] vase) - :_ state - %+ give-simple-payload:app eyre-id - %+ require-authorization:app inbound-request - poke-handle-http-request:wc + ?+ mark (on-poke:def mark vase) + %json (poke-json:wc !<(json vase)) == [cards this] :: ++ on-watch |= =wire ^- (quip card _this) - ?: ?=([%weathertile ~] wire) - :_ this - [%give %fact ~ %json !>(data)]~ - ?: ?=([%http-response *] wire) - [~ this] - (on-watch:def wire) + ?. ?=([%weathertile ~] wire) (on-watch:def wire) + :_ this + [%give %fact ~ %json !>(data)]~ :: ++ on-arvo |= [=wire =sign-arvo] @@ -82,7 +57,6 @@ (http-response:wc wire client-response.sign-arvo) [cards this] (on-arvo:def wire sign-arvo) - :: ++ on-leave on-leave:def ++ on-peek on-peek:def @@ -143,29 +117,6 @@ time now.bol == :: -++ poke-handle-http-request - |= =inbound-request:eyre - ^- simple-payload:http - :: - =/ 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 - not-found:gen - ?: =(name 'tile') - (js-response:gen tile-js) - ?: (lte (lent back-path) 1) - not-found:gen - ?: =(&2:site.request-line 'img') - =/ img (as-octs:mimes:html (~(got by weather-png) `@ta`name)) - (png-response:gen img) - not-found:gen -:: ++ wake |= [wir=wire err=(unit tang)] ^- (quip card _state) diff --git a/pkg/arvo/lib/contact-json.hoon b/pkg/arvo/lib/contact-json.hoon index 67e8172fb..ad0831363 100644 --- a/pkg/arvo/lib/contact-json.hoon +++ b/pkg/arvo/lib/contact-json.hoon @@ -74,7 +74,7 @@ :- %s %- crip %- zing - :~ "/~groups/avatar" + :~ "/contact-view" (trip (spat path)) "/" (trip (scot %p ship))