2020-05-10 04:24:46 -07:00
|
|
|
/+ *server, default-agent
|
|
|
|
/= index
|
|
|
|
/^ octs
|
|
|
|
/; as-octs:mimes:html
|
2020-05-12 00:10:53 -07:00
|
|
|
/: /===/app/bartinfo/index
|
2020-05-10 04:24:46 -07:00
|
|
|
/| /html/
|
|
|
|
/~ ~
|
|
|
|
==
|
|
|
|
/= tile-js
|
|
|
|
/^ octs
|
|
|
|
/; as-octs:mimes:html
|
2020-05-12 00:10:53 -07:00
|
|
|
/: /===/app/bartinfo/js/tile
|
2020-05-10 04:24:46 -07:00
|
|
|
/| /js/
|
|
|
|
/~ ~
|
|
|
|
==
|
|
|
|
/= script
|
|
|
|
/^ octs
|
|
|
|
/; as-octs:mimes:html
|
2020-05-12 00:10:53 -07:00
|
|
|
/: /===/app/bartinfo/js/index
|
2020-05-10 04:24:46 -07:00
|
|
|
/| /js/
|
|
|
|
/~ ~
|
|
|
|
==
|
|
|
|
/= style
|
|
|
|
/^ octs
|
|
|
|
/; as-octs:mimes:html
|
2020-05-12 00:10:53 -07:00
|
|
|
/: /===/app/bartinfo/css/index
|
2020-05-10 04:24:46 -07:00
|
|
|
/| /css/
|
|
|
|
/~ ~
|
|
|
|
==
|
2020-05-12 00:10:53 -07:00
|
|
|
/= bartinfo-png
|
2020-05-10 04:24:46 -07:00
|
|
|
/^ (map knot @)
|
2020-05-12 00:10:53 -07:00
|
|
|
/: /===/app/bartinfo/img /_ /png/
|
2020-05-10 04:24:46 -07:00
|
|
|
::
|
|
|
|
|%
|
|
|
|
+$ card card:agent:gall
|
|
|
|
--
|
|
|
|
^- agent:gall
|
|
|
|
=<
|
|
|
|
|_ bol=bowl:gall
|
|
|
|
+* this .
|
2020-05-12 00:10:53 -07:00
|
|
|
bartinfo-core +>
|
|
|
|
cc ~(. bartinfo-core bol)
|
2020-05-10 04:24:46 -07:00
|
|
|
def ~(. (default-agent this %|) bol)
|
|
|
|
::
|
|
|
|
++ on-init
|
|
|
|
^- (quip card _this)
|
2020-05-12 00:10:53 -07:00
|
|
|
=/ launcha [%launch-action !>([%add %bartinfo / '/~bartinfo/js/tile.js'])]
|
2020-05-10 04:24:46 -07:00
|
|
|
:_ this
|
2020-05-12 00:10:53 -07:00
|
|
|
:~ [%pass / %arvo %e %connect [~ /'~bartinfo'] %bartinfo]
|
|
|
|
[%pass /bartinfo %agent [our.bol %launch] %poke launcha]
|
2020-05-10 04:24:46 -07:00
|
|
|
==
|
|
|
|
++ on-poke
|
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
|
|
|
?> (team:title our.bol src.bol)
|
|
|
|
?+ mark (on-poke:def mark vase)
|
|
|
|
%handle-http-request
|
|
|
|
=+ !<([eyre-id=@ta =inbound-request:eyre] vase)
|
|
|
|
:_ this
|
|
|
|
%+ give-simple-payload:app eyre-id
|
|
|
|
%+ require-authorization:app inbound-request
|
|
|
|
poke-handle-http-request:cc
|
|
|
|
::
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ on-watch
|
|
|
|
|= =path
|
|
|
|
^- (quip card:agent:gall _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]
|
|
|
|
::
|
|
|
|
++ on-save on-save:def
|
|
|
|
++ on-load on-load:def
|
|
|
|
++ on-leave on-leave:def
|
|
|
|
++ on-peek on-peek:def
|
|
|
|
++ on-fail on-fail:def
|
|
|
|
--
|
|
|
|
::
|
|
|
|
::
|
|
|
|
|_ bol=bowl:gall
|
|
|
|
::
|
2020-05-21 02:49:43 -07:00
|
|
|
:: request to http://api.bart.gov/api/stn.aspx?cmd=stns&key=Q5RQ-PUEB-999T-DWEI&json=y
|
|
|
|
:: get .root | .stations | .station for list of stations
|
2020-05-21 04:09:24 -07:00
|
|
|
|
|
|
|
++ bart-api-key "Q5RQ-PUEB-999T-DWEI"
|
|
|
|
++ bart-api-url-base "http://api.bart.gov/api"
|
2020-05-10 04:24:46 -07:00
|
|
|
++ poke-handle-http-request
|
|
|
|
|= =inbound-request:eyre
|
|
|
|
^- simple-payload:http
|
|
|
|
=+ url=(parse-request-line url.request.inbound-request)
|
|
|
|
?+ site.url not-found:gen
|
2020-05-12 00:10:53 -07:00
|
|
|
[%'~bartinfo' %css %index ~] (css-response:gen style)
|
|
|
|
[%'~bartinfo' %js %tile ~] (js-response:gen tile-js)
|
|
|
|
[%'~bartinfo' %js %index ~] (js-response:gen script)
|
2020-05-21 03:30:07 -07:00
|
|
|
[%'~bartinfo' %js %bogus ~] (js-response:gen (json-to-octs (bogus-json)))
|
2020-05-10 04:24:46 -07:00
|
|
|
::
|
2020-05-12 00:10:53 -07:00
|
|
|
[%'~bartinfo' %img @t *]
|
2020-05-10 04:24:46 -07:00
|
|
|
=/ name=@t i.t.t.site.url
|
2020-05-12 00:10:53 -07:00
|
|
|
=/ img (~(get by bartinfo-png) name)
|
2020-05-10 04:24:46 -07:00
|
|
|
?~ img
|
|
|
|
not-found:gen
|
|
|
|
(png-response:gen (as-octs:mimes:html u.img))
|
|
|
|
::
|
2020-05-12 00:10:53 -07:00
|
|
|
[%'~bartinfo' *] (html-response:gen index)
|
2020-05-10 04:24:46 -07:00
|
|
|
==
|
2020-05-21 03:30:07 -07:00
|
|
|
++ bogus-json
|
|
|
|
|= ~
|
|
|
|
^- json
|
|
|
|
%- pairs:enjs:format
|
2020-05-21 04:09:24 -07:00
|
|
|
:~
|
|
|
|
success+b+%.n
|
2020-05-21 03:30:07 -07:00
|
|
|
==
|
2020-05-21 04:09:24 -07:00
|
|
|
++ request-bart-stations
|
|
|
|
^- request:http
|
|
|
|
=/ url (crip "{bart-api-url-base}/stn.aspx?cmd=stns&key={bart-api-key}&json=y")
|
|
|
|
=/ headers [['Accept' 'application/json']]~
|
|
|
|
[%'GET' url headers *(unit octs)]
|
|
|
|
::;++ request-darksky
|
|
|
|
:: |= location=@t
|
|
|
|
:: ^- request:http
|
|
|
|
:: =/ base 'https://api.darksky.net/forecast/634639c10670c7376dc66b6692fe57ca/'
|
|
|
|
:: =/ url=@t (cat 3 (cat 3 base location) '?units=auto')
|
|
|
|
:: =/ hed [['Accept' 'application/json']]~
|
|
|
|
:: [%'GET' url hed *(unit octs)]
|
2020-05-10 04:24:46 -07:00
|
|
|
::
|
|
|
|
--
|