pages.html 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. {{define "guide"}}<article class="doc">
  2. <p class="crumb">{{.Guide.Guide.Group}}</p>
  3. <h1 class="doc-title">{{.Title}}</h1>
  4. {{with .Desc}}<p class="doc-lead">{{.}}</p>{{end}}
  5. <div class="prose">
  6. {{.Guide.Intro}}
  7. {{range .Guide.Items}}{{heading .Heading.Level .Heading.ID .Heading.Aliases .Heading.HTML}}
  8. {{.Body}}
  9. {{end}}
  10. </div>
  11. </article>{{end}}
  12. {{define "ref"}}<article class="doc">
  13. <p class="crumb">{{if .Ref.Builtin}}Built-in functions{{else}}Library{{end}}</p>
  14. <h1 class="doc-title">{{if .Ref.Builtin}}{{.Title}}{{else}}<code>{{.Title}}</code>{{end}}</h1>
  15. {{with .Desc}}<p class="doc-lead">{{.}}</p>{{end}}
  16. <div class="meta-row">
  17. {{if .Ref.Page.Load}}<span class="load"><code>{{.Ref.Page.Load}}</code><button type="button" class="copy-mini" data-copy="{{.Ref.Page.Load}}" aria-label="Copy">{{icon "copy"}}</button></span>{{else}}<span class="pill">Always available, no <code>requirelib()</code></span>{{end}}
  18. {{if .Ref.Index}}<span class="pill">{{len .Ref.Index}} functions</span>{{end}}
  19. <a class="pill pill-pg" href="../playground.html" title="{{if eq .Ref.Play "runs"}}The playground runs this against its virtual drive and session{{else}}The playground answers with the responses you set in its {{.Ref.Play}} window{{end}}">{{icon "play"}}{{if eq .Ref.Play "runs"}}Runs in the playground{{else}}Mocked in the playground ({{.Ref.Play}} window){{end}}</a>
  20. </div>
  21. <div class="prose">{{.Ref.Intro}}</div>
  22. {{if .Ref.Index}}<details class="fn-index"{{if le (len .Ref.Index) 24}} open{{end}}>
  23. <summary>Functions <span>{{len .Ref.Index}}</span></summary>
  24. <table>
  25. <tbody>{{range .Ref.Index}}<tr><td><a href="#{{.Anchor}}"><code>{{.Name}}</code></a></td><td class="ix-ret">{{with .Ret}}<code>{{.}}</code>{{end}}</td><td class="ix-desc">{{.Desc}}</td></tr>{{end}}</tbody>
  26. </table>
  27. </details>{{end}}
  28. <div class="prose ref-body">
  29. {{range .Ref.Items}}{{if .Fn}}{{template "fn" .Fn}}{{else}}{{heading .Heading.Level .Heading.ID .Heading.Aliases .Heading.HTML}}
  30. {{.Body}}{{end}}
  31. {{end}}
  32. </div>
  33. </article>{{end}}
  34. {{define "fn"}}<section class="fn" id="{{.ID}}">
  35. {{range .Aliases}}<span id="{{.}}" class="alias"></span>{{end}}
  36. <div class="fn-head">
  37. {{range $i, $s := .Sigs}}<div class="fn-sig"{{if eq $i 0}} role="heading" aria-level="{{$.Level}}"{{end}}>
  38. <code class="sig"><span class="sig-name">{{.Name}}</span>{{with .Args}}<span class="sig-args">{{.}}</span>{{end}}</code>
  39. {{with .Ret}}<span class="ret" title="Returns">{{.}}</span>{{end}}
  40. {{if eq $i 0}}{{range $.Badges}}<span class="badge">{{.}}</span>{{end}}<a class="hd-link" href="#{{$.ID}}" aria-label="Link to {{.Name}}">#</a>{{end}}
  41. </div>
  42. {{with .Also}}<p class="also">Also covers {{range $j, $n := .}}{{if $j}}, {{end}}<code>{{$n}}</code>{{end}}</p>{{end}}
  43. {{with .Desc}}<p class="fn-desc">{{.}}</p>{{end}}{{end}}
  44. </div>
  45. {{if .Body}}<div class="fn-body">{{.Body}}</div>{{end}}
  46. {{range .Examples}}<pre class="example"><code class="language-javascript">{{.}}</code></pre>{{end}}
  47. </section>{{end}}
  48. {{define "home"}}<section class="hero">
  49. <div class="hero-glow" aria-hidden="true"></div>
  50. <div class="hero-in">
  51. <p class="eyebrow">ArozOS Developers</p>
  52. <h1 class="hero-title">Build WebApps with <span class="grad">AGI</span>.</h1>
  53. <p class="hero-lead">AGI is the server-side JavaScript runtime of ArozOS. Your WebApp's scripts read and write the user's files, keep data, talk to other services and answer the page, all inside the user's permissions.</p>
  54. <div class="btns">
  55. <a class="btn primary" href="introduction.html">Get started</a>
  56. <a class="btn secondary" href="playground.html">{{icon "play"}}<span>Open the playground</span></a>
  57. </div>
  58. <button type="button" class="hero-search" data-search-open>{{icon "search"}}<span>Search {{.Home.FnCount}} functions</span><kbd data-kbd>Ctrl K</kbd></button>
  59. </div>
  60. </section>
  61. <section class="band">
  62. <div class="wrap">
  63. <div class="quick">
  64. <a class="qcard" href="introduction.html">
  65. <span class="qicon">{{icon "book"}}</span>
  66. <h2>Guides</h2>
  67. <p>What AGI is, where scripts run, the globals they see and how paths and permissions work.</p>
  68. <span class="qmore">Read the introduction {{icon "arrow-right"}}</span>
  69. </a>
  70. <a class="qcard" href="reference/core.html">
  71. <span class="qicon">{{icon "code"}}</span>
  72. <h2>API reference</h2>
  73. <p>Every function of every library, with its signature, return value and an example you can run.</p>
  74. <span class="qmore">Browse the reference {{icon "arrow-right"}}</span>
  75. </a>
  76. <a class="qcard" href="playground.html">
  77. <span class="qicon">{{icon "play"}}</span>
  78. <h2>Playground</h2>
  79. <p>The real Otto interpreter in your browser, a virtual file system to upload to, and mock services for HTTP, LLM and CNN.</p>
  80. <span class="qmore">Try {{.Home.Samples}} samples {{icon "arrow-right"}}</span>
  81. </a>
  82. </div>
  83. </div>
  84. </section>
  85. <section class="band">
  86. <div class="wrap">
  87. <div class="split">
  88. <div>
  89. <h2 class="band-title">A first script</h2>
  90. <p class="band-lead">A WebApp's page calls its backend script with <code>ao_module_agirun()</code>. The script runs as the signed-in user and answers with <code>sendResp</code> or <code>sendJSONResp</code>.</p>
  91. <ul class="start">{{range .Home.Start}}<li><a href="{{.URL}}"><strong>{{.Title}}</strong><span>{{.Sub}}</span></a></li>{{end}}</ul>
  92. </div>
  93. <pre class="example hero-code"><code class="language-javascript">// MyApp/backend.agi
  94. requirelib("filelib");
  95. var notes = filelib.readdir("user:/Documents");
  96. var names = [];
  97. for (var i = 0; i &lt; notes.length; i++) {
  98. if (!notes[i].IsDir) names.push(notes[i].Filename);
  99. }
  100. sendJSONResp({ user: USERNAME, files: names });</code></pre>
  101. </div>
  102. </div>
  103. </section>
  104. <section class="band">
  105. <div class="wrap">
  106. <h2 class="band-title">Built-in functions</h2>
  107. <p class="band-lead">Always there, without <code>requirelib()</code>.</p>
  108. <div class="libs">{{range .Home.Builtins}}{{template "libcard" .}}{{end}}</div>
  109. <h2 class="band-title">Libraries</h2>
  110. <p class="band-lead">Load one with <code>requirelib("name")</code> before using it.</p>
  111. <div class="libs">{{range .Home.Libraries}}{{template "libcard" .}}{{end}}</div>
  112. </div>
  113. </section>{{end}}
  114. {{define "libcard"}}<a class="lib" href="{{.URL}}">
  115. <span class="lib-ic">{{icon .Icon}}</span>
  116. <span class="lib-txt"><strong>{{.Title}}</strong><span>{{.Desc}}</span></span>
  117. <span class="lib-n">{{.Count}}</span>
  118. </a>{{end}}