developer_guidelines.rst 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. Developer guidelines
  2. ====================
  3. If you want to work with the non-minified Javascript and CSS files you'll soon
  4. notice that there are references to missing *components* and *node_modules* directories.
  5. Please follow the instructions below to create these directories and fetch Converse's
  6. 3rd-party dependencies.
  7. .. note::
  8. Windows environment: We recommend installing the required tools using `Chocolatey <https://chocolatey.org/>`_
  9. You will need Node.js (nodejs.install), Git (git.install) and optionally to build using Makefile, GNU Make (make)
  10. If you have trouble setting up a development environment on Windows,
  11. please read `this post <http://librelist.com/browser//conversejs/2014/11/5/openfire-converse-and-visual-studio-questions/#b28387e7f8f126693b11598a8acbe810>`_
  12. in the mailing list.:
  13. Installing the development and front-end dependencies
  14. -----------------------------------------------------
  15. We use development tools (`Grunt <http://gruntjs.com>`_ and `Bower <http://bower.io>`_)
  16. which depend on Node.js and npm (the Node package manager).
  17. If you don't have Node.js installed, you can download and install the latest
  18. version `here <https://nodejs.org/download>`_.
  19. Also make sure you have ``Git`` installed. `Details <http://git-scm.com/book/en/Getting-Started-Installing-Git>`_.
  20. .. note::
  21. Windows users should use Chocolatey as recommended above.
  22. .. note::
  23. Debian & Ubuntu users : apt-get install git npm nodejs-legacy
  24. Once you have *Node.js* and *git* installed, run the following command inside the Converse.js
  25. directory:
  26. ::
  27. make dev
  28. On Windows you need to specify Makefile.win to be used by running: ::
  29. make -f Makefile.win dev
  30. Or alternatively, if you don't have GNU Make:
  31. ::
  32. npm install
  33. bower update
  34. This will first install the Node.js development tools (like Grunt and Bower)
  35. as well as Converse.js's front-end dependencies.
  36. The front-end dependencies are those javascript files on which
  37. Converse.js directly depends and which will be loaded in the browser.
  38. To see the dependencies, take a look at whats under the *devDependencies* key in
  39. `package.json <https://github.com/jcbrand/converse.js/blob/master/package.json>`_.
  40. .. note::
  41. After running ```make dev```, you should now have new directories *components*
  42. and *node_modules*, which contain all the front-end dependencies of Converse.js.
  43. If these directory does NOT exist, something must have gone wrong.
  44. Double-check the output of ```make dev``` to see if there are any errors
  45. listed. For support, you can write to the mailing list: conversejs@librelist.com
  46. Loading converse.js and its dependencies
  47. ----------------------------------------
  48. With AMD and require.js (recommended)
  49. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  50. Converse.js uses `require.js <http://requirejs.org>`_ to asynchronously load dependencies.
  51. If you want to develop or customize converse.js, you'll want to load the
  52. non-minified javascript files.
  53. Add the following two lines to the *<head>* section of your webpage:
  54. .. code-block:: html
  55. <link rel="stylesheet" type="text/css" media="screen" href="converse.css">
  56. <script data-main="main" src="components/requirejs/require.js"></script>
  57. require.js will then let the main.js file be parsed (because of the *data-main*
  58. attribute on the *script* tag), which will in turn cause converse.js to be
  59. parsed.
  60. Without AMD and require.js
  61. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  62. Converse.js can also be used without require.js. If you for some reason prefer
  63. to use it this way, please refer to
  64. `non_amd.html <https://github.com/jcbrand/converse.js/blob/master/non_amd.html>`_
  65. for an example of how and in what order all the Javascript files that converse.js
  66. depends on need to be loaded.
  67. Brief description of converse.js's dependencies
  68. -----------------------------------------------
  69. Converse.js relies on the following dependencies:
  70. * `JQuery <http://jquery.com/>`_ for DOM manipulation and `promises <http://api.jquery.com/promise/>`_.
  71. * `moment.js <http://momentjs.com/>`_ provides a better API for handling dates and times.
  72. * `Strophe.js <http://strophe.im/>`_ maintains the XMPP session, is used to
  73. build XMPP stanzas, to send them, and to register handlers for received stanzas.
  74. * `Underscore <http://underscorejs.org/>`_ provides very useful utility functions.
  75. * `Backbone <http://backbonejs.org/>`_ is used to model the data as Models and
  76. Collections and to create Views that render the UI.
  77. * `backbone.overview <http://github.com/jcbrand/backbone.overview>`_ provides
  78. Overviews, which are to Views as Backbone Collections are to Models.
  79. * `pluggable.js <https://github.com/jcbrand/pluggable.js>`_ is the plugin
  80. architecture for Converse.js. It registers and initializes plugins and
  81. allows existing attributes, functions and objects on converse.js to be
  82. overridden inside plugins.
  83. When submitting a pull request
  84. ------------------------------
  85. Please follow the usual github workflow. Create your own local fork of this repository,
  86. make your changes and then submit a pull request.
  87. Follow the programming style guide
  88. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  89. Please read the `style guide </docs/html/style_guide.html>`_ and make sure that your code follows it.
  90. Add tests for your bugfix or feature
  91. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  92. Add a test for any bug fixed or feature added. We use Jasmine
  93. for testing.
  94. Take a look at `tests.html <https://github.com/jcbrand/converse.js/blob/master/tests.html>`_
  95. and the `spec files <https://github.com/jcbrand/converse.js/blob/master/tests.html>`_
  96. to see how tests are implemented.
  97. Check that the tests pass
  98. ~~~~~~~~~~~~~~~~~~~~~~~~~
  99. Check that all tests complete sucessfully.
  100. Run ``make check`` in your terminal or open `tests.html <https://github.com/jcbrand/converse.js/blob/master/tests.html>`_
  101. in your browser.