developer_guidelines.rst 5.9 KB

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