on master help sign in
http api guide: fix codeblocks final
commit6250f16e6976a34df36128bbe0c1cbe25bc68a6f authorTinnus Napbus <admin@tinnus-napbus.xyz> dateSat 5 Mar 2022, 00:07 (5 years ago) parentefc854b
1 file changed+74−74
content/docs/userspace/http-api-guide.md+74−74
content/docs/userspace/http-api-guide.md+74−74
@@ -190,7 +190,7 @@ window.ship = "zod";
190190include this file like:
191191
192192```
193−&lt;script src="/session.js">&lt;/script>
193+<script src="/session.js"></script>
194194```
195195
196196Then 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
275275_Connect_ button is pressed:
276276
277277```
278−&lt;html>
279− &lt;head>
280− &lt;script src="https://unpkg.com/@urbit/http-api">&lt;/script>
281− &lt;/head>
282− &lt;body>
283− &lt;button id="start" type="button" onClick="connect()" >Connect&lt;/button>
284− &lt;/body>
285− &lt;script>
278+<html>
279+ <head>
280+ <script src="https://unpkg.com/@urbit/http-api"></script>
281+ </head>
282+ <body>
283+ <button id="start" type="button" onClick="connect()" >Connect</button>
284+ </body>
285+ <script>
286286 async function connect() {
287287 window.api = await UrbitHttpApi.Urbit.authenticate({
288288 ship: "zod",
@@ -292,8 +292,8 @@ _Connect_ button is pressed:
292292 });
293293 document.body.innerHTML = "Connected!";
294294 };
295− &lt;/script>
296−&lt;/html>
295+ </script>
296+</html>
297297```
298298
299299`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
325325the page.
326326
327327```
328−&lt;html>
329− &lt;head>
330− &lt;script src="https://unpkg.com/@urbit/http-api">&lt;/script>
331− &lt;script src="/session.js">&lt;/script>
332− &lt;/head>
333− &lt;body>
334− &lt;input id="msg" type="text" placeholder="Message for ship" />
335− &lt;button id="submit" type="button" onClick="doPoke()" >Submit&lt;/button>
336− &lt;p id="err">&lt;/p>
337− &lt;/body>
338− &lt;script>
328+<html>
329+ <head>
330+ <script src="https://unpkg.com/@urbit/http-api"></script>
331+ <script src="/session.js"></script>
332+ </head>
333+ <body>
334+ <input id="msg" type="text" placeholder="Message for ship" />
335+ <button id="submit" type="button" onClick="doPoke()" >Submit</button>
336+ <p id="err"></p>
337+ </body>
338+ <script>
339339 document.getElementById("msg")
340340 .addEventListener("keyup", function(event) {
341341 if (event.keyCode === 13) {
@@ -362,8 +362,8 @@ the page.
362362 document.getElementById("msg").value = "";
363363 document.getElementById("err").innerHTML = "Poke failed!";
364364 }
365− &lt;/script>
366−&lt;/html>
365+ </script>
366+</html>
367367```
368368
369369### Subscribe and Unsubscribe {#subscribe}
@@ -401,16 +401,16 @@ update it receives. You can test it by doing something like posting a message in
401401a chat. You can also unsubscribe by clicking the "Unsubscribe" button.
402402
403403```
404−&lt;html>
405− &lt;head>
406− &lt;script src="https://unpkg.com/@urbit/http-api">&lt;/script>
407− &lt;script src="/session.js">&lt;/script>
408− &lt;/head>
409− &lt;body>
410− &lt;button id="toggle" type="button" onClick="doSub()" >Subscribe&lt;/button>
411− &lt;pre id="event">&lt;/pre>
412− &lt;/body>
413− &lt;script>
404+<html>
405+ <head>
406+ <script src="https://unpkg.com/@urbit/http-api"></script>
407+ <script src="/session.js"></script>
408+ </head>
409+ <body>
410+ <button id="toggle" type="button" onClick="doSub()" >Subscribe</button>
411+ <pre id="event"></pre>
412+ </body>
413+ <script>
414414 const api = new UrbitHttpApi.Urbit("");
415415 api.ship = window.ship;
416416 const toggle = document.getElementById("toggle");
@@ -439,8 +439,8 @@ a chat. You can also unsubscribe by clicking the "Unsubscribe" button.
439439 function subFail() {
440440 event.innerHTML = "Subscription failed!";
441441 };
442− &lt;/script>
443−&lt;/html>
442+ </script>
443+</html>
444444```
445445
446446### Subscribe Once
@@ -478,16 +478,16 @@ first one it receives and close the subscription. Additionally, it sets a five
478478second timeout, and prints an error message if it times out.
479479
480480```
481−&lt;html>
482− &lt;head>
483− &lt;script src="https://unpkg.com/@urbit/http-api">&lt;/script>
484− &lt;script src="/session.js">&lt;/script>
485− &lt;/head>
486− &lt;body>
487− &lt;button type="button" onClick="doSub()" >Subscribe Once&lt;/button>
488− &lt;pre id="event">&lt;/pre>
489− &lt;/body>
490− &lt;script>
481+<html>
482+ <head>
483+ <script src="https://unpkg.com/@urbit/http-api"></script>
484+ <script src="/session.js"></script>
485+ </head>
486+ <body>
487+ <button type="button" onClick="doSub()" >Subscribe Once</button>
488+ <pre id="event"></pre>
489+ </body>
490+ <script>
491491 const api = new UrbitHttpApi.Urbit("");
492492 api.ship = window.ship;
493493 const event = document.getElementById("event");
@@ -502,8 +502,8 @@ second timeout, and prints an error message if it times out.
502502 function noEvent(error) {
503503 event.innerHTML = error;
504504 };
505− &lt;/script>
506−&lt;/html>
505+ </script>
506+</html>
507507```
508508
509509### Scries
@@ -526,16 +526,16 @@ agent's `/keys` endpoint for the list of graphs, and print the resulting JSON
526526data.
527527
528528```
529−&lt;html>
530− &lt;head>
531− &lt;script src="https://unpkg.com/@urbit/http-api">&lt;/script>
532− &lt;script src="/session.js">&lt;/script>
533− &lt;/head>
534− &lt;body>
535− &lt;button id="scry" type="button" onClick="doScry()" >Scry Graphs&lt;/button>
536− &lt;pre id="result">&lt;/pre>
537− &lt;/body>
538− &lt;script>
529+<html>
530+ <head>
531+ <script src="https://unpkg.com/@urbit/http-api"></script>
532+ <script src="/session.js"></script>
533+ </head>
534+ <body>
535+ <button id="scry" type="button" onClick="doScry()" >Scry Graphs</button>
536+ <pre id="result"></pre>
537+ </body>
538+ <script>
539539 const api = new UrbitHttpApi.Urbit("");
540540 api.ship = window.ship;
541541 async function doScry() {
@@ -543,8 +543,8 @@ data.
543543 document.getElementById("result")
544544 .innerHTML = JSON.stringify(groups, null, 2);
545545 }
546− &lt;/script>
547−&lt;/html>
546+ </script>
547+</html>
548548```
549549
550550### Thread
@@ -569,18 +569,18 @@ This example takes a hoon expression (such as `(add 1 1)`), evalutes it with the
569569`graph-eval` thread in the `landscape` desk, and prints the result.
570570
571571```
572−&lt;html>
573− &lt;head>
574− &lt;script src="https://unpkg.com/@urbit/http-api">&lt;/script>
575− &lt;script src="/session.js">&lt;/script>
576− &lt;/head>
577− &lt;body>
578− &lt;input id="hoon" type="text" placeholder="Hoon to evaluate" />
579− &lt;button id="submit" type="button" onClick="runThread()" >Submit&lt;/button>
580− &lt;pre id="expr">&lt;/pre>
581− &lt;pre id="result">&lt;/pre>
582− &lt;/body>
583− &lt;script>
572+<html>
573+ <head>
574+ <script src="https://unpkg.com/@urbit/http-api"></script>
575+ <script src="/session.js"></script>
576+ </head>
577+ <body>
578+ <input id="hoon" type="text" placeholder="Hoon to evaluate" />
579+ <button id="submit" type="button" onClick="runThread()" >Submit</button>
580+ <pre id="expr"></pre>
581+ <pre id="result"></pre>
582+ </body>
583+ <script>
584584 document.getElementById("hoon")
585585 .addEventListener("keyup", function(event) {
586586 if (event.keyCode === 13) {
@@ -604,8 +604,8 @@ This example takes a hoon expression (such as `(add 1 1)`), evalutes it with the
604604 expr.innerHTML = hoon.value;
605605 hoon.value = "";
606606 };
607− &lt;/script>
608−&lt;/html>
607+ </script>
608+</html>
609609```
610610
611611### Delete Channel