diff --git a/library.dylan b/library.dylan index 3279a70..2d91ab0 100644 --- a/library.dylan +++ b/library.dylan @@ -55,7 +55,7 @@ define module dylan-playground respond-to-post, server-root }; use json, - import: { encode-json, parse-json, }; + import: { print-json, parse-json, }; use locators, import: { , , diff --git a/play.dylan b/play.dylan index 8880ee9..8830662 100644 --- a/play.dylan +++ b/play.dylan @@ -85,7 +85,7 @@ define taglib playground () output("%s", get-attribute(page-context(), $main-code-attr) | get-query-value($main-code-attr) - | find-example-code($hello-world)); + | find-example-code($default-example)); end; tag library-code (page :: ) () begin @@ -95,9 +95,10 @@ define taglib playground () tag examples-menu (page :: ) () for (v in $examples) let name = v[0]; - output("\n", name, name); + output("\n", + name, (name = $default-example & "selected") | "", name); end; - tag example (page :: ) (name :: = $hello-world) + tag example (page :: ) (name :: = $default-example) output(find-example-code(name) | "example not found"); end; @@ -119,7 +120,7 @@ define method respond-to-post (resource :: , #key) => () else result[$compiler-output-attr] := "Please enter some code."; end; - encode-json(current-response(), result); + print-json(result, current-response()); end method; define function generate-project-name () => (project-name :: ) @@ -253,7 +254,7 @@ define module %s use print; use pprint; use streams; - // from libraries with only one exported module + // from libraries with one module, named the same as the library. use hash-algorithms; use logging; use regular-expressions; diff --git a/share.dylan b/share.dylan index 70393b3..754ed46 100644 --- a/share.dylan +++ b/share.dylan @@ -37,7 +37,7 @@ define method respond-to-post (resource :: , #key) => () else result["error"] := "nothing to share!"; end; - encode-json(current-response(), result); + print-json(result, current-response()); end method; // 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 :: , text :: ) => () fs/with-open-file (stream = locator, direction: #"output", if-does-not-exist: #"create") - encode-json(stream, begin - let t = make(); - t["format"] := $share-format; - t["code"] := text; - t - end); + print-json(begin + let t = make(); + t["format"] := $share-format; + t["code"] := text; + t + end, + stream); end; end function;