on master help sign in
http api guide: fix codeblocks final
6250f16Tinnus Napbus
content/docs/userspace/http-api-guide.md+74−74
@@ -190,7 +190,7 @@ window.ship = "zod";
190include this file like:
190include this file like:
191
191
192```
192```
193−<script src="/session.js"></script>
193+<script src="/session.js"></script>
194```
194```
195
195
196Then you need to set the `ship` field in the `Urbit` object. You would typically
196Then you need to set the `ship` field in the `Urbit` object. You would typically
@@ -275,14 +275,14 @@ Here's a simple example that will run `authenticate` for a fakezod when the
275_Connect_ button is pressed:
275_Connect_ button is pressed:
276
276
277```
277```
278−&lt;html>
278+<html>
279− &lt;head>
279+ <head>
280− &lt;script src="https://unpkg.com/@urbit/http-api">&lt;/script>
280+ <script src="https://unpkg.com/@urbit/http-api"></script>
281− &lt;/head>
281+ </head>
282− &lt;body>
282+ <body>
283− &lt;button id="start" type="button" onClick="connect()" >Connect&lt;/button>
283+ <button id="start" type="button" onClick="connect()" >Connect</button>
284− &lt;/body>
284+ </body>
285− &lt;script>
285+ <script>
286 async function connect() {
286 async function connect() {
287 window.api = await UrbitHttpApi.Urbit.authenticate({
287 window.api = await UrbitHttpApi.Urbit.authenticate({
288 ship: "zod",
288 ship: "zod",
@@ -292,8 +292,8 @@ _Connect_ button is pressed:
292 });
292 });
293 document.body.innerHTML = "Connected!";
293 document.body.innerHTML = "Connected!";
294 };
294 };
295− &lt;/script>
295+ </script>
296−&lt;/html>
296+</html>
297```
297```
298
298
299`window.api` can then be used for further communications.
299`window.api` can then be used for further communications.
@@ -325,17 +325,17 @@ reason the `hood` agent rejects the poke, "Poke failed!" will be displayed on
325the page.
325the page.
326
326
327```
327```
328−&lt;html>
328+<html>
329− &lt;head>
329+ <head>
330− &lt;script src="https://unpkg.com/@urbit/http-api">&lt;/script>
330+ <script src="https://unpkg.com/@urbit/http-api"></script>
331− &lt;script src="/session.js">&lt;/script>
331+ <script src="/session.js"></script>
332− &lt;/head>
332+ </head>
333− &lt;body>
333+ <body>
334− &lt;input id="msg" type="text" placeholder="Message for ship" />
334+ <input id="msg" type="text" placeholder="Message for ship" />
335− &lt;button id="submit" type="button" onClick="doPoke()" >Submit&lt;/button>
335+ <button id="submit" type="button" onClick="doPoke()" >Submit</button>
336− &lt;p id="err">&lt;/p>
336+ <p id="err"></p>
337− &lt;/body>
337+ </body>
338− &lt;script>
338+ <script>
339 document.getElementById("msg")
339 document.getElementById("msg")
340 .addEventListener("keyup", function(event) {
340 .addEventListener("keyup", function(event) {
341 if (event.keyCode === 13) {
341 if (event.keyCode === 13) {
@@ -362,8 +362,8 @@ the page.
362 document.getElementById("msg").value = "";
362 document.getElementById("msg").value = "";
363 document.getElementById("err").innerHTML = "Poke failed!";
363 document.getElementById("err").innerHTML = "Poke failed!";
364 }
364 }
365− &lt;/script>
365+ </script>
366−&lt;/html>
366+</html>
367```
367```
368
368
369### Subscribe and Unsubscribe {#subscribe}
369### Subscribe and Unsubscribe {#subscribe}
@@ -401,16 +401,16 @@ update it receives. You can test it by doing something like posting a message in
401a chat. You can also unsubscribe by clicking the "Unsubscribe" button.
401a chat. You can also unsubscribe by clicking the "Unsubscribe" button.
402
402
403```
403```
404−&lt;html>
404+<html>
405− &lt;head>
405+ <head>
406− &lt;script src="https://unpkg.com/@urbit/http-api">&lt;/script>
406+ <script src="https://unpkg.com/@urbit/http-api"></script>
407− &lt;script src="/session.js">&lt;/script>
407+ <script src="/session.js"></script>
408− &lt;/head>
408+ </head>
409− &lt;body>
409+ <body>
410− &lt;button id="toggle" type="button" onClick="doSub()" >Subscribe&lt;/button>
410+ <button id="toggle" type="button" onClick="doSub()" >Subscribe</button>
411− &lt;pre id="event">&lt;/pre>
411+ <pre id="event"></pre>
412− &lt;/body>
412+ </body>
413− &lt;script>
413+ <script>
414 const api = new UrbitHttpApi.Urbit("");
414 const api = new UrbitHttpApi.Urbit("");
415 api.ship = window.ship;
415 api.ship = window.ship;
416 const toggle = document.getElementById("toggle");
416 const toggle = document.getElementById("toggle");
@@ -439,8 +439,8 @@ a chat. You can also unsubscribe by clicking the "Unsubscribe" button.
439 function subFail() {
439 function subFail() {
440 event.innerHTML = "Subscription failed!";
440 event.innerHTML = "Subscription failed!";
441 };
441 };
442− &lt;/script>
442+ </script>
443−&lt;/html>
443+</html>
444```
444```
445
445
446### Subscribe Once
446### Subscribe Once
@@ -478,16 +478,16 @@ first one it receives and close the subscription. Additionally, it sets a five
478second timeout, and prints an error message if it times out.
478second timeout, and prints an error message if it times out.
479
479
480```
480```
481−&lt;html>
481+<html>
482− &lt;head>
482+ <head>
483− &lt;script src="https://unpkg.com/@urbit/http-api">&lt;/script>
483+ <script src="https://unpkg.com/@urbit/http-api"></script>
484− &lt;script src="/session.js">&lt;/script>
484+ <script src="/session.js"></script>
485− &lt;/head>
485+ </head>
486− &lt;body>
486+ <body>
487− &lt;button type="button" onClick="doSub()" >Subscribe Once&lt;/button>
487+ <button type="button" onClick="doSub()" >Subscribe Once</button>
488− &lt;pre id="event">&lt;/pre>
488+ <pre id="event"></pre>
489− &lt;/body>
489+ </body>
490− &lt;script>
490+ <script>
491 const api = new UrbitHttpApi.Urbit("");
491 const api = new UrbitHttpApi.Urbit("");
492 api.ship = window.ship;
492 api.ship = window.ship;
493 const event = document.getElementById("event");
493 const event = document.getElementById("event");
@@ -502,8 +502,8 @@ second timeout, and prints an error message if it times out.
502 function noEvent(error) {
502 function noEvent(error) {
503 event.innerHTML = error;
503 event.innerHTML = error;
504 };
504 };
505− &lt;/script>
505+ </script>
506−&lt;/html>
506+</html>
507```
507```
508
508
509### Scries
509### Scries
@@ -526,16 +526,16 @@ agent's `/keys` endpoint for the list of graphs, and print the resulting JSON
526data.
526data.
527
527
528```
528```
529−&lt;html>
529+<html>
530− &lt;head>
530+ <head>
531− &lt;script src="https://unpkg.com/@urbit/http-api">&lt;/script>
531+ <script src="https://unpkg.com/@urbit/http-api"></script>
532− &lt;script src="/session.js">&lt;/script>
532+ <script src="/session.js"></script>
533− &lt;/head>
533+ </head>
534− &lt;body>
534+ <body>
535− &lt;button id="scry" type="button" onClick="doScry()" >Scry Graphs&lt;/button>
535+ <button id="scry" type="button" onClick="doScry()" >Scry Graphs</button>
536− &lt;pre id="result">&lt;/pre>
536+ <pre id="result"></pre>
537− &lt;/body>
537+ </body>
538− &lt;script>
538+ <script>
539 const api = new UrbitHttpApi.Urbit("");
539 const api = new UrbitHttpApi.Urbit("");
540 api.ship = window.ship;
540 api.ship = window.ship;
541 async function doScry() {
541 async function doScry() {
@@ -543,8 +543,8 @@ data.
543 document.getElementById("result")
543 document.getElementById("result")
544 .innerHTML = JSON.stringify(groups, null, 2);
544 .innerHTML = JSON.stringify(groups, null, 2);
545 }
545 }
546− &lt;/script>
546+ </script>
547−&lt;/html>
547+</html>
548```
548```
549
549
550### Thread
550### Thread
@@ -569,18 +569,18 @@ This example takes a hoon expression (such as `(add 1 1)`), evalutes it with the
569`graph-eval` thread in the `landscape` desk, and prints the result.
569`graph-eval` thread in the `landscape` desk, and prints the result.
570
570
571```
571```
572−&lt;html>
572+<html>
573− &lt;head>
573+ <head>
574− &lt;script src="https://unpkg.com/@urbit/http-api">&lt;/script>
574+ <script src="https://unpkg.com/@urbit/http-api"></script>
575− &lt;script src="/session.js">&lt;/script>
575+ <script src="/session.js"></script>
576− &lt;/head>
576+ </head>
577− &lt;body>
577+ <body>
578− &lt;input id="hoon" type="text" placeholder="Hoon to evaluate" />
578+ <input id="hoon" type="text" placeholder="Hoon to evaluate" />
579− &lt;button id="submit" type="button" onClick="runThread()" >Submit&lt;/button>
579+ <button id="submit" type="button" onClick="runThread()" >Submit</button>
580− &lt;pre id="expr">&lt;/pre>
580+ <pre id="expr"></pre>
581− &lt;pre id="result">&lt;/pre>
581+ <pre id="result"></pre>
582− &lt;/body>
582+ </body>
583− &lt;script>
583+ <script>
584 document.getElementById("hoon")
584 document.getElementById("hoon")
585 .addEventListener("keyup", function(event) {
585 .addEventListener("keyup", function(event) {
586 if (event.keyCode === 13) {
586 if (event.keyCode === 13) {
@@ -604,8 +604,8 @@ This example takes a hoon expression (such as `(add 1 1)`), evalutes it with the
604 expr.innerHTML = hoon.value;
604 expr.innerHTML = hoon.value;
605 hoon.value = "";
605 hoon.value = "";
606 };
606 };
607− &lt;/script>
607+ </script>
608−&lt;/html>
608+</html>
609```
609```
610
610
611### Delete Channel
611### Delete Channel