index.html 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <!DOCTYPE html>
  2. <html><head><meta charset="utf-8" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  3. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  4. <meta name="description" content="" />
  5. <meta name="author" content="Maxim Sokhatsky" />
  6. <title>NITRO</title>
  7. <link rel="stylesheet" href="https://n2o.dev/blank.css?x=14" />
  8. <link rel="stylesheet" href="https://n2o.dev/zima.css?x=14" />
  9. </head><body><nav>
  10. <a href="https://n2o.dev">DEV</a>
  11. <a href="https://nitro.n2o.space" style="background:#ededed;">NITRO</a>
  12. <div class="dropdown">
  13. <a onclick="drop()" class="dropbtn">EN</a>
  14. <div id="dropdown" class="dropdown-content">
  15. <a href="https://n2o.dev/deps/nitro/man/ua/index.html">UA</a>
  16. <a href="https://nitro.n2o.space/">EN</a>
  17. </div>
  18. </div>
  19. </nav><header>
  20. <a href="https://github.com/synrc/nitro"><img src="https://synrc.space/images/Synrc Neo.svg?v=1" /></a>
  21. <h1>NITRO</h1>
  22. </header><aside>
  23. <article>
  24. <section>
  25. <h3>SYNOPSIS</h3>
  26. <div>NITRO is <a href="http://nitrogenproject.com">Nitrogen</a>-like Web Framework for Erlang/OTP.
  27. It can be used not only in web applications but also in console applications
  28. that need to perform an HTML5 rendering.
  29. </div>
  30. <br/>
  31. <div>
  32. NOV 2018 © 5HT <a href="https://5ht.co/license.htm">ISC</a>
  33. </div>
  34. </section>
  35. <section>
  36. <a name="plugin"></a><h3>USAGE</h3>
  37. <div>You can get rebar dependency and compile it:</div><br/>
  38. <figure>
  39. <code> $ mad get nitro
  40. $ cd deps/nitro
  41. $ mad dep com pla rep</code></figure>
  42. </section>
  43. </article>
  44. </aside><main>
  45. <section>
  46. <a name="endpoint"></a><h3>API</h3>
  47. <ul><li><b><a href="man/nitro.htm">nitro</a></b> — The public Nitrogen Web Framework API</li>
  48. </ul>
  49. </section>
  50. <section>
  51. <a name="endpoint"></a><h3>ELEMENTS</h3>
  52. <p> Nitrogen Elements is an HTML template engine for Erlang language where
  53. all HTML tags are being rendered from Erlang records.
  54. </p>
  55. <p>With N2O you don’t need to use HTML at all. Instead you define your page in the form of Erlang records so that the page is type checked at the compile time. This is a classic CGI approach for compiled pages and it gives us all the benefits of compile time error checking and provides DSL for client and server-side rendering.</p>
  56. <p>Nitrogen elements, by their nature, are UI control primitives that can be used to construct Nitrogen pages with Erlang internal DSL. They are compiled into HTML and JavaScript. Behavior of all elements is controlled on server-side and all the communication between browser and server-side is performed over WebSocket channels. Hence there is no need to use POST requests or HTML forms. I.e.</p>
  57. <figure><code>
  58. #textbox { id=userName, body= &lt;&lt;"Anonymous">> },
  59. #panel { id=chatHistory, class=chat_history }
  60. </code></figure>
  61. <p>will produce</p>
  62. <figure><code>
  63. &lt;input value="Anonymous" id="userName" type="text"/&gt;
  64. &lt;div id="chatHistory" class="chat_history"&gt;&lt;/div&gt;
  65. </code></figure>
  66. <ul><li><b><a href="man/element_textbox.htm">element_textbox</a></b> — HTML Text Box</li><li><b><a href="man/element_input.htm">element_input</a></b> — HTML Input</li><li><b><a href="man/element_textarea.htm">element_textarea</a></b> — HTML Text Area</li><li><b><a href="man/element_th.htm">element_th</a></b> — HTML Table Header</li><li><b><a href="man/element_tr.htm">element_tr</a></b> — HTML Table Row</li><li><b><a href="man/element_table.htm">element_table</a></b> — HTML Table</li><li><b><a href="man/element_select.htm">element_select</a></b> — HTML Select</li><li><b><a href="man/element_button.htm">element_button</a></b> — HTML Button</li><li><b><a href="man/element_fieldset.htm">element_fieldset</a></b> — HTML Fieldset</li><li><b><a href="man/element_image.htm">element_image</a></b> — HTML Image</li><li><b><a href="man/element_label.htm">element_label</a></b> — HTML Label</li><li><b><a href="man/element_radio.htm">element_radio</a></b> — HTML Radiobutton</li><li><b><a href="man/element_password.htm">element_password</a></b> — NITRO Password Element</li><li><b><a href="man/element_upload.htm">element_upload</a></b> — NITRO Upload Element</li><li><b><a href="man/element_calendar.htm">element_calendar</a></b> — NITRO Calendar Element</li><li><b><a href="man/element_dtl.htm">element_dtl</a></b> — Django DTL Element</li></ul>
  67. </section>
  68. <section>
  69. <a name="endpoint"></a><h3>ACTIONS</h3>
  70. <p> Nitrogen Ations is an JavaScript template engine for Erlang language where
  71. all events and button reactions are being rendered from Erlang language.
  72. </p>
  73. <figure><code>
  74. nitro:update(loginButton,
  75. #button{id=loginButton,
  76. body="Login",postback=login,source=[user,pass]});
  77. </code></figure>
  78. <p>This will produce the following HTML:
  79. </p><figure><code>
  80. &lt;input value="Login" id="loginButton" type="button"/&gt;
  81. </code></figure>
  82. <p>and JavaScript code:</p>
  83. <figure><code>
  84. qi('loginButton').outerHTML='&lt;button id=\"loginButton\"
  85. type=\"button\"&gt;Login&lt;/button&gt;';{var x=qi('loginButton');
  86. x &#38;&#38; x.addEventListener('click',function (event){
  87. event.preventDefault(); { if (validateSources(['user','pass'])) {
  88. ws.send(enc(tuple(atom('pickle'),bin('loginButton'),
  89. bin('b840bca20b3295619d1157105e355880f850bf0223f2f081549dc
  90. 8934ecbcd3653f617bd96cc9b36b2e7a19d2d47fb8f9fbe32d3c768866
  91. cb9d6d85700416edf47b9b90742b0632c750a4240a62dfc56789e0f5d8
  92. 590f9afdfb31f35fbab1563ec54fcb17a8e3bad463218d6402f1304'),
  93. [tuple(tuple(string('loginButton'),bin('detail')),[]),
  94. tuple(atom('user'),querySource('user')),
  95. tuple(atom('pass'),querySource('pass'))]))); }
  96. else console.log('Validation Error'); }});};
  97. </code></figure>
  98. <ul><li><b><a href="man/action_bind.htm">action_bind</a></b> — JavaScript Bind</li><li><b><a href="man/action_confirm.htm">action_confirm</a></b> — JavaScript Confirm</li><li><b><a href="man/action_event.htm">action_event</a></b> — JavaScript Postback Event</li></ul>
  99. </section>
  100. <section>
  101. <a name="mqtt"></a><h3>RENDER</h3>
  102. <ul><li><b><a href="man/wf_render.htm">wf_render</a></b> — Render Engine for Elements and Actions</li>
  103. <li><b><a href="man/wf_event.htm">wf_event</a></b> — Event JavaScript postback renderer</li>
  104. <li><b><a href="man/wf_tags.htm">wf_tags</a></b> — HTML5 XML renderer</li></ul>
  105. </section>
  106. <section>
  107. <a name="mqtt"></a><h3>SPEC</h3>
  108. <p>NITRO supports streaming of
  109. prerendered forms over WebSocket and MQTT
  110. and provides tiny JavaScript library to work with document model.
  111. This library is compatible across implementations.</p>
  112. <figure><figcaption>NITRO:</figcaption><code>
  113. -spec render(list(#element{})) -> binary().
  114. -spec wire(list(#action{})) -> [].
  115. -spec insert_top(atom(), list(#element{})) -> [].
  116. -spec insert_bottom(atom(), list(#element{})) -> [].
  117. -spec update(atom(), list(#element{})) -> [].
  118. -spec clear(atom()) -> [].
  119. -spec remove(atom()) -> [].
  120. -record(init, { token = [] :: [] | binary() }).
  121. -record(pickle, { source = [], pickled=[], args=[] }).
  122. -record(flush, { data = [] :: [] | term() }).
  123. -record(direct, { data = [] :: [] | term() }).
  124. -record(ev, { module = [] :: [] | atom(),
  125. msg = [] :: [] | term(),
  126. trigger= [] :: [] | atom() | binary(),
  127. name = [] :: [] | atom() | binary() }).
  128. </code></figure>
  129. <p>
  130. </p>
  131. </section>
  132. </main><footer>
  133. Made with <span class="heart">❤</span> to N2O
  134. </footer>
  135. <script>function drop(){document.getElementById("dropdown").classList.toggle("show");}</script>
  136. </body></html>