This commit is contained in:
Isaac Visintainer 2019-06-19 16:06:51 -07:00
commit e90774a677
20 changed files with 253 additions and 259 deletions

View File

@ -13,7 +13,7 @@ class UrbitApi {
bind(path, method, ship = this.authTokens.ship, appl = "hall", success, fail) { bind(path, method, ship = this.authTokens.ship, appl = "hall", success, fail) {
this.bindPaths = _.uniq([...this.bindPaths, path]); this.bindPaths = _.uniq([...this.bindPaths, path]);
window.urb.subscribe(ship, appl, path, window.subscriptionId = window.urb.subscribe(ship, appl, path,
(err) => { (err) => {
fail(err); fail(err);
}, },

View File

@ -48,10 +48,13 @@ export class ChatInput extends Component {
}); });
} }
setTimeout(closure, 1000); //setTimeout(closure, 2000);
setTimeout(() => {
window.location.reload(false);
}, 1000);
}; };
//closure(); //setTimeout(closure, 2000);
this.state = { this.state = {

View File

@ -39,6 +39,11 @@ export class Message extends Component {
render() { render() {
let pending = !!this.props.msg.pending ? ' o-80' : ''; let pending = !!this.props.msg.pending ? ' o-80' : '';
let timestamp = moment.unix(this.props.msg.wen / 1000).format('hh:mm');
window.timestamp = timestamp;
window.wen = this.props.msg.wen;
window.moment = moment;
return ( return (
<div className={"w-100 pl3 pr3 pt2 pb2 mb2 cf flex" + pending}> <div className={"w-100 pl3 pr3 pt2 pb2 mb2 cf flex" + pending}>
<div className="fl mr2"> <div className="fl mr2">
@ -47,7 +52,7 @@ export class Message extends Component {
<div className="fr" style={{ flexGrow: 1, marginTop: -4 }}> <div className="fr" style={{ flexGrow: 1, marginTop: -4 }}>
<div> <div>
<p className="v-top label-small-mono gray dib mr3">~{this.props.msg.aut}</p> <p className="v-top label-small-mono gray dib mr3">~{this.props.msg.aut}</p>
<p className="v-top label-small-mono gray dib">{moment.unix(this.props.msg.wen).format('hh:mm')}</p> <p className="v-top label-small-mono gray dib">{timestamp}</p>
</div> </div>
{this.renderContent(this.props.details.type)} {this.renderContent(this.props.details.type)}
</div> </div>

View File

@ -1,5 +1,6 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import classnames from 'classnames'; import classnames from 'classnames';
import { uuid } from '/lib/util';
export class NewScreen extends Component { export class NewScreen extends Component {

View File

@ -18,6 +18,17 @@ export class Subscription {
api.bind('/primary', 'PUT', api.authTokens.ship, 'chat', api.bind('/primary', 'PUT', api.authTokens.ship, 'chat',
this.handleEvent.bind(this), this.handleEvent.bind(this),
this.handleError.bind(this)); this.handleError.bind(this));
/*window.addEventListener('beforeunload', (event) => {
// Cancel the event as stated by the standard.
event.preventDefault();
// Chrome requires returnValue to be set.
event.returnValue = '';
if (window.subscriptionId) {
window.urb.unsubscribe(window.subscriptionId);
}
});*/
} }
fetchMessages(circle, start, end) { fetchMessages(circle, start, end) {

View File

@ -4,7 +4,28 @@ import classnames from 'classnames';
export default class ChatTile extends Component { export default class ChatTile extends Component {
constructor(props) {
super(props);
this.state = {
configs: null,
messages: null,
message: null
};
}
componentDidUpdate(prevProps, prevState) {
const { props, state } = this;
if (prevProps !== props) {
// TODO: reducer logic :(
this.setState(props);
}
}
render() { render() {
console.log(this.state);
return ( return (
<div className="bg-dark-gray w-100 h-100"> <div className="bg-dark-gray w-100 h-100">
<a className="w-100 h-100 db" style={{ <a className="w-100 h-100 db" style={{

View File

@ -14,7 +14,6 @@
/| /js/ /| /js/
/~ ~ /~ ~
== ==
/= script /= script
/^ octs /^ octs
/; as-octs:mimes:html /; as-octs:mimes:html
@ -63,9 +62,9 @@
[ost.bol %peer circlespat [our.bol %hall] circlespat] [ost.bol %peer circlespat [our.bol %hall] circlespat]
[ost.bol %connect / [~ /'~chat'] %chat] [ost.bol %connect / [~ /'~chat'] %chat]
[ost.bol %poke /chat [our.bol %hall] inboxi] [ost.bol %poke /chat [our.bol %hall] inboxi]
[ost.bol %poke /chat [our.bol %launch] [%noun [%chat /chattile]]] [ost.bol %poke /chat [our.bol %launch] [%noun [%chat /chattile '/~chat/js/tile.js']]]
== ==
:- [ost.bol %poke /chat [our.bol %launch] [%noun [%chat /chattile]]]~ :- [ost.bol %poke /chat [our.bol %launch] [%noun [%chat /chattile '/~chat/js/tile.js']]]~
this(sta u.old) this(sta u.old)
:: ::
:: ::
@ -73,7 +72,16 @@
++ peer-chattile ++ peer-chattile
|= wir=wire |= wir=wire
^- (quip move _this) ^- (quip move _this)
[~ this] =/ numbers/(list [circle:hall @ud])
%+ turn ~(tap by messages.str.sta)
|= [cir=circle:hall lis=(list envelope:hall)]
^- [circle:hall @ud]
[cir (lent lis)]
:_ this
:~
[ost.bol %diff %json (config-to-json str.sta)]
[ost.bol %diff %json (numbers-to-json numbers)]
==
:: ::
:: +peer-messages: subscribe to subset of messages and updates :: +peer-messages: subscribe to subset of messages and updates
:: ::
@ -81,6 +89,7 @@
++ peer-primary ++ peer-primary
|= wir=wire |= wir=wire
^- (quip move _this) ^- (quip move _this)
~& (lent (prey:pubsub:userlib /primary bol))
=* messages messages.str.sta =* messages messages.str.sta
=/ lisunitmov=(list (unit move)) =/ lisunitmov=(list (unit move))
%+ turn ~(tap by messages) %+ turn ~(tap by messages)
@ -134,9 +143,13 @@
++ send-chat-update ++ send-chat-update
|= upd=update |= upd=update
^- (list move) ^- (list move)
%+ weld
%+ turn (prey:pubsub:userlib /primary bol) %+ turn (prey:pubsub:userlib /primary bol)
|= [=bone *] |= [=bone *]
~& bone [bone %diff %chat-update upd]
::
%+ turn (prey:pubsub:userlib /chattile bol)
|= [=bone *]
[bone %diff %chat-update upd] [bone %diff %chat-update upd]
:: ::
:: ::

View File

@ -17,10 +17,6 @@
return module = { exports: {} }, fn(module, module.exports), module.exports; return module = { exports: {} }, fn(module, module.exports), module.exports;
} }
function getCjsExportFromNamespace (n) {
return n && n.default || n;
}
/* /*
object-assign object-assign
(c) Sindre Sorhus (c) Sindre Sorhus
@ -45633,7 +45629,7 @@
bind(path, method, ship = this.authTokens.ship, appl = "hall", success, fail) { bind(path, method, ship = this.authTokens.ship, appl = "hall", success, fail) {
this.bindPaths = lodash.uniq([...this.bindPaths, path]); this.bindPaths = lodash.uniq([...this.bindPaths, path]);
window.urb.subscribe(ship, appl, path, window.subscriptionId = window.urb.subscribe(ship, appl, path,
(err) => { (err) => {
fail(err); fail(err);
}, },
@ -47896,8 +47892,6 @@
isBuffer: isBuffer isBuffer: isBuffer
}); });
var require$$0 = getCjsExportFromNamespace(bufferEs6);
var bn = createCommonjsModule(function (module) { var bn = createCommonjsModule(function (module) {
(function (module, exports) { (function (module, exports) {
@ -47950,7 +47944,7 @@
var Buffer; var Buffer;
try { try {
Buffer = require$$0.Buffer; Buffer = bufferEs6.Buffer;
} catch (e) { } catch (e) {
} }
@ -51997,6 +51991,17 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
api.bind('/primary', 'PUT', api.authTokens.ship, 'chat', api.bind('/primary', 'PUT', api.authTokens.ship, 'chat',
this.handleEvent.bind(this), this.handleEvent.bind(this),
this.handleError.bind(this)); this.handleError.bind(this));
/*window.addEventListener('beforeunload', (event) => {
// Cancel the event as stated by the standard.
event.preventDefault();
// Chrome requires returnValue to be set.
event.returnValue = '';
if (window.subscriptionId) {
window.urb.unsubscribe(window.subscriptionId);
}
});*/
} }
fetchMessages(circle, start, end) { fetchMessages(circle, start, end) {
@ -56951,15 +56956,20 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
render() { render() {
let pending = !!this.props.msg.pending ? ' o-80' : ''; let pending = !!this.props.msg.pending ? ' o-80' : '';
let timestamp = moment.unix(this.props.msg.wen / 1000).format('hh:mm');
window.timestamp = timestamp;
window.wen = this.props.msg.wen;
window.moment = moment;
return ( return (
react.createElement('div', { className: "w-100 pl3 pr3 pt2 pb2 mb2 cf flex" + pending, __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 43}} react.createElement('div', { className: "w-100 pl3 pr3 pt2 pb2 mb2 cf flex" + pending, __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 48}}
, react.createElement('div', { className: "fl mr2" , __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 44}} , react.createElement('div', { className: "fl mr2" , __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 49}}
, react.createElement(Sigil, { ship: this.props.msg.aut, size: 32, __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 45}} ) , react.createElement(Sigil, { ship: this.props.msg.aut, size: 32, __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 50}} )
) )
, react.createElement('div', { className: "fr", style: { flexGrow: 1, marginTop: -4 }, __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 47}} , react.createElement('div', { className: "fr", style: { flexGrow: 1, marginTop: -4 }, __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 52}}
, react.createElement('div', {__self: this, __source: {fileName: _jsxFileName$8, lineNumber: 48}} , react.createElement('div', {__self: this, __source: {fileName: _jsxFileName$8, lineNumber: 53}}
, react.createElement('p', { className: "v-top label-small-mono gray dib mr3" , __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 49}}, "~", this.props.msg.aut) , react.createElement('p', { className: "v-top label-small-mono gray dib mr3" , __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 54}}, "~", this.props.msg.aut)
, react.createElement('p', { className: "v-top label-small-mono gray dib" , __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 50}}, moment.unix(this.props.msg.wen).format('hh:mm')) , react.createElement('p', { className: "v-top label-small-mono gray dib" , __self: this, __source: {fileName: _jsxFileName$8, lineNumber: 55}}, timestamp)
) )
, this.renderContent(this.props.details.type) , this.renderContent(this.props.details.type)
) )
@ -57041,7 +57051,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
constructor(props) { constructor(props) {
super(props); super(props);
//closure(); //setTimeout(closure, 2000);
this.state = { this.state = {
@ -57149,19 +57159,19 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
const { props, state } = this; const { props, state } = this;
return ( return (
react.createElement('div', { className: "mt2 pa3 cf flex black bt" , __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 162}} react.createElement('div', { className: "mt2 pa3 cf flex black bt" , __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 165}}
, react.createElement('div', { className: "fl", style: { flexBasis: 35, height: 40 }, __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 163}} , react.createElement('div', { className: "fl", style: { flexBasis: 35, height: 40 }, __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 166}}
, react.createElement(Sigil, { ship: window.ship, size: 32, __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 164}} ) , react.createElement(Sigil, { ship: window.ship, size: 32, __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 167}} )
) )
, react.createElement('div', { className: "fr h-100 flex" , style: { flexGrow: 1, height: 40 }, __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 166}} , react.createElement('div', { className: "fr h-100 flex" , style: { flexGrow: 1, height: 40 }, __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 169}}
, react.createElement('input', { className: "ml2 bn" , , react.createElement('input', { className: "ml2 bn" ,
style: { flexGrow: 1 }, style: { flexGrow: 1 },
ref: this.textareaRef, ref: this.textareaRef,
placeholder: props.placeholder, placeholder: props.placeholder,
value: state.message, value: state.message,
onChange: this.messageChange, __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 167}} ) onChange: this.messageChange, __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 170}} )
, react.createElement('div', { className: "pointer", onClick: this.messageSubmit, __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 173}} , react.createElement('div', { className: "pointer", onClick: this.messageSubmit, __self: this, __source: {fileName: _jsxFileName$b, lineNumber: 176}}
, react.createElement(IconSend, {__self: this, __source: {fileName: _jsxFileName$b, lineNumber: 174}} ) , react.createElement(IconSend, {__self: this, __source: {fileName: _jsxFileName$b, lineNumber: 177}} )
) )
) )
) )
@ -57681,23 +57691,23 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\
render() { render() {
return ( return (
react.createElement('div', { className: "h-100 w-100 pa3 pt2 overflow-x-hidden flex flex-column" , __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 86}} react.createElement('div', { className: "h-100 w-100 pa3 pt2 overflow-x-hidden flex flex-column" , __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 87}}
, react.createElement('h2', { className: "mb3", __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 87}}, "Create a New Chat" ) , react.createElement('h2', { className: "mb3", __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 88}}, "Create a New Chat" )
, react.createElement('div', {__self: this, __source: {fileName: _jsxFileName$g, lineNumber: 88}} , react.createElement('div', {__self: this, __source: {fileName: _jsxFileName$g, lineNumber: 89}}
, react.createElement('p', { className: "label-regular fw-bold" , __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 89}}, "Name") , react.createElement('p', { className: "label-regular fw-bold" , __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 90}}, "Name")
, react.createElement('input', { , react.createElement('input', {
className: "body-large bn pa2 pl0 mb2 w-50" , className: "body-large bn pa2 pl0 mb2 w-50" ,
placeholder: "secret-chat", placeholder: "secret-chat",
onChange: this.idChange, __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 90}} ) onChange: this.idChange, __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 91}} )
, react.createElement('p', { className: "label-regular fw-bold" , __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 94}}, "Invites") , react.createElement('p', { className: "label-regular fw-bold" , __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 95}}, "Invites")
, react.createElement('input', { , react.createElement('input', {
className: "body-large bn pa2 pl0 mb2 w-50" , className: "body-large bn pa2 pl0 mb2 w-50" ,
placeholder: "~zod, ~bus" , placeholder: "~zod, ~bus" ,
onChange: this.invChange, __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 95}} ) onChange: this.invChange, __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 96}} )
, react.createElement('br', {__self: this, __source: {fileName: _jsxFileName$g, lineNumber: 99}} ) , react.createElement('br', {__self: this, __source: {fileName: _jsxFileName$g, lineNumber: 100}} )
, react.createElement('button', { , react.createElement('button', {
onClick: this.onClickCreate.bind(this), onClick: this.onClickCreate.bind(this),
className: "body-large pointer underline bn" , __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 100}}, "-> Create" ) className: "body-large pointer underline bn" , __self: this, __source: {fileName: _jsxFileName$g, lineNumber: 101}}, "-> Create" )
) )
) )
); );

View File

@ -2206,17 +2206,38 @@
class ChatTile extends react_1 { class ChatTile extends react_1 {
constructor(props) {
super(props);
this.state = {
configs: null,
messages: null,
message: null
};
}
componentDidUpdate(prevProps, prevState) {
const { props, state } = this;
if (prevProps !== props) {
// TODO: reducer logic :(
this.setState(props);
}
}
render() { render() {
console.log(this.state);
return ( return (
react.createElement('div', { className: "bg-dark-gray w-100 h-100" , __self: this, __source: {fileName: _jsxFileName, lineNumber: 9}} react.createElement('div', { className: "bg-dark-gray w-100 h-100" , __self: this, __source: {fileName: _jsxFileName, lineNumber: 30}}
, react.createElement('a', { className: "w-100 h-100 db" , style: { , react.createElement('a', { className: "w-100 h-100 db" , style: {
paddingTop: 68, paddingTop: 68,
paddingBottom: 68, paddingBottom: 68,
paddingLeft: 64, paddingLeft: 64,
paddingRight: 64 paddingRight: 64
}, },
href: "/~chat", __self: this, __source: {fileName: _jsxFileName, lineNumber: 10}} href: "/~chat", __self: this, __source: {fileName: _jsxFileName, lineNumber: 31}}
, react.createElement('img', { src: "/~chat/img/Tile.png", width: 106, height: 98, __self: this, __source: {fileName: _jsxFileName, lineNumber: 17}} ) , react.createElement('img', { src: "/~chat/img/Tile.png", width: 106, height: 98, __self: this, __source: {fileName: _jsxFileName, lineNumber: 38}} )
) )
) )
); );

View File

@ -17,14 +17,14 @@
:: ::
+$ diff +$ diff
$% [%hall-rumor rumor:hall] $% [%hall-rumor rumor:hall]
[%chat-initial streams]
[%chat-update update] [%chat-update update]
[%chat-config streams] [%chat-config streams]
[%json json]
== ==
:: ::
+$ poke +$ poke
$% [%hall-action action:hall] $% [%hall-action action:hall]
[%noun [@tas path]] [%noun [@tas path @t]]
== ==
:: ::
+$ state +$ state
@ -81,61 +81,59 @@
== ==
== ==
:: ::
++ parse-chat-command ++ config-to-json
=, dejs:format |= str=streams
=, dejs:hall-json =, enjs:format
%- of ^- json
%+ frond %chat
%- pairs
:~ :~
[%messages (ot circle+circ start+ni end+ni ~)] ::
[%inbox (conf:enjs:hall-json inbox.str)]
::
:- %configs
%- pairs
%+ turn ~(tap by configs.str)
|= [cir=circle:hall con=(unit config:hall)]
^- [@t json]
:- (crip (circ:en-tape:hall-json cir))
?~(con ~ (conf:enjs:hall-json u.con))
::
:- %circles :- %a
%+ turn ~(tap in circles.str)
|= nom=name:hall
[%s nom]
::
:- %peers
%- pairs
%+ turn ~(tap by peers.str)
|= [cir=circle:hall per=(set @p)]
^- [@t json]
:- (crip (circ:en-tape:hall-json cir))
[%a (turn ~(tap in per) ship)]
::
== ==
:: ::
+$ indices-internal-state ++ numbers-to-json
$: |= num=(list [circle:hall @ud])
lis=(list [circle:hall @]) ^- json
item=[cir=circle:hall count=@ud] =, enjs:format
index=@ %+ frond %chat
== %- pairs
:~
:: ::
++ generate-circle-indices :: %config
|= wir=wire :- %numbers
^- (list [circle:hall @]) :- %a
=/ data %+ turn num
%^ spin (swag [0 (lent wir)] wir) *indices-internal-state |= [cir=circle:hall len=@ud]
|= [a=@ta b=indices-internal-state] ^- json
^- [* out=indices-internal-state] %- pairs
=/ switch (dvr index.b 3) :~
?: =(q.switch 0) :: remainder 0, should be a ship [%circle (circ:enjs:hall-json cir)]
?: =(index.b 0) :: if item is null, don't add to list [%length (numb len)]
:- 0
%= b
hos.cir.item (slav %p a)
index +(index.b)
== ==
:: if item is not null, add to list
:- 0
%= b
hos.cir.item (slav %p a)
nom.cir.item *name:hall
count.item 0
lis (snoc lis.b item.b)
index +(index.b)
== ==
?: =(q.switch 1) :: remainder 1, should be a circle name
:- 0
%= b
nom.cir.item a
index +(index.b)
==
?: =(q.switch 2) :: remainder 2, should be a number
:- 0
%= b
count.item (need (rush a dem))
index +(index.b)
==
!! :: impossible
?: =(index.q.data 0)
~
(snoc lis.q.data item.q.data)
:: ::
-- --
:: ::

View File

@ -1,56 +0,0 @@
::
::
/? 309
::
/- hall
/+ chat, hall-json
::
|_ str=streams:chat
++ grow
|%
++ json
=, enjs:format
^- ^json
%+ frond %initial
%- pairs
:~
::
[%inbox (conf:enjs:hall-json inbox.str)]
::
:- %configs
%- pairs
%+ turn ~(tap by configs.str)
|= [cir=circle:hall con=(unit config:hall)]
^- [@t ^json]
:- (crip (circ:en-tape:hall-json cir))
?~(con ~ (conf:enjs:hall-json u.con))
::
:- %messages
%- pairs
%+ turn ~(tap by messages.str)
|= [cir=circle:hall lis=(list envelope:hall)]
^- [@t ^json]
:- (crip (circ:en-tape:hall-json cir))
[%a (turn lis enve:enjs:hall-json)]
::
:- %circles :- %a
%+ turn ~(tap in circles.str)
|= nom=name:hall
[%s nom]
::
:- %peers
%- pairs
%+ turn ~(tap by peers.str)
|= [cir=circle:hall per=(set @p)]
^- [@t ^json]
:- (crip (circ:en-tape:hall-json cir))
[%a (turn ~(tap in per) ship)]
::
==
--
::
++ grab
|%
++ noun streams:chat
--
--

View File

@ -15,7 +15,7 @@
:: +card: output effect payload :: +card: output effect payload
:: ::
+$ poke +$ poke
$% [%noun [@tas path]] $% [%noun [@tas path @t]]
== ==
:: ::
+$ card +$ card
@ -41,7 +41,7 @@
^- (quip move _this) ^- (quip move _this)
=/ lismov/(list move) %+ weld =/ lismov/(list move) %+ weld
`(list move)`[ost.bol %connect / [~ /'~clock'] %clock]~ `(list move)`[ost.bol %connect / [~ /'~clock'] %clock]~
`(list move)`[ost.bol %poke /clock [our.bol %launch] [%noun [%clock /tile]]]~ `(list move)`[ost.bol %poke /clock [our.bol %launch] [%noun [%clock /tile '/~clock/js/tile.js']]]~
:- lismov :- lismov
this this
:: ::

View File

@ -6,44 +6,17 @@ import classnames from 'classnames';
import Header from '/components/header'; import Header from '/components/header';
import Tile from '/components/tile'; import Tile from '/components/tile';
const loadExternalScript = (ext, callback) => {
const script = document.createElement('script');
script.src = '/~' + ext + '/tile.js';
script.id = ext;
document.body.appendChild(script);
script.onload = () => {
console.log('callback');
if (callback) callback();
};
};
export default class Home extends Component { export default class Home extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.loadedScripts = new Set();
subscription.subscribe("/main"); subscription.subscribe("/main");
} }
componentDidUpdate(prevProps, prevState) {
let difference = new Set(
[...this.props.keys]
.filter(x => !prevProps.keys.has(x))
);
difference.forEach((external) => {
loadExternalScript(external, this.forceUpdate.bind(this));
});
}
render() { render() {
let keys = [...this.props.keys]; let keys = [...this.props.keys];
console.log(keys);
let tileElems = keys.map((tile) => { let tileElems = keys.map((tile) => {
console.log(tile);
console.log(this.props.data[tile]);
return ( return (
<Tile key={tile} type={tile} data={this.props.data[tile]} /> <Tile key={tile} type={tile} data={this.props.data[tile]} />
); );

View File

@ -11,7 +11,7 @@ export default class Tile extends Component {
render() { render() {
let SpecificTile = window[this.props.type + 'Tile']; let SpecificTile = window[this.props.type + 'Tile'];
console.log(this.props.type, this.props.data);
return ( return (
<div className="fl ma2 bg-white overflow-hidden" <div className="fl ma2 bg-white overflow-hidden"
style={{ height: '234px', width: '234px' }}> style={{ height: '234px', width: '234px' }}>

View File

@ -1,11 +1,8 @@
/+ *server, collections /+ *server, collections
/= index /= index
/^ octs /^ $-(marl manx)
/; as-octs:mimes:html /: /===/app/launch/index /!noun/
/: /===/app/launch/index
/| /html/
/~ ~
==
/= script /= script
/^ octs /^ octs
/; as-octs:mimes:html /; as-octs:mimes:html
@ -35,7 +32,7 @@
[%diff %json json] [%diff %json json]
== ==
+$ tile [name=@tas subscribe=path] +$ tile [name=@tas subscribe=path]
+$ tile-data (map @tas json) +$ tile-data (map @tas [jon=json url=@t])
+$ state +$ state
$% [%0 tiles=(set tile) data=tile-data path-to-tile=(map path @tas)] $% [%0 tiles=(set tile) data=tile-data path-to-tile=(map path @tas)]
== ==
@ -49,6 +46,7 @@
++ prep ++ prep
|= old=(unit state) |= old=(unit state)
^- (quip move _this) ^- (quip move _this)
~& 'launch prep'
?~ old ?~ old
:_ this :_ this
[ost.bol %connect / [~ /] %launch]~ [ost.bol %connect / [~ /] %launch]~
@ -60,33 +58,54 @@
[~ this] [~ this]
:: ::
++ poke-noun ++ poke-noun
|= [name=@tas subscribe=path] |= [name=@tas subscribe=path url=@t]
^- (quip move _this) ^- (quip move _this)
=/ beforedata (~(get by data.sta) name)
=/ 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]~ :- [ost.bol %peer subscribe [our.bol name] subscribe]~
%= this %= this
tiles.sta (~(put in tiles.sta) [name subscribe]) tiles.sta (~(put in tiles.sta) [name subscribe])
data.sta (~(put by data.sta) name *json) 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 name)
== ==
:: ::
++ diff-json ++ diff-json
|= [pax=path jon=json] |= [pax=path jon=json]
^- (quip move _this)
=/ name/@tas (~(got by path-to-tile.sta) pax) =/ name/@tas (~(got by path-to-tile.sta) pax)
=/ data/(unit [json url=@t]) (~(get by data.sta) name)
?~ data
[~ this]
:- :-
%+ turn (prey:pubsub:userlib /main bol) %+ turn (prey:pubsub:userlib /main bol)
|= [=bone *] |= [=bone *]
[bone %diff %json (frond:enjs:format name jon)] [bone %diff %json (frond:enjs:format name jon)]
%= this %= this
data.sta (~(put by data.sta) name jon) data.sta (~(put by data.sta) name [jon url.u.data])
== ==
:: ::
++ peer-main ++ peer-main
|= [pax=path] |= [pax=path]
^- (quip move _this) ^- (quip move _this)
=/ data/json %- pairs:enjs:format ~(tap by data.sta) =/ data/json
%- pairs:enjs:format
%+ turn ~(tap by data.sta)
|= [key=@tas [jon=json url=@t]]
[key jon]
:_ this :_ this
[ost.bol %diff %json data]~ [ost.bol %diff %json data]~
:: ::
++ generate-script-marl
|= data=tile-data
^- marl
%+ turn ~(tap by data)
|= [key=@tas [jon=json url=@t]]
^- manx
;script@"{(trip url)}";
::
++ poke-handle-http-request ++ poke-handle-http-request
%- (require-authorization:app ost.bol move this) %- (require-authorization:app ost.bol move this)
|= =inbound-request:http-server |= =inbound-request:http-server
@ -100,8 +119,9 @@
i.back-path i.back-path
=/ site (flop site.request-line) =/ site (flop site.request-line)
?~ site ?~ site
=/ hym=manx (index (generate-script-marl data.sta))
:_ this :_ this
[ost.bol %http-response (html-response:app index)]~ [ost.bol %http-response (manx-response:app hym)]~
?+ site.request-line ?+ site.request-line
:_ this :_ this
[ost.bol %http-response not-found:app]~ [ost.bol %http-response not-found:app]~

View File

@ -0,0 +1,18 @@
|= 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 "stylesheet", href "/~launch/css/index.css");
==
;body
;div#root;
;script@"/~/channel/channel.js";
;script@"/~modulo/session.js";
;* scripts
;script@"/~launch/js/index.js";
==
==

View File

@ -1,16 +0,0 @@
<!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"/>
<link rel="stylesheet" href="/~launch/css/index.css" />
</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>

View File

@ -49126,7 +49126,7 @@
render() { render() {
let SpecificTile = window[this.props.type + 'Tile']; let SpecificTile = window[this.props.type + 'Tile'];
console.log(this.props.type, this.props.data);
return ( return (
react.createElement('div', { className: "fl ma2 bg-white overflow-hidden" , react.createElement('div', { className: "fl ma2 bg-white overflow-hidden" ,
style: { height: '234px', width: '234px' }, __self: this, __source: {fileName: _jsxFileName$2, lineNumber: 16}} style: { height: '234px', width: '234px' }, __self: this, __source: {fileName: _jsxFileName$2, lineNumber: 16}}
@ -49141,53 +49141,26 @@
} }
const _jsxFileName$3 = "/Users/logan/Dev/interface/apps/launch/src/js/components/home.js"; const _jsxFileName$3 = "/Users/logan/Dev/interface/apps/launch/src/js/components/home.js";
const loadExternalScript = (ext, callback) => {
const script = document.createElement('script');
script.src = '/~' + ext + '/tile.js';
script.id = ext;
document.body.appendChild(script);
script.onload = () => {
console.log('callback');
if (callback) callback();
};
};
class Home extends react_1 { class Home extends react_1 {
constructor(props) { constructor(props) {
super(props); super(props);
this.loadedScripts = new Set();
subscription.subscribe("/main"); subscription.subscribe("/main");
} }
componentDidUpdate(prevProps, prevState) {
let difference = new Set(
[...this.props.keys]
.filter(x => !prevProps.keys.has(x))
);
difference.forEach((external) => {
loadExternalScript(external, this.forceUpdate.bind(this));
});
}
render() { render() {
let keys = [...this.props.keys]; let keys = [...this.props.keys];
console.log(keys);
let tileElems = keys.map((tile) => { let tileElems = keys.map((tile) => {
console.log(tile);
console.log(this.props.data[tile]);
return ( return (
react.createElement(Tile, { key: tile, type: tile, data: this.props.data[tile], __self: this, __source: {fileName: _jsxFileName$3, lineNumber: 48}} ) react.createElement(Tile, { key: tile, type: tile, data: this.props.data[tile], __self: this, __source: {fileName: _jsxFileName$3, lineNumber: 21}} )
); );
}); });
return ( return (
react.createElement('div', { className: "fl w-100 vh-100 bg-black center" , __self: this, __source: {fileName: _jsxFileName$3, lineNumber: 53}} react.createElement('div', { className: "fl w-100 vh-100 bg-black center" , __self: this, __source: {fileName: _jsxFileName$3, lineNumber: 26}}
, react.createElement(Header, {__self: this, __source: {fileName: _jsxFileName$3, lineNumber: 54}} ) , react.createElement(Header, {__self: this, __source: {fileName: _jsxFileName$3, lineNumber: 27}} )
, react.createElement('div', { className: "v-mid pa2 dtc" , __self: this, __source: {fileName: _jsxFileName$3, lineNumber: 55}} , react.createElement('div', { className: "v-mid pa2 dtc" , __self: this, __source: {fileName: _jsxFileName$3, lineNumber: 28}}
, tileElems , tileElems
) )
) )

View File

@ -18,7 +18,7 @@
:: +card: output effect payload :: +card: output effect payload
:: ::
+$ poke +$ poke
$% [%noun [@tas path]] $% [%noun [@tas path @t]]
== ==
:: ::
+$ card +$ card
@ -46,7 +46,7 @@
^- (quip move _this) ^- (quip move _this)
=/ lismov/(list move) %+ weld =/ lismov/(list move) %+ weld
`(list move)`[ost.bol %connect / [~ /'~timer'] %timer]~ `(list move)`[ost.bol %connect / [~ /'~timer'] %timer]~
`(list move)`[ost.bol %poke /timer [our.bol %launch] [%noun [%timer /tile]]]~ `(list move)`[ost.bol %poke /timer [our.bol %launch] [%noun [%timer /tile '/~timer/js/tile.js']]]~
:- lismov :- lismov
?~ old ?~ old
this this
@ -71,7 +71,6 @@
++ poke-json ++ poke-json
|= jon=json |= jon=json
^- (quip move _this) ^- (quip move _this)
~& jon
?. ?=(%s -.jon) ?. ?=(%s -.jon)
[~ this] [~ this]
=/ str/@t +.jon =/ str/@t +.jon
@ -100,13 +99,12 @@
'' ''
i.back-path i.back-path
:: ::
~& site.request-line
?+ site.request-line ?+ site.request-line
[[ost.bol %http-response not-found:app]~ this] [[ost.bol %http-response not-found:app]~ this]
:: ::
:: tile :: tile
:: ::
[%'~timer' %tile ~] [%'~timer' %js %tile ~]
[[ost.bol %http-response (js-response:app tile-js)]~ this] [[ost.bol %http-response (js-response:app tile-js)]~ this]
:: ::
:: images :: images

View File

@ -26,7 +26,7 @@
[%wait wire @da] [%wait wire @da]
== ==
+$ poke +$ poke
$% [%noun [@tas path]] $% [%noun [@tas path @t]]
== ==
+$ state +$ state
$% [%0 data=json time=@da location=@t timer=(unit @da)] $% [%0 data=json time=@da location=@t timer=(unit @da)]
@ -45,10 +45,11 @@
++ prep ++ prep
|= old=(unit state) |= old=(unit state)
^- (quip move _this) ^- (quip move _this)
=/ lismov/(list move) %+ weld :-
`(list move)`[ost.bol %connect / [~ /'~weather'] %weather]~ :~
`(list move)`[ost.bol %poke /weather [our.bol %launch] [%noun [%weather /weathertile]]]~ [ost.bol %connect / [~ /'~weather'] %weather]
:- lismov [ost.bol %poke /weather [our.bol %launch] [%noun [%weather /weathertile '/~weather/js/tile.js']]]
==
?~ old ?~ old
this this
%= this %= this