Skip to content

Commit 68440de

Browse files
committed
Update for new json printer
1 parent 2c24c12 commit 68440de

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

library.dylan

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ define module dylan-playground
5555
respond-to-post,
5656
server-root };
5757
use json,
58-
import: { encode-json, parse-json, <json-parse-error> };
58+
import: { print-json, parse-json, <json-parse-error> };
5959
use locators,
6060
import: { <directory-locator>,
6161
<file-locator>,

play.dylan

+6-5
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ define taglib playground ()
8585
output("%s",
8686
get-attribute(page-context(), $main-code-attr)
8787
| get-query-value($main-code-attr)
88-
| find-example-code($hello-world));
88+
| find-example-code($default-example));
8989
end;
9090
tag library-code (page :: <playground-page>) ()
9191
begin
@@ -95,9 +95,10 @@ define taglib playground ()
9595
tag examples-menu (page :: <playground-page>) ()
9696
for (v in $examples)
9797
let name = v[0];
98-
output("<option value=\"%s\">%s</option>\n", name, name);
98+
output("<option value=\"%s\" %s>%s</option>\n",
99+
name, (name = $default-example & "selected") | "", name);
99100
end;
100-
tag example (page :: <playground-page>) (name :: <string> = $hello-world)
101+
tag example (page :: <playground-page>) (name :: <string> = $default-example)
101102
output(find-example-code(name) | "example not found");
102103
end;
103104

@@ -119,7 +120,7 @@ define method respond-to-post (resource :: <build-and-run>, #key) => ()
119120
else
120121
result[$compiler-output-attr] := "Please enter some code.";
121122
end;
122-
encode-json(current-response(), result);
123+
print-json(result, current-response());
123124
end method;
124125

125126
define function generate-project-name () => (project-name :: <string>)
@@ -253,7 +254,7 @@ define module %s
253254
use print;
254255
use pprint;
255256
use streams;
256-
// from libraries with only one exported module
257+
// from libraries with one module, named the same as the library.
257258
use hash-algorithms;
258259
use logging;
259260
use regular-expressions;

share.dylan

+8-7
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ define method respond-to-post (resource :: <create-share>, #key) => ()
3737
else
3838
result["error"] := "nothing to share!";
3939
end;
40-
encode-json(current-response(), result);
40+
print-json(result, current-response());
4141
end method;
4242

4343
// Generate a key to use to find a playground share. The key is used in the
@@ -78,12 +78,13 @@ define function save-share (key :: <string>, text :: <string>) => ()
7878
fs/with-open-file (stream = locator,
7979
direction: #"output",
8080
if-does-not-exist: #"create")
81-
encode-json(stream, begin
82-
let t = make(<string-table>);
83-
t["format"] := $share-format;
84-
t["code"] := text;
85-
t
86-
end);
81+
print-json(begin
82+
let t = make(<string-table>);
83+
t["format"] := $share-format;
84+
t["code"] := text;
85+
t
86+
end,
87+
stream);
8788
end;
8889
end function;
8990

0 commit comments

Comments
 (0)