Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
9908dee
Add more options to server
cmontella Jul 30, 2017
d561cd4
Get rid of old watcher file
cmontella Jul 30, 2017
0a0ae0a
Watchers self-report their name
cmontella Jul 30, 2017
28436ad
make watchers self-report their name
cmontella Jul 30, 2017
97fa1de
new options for main exe
cmontella Jul 30, 2017
b2b8749
Print a message when a watcher is attached
cmontella Jul 30, 2017
5f7e587
Merge remote-tracking branch 'refs/remotes/origin/master' into featur…
cmontella Jul 31, 2017
f65b0cd
add ability to set name on watcher
cmontella Jul 31, 2017
ac9e3a5
add watcher skeleton
cmontella Jul 31, 2017
587c9b9
Merge remote-tracking branch 'refs/remotes/origin/master' into featur…
cmontella Jul 31, 2017
1f61855
Fix loading watcher in main
cmontella Jul 31, 2017
9a4690a
rename print diff to match TS version
cmontella Jul 31, 2017
d90b930
fix spelling, remove println
cmontella Jul 31, 2017
bbb140f
Merge remote-tracking branch 'refs/remotes/origin/master' into featur…
cmontella Jul 31, 2017
c646ba2
Merge remote-tracking branch 'refs/remotes/origin/master' into featur…
cmontella Aug 1, 2017
acf015c
Merge remote-tracking branch 'refs/remotes/origin/feature/more-server…
cmontella Aug 1, 2017
8081023
Json deserialize
cmontella Aug 1, 2017
d2cbada
update json decoding
cmontella Aug 1, 2017
c9fa39a
Merge remote-tracking branch 'refs/remotes/origin/master' into featur…
cmontella Aug 1, 2017
2f14f6f
Serialize records
cmontella Aug 2, 2017
f628b67
Merge remote-tracking branch 'refs/remotes/origin/master' into featur…
cmontella Aug 2, 2017
6b959ae
Try nested records again
cmontella Aug 3, 2017
dd094c3
commit tests
cmontella Aug 3, 2017
55505d2
Merge remote-tracking branch 'refs/remotes/origin/master' into featur…
cmontella Aug 7, 2017
274f4de
add hyper dep
cmontella Aug 7, 2017
ff41684
test http send
cmontella Aug 7, 2017
6a4c845
add http watcher
cmontella Aug 7, 2017
102ed36
Merge remote-tracking branch 'refs/remotes/origin/master' into featur…
cmontella Aug 7, 2017
da3e34b
Merge remote-tracking branch 'refs/remotes/origin/master' into featur…
cmontella Aug 9, 2017
63e4cd9
fix watcher import
cmontella Aug 9, 2017
bb5a021
inject response into eve
cmontella Aug 9, 2017
15d155b
test HTTP request
cmontella Aug 9, 2017
a8858b7
Merge remote-tracking branch 'refs/remotes/origin/master' into featur…
cmontella Aug 9, 2017
da76889
Merge remote-tracking branch 'refs/remotes/origin/master' into featur…
cmontella Aug 9, 2017
4752d2e
Merge remote-tracking branch 'refs/remotes/origin/master' into featur…
cmontella Aug 9, 2017
d85ab5b
Fix up deser
cmontella Aug 10, 2017
371bd8f
json encoding
cmontella Aug 10, 2017
548e44a
tests
cmontella Aug 10, 2017
45874e5
Merge remote-tracking branch 'refs/remotes/origin/master' into featur…
cmontella Aug 10, 2017
bf70661
Merge remote-tracking branch 'refs/remotes/origin/master' into featur…
cmontella Aug 10, 2017
14432b9
test if we are in the process of decoding
cmontella Aug 10, 2017
3db35b5
Merge remote-tracking branch 'refs/remotes/origin/feature/json-watche…
cmontella Aug 10, 2017
523a0e8
add http to main
cmontella Aug 10, 2017
0f21740
add from_str method for internables
cmontella Aug 10, 2017
20d08bd
rename some things in JSON watcher
cmontella Aug 10, 2017
a568b6b
update http requests
cmontella Aug 10, 2017
39a448c
update example
cmontella Aug 10, 2017
0e246e7
stub in http server
cmontella Aug 10, 2017
c0c921f
Stub in http error
cmontella Aug 10, 2017
aefe11b
Add https support
cmontella Aug 11, 2017
fffa212
Decode into a string, implement https on sender
cmontella Aug 11, 2017
2d63257
do some cleanup
cmontella Aug 11, 2017
4691364
remove println
cmontella Aug 11, 2017
9ea340f
update test
cmontella Aug 11, 2017
87a629d
Start an http server in Eve
cmontella Aug 12, 2017
20db817
Merge branch 'master' into feature/http
cmontella Aug 14, 2017
c0a7af8
Merge branch 'master' into feature/http
cmontella Aug 15, 2017
62d3d37
add redirect
cmontella Aug 15, 2017
ed9a760
Add url-change event
cmontella Aug 16, 2017
4dd0834
Add page-show event
cmontella Aug 16, 2017
9040857
decode URL queries
cmontella Aug 16, 2017
a414907
handle multiple reuquests at once
cmontella Aug 17, 2017
bcb6191
Plumb in errors
cmontella Aug 17, 2017
4d668c7
Merge branch 'master' into feature/http
cmontella Aug 17, 2017
5f3a423
clean up some things
cmontella Aug 17, 2017
b209b4c
Add string/url-encode and string/encode
cmontella Aug 18, 2017
8db57fa
Property intern ints
cmontella Aug 18, 2017
d219c37
default body
cmontella Aug 18, 2017
acd6d55
add tag to url query
cmontella Aug 18, 2017
b8c7809
ignore vscode file
cmontella Aug 18, 2017
0639979
Parse kvs in hash string
cmontella Aug 20, 2017
089d7d0
parse bools in json
cmontella Aug 22, 2017
7a64f61
implement a stream watcher
cmontella Aug 22, 2017
20e9202
handle multiple chunks
cmontella Aug 23, 2017
48b80ee
more edits to setlist app
cmontella Aug 23, 2017
e0639d3
update json from http watcher
cmontella Aug 23, 2017
73e391f
Merge branch 'master' into feature/json-watcher
cmontella Aug 23, 2017
dc532a5
don't include json file
cmontella Aug 23, 2017
b62233b
Merge branch 'master' into feature/http
cmontella Aug 24, 2017
dff2b5f
Merge branch 'master' into feature/http
cmontella Aug 24, 2017
aca663e
fix merge conflicts
cmontella Aug 24, 2017
b887143
properly sort chunks
cmontella Aug 24, 2017
74ffb12
Lay groundwork for putting HTTP requests into Eve
cmontella Aug 25, 2017
416fb33
put body in response, mark requests as finished
cmontella Aug 25, 2017
b3e3ae3
save progress on setlist app
cmontella Aug 26, 2017
d75235e
updates to setlist app
cmontella Aug 29, 2017
3ff52d5
updates to groove and setlist
cmontella Aug 30, 2017
43f0579
save state for update
cmontella Aug 30, 2017
61ac1b7
Merge branch 'master' into feature/json-watcher
cmontella Aug 30, 2017
b051e0a
Fix some json bugs
cmontella Aug 31, 2017
c288c27
Do encoding in Eve
cmontella Sep 1, 2017
bdf44a2
undo accidental commit
cmontella Sep 1, 2017
38a15c4
Merge branch 'master' into feature/json-watcher
cmontella Sep 1, 2017
d85779a
update markdown in json
cmontella Sep 1, 2017
692a058
remove println
cmontella Sep 1, 2017
c26bca7
fix warnings
cmontella Sep 1, 2017
529e3ae
remove test file
cmontella Sep 1, 2017
3538e0f
Merge branch 'feature/http' into feature/json-watcher
cmontella Sep 1, 2017
f3271bb
Merge pull request #43 from Kodowa/feature/json-watcher
cmontella Sep 1, 2017
3b9a660
done define json twice
cmontella Sep 1, 2017
2ddb1d9
done use json twice
cmontella Sep 1, 2017
54fe789
fix error in package
cmontella Sep 1, 2017
026e54b
Update http intro
cmontella Sep 1, 2017
33d5b55
fix escape chars
cmontella Sep 2, 2017
c567f05
add test for base strings and escapes
cmontella Sep 2, 2017
06db611
Merge branch 'master' into fix/escape-chars
cmontella Sep 2, 2017
3753420
escape \
cmontella Sep 2, 2017
20bb24c
Merge branch 'fix/escape-chars' into feature/json-watcher
cmontella Sep 2, 2017
b66c058
fix some merge errors, use " instead of '
cmontella Sep 2, 2017
ab69895
remove test
cmontella Sep 2, 2017
5fa8057
Merge branch 'master' into feature/http
cmontella Sep 3, 2017
dcec730
Merge branch 'feature/http' into feature/json-watcher
cmontella Sep 6, 2017
605ba9c
delete accidental file
cmontella Sep 6, 2017
2752fc5
fix includes
cmontella Sep 6, 2017
04df1c2
remove setlist app from this branch
cmontella Sep 6, 2017
de547ae
remove unnecessary pipes
cmontella Sep 6, 2017
608cc7e
don't parse query strings and hash strings automatically
cmontella Sep 6, 2017
22a6ba8
cut hls from this PR
cmontella Sep 6, 2017
0e14036
remove response when we've got a handle on it
cmontella Sep 6, 2017
7853169
add a response/change event
cmontella Sep 6, 2017
f7668c2
fix typo
cmontella Sep 6, 2017
fbadded
pass through numbers
cmontella Sep 6, 2017
b255048
try to update this diff
cmontella Sep 6, 2017
e35fa07
parse query strings automatically
cmontella Sep 6, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ node_modules/
build/
dist/
.vscode/tasks.json
examples/test.eve
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,11 @@ unicode-segmentation = "1.1.0"
iron = "0.5"
staticfile = "*"
mount = "*"
hyper = "0.11.2"
hyper-tls = "0.1.2"
futures = "0.1.14"
tokio-core = "0.1.9"
data-encoding = "1.2.0"
urlencoding = "1.0.0"
natord = "1.0.9"
notify = "4.0.0"
159 changes: 159 additions & 0 deletions examples/json-demo.eve
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# JSON Testing

## Test Encoding

commit
corey = [#person name: "Corey" | age: 31]
giselle = [#cat name: "Giselle" | age: 7]
twylah = [#cat name: "Twylah" | age: 7]
rachel = [#person name: "Rachel" | age: 28 cats: (giselle, twylah) husband: corey]
end

commit
[#system/timer resolution: 1000]
end

search
p = [#person name: "Rachel" age]
[#system/timer second]
bind
p.time += second
end

search
p = [#person name: "Rachel"]
bind
[#json/encode record: p]
end

commit
[#ui/button #change-record sort: -1 text: "Change"]
[#ui/button #add-record sort: -1 text: "Add"]
end

search
[#html/event/click element: [#change-record]]
p = [#person name: "Rachel"]
commit
p.age := 29
end

search
[#html/event/click element: [#add-record]]
p = [#person name: "Rachel"]
commit
p.foo := "Hello"
end



search
[#json/encode json-string]
bind
[#html/div text: "Encoded JSON: {{json-string}}"]
end

## Test Decode

Decode the record we just encoded

//search
//[#json/encode json-string]
//commit
//[#json/decode json: json-string]
//end

//search
//[#json/decode json-object]
//commit
//[#html/div text: "Decoded JSON: {{json-object.name}} is {{json-object.age}} years old"]
//end


//commit
//[#ui/button #add-record text: "Add to record"]
//[#ui/button #remove-record text: "Remove From Record"]
//end

## Debug Display

search
[#json/encode]
[#json/encode/record record json-string]
output = [#output]
bind
output.children += [#html/div sort: json-string text: "Target: {{json-string}}"]
end

search
[#json/encode]
[#json/encode/sub-target record json-string]
output = [#output]
bind
output.children += [#html/div text: "Sub: {{json-string}}"]
end

search
[#json/encode]
[#completed/target record json-string]
output = [#application]
bind
output.children += [#html/div text: "Completed {{json-string}}"]
end

search
[#json/encode]
encode = [#encode-eavs]
eav = [#json/encode/eav record attribute value]
entity? = if eav = [#json/encode/entity] then "entity"
else ""
bind
encode <- [children:
[#html/div sort: 0 text: "Encode EAVs"]
[#html/table #eav-table | children:
[#html/tr #eav-row eav children:
[#html/td sort:1 text: record]
[#html/td sort:2 text: attribute]
[#html/td sort:3 text: value]
[#html/td sort:4 text: entity?]
]
]

]
end

search
[#json/encode]
encode = [#flatten]
[#json/encode/flatten record]
bind
encode <- [children:
[#html/div sort: 0 text: "Flatten"]
[#html/div sort: 1 text: "{{record}}"]
]
end

search
[#json/encode]
commit
[#ui/column #application | children:
[#ui/column #output | children:
[#ui/button #next sort: -1 text: "Next"]
]
[#ui/row #debug | children:
[#ui/column #encode-eavs]
[#ui/column #flatten]
]
]
end

commit
[#html/style text: "
td {padding: 10px;}
table {margin: 10px;}
.ui/column {padding: 10px;}
.ui/row {padding: 10px;}
.output {padding: 20px;}
.encode-eavs {min-width: 350px;}
"]
end
14 changes: 14 additions & 0 deletions libraries/html/html.eve
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ commit
"li"
"ul"
"ol"
"audio"
"source"
"video"
"table"
"tr"
"td"
)]
end
~~~
Expand Down Expand Up @@ -373,3 +379,11 @@ watch client/websocket
("html/export triggers" element trigger)
end
~~~

Redirect to a url.
~~~ eve
search
[#html/redirect url]
watch client/websocket
("html/redirect" url)
end
42 changes: 37 additions & 5 deletions libraries/html/html.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import md5 from "md5";
import "setimmediate";
import {Program, Library, createId, RawValue, RawEAV, RawMap, handleTuples} from "../../ts";
import url from "url";

const EMPTY:never[] = [];

Expand Down Expand Up @@ -99,23 +100,27 @@ export class HTML extends Library {
this._dummy = document.createElement("div");

window.addEventListener("resize", this._resizeEventHandler("resize-window"));

// Mouse events
window.addEventListener("click", this._mouseEventHandler("click"));
window.addEventListener("dblclick", this._mouseEventHandler("double-click"));
window.addEventListener("mousedown", this._mouseEventHandler("mouse-down"));
window.addEventListener("mouseup", this._mouseEventHandler("mouse-up"));
window.addEventListener("contextmenu", this._captureContextMenuHandler());
document.body.addEventListener("mouseenter", this._hoverEventHandler("hover-in"), true);
document.body.addEventListener("mouseleave", this._hoverEventHandler("hover-out"), true);

// Form events
window.addEventListener("change", this._changeEventHandler("change"));
window.addEventListener("input", this._inputEventHandler("change"));
window.addEventListener("keydown", this._keyEventHandler("key-down"));
window.addEventListener("keyup", this._keyEventHandler("key-up"));
window.addEventListener("focus", this._focusEventHandler("focus"), true);
window.addEventListener("blur", this._focusEventHandler("blur"), true);

document.body.addEventListener("mouseenter", this._hoverEventHandler("hover-in"), true);
document.body.addEventListener("mouseleave", this._hoverEventHandler("hover-out"), true);
// Keyboard events
window.addEventListener("keydown", this._keyEventHandler("key-down"));
window.addEventListener("keyup", this._keyEventHandler("key-up"));

// window.addEventListener("hashchange", this._hashChangeHandler("url-change"));
this.getURL(window.location);
}

protected decorate(elem:Element, elemId:RawValue): Instance {
Expand Down Expand Up @@ -397,6 +402,11 @@ export class HTML extends Library {
if(!instance.__capturedKeys) instance.__capturedKeys = {[code]: true};
else instance.__capturedKeys[code] = true;
}
}),
"redirect": handleTuples(({adds, removes}) => {
for(let [url] of adds || EMPTY) {
window.location.replace(`${url}`);
}
})
};

Expand Down Expand Up @@ -631,6 +641,28 @@ export class HTML extends Library {
if(eavs.length) this._sendEvent(eavs);
};
}

getURL(location: Location) {
let {hash, host, hostname, href, pathname, port, protocol, search} = location;
let eavs:RawEAV[] = [];
let urlId = createId();
eavs.push(
[urlId, "tag", "html/url"],
[urlId, "host", `${host}`],
[urlId, "hostname", `${hostname}`],
[urlId, "href", `${href}`],
[urlId, "pathname", `${pathname}`],
[urlId, "port", `${port}`],
[urlId, "protocol", `${protocol}`],
);
if(hash !== "") {
eavs.push([urlId, "hash", `${hash.substring(1)}`]);
}
if(search !== "") {
eavs.push([urlId, "query", `${search.substring(1)}`]);
}
this._sendEvent(eavs);
}
}

Library.register(HTML.id, HTML);
Expand Down
Loading