Merge pull request #1319 from urbit/rc-modulo

Updated parts of interface and rver
This commit is contained in:
Logan 2019-07-05 14:29:25 -07:00 committed by GitHub
commit fb700523ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 221 additions and 114 deletions

View File

@ -50,7 +50,8 @@
++ prep
|= old=(unit state)
^- (quip move _this)
=/ launchnoun [%noun [%chat /chattile '/~chat/js/tile.js']]
=/ launcha/poke
[%launch-action [%chat /chattile '/~chat/js/tile.js']]
?~ old
=/ inboxpat /circle/inbox/config/group
=/ circlespat /circles/[(scot %p our.bol)]
@ -63,9 +64,9 @@
[ost.bol %peer circlespat [our.bol %hall] circlespat]
[ost.bol %connect / [~ /'~chat'] %chat]
[ost.bol %poke /chat [our.bol %hall] inboxi]
[ost.bol %poke /chat [our.bol %launch] launchnoun]
[ost.bol %poke /chat [our.bol %launch] launcha]
==
:- [ost.bol %poke /chat [our.bol %launch] launchnoun]~
:- [ost.bol %poke /chat [our.bol %launch] launcha]~
this(sta u.old)
::
::

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -15,7 +15,7 @@
:: +card: output effect payload
::
+$ poke
$% [%noun [@tas path @t]]
$% [%launch-action [@tas path @t]]
==
::
+$ card
@ -39,11 +39,12 @@
++ prep
|= old=(unit ~)
^- (quip move _this)
=/ launchnoun [%noun [%clock /tile '/~clock/js/tile.js']]
=/ launcha
[%launch-action [%clock /tile '/~clock/js/tile.js']]
:_ this
:~
[ost.bol %connect / [~ /'~clock'] %clock]
[ost.bol %poke /clock [our.bol %launch] launchnoun]
[ost.bol %poke /clock [our.bol %launch] launcha]
==
::
++ peer-tile

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,4 @@
/+ *server, collections
/+ *server, launch
/= index
/^ $-(marl manx)
/: /===/app/launch/index /!noun/
@ -21,23 +20,7 @@
/^ (map knot @)
/: /===/app/launch/img /_ /png/
::
|%
::
+$ move [bone card]
::
+$ card
$% [%http-response =http-event:http]
[%connect wire binding:eyre term]
[%peer wire dock path]
[%diff %json json]
==
+$ tile [name=@tas subscribe=path]
+$ tile-data (map @tas [jon=json url=@t])
+$ state
$% [%0 tiles=(set tile) data=tile-data path-to-tile=(map path @tas)]
==
::
--
=, launch
::
|_ [bol=bowl:gall sta=state]
::
@ -46,32 +29,37 @@
++ prep
|= old=(unit state)
^- (quip move _this)
~& 'launch prep'
?~ old
:_ this
[ost.bol %connect / [~ /] %launch]~
[~ this(sta u.old)]
::
++ bound
|= [wir=wire success=? binding=binding:eyre]
++ poke-launch-action
|= act=action:launch
^- (quip move _this)
[~ this]
::
++ poke-noun
|= [name=@tas subscribe=path url=@t]
^- (quip move _this)
=/ beforedata (~(get by data.sta) name)
=/ beforedata (~(get by data.sta) name.act)
=/ newdata
?~ beforedata
(~(put by data.sta) name [*json url])
(~(put by data.sta) name [jon.u.beforedata url])
:- [ost.bol %peer subscribe [our.bol name] subscribe]~
(~(put by data.sta) name.act [*json url.act])
(~(put by data.sta) name.act [jon.u.beforedata url.act])
:- [ost.bol %peer subscribe.act [our.bol name.act] subscribe.act]~
%= this
tiles.sta (~(put in tiles.sta) [name subscribe])
tiles.sta (~(put in tiles.sta) [name.act subscribe.act])
data.sta newdata
path-to-tile.sta (~(put by path-to-tile.sta) subscribe name)
path-to-tile.sta (~(put by path-to-tile.sta) subscribe.act name.act)
==
::
++ peer-main
|= [pax=path]
^- (quip move _this)
=/ data/json
%- pairs:enjs:format
%+ turn ~(tap by data.sta)
|= [key=@tas [jon=json url=@t]]
[key jon]
:_ this
[ost.bol %diff %json data]~
::
++ diff-json
|= [pax=path jon=json]
^- (quip move _this)
@ -89,17 +77,6 @@
data.sta (~(put by data.sta) name [jon url.u.data])
==
::
++ peer-main
|= [pax=path]
^- (quip move _this)
=/ data/json
%- pairs:enjs:format
%+ turn ~(tap by data.sta)
|= [key=@tas [jon=json url=@t]]
[key jon]
:_ this
[ost.bol %diff %json data]~
::
++ generate-script-marl
|= data=tile-data
^- marl
@ -113,9 +90,9 @@
|= =inbound-request:eyre
^- (quip move _this)
::
=+ request-line=(parse-request-line url.request.inbound-request)
=/ request-line (parse-request-line url.request.inbound-request)
=/ name=@t
=+ back-path=(flop site.request-line)
=/ back-path (flop site.request-line)
?~ back-path
''
i.back-path
@ -148,4 +125,9 @@
[ost.bol %http-response (png-response:app img)]~
==
::
++ bound
|= [wir=wire success=? binding=binding:eyre]
^- (quip move _this)
[~ this]
::
--

File diff suppressed because one or more lines are too long

View File

@ -18,7 +18,7 @@
:: +card: output effect payload
::
+$ poke
$% [%noun [@tas path @t]]
$% [%launch-action [@tas path @t]]
==
::
+$ card
@ -44,11 +44,11 @@
++ prep
|= old=(unit tim=@da)
^- (quip move _this)
=/ launchnoun [%noun [%timer /tile '/~timer/js/tile.js']]
=/ launcha [%launch-action [%timer /tile '/~timer/js/tile.js']]
:-
:~
[ost.bol %connect / [~ /'~timer'] %timer]
[ost.bol %poke /timer [our.bol %launch] launchnoun]
[ost.bol %poke /timer [our.bol %launch] launcha]
==
?~ old
this
@ -116,7 +116,10 @@
++ wake
|= [wir=wire err=(unit tang)]
^- (quip move _this)
?~ err
:- (send-tile-diff [%s 'alarm'])
this(tim *@da)
~& err
[~ this]
::
--

File diff suppressed because one or more lines are too long

View File

@ -26,7 +26,7 @@
[%wait wire @da]
==
+$ poke
$% [%noun [@tas path @t]]
$% [%launch-action [@tas path @t]]
==
+$ state
$% [%0 data=json time=@da location=@t timer=(unit @da)]
@ -45,10 +45,12 @@
++ prep
|= old=(unit state)
^- (quip move _this)
=/ launcha
[%launch-action [%weather /weathertile '/~weather/js/tile.js']]
:-
:~
[ost.bol %connect / [~ /'~weather'] %weather]
[ost.bol %poke /weather [our.bol %launch] [%noun [%weather /weathertile '/~weather/js/tile.js']]]
[ost.bol %poke /weather [our.bol %launch] launcha]
==
?~ old
this
@ -70,15 +72,14 @@
=/ str/@t +.jon
=/ req/request:http (request-darksky str)
=/ out *outbound-config:iris
=/ lismov [ost.bol %request /[(scot %da now.bol)] req out]~
?~ timer
:- %+ weld
`(list move)`[ost.bol %wait /timer (add now.bol ~d1)]~
`(list move)`[ost.bol %request /[(scot %da now.bol)] req out]~
:- [[ost.bol %wait /timer (add now.bol ~h3)] lismov]
%= this
location str
timer `(add now.bol ~d1)
timer `(add now.bol ~h3)
==
:- [ost.bol %request /[(scot %da now.bol)] req out]~
:- lismov
%= this
location str
==
@ -110,17 +111,21 @@
?~ data
:: data is null
[~ this]
=/ jon/(unit json) (de-json:html q.data.u.data)
?~ jon
=/ ujon/(unit json) (de-json:html q.data.u.data)
?~ ujon
[~ this]
?> ?=(%o -.u.jon)
=/ ayyy/json %- pairs:enjs:format :~
currently+(~(got by p.u.jon) 'currently')
daily+(~(got by p.u.jon) 'daily')
?> ?=(%o -.u.ujon)
?: (gth 200 status-code.response-header.response)
~& weather+u.ujon
~& weather+location
[~ this]
=/ jon/json %- pairs:enjs:format :~
currently+(~(got by p.u.ujon) 'currently')
daily+(~(got by p.u.ujon) 'daily')
==
:- (send-tile-diff ayyy)
:- (send-tile-diff jon)
%= this
data ayyy
data jon
time now.bol
==
::
@ -128,10 +133,10 @@
%- (require-authorization:app ost.bol move this)
|= =inbound-request:eyre
^- (quip move _this)
=+ request-line=(parse-request-line url.request.inbound-request)
=+ back-path=(flop site.request-line)
=/ 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 (flop site.request-line)
?~ back-path
''
i.back-path
@ -150,12 +155,16 @@
++ wake
|= [wir=wire err=(unit tang)]
^- (quip move _this)
?~ err
=/ req/request:http (request-darksky location)
=/ out *outbound-config:iris
=/ lismov/(list move)
`(list move)`[ost.bol %request /[(scot %da now.bol)] req *outbound-config:iris]~
[ost.bol %request /[(scot %da now.bol)] req out]~
?~ timer
:- (weld lismov `(list move)`[ost.bol %wait /timer (add now.bol ~h3)]~)
:- [[ost.bol %wait /timer (add now.bol ~h3)] lismov]
this(timer `(add now.bol ~h3))
[lismov this]
~& err
[~ this]
::
--

File diff suppressed because one or more lines are too long

View File

@ -55,7 +55,7 @@
+$ poke
$% [%hall-action action:hall]
[%write-action action]
[%noun @tas path @t]
[%launch-action @tas path @t]
==
::
+$ diff
@ -188,7 +188,7 @@
:_ this(sat *state)
:~ [ost.bol %connect / [~ /'~publish'] %write]
:* ost.bol %poke /publish [our.bol %launch]
%noun %write /publishtile '/~publish/tile.js'
%launch-action %write /publishtile '/~publish/tile.js'
==
==
::

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -24,7 +24,7 @@
::
+$ poke
$% [%hall-action action:hall]
[%noun [@tas path @t]]
[%launch-action [@tas path @t]]
==
::
+$ state

24
pkg/arvo/lib/launch.hoon Normal file
View File

@ -0,0 +1,24 @@
::
|%
::
+$ move [bone card]
::
+$ card
$% [%http-response =http-event:http]
[%connect wire binding:eyre term]
[%peer wire dock path]
[%diff %json json]
==
::
+$ tile [name=@tas subscribe=path]
::
+$ tile-data (map @tas [jon=json url=@t])
::
+$ action [name=@tas subscribe=path url=@t]
::
+$ state
$% [%0 tiles=(set tile) data=tile-data path-to-tile=(map path @tas)]
==
::
--
::

View File

@ -0,0 +1,11 @@
::
::
/+ launch
::
|_ act=action:launch
::
++ grab
|%
++ noun action:launch
--
--

View File

@ -339,7 +339,7 @@
:: +login-page: internal page to login to an Urbit
::
++ login-page
|= redirect-url=(unit @t)
|= [redirect-url=(unit @t) our=@p]
^- octs
=+ redirect-str=?~(redirect-url "" (trip u.redirect-url))
%- as-octs:mimes:html
@ -347,14 +347,91 @@
%- en-xml:html
;html
;head
;meta(charset "utf-8");
;title:"Sign in"
;style:'''
@import url("https://rsms.me/inter/inter.css");
@font-face {
font-family: "Source Code Pro";
src: url("https://storage.googleapis.com/media.urbit.org/fonts/scp-medium.woff");
font-weight: 500
}
html, body {
font-family: Inter, sans-serif;
height: 100%;
margin: 0 !important;
width: 100%;
background: #000;
color: #fff;
display: table;
}
form {
margin: 0 !important;
display: flex;
flex-direction: column;
flex: 2;
}
#topborder {
border-top: 3px #fff solid;
}
h1 {
line-height: 77px;
font-size: 64px;
-webkit-margin-before: 0;
-webkit-margin-after: 0;
-webkit-margin-start: 0;
-webkit-margin-end: 0;
font-weight: 500;
flex: 1;
padding-top: 22px;
margin-bottom: 66px;
}
#main {
vertical-align: middle;
display: table-cell;
}
input {
display: block;
width: 100%;
font-size: 64px;
line-height: 77px;
color: #fff;
background: #000;
border: none;
flex: 1;
margin-bottom: 66px;
font-weight: 500;
font-family: 'Source Code Pro', monospace, sans-serif;
}
button {
background: #000;
border: none;
color: #fff;
line-height: 77px;
font-size: 64px;
text-align: left;
flex: 1;
font-weight: 500;
}
#inner {
width: 75%;
margin: 0 auto;
display: flex;
flex-direction: column;
}
'''
==
;body
;h1:"Sign in"
;div#main
;div#inner
;h1#topborder:"Modulo"
;h1:"{(scow %p our)}"
;form(action "/~/login", method "post", enctype "application/x-www-form-urlencoded")
;input(type "password", name "password", placeholder "passcode");
;input(type "password", name "password", placeholder "passcode", autofocus "true");
;input(type "hidden", name "redirect", value redirect-str);
;button(type "submit"):"Login"
;button(type "submit"):"→ Authenticate"
==
==
==
==
==
@ -546,10 +623,10 @@
//
delete() {
var id = this.nextId();
this.sendJSONToChannel({
navigator.sendBeacon(this.channelURL(), JSON.stringify([{
"id": id,
"action": "delete"
}, false);
}]));
}
// unsubscribe to a specific subscription
@ -565,7 +642,7 @@
// sends a JSON command command to the server.
//
sendJSONToChannel(j, connectAgain = true) {
sendJSONToChannel(j) {
var req = new XMLHttpRequest();
req.open("PUT", this.channelURL());
req.setRequestHeader("Content-Type", "application/json");
@ -586,10 +663,8 @@
this.lastEventId = this.lastAcknowledgedEventId;
}
if (connectAgain) {
this.connectIfDisconnected();
}
}
// connects to the EventSource if we are not currently connected
//
@ -879,27 +954,27 @@
::
=+ request-line=(parse-request-line url.request)
%^ return-static-data-on-duct 200 'text/html'
(login-page (get-header:http 'redirect' args.request-line))
(login-page (get-header:http 'redirect' args.request-line) our)
:: if we are not a post, return an error
::
?. =('POST' method.request)
(return-static-data-on-duct 400 'text/html' (login-page ~))
(return-static-data-on-duct 400 'text/html' (login-page ~ our))
:: we are a post, and must process the body type as form data
::
?~ body.request
(return-static-data-on-duct 400 'text/html' (login-page ~))
(return-static-data-on-duct 400 'text/html' (login-page ~ our))
::
=/ parsed=(unit (list [key=@t value=@t]))
(rush q.u.body.request yquy:de-purl:html)
?~ parsed
(return-static-data-on-duct 400 'text/html' (login-page ~))
(return-static-data-on-duct 400 'text/html' (login-page ~ our))
::
?~ password=(get-header:http 'password' u.parsed)
(return-static-data-on-duct 400 'text/html' (login-page ~))
(return-static-data-on-duct 400 'text/html' (login-page ~ our))
:: check that the password is correct
::
?. =(u.password code)
(return-static-data-on-duct 400 'text/html' (login-page ~))
(return-static-data-on-duct 400 'text/html' (login-page ~ our))
:: mint a unique session cookie
::
=/ session=@uv
@ -1032,6 +1107,9 @@
::
?: =('GET' method.request)
(on-get-request channel-id request)
?: =('POST' method.request)
:: POST methods are used solely for deleting channels
(on-put-request channel-id request)
::
~& %session-not-a-put
[~ state]

View File

@ -2033,9 +2033,9 @@
%start
:- 200
:~ ['content-type' 'text/html']
['content-length' '348']
['content-length' '1751']
==
[~ (login-page:http-server-gate `'/~landscape/inner-path')]
[~ (login-page:http-server-gate `'/~landscape/inner-path' ~nul)]
complete=%.y
== ==
==