2
0

developer_guidelines.rst 5.7 KB

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