landscape: added landscape.hoon that serves all HTTP urls but the publish-related ones
Before Width: | Height: | Size: 880 B After Width: | Height: | Size: 880 B |
Before Width: | Height: | Size: 865 B After Width: | Height: | Size: 865 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 679 B After Width: | Height: | Size: 679 B |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 951 B After Width: | Height: | Size: 951 B |
132
pkg/arvo/app/landscape.hoon
Normal file
@ -0,0 +1,132 @@
|
||||
/+ *server, default-agent, verb, dbug
|
||||
|%
|
||||
+$ card card:agent:gall
|
||||
+$ versioned-state
|
||||
$% state-zero
|
||||
==
|
||||
::
|
||||
+$ state-zero [%0 =configuration]
|
||||
+$ configuration
|
||||
$: url-prefix=(unit @t)
|
||||
==
|
||||
--
|
||||
%+ verb |
|
||||
%- agent:dbug
|
||||
=| state-zero
|
||||
=* state -
|
||||
^- agent:gall
|
||||
|_ =bowl:gall
|
||||
+* this .
|
||||
def ~(. (default-agent this %|) bowl)
|
||||
::
|
||||
++ on-init
|
||||
^- (quip card _this)
|
||||
:_ this
|
||||
:~ [%pass /chat-bind %arvo %e %connect [~ /'~chat'] %landscape]
|
||||
[%pass /group-bind %arvo %e %connect [~ /'~groups'] %landscape]
|
||||
[%pass /link-bind %arvo %e %connect [~ /'~link'] %landscape]
|
||||
[%pass /dojo-bind %arvo %e %connect [~ /'~dojo'] %landscape]
|
||||
[%pass /modulo-bind %arvo %e %connect [~ /'~modulo'] %landscape]
|
||||
[%pass /channel-bind %arvo %e %connect [~ /'~channel'] %landscape]
|
||||
[%pass /launch-bind %arvo %e %connect [~ /'~launch'] %landscape]
|
||||
[%pass /index-bind %arvo %e %connect [~ /] %landscape]
|
||||
==
|
||||
++ on-save !>(state)
|
||||
++ on-load
|
||||
|= old-vase=vase
|
||||
^- (quip card _this)
|
||||
[~ this(state !<(state-zero old-vase))]
|
||||
::
|
||||
++ on-poke
|
||||
|= [=mark =vase]
|
||||
^- (quip card _this)
|
||||
|^
|
||||
?+ mark (on-poke:def mark vase)
|
||||
%handle-http-request
|
||||
=+ !<([id=@ta req=inbound-request:eyre] vase)
|
||||
:_ this
|
||||
%+ give-simple-payload:app id
|
||||
%+ require-authorization:app req
|
||||
handle-http-request
|
||||
==
|
||||
::
|
||||
++ handle-http-request
|
||||
|= =inbound-request:eyre
|
||||
^- simple-payload:http
|
||||
?. =(src.bowl our.bowl) [[403 ~] ~]
|
||||
=* req request.inbound-request
|
||||
=/ req-line (parse-request-line url.req)
|
||||
?+ method.req not-found:gen
|
||||
%'GET' (handle-get header-list.req req-line)
|
||||
==
|
||||
::
|
||||
++ handle-get
|
||||
|= [headers=header-list:http req-line=request-line]
|
||||
^- simple-payload:http
|
||||
?~ ext.req-line
|
||||
$(req-line [[[~ %html] (snoc site.req-line 'index')] args.req-line])
|
||||
?~ site.req-line not-found:gen
|
||||
=* url-prefix url-prefix.configuration
|
||||
?. ?| ?&(?=(^ url-prefix) =((need url-prefix) i.site.req-line))
|
||||
=(url-prefix ~)
|
||||
==
|
||||
not-found:gen
|
||||
=/ file=(unit octs)
|
||||
?+ site.req-line ~
|
||||
[%'' %'index' ~] (get-file-at /app/launch [t.site u.ext]:req-line)
|
||||
[%'~launch' *] (get-file-at /app/launch [t.site u.ext]:req-line)
|
||||
[%'~link' *] (get-file-at /app/link [t.site u.ext]:req-line)
|
||||
[%'~chat' *] (get-file-at /app/chat [t.site u.ext]:req-line)
|
||||
[%'~dojo' *] (get-file-at /app/soto [t.site u.ext]:req-line)
|
||||
[%'~groups' *] (get-file-at /app/groups [t.site u.ext]:req-line)
|
||||
[%'~modulo' %session ~]
|
||||
%- some
|
||||
%- as-octt:mimes:html
|
||||
%+ weld
|
||||
"window.ship = '{+:(scow %p our.bowl)}';"
|
||||
"window.urb = new Channel();"
|
||||
::
|
||||
[%'~channel' %channel ~]
|
||||
(get-file-at /app/launch/js /channel u.ext.req-line)
|
||||
==
|
||||
?~ file not-found:gen
|
||||
?+ u.ext.req-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)
|
||||
?. ?=(?(%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)))
|
||||
--
|
||||
::
|
||||
++ on-watch
|
||||
|= =path
|
||||
^- (quip card _this)
|
||||
?+ path (on-watch:def path)
|
||||
[%http-response *] [~ this]
|
||||
==
|
||||
::
|
||||
++ on-arvo
|
||||
|= [=wire sign=sign-arvo]
|
||||
^- (quip card _this)
|
||||
?+ +<.sign (on-arvo:def wire sign)
|
||||
%bound [~ this]
|
||||
==
|
||||
::
|
||||
++ on-leave on-leave:def
|
||||
++ on-peek on-peek:def
|
||||
++ on-agent on-agent:def
|
||||
++ on-fail on-fail:def
|
||||
--
|
@ -1,34 +1,5 @@
|
||||
/- launch
|
||||
/+ *server, default-agent, dbug
|
||||
::
|
||||
/= index
|
||||
/^ $-([json marl] manx)
|
||||
/: /===/app/launch/index /!noun/
|
||||
/= script
|
||||
/^ octs
|
||||
/; as-octs:mimes:html
|
||||
/: /===/app/launch/js/index
|
||||
/| /js/
|
||||
/~ ~
|
||||
==
|
||||
/= channel-js
|
||||
/^ octs
|
||||
/; as-octs:mimes:html
|
||||
/: /===/app/launch/js/channel
|
||||
/| /js/
|
||||
/~ ~
|
||||
==
|
||||
/= style
|
||||
/^ octs
|
||||
/; as-octs:mimes:html
|
||||
/: /===/app/launch/css/index
|
||||
/| /css/
|
||||
/~ ~
|
||||
==
|
||||
/= launch-png
|
||||
/^ (map knot @)
|
||||
/: /===/app/launch/img /_ /png/
|
||||
::
|
||||
|%
|
||||
+$ versioned-state
|
||||
$% [%0 state-zero]
|
||||
@ -136,65 +107,11 @@
|
||||
path-to-tile (~(del by path-to-tile) subscribe.act)
|
||||
==
|
||||
==
|
||||
::
|
||||
%handle-http-request
|
||||
=+ !<([eyre-id=@ta =inbound-request:eyre] vas)
|
||||
:_ this
|
||||
%+ give-simple-payload:app eyre-id
|
||||
%+ require-authorization:app inbound-request
|
||||
|= =inbound-request:eyre
|
||||
^- simple-payload:http
|
||||
=/ request-line (parse-request-line url.request.inbound-request)
|
||||
=/ name=@t
|
||||
=/ back-path (flop site.request-line)
|
||||
?~ back-path
|
||||
''
|
||||
i.back-path
|
||||
?+ site.request-line
|
||||
not-found:gen
|
||||
::
|
||||
[~ ~]
|
||||
=/ hym=manx
|
||||
%+ index
|
||||
[%b first-time]
|
||||
^- marl
|
||||
%+ turn ~(tap by data)
|
||||
|= [key=@tas [jon=json url=@t]]
|
||||
^- manx
|
||||
;script@"{(trip url)}";
|
||||
(manx-response:gen hym)
|
||||
::
|
||||
[%'~launch' %css %index ~] :: styling
|
||||
(css-response:gen style)
|
||||
::
|
||||
[%'~launch' %js %index ~] :: javascript
|
||||
(js-response:gen script)
|
||||
::
|
||||
[%'~launch' %img *] :: images
|
||||
=/ img=(unit @) (~(get by launch-png) `@ta`name)
|
||||
?~ img
|
||||
not-found:gen
|
||||
(png-response:gen (as-octs:mimes:html u.img))
|
||||
::
|
||||
[%'~modulo' %session ~]
|
||||
=/ session-js
|
||||
%- as-octt:mimes:html
|
||||
;: weld
|
||||
"window.ship = '{+:(scow %p our.bol)}';"
|
||||
"window.urb = new Channel();"
|
||||
==
|
||||
(js-response:gen session-js)
|
||||
::
|
||||
[%'~channel' %channel ~]
|
||||
(js-response:gen channel-js)
|
||||
==
|
||||
==
|
||||
::
|
||||
++ on-watch
|
||||
|= pax=path
|
||||
^- (quip card _this)
|
||||
?: ?=([%http-response *] pax)
|
||||
[~ this]
|
||||
?. ?=([%main *] pax)
|
||||
(on-watch:def pax)
|
||||
=/ data=json
|
||||
|
@ -1,19 +0,0 @@
|
||||
|= [startup=json scripts=marl]
|
||||
;html
|
||||
;head
|
||||
;title: Home
|
||||
;meta(charset "utf-8");
|
||||
;meta
|
||||
=name "viewport"
|
||||
=content "width=device-width, initial-scale=1, shrink-to-fit=no";
|
||||
;link(rel "icon", type "image/png", href "/~launch/img/Favicon.png");
|
||||
==
|
||||
;body
|
||||
;div#root;
|
||||
;script@"/~channel/channel.js";
|
||||
;script@"/~modulo/session.js";
|
||||
;* scripts
|
||||
;script@"/~launch/js/index.js";
|
||||
;script: window.startupMessage = {(en-json:html startup)}
|
||||
==
|
||||
==
|
20
pkg/arvo/app/launch/index.html
Normal file
@ -0,0 +1,20 @@
|
||||
<!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"/>
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-touch-fullscreen" content="yes" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
|
||||
<link rel="stylesheet" href="/~launch/css/index.css" />
|
||||
<link rel="icon" type="image/png" href="/~launch/img/Favicon.png">
|
||||
</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>
|