documentation.html 4.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ---
  2. layout: default
  3. title: Jtalk Smalltalk - documentation
  4. ---
  5. <div class="box last doc" id="documentation">
  6. <h2>Documentation</h2>
  7. <div class="content">
  8. <h3 id="intro">1. Introduction <a href="#intro">&para;</a></h3>
  9. <p class="warning">This documentation is a work in progress.</p>
  10. <p>Jtalk is an implementation of the Smalltalk-80 language. It allows developers to write client-side heavy web applications in Smalltalk. Jtalk includes an integrated development environment with a class browser, workspace and transcript.</p>
  11. <p class="information">Jtalk is a young piece of code and evolves quickly. Some features are still incomplete and you may very well encounter bugs, in which case you can <a href="https://github.com/NicolasPetton/jtalk/issues">file an issue</a> or a pull request on the <a href="https://github.com/NicolasPetton/jtalk">repository</a>.</p>
  12. <p>Jtalk includes the following features:</p>
  13. <ol>
  14. <li>It is semantically and syntaxically equivalent to <a href="http://www.pharo-project.org">Pharo Smalltalk</a> (the implementation considered as the reference)</li>
  15. <li>It is written in itself and compiles into efficient JavaScript</li>
  16. <li>A canvas API similar to <a href="http://www.seaside.st">Seaside</a> to generate HTML</li>
  17. <li>A <a href="http://www.jquery.com">jQuery</a> binding</li>
  18. </ol>
  19. <h3 id="differences-other-smalltalks">2. Differences with other Smalltalk implementations <a href="#differences-other-smalltalks">&para;</a></h3>
  20. <h3 id="committing">3. Committing changes to disk with the web-based IDE <a href="#committing">&para;</a></h3>
  21. <p>The class browser is able to commit changes to disk. The <code>commit category</code> button will send a PUT request with the compiled JavaScript code of all classes in the selected class category in a file named <code>js/CATEGORY.js</code>.</p>
  22. <p>The easiest way to enable committing is probably to setup a webdav with Apache.</p>
  23. <p class="information">The following steps explain how to setup a webdav for Jtalk with Debian, but the setup on OSX and other Linux distros should be similar.</p>
  24. <h4>Installing Apache and enabling the dav module</h4>
  25. <p>Evaluate the following as root:</p>
  26. <pre><span class="prompt">~#</span> <span class="kbd">apt-get install</span> <span class="kbd var">apache2</span>
  27. <span class="prompt">~#</span> <span class="kbd">a2enmod</span> <span class="kbd var">dav</span>
  28. <span class="prompt">~#</span> <span class="kbd">a2enmod</span> <span class="kbd var">dav_fs</span></pre>
  29. <h4>Creating a password for the webdav</h4>
  30. <pre><span class="prompt">~#</span> <span class="kbd">htpasswd -c /etc/apache2/htpasswd-webdav <span class="kbd var">USERNAME</span></span></pre>
  31. <h4>Setting up the webdav directory</h4>
  32. <p>Add the following lines to the default vhost (in /etc/apache2/sites-available/default):</p>
  33. <pre>Alias /jtalk/ "/path/to/jtalk/"
  34. &lt;Directory "/path/to/jtalk/"&gt;
  35. Options Indexes MultiViews FollowSymLinks
  36. DirectoryIndex index.html
  37. AllowOverride None
  38. Order allow,deny
  39. allow from all
  40. Dav on
  41. AuthType Basic
  42. AuthName "jtalk"
  43. AuthUserFile /etc/apache2/htpasswd-webdav
  44. &lt;LimitExcept GET OPTIONS&gt;
  45. Require valid-user
  46. &lt;/LimitExcept&gt;
  47. &lt;/Directory&gt;</pre>
  48. <p>Make sure the group <code>www-data</code> has required rights to make changes to files in the webdav directory.</p>
  49. <h4>Restarting Apache</h4>
  50. <p>To restart Apache, evaluate the following: </p>
  51. <pre><span class="prompt">~#</span> <span class="kbd">/etc/init.d/apache2</span> <span class="kbd var">restart</span></pre>
  52. <p>and go to <code>http://localhost/jtalk/</code>.</p>
  53. <p>The class browser should now be able to commit changes to disk.</p>
  54. <h3 id="counter-example">4. The counter example <a href="#counter-example">&para;</a></h3>
  55. <p>The following example is the traditional Seaside-like multi-counter application. The buttons at the bottom of each counter increase or decrease the counter.</p>
  56. <div id="counters"></div>
  57. <script type="text/javascript">
  58. jQuery(document).ready(function() {'#counters'._asJQuery()._append_(smalltalk.Counter._new())._append_(smalltalk.Counter._new())});
  59. </script>
  60. <p>Open a <button onclick="smalltalk.Browser._openOn_(smalltalk.Counter);">browser</button> on the <code>Counter</code> class in the <code>Canvas</code> class category.
  61. <p>Each Jtalk widget is a subclass of <code>Widget</code>. A widget is a graphical component. The <code>#renderOn:</code> method is used to generate HTML using the HTML canvas.</p>
  62. <h3 id="html-canvas">5. The HTML canvas <a href="#html-canvas">&para;</a></h3>
  63. <h3 id="widgets">6. Widgets <a href="#widgets">&para;</a></h3>
  64. <h3 id="jquery">7. jQuery <a href="#jquery">&para;</a></h3>
  65. </div>
  66. </div>