Commit 95bc55c1 authored by JC Brand's avatar JC Brand

Merge branch 'master' into amd-strophe

parents e5e8539f af87d59e
module.exports = function(grunt) {
var path = require('path');
var cfg = require('./package.json');
grunt.initConfig({
jst: {
......@@ -62,6 +63,10 @@ module.exports = function(grunt) {
dest: 'css/converse.min.css',
src: ['css/converse.css']
}
},
touch: {
npm: ['stamp-npm'],
bower: ['stamp-bower']
}
});
grunt.loadNpmTasks('grunt-contrib-cssmin');
......@@ -69,6 +74,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-jst');
grunt.loadNpmTasks('grunt-json');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-touch');
grunt.registerTask('test', 'Run Tests', function () {
var done = this.async();
......@@ -107,23 +113,26 @@ module.exports = function(grunt) {
var child_process = require('child_process');
var exec = child_process.exec;
var callback = function (err, stdout, stderr) {
grunt.log.write(stdout);
if (err) {
grunt.log.write('build failed with error code '+err.code);
grunt.log.write(stderr);
}
grunt.log.write(stdout);
done();
done(false);
} else
done();
};
exec('./node_modules/requirejs/bin/r.js -o src/build.js && ' +
'./node_modules/requirejs/bin/r.js -o src/build.js optimize=none out=builds/converse.js && ' +
'./node_modules/requirejs/bin/r.js -o src/build-no-jquery.js &&' +
'./node_modules/requirejs/bin/r.js -o src/build-no-jquery.js optimize=none out=builds/converse.nojquery.js && ' +
'./node_modules/requirejs/bin/r.js -o src/build-no-locales-no-otr.js && ' +
'./node_modules/requirejs/bin/r.js -o src/build-no-locales-no-otr.js optimize=none out=builds/converse-no-locales-no-otr.js && ' +
'./node_modules/requirejs/bin/r.js -o src/build-no-otr.js &&' +
'./node_modules/requirejs/bin/r.js -o src/build-no-otr.js optimize=none out=builds/converse-no-otr.js && ' +
'./node_modules/requirejs/bin/r.js -o src/build-website-no-otr.js &&' +
'./node_modules/requirejs/bin/r.js -o src/build-website.js', callback);
var rjsext = (process.platform === 'win32') ? '.cmd' : '';
var rjs = path.resolve('./node_modules/.bin/r.js' + rjsext);
exec(rjs + ' -o src/build.js && ' +
rjs + ' -o src/build.js optimize=none out=builds/converse.js && ' +
rjs + ' -o src/build-no-jquery.js &&' +
rjs + ' -o src/build-no-jquery.js optimize=none out=builds/converse.nojquery.js && ' +
rjs + ' -o src/build-no-locales-no-otr.js && ' +
rjs + ' -o src/build-no-locales-no-otr.js optimize=none out=builds/converse-no-locales-no-otr.js && ' +
rjs + ' -o src/build-no-otr.js &&' +
rjs + ' -o src/build-no-otr.js optimize=none out=builds/converse-no-otr.js && ' +
rjs + ' -o src/build-website-no-otr.js &&' +
rjs + ' -o src/build-website.js', callback);
// XXX: It might be possible to not have separate build config files. For example:
// 'r.js -o src/build.js paths.converse-dependencies=src/deps-no-otr paths.locales=locale/nolocales out=builds/converse-no-locales-no-otr.min.js'
});
......
# You can set these variables from the command line.
BOWER ?= ./node_modules/.bin/bower
BUILDDIR = ./docs
PAPER =
BOWER ?= node_modules/.bin/bower
BUILDDIR = ./docs
PAPER =
PHANTOMJS ?= ./node_modules/.bin/phantomjs
SPHINXBUILD ?= ./bin/sphinx-build
SPHINXOPTS =
PO2JSON ?= ./node_modules/.bin/po2json
SASS ?= sass
SPHINXBUILD ?= ./bin/sphinx-build
SPHINXOPTS =
PO2JSON ?= ./node_modules/.bin/po2json
SASS ?= sass
GRUNT ?= ./node_modules/.bin/grunt
HTTPSERVE ?= ./node_modules/.bin/http-server
# Internal variables.
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) ./docs/source
......@@ -19,18 +20,27 @@ I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) ./docs/source
all: dev
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " dev to set up the development environment"
@echo "Please use \`make <target>' where <target> is one of the following"
@echo " build create minified builds containing converse.js and all its dependencies"
@echo " gettext to make PO message catalogs of the documentation"
@echo " html to make standalone HTML files of the documentation"
@echo " pot to generate a gettext POT file to be used for translations"
@echo " po to generate gettext PO files for each i18n language"
@echo " po2json to generate JSON files from the language PO files"
@echo " release to make a new minified release"
@echo " linkcheck to check all documentation external links for integrity"
@echo " epub to export the documentation to epub"
@echo " changes to make an overview of all changed/added/deprecated items added to the documentation"
@echo " changes make an overview of all changed/added/deprecated items added to the documentation"
@echo " css generate CSS from the Sass files"
@echo " dev set up the development environment"
@echo " epub export the documentation to epub"
@echo " gettext make PO message catalogs of the documentation"
@echo " html make standalone HTML files of the documentation"
@echo " linkcheck check all documentation external links for integrity"
@echo " cssmin minify the CSS files"
@echo " po generate gettext PO files for each i18n language"
@echo " po2json generate JSON files from the language PO files"
@echo " pot generate a gettext POT file to be used for translations"
@echo " release make a new minified release"
@echo " serve serve this directory via a webserver on port 8000"
########################################################################
## Miscellaneous
serve: dev
$(HTTPSERVE) -p 8000
########################################################################
## Translation machinery
......@@ -49,12 +59,6 @@ po2json:
########################################################################
## Release management
jsmin:
./node_modules/requirejs/bin/r.js -o src/build.js && ./node_modules/requirejs/bin/r.js -o src/build-no-locales-no-otr.js && ./node_modules/requirejs/bin/r.js -o src/build-no-otr.js && ./node_modules/requirejs/bin/r.js -o src/build-website.js
cssmin:
$(GRUNT) cssmin
release:
sed -i s/Project-Id-Version:\ Converse\.js\ [0-9]\.[0-9]\.[0-9]/Project-Id-Version:\ Converse.js\ $(VERSION)/ locale/converse.pot
sed -i s/\"version\":\ \"[0-9]\.[0-9]\.[0-9]\"/\"version\":\ \"$(VERSION)\"/ bower.json
......@@ -86,14 +90,20 @@ clean::
dev: clean
npm install
${BOWER} update;
$(BOWER) update;
bundler install --path=.
########################################################################
## Builds
css::
${SASS} sass/converse.scss > css/converse.css
$(SASS) sass/converse.scss > css/converse.css
jsmin:
./node_modules/requirejs/bin/r.js -o src/build.js && ./node_modules/requirejs/bin/r.js -o src/build-no-locales-no-otr.js && ./node_modules/requirejs/bin/r.js -o src/build-no-otr.js && ./node_modules/requirejs/bin/r.js -o src/build-website.js
cssmin:
$(GRUNT) cssmin
build::
$(GRUNT) jst
......
# You can set these variables from the command line.
GRUNT ?= node_modules\.bin\grunt.cmd
BOWER ?= node_modules\.bin\bower
PHANTOMJS ?= node_modules\.bin\phantomjs
SASS ?= sass
RMRF ?= rmdir /q /s
RMF ?= del /q
HTTPSERVE ?= ./node_modules/.bin/http-server
.PHONY: all help clean css minjs build
all: dev
help:
@echo "Please use \`make <target>' where <target> is one of the following"
@echo " dev to set up the development environment"
@echo " build create minified builds containing converse.js and all its dependencies"
@echo " serve to serve this directory via a webserver on port 8000"
########################################################################
## Miscellaneous
serve:
$(HTTPSERVE) -p 8000
########################################################################
## Install dependencies
stamp-npm: package.json
npm install
$(GRUNT) touch:npm
stamp-bower: stamp-npm bower.json
$(BOWER) install
$(GRUNT) touch:bower
clean::
@if EXIST stamp-npm $(RMF) stamp-npm
@if EXIST stamp-bower $(RMF) stamp-bower
@if EXIST node_modules\. $(RMRF) node_modules
@if EXIST components\. $(RMRF) components
dev: clean
npm install
$(BOWER) update
bundler install --path=.
########################################################################
## Builds
css::
$(SASS) sass/converse.scss > css/converse.css
build::
$(GRUNT) jst
$(GRUNT) minify
########################################################################
## Tests
check:: stamp-npm
$(PHANTOMJS) node_modules/phantom-jasmine/lib/run_jasmine_test.coffee tests.html
......@@ -22,7 +22,7 @@
"requirejs-text": "~2.0.12",
"requirejs-tpl-jcbrand": "*",
"momentjs": "~2.6.0",
"jquery.browser": "https://raw.githubusercontent.com/jcbrand/jquery-browser-plugin/ae5e88aa7a26f583e8865c3961ba857918c4c9c1/dist/jquery.browser.js",
"jquery.browser": ">=0.0.7",
"jquery-easing-original": "https://raw.githubusercontent.com/jcbrand/jquery.easing/7de3458b1845a72c1f407debf6b223c8446396bf/jquery.easing.1.3.js",
"bootstrap": "~3.2.0",
"bootstrapJS": "https://raw.githubusercontent.com/jcbrand/bootstrap/7d96a5f60d26c67b5348b270a775518b96a702c8/dist/js/bootstrap.js",
......
......@@ -170,8 +170,8 @@
var converse = this;
// Logging
Strophe.log = function (level, msg) { console.log(level+' '+msg); };
Strophe.error = function (msg) { console.log('ERROR: '+msg); };
Strophe.log = function (level, msg) { converse.log(level+' '+msg, level); };
Strophe.error = function (msg) { converse.log(msg, 'error'); };
// Add Strophe Namespaces
Strophe.addNamespace('CHATSTATES', 'http://jabber.org/protocol/chatstates');
......@@ -4257,7 +4257,7 @@
this.XMPPStatus = Backbone.Model.extend({
initialize: function () {
this.set({
'status' : this.get('status') || 'online'
'status' : this.getStatus()
});
this.on('change', $.proxy(function (item) {
if (this.get('fullname') === undefined) {
......@@ -4277,12 +4277,14 @@
}, this));
},
sendPresence: function (type) {
if (type === undefined) {
sendPresence: function (type, status_message) {
if (typeof type === 'undefined') {
type = this.get('status') || 'online';
}
var status_message = this.get('status_message'),
presence;
if (typeof status_message === 'undefined') {
status_message = this.get('status_message');
}
var presence;
// Most of these presence types are actually not explicitly sent,
// but I add all of them here fore reference and future proofing.
if ((type === 'unavailable') ||
......@@ -4316,8 +4318,12 @@
this.save({'status': value});
},
getStatus: function() {
return this.get('status') || 'online';
},
setStatusMessage: function (status_message) {
converse.connection.send($pres().c('show').t(this.get('status')).up().c('status').t(status_message));
this.sendPresence(this.getStatus(), status_message);
this.save({'status_message': status_message});
if (this.xhr_custom_status) {
$.ajax({
......
......@@ -12,6 +12,9 @@ Changelog
* #292 Better support for XEP-0085 Chat State Notifications. [jcbrand]
* #295 Document "allow_registration". [gbonvehi]
* #304 Added Polish translations. [ser]
* New Makefile.win to build in Windows environments. [gbonvehi]
* Strophe.log and Strophe.error now uses converse.log to output messages. [gbonvehi]
* #305 presence/show text in XMPP request isn't allowed by specification. [gbonvehi]
0.8.6 (2014-12-07)
------------------
......
......@@ -3,7 +3,7 @@
{# Custom CSS overrides #}
{% set bootswatch_css_custom = ['_static/style.css', "../../css/converse.min.css"] %}
{% set script_files = script_files + ["../../builds/converse.min.js"] %}
{% set script_files = script_files + ["../../builds/converse.min.js", "../../analytics.js"] %}
{# Add some extra stuff before and use existing with 'super()' call. #}
{% block footer %}
......
======================
Creating custom builds
======================
.. _builds:
===============
Creating builds
===============
.. contents:: Table of Contents
:depth: 3
......@@ -10,31 +12,53 @@ Creating custom builds
.. warning:: There current documentation in this section does not adequately
explain how to create custom builds.
.. _`minification`:
.. note:: Please make sure to read the section :doc:`development` and that you have installed
all development dependencies (long story short, you should be able to just run ``make dev``)
Creating builds
===============
We use `require.js <http://requirejs.org>`_ to keep track of *Converse.js* and
its dependencies and to to bundle them together in a single file fit for
deployment to a production site.
To create the bundles, simply run::
make build
Minification
============
This command does the following:
Minifying Javascript and CSS
----------------------------
* It creates different Javascript bundles of Converse.js.
The individual javascript files will be bundled and minified with `require.js`_'s
optimization tool, using `almond <https://github.com/jrburke/almond>`_.
You can `read more about require.js's optimizer here <http://requirejs.org/docs/optimization.html>`_.
Please make sure to read the section :doc:`development` and that you have installed
all development dependencies (long story short, you can run ``npm install``
and then ``grunt fetch``).
* It bundles the HTML templates in ``./src/templates/`` into a single file called ``templates.js``.
This file can then be included via the ``<script>`` tag. See for example the ``non_amd.html`` example page.
We use `require.js <http://requirejs.org>`_ to keep track of *Converse.js* and its dependencies and to
to bundle them together in a single minified file fit for deployment to a
production site.
* It bundles all the translation files in ``./locale/`` into a single file ``locales.js``.
This file can then be included via the ``<script>`` tag. See for example the ``non_amd.html`` example page.
To minify the Javascript and CSS, run the following command:
* Also, the CSS files in the ``./css`` directory will be minified.
The built Javasript bundles are contained in the ``./builds`` directory:
.. code-block:: bash
jc@conversejs:~/converse.js (master)$ ls builds/
converse.js converse-no-locales-no-otr.js converse.website.min.js
converse.min.js converse-no-locales-no-otr.min.js converse.website-no-otr.min.js
converse.nojquery.js converse-no-otr.js locales.js
converse.nojquery.min.js converse-no-otr.min.js templates.js
.. _`minification`:
::
Minifying the CSS
-----------------
grunt minify
To only minify the CSS files, nothing else, run the following command::
Javascript will be bundled and minified with `require.js`_'s optimization tool,
using `almond <https://github.com/jrburke/almond>`_.
make cssmin
You can `read more about require.js's optimizer here <http://requirejs.org/docs/optimization.html>`_.
The CSS files are minified via `cssmin <https://github.com/gruntjs/grunt-contrib-cssmin>`_.
CSS is minified via `cssmin <https://github.com/gruntjs/grunt-contrib-cssmin>`_.
.. _development:
===========
Development
===========
......@@ -12,6 +14,8 @@ follow the instructions below to create this folder and fetch Converse's
3rd-party dependencies.
.. note::
Windows environment: We recommend installing the required tools using `Chocolatey <https://chocolatey.org/>`_
You will need Node.js (nodejs.install), Git (git.install) and optionally to build using Makefile, GNU Make (make)
If you have trouble setting up a development environment on Windows,
please read `this post <http://librelist.com/browser//conversejs/2014/11/5/openfire-converse-and-visual-studio-questions/#b28387e7f8f126693b11598a8acbe810>`_
in the mailing list.:
......@@ -27,6 +31,9 @@ version `here <https://nodejs.org/download>`_.
Also make sure you have ``Git`` installed. `Details <http://git-scm.com/book/en/Getting-Started-Installing-Git>`_.
.. note::
Windows users should use Chocolatey as recommended above.:
Once you have *Node.js* and *git* installed, run the following command inside the Converse.js
directory:
......@@ -34,13 +41,18 @@ directory:
make dev
On Windows you need to specify Makefile.win to be used by running:
::
make -f Makefile.win dev
Or alternatively, if you don't have GNU Make:
::
npm install
bower update
This will first install the Node.js development tools (like Grunt and Bower)
and then use Bower to install all of Converse.js's front-end dependencies.
......@@ -64,7 +76,6 @@ If you are curious to know what the different dependencies are:
Double-check the output of ```make dev``` to see if there are any errors
listed. For support, you can write to the mailing list: conversejs@librelist.com
With AMD and require.js (recommended)
=====================================
......
......@@ -33,7 +33,7 @@ The :ref:`what-you-will-need` and :ref:`session-support` sections provide more i
Table of Contents
=================
.. toctree::
:maxdepth: 2
......@@ -42,6 +42,7 @@ Table of Contents
setup
configuration
development
theming
translations
documentation
builds
=======
Theming
=======
.. contents:: Table of Contents
:depth: 2
:local:
Setting up your environment
===========================
In order to theme converse.js, you'll first need to set up a `development_` environment.
You'll also want to preview the changes you make in the browser.
To set up the development environment and also start up a web browser which
will serve the files for you, simply run::
make serve
You can now open http://localhost:8000 in your webbrowser to see the
converse.js website.
However, when developing or changing the theme, you'll want to load all the
unminified JS and CSS resources. To do this, open http://localhost:8000/dev.html
instead.
Mockups
=======
Converse.js contains some mockups in the ``./mockup`` directory against which you
can preview and tweak your changes.
The ``./mockup/index.html`` file contains the most comprehensive mockup, while
the other files focus on particular UI aspects.
To see it in your browser, simply open: http://localhost:8000/mockup
Modifying the HTML templates of Converse.js
===========================================
The HTML markup of converse.js is contained small ``.html`` files in the
``./src/templates`` directory.
Modifying the CSS
=================
The CSS files are generated from `Sass <http://sass-lang.com>`_ files in
the ``./sass`` directory.
To generate the CSS you can run::
make css
Creating builds
===============
Once you've themed converse.js, you'll want to create new minified builds of
the Javascript and CSS files.
Please refer to the :doc:`builds` section for information on how this is done.
This diff is collapsed.
This diff is collapsed.
......@@ -24,7 +24,7 @@ require.config({
"eventemitter": "components/otr/build/dep/eventemitter",
"jquery": "components/jquery/dist/jquery",
"jquery-private": "src/jquery-private",
"jquery.browser": "components/jquery.browser/index",
"jquery.browser": "components/jquery.browser/dist/jquery.browser",
"jquery.easing": "components/jquery-easing-original/index", // XXX: Only required for https://conversejs.org website
"moment": "components/momentjs/moment",
"strophe-base64": "components/strophe/src/base64",
......
......@@ -41,7 +41,7 @@
<script type="text/javascript" src="components/backbone.browserStorage/backbone.browserStorage.js"></script>
<script type="text/javascript" src="components/backbone.overview/backbone.overview.js"></script>
<script type="text/javascript" src="components/momentjs/moment.js"></script>
<script type="text/javascript" src="components/jquery.browser/index.js"></script>
<script type="text/javascript" src="components/jquery.browser/dist/jquery.browser.js"></script>
<script type="text/javascript" src="components/typeahead.js/index.js"></script>
<script type="text/javascript" src="components/jed/jed.js"></script>
<script type="text/javascript" src="builds/locales.js"></script>
......
(function (root, factory) {
define([
"jquery",
"mock",
"test_utils"
], function ($, mock, test_utils) {
return factory($, mock, test_utils);
}
);
} (this, function ($, mock, test_utils) {
return describe("The XMPPStatus model", $.proxy(function(mock, test_utils) {
beforeEach($.proxy(function () {
window.localStorage.clear();
window.sessionStorage.clear();
}, converse));
it("won't send <show>online when setting a custom status message", $.proxy(function () {
this.xmppstatus.save({'status': 'online'});
spyOn(this.xmppstatus, 'setStatusMessage').andCallThrough();
spyOn(converse.connection, 'send');
this.xmppstatus.setStatusMessage("I'm also happy!");
runs (function () {
expect(converse.connection.send).toHaveBeenCalled();
var $stanza = $(converse.connection.send.argsForCall[0][0].tree());
expect($stanza.children().length).toBe(1);
expect($stanza.children('show').length).toBe(0);
});
}, converse));
}, converse, mock, test_utils));
}));
......@@ -67,7 +67,8 @@ require([
"spec/chatroom",
"spec/minchats",
"spec/profiling",
"spec/register"
"spec/register",
"spec/xmppstatus"
], function () {
// Make sure this callback is only called once.
delete converse.callback;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment