Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Minimal backbone version #11

Merged
merged 22 commits into from

4 participants

@n1k0
Collaborator

Based on #9, a much lighter approach for a backbone implementation:

  • requirejs is no more used
  • nor handlebars
  • app code fits in a single javascript file
@dmose
Owner

Given our conversations today, I'm assuming that the next step with this PR is to split it up into the refactored talkilla as well as separate PRs for vendor libraries to be landed.

Once that happens, I suspect tOkeshu would be a good choice for the reviewer of record, since he has some past experience there.

n1k0 added some commits
@n1k0 n1k0 sync with master dc4074e
@n1k0 n1k0 removed dependency to bower
linked statics will be added in another PR
b80fcb8
@n1k0 n1k0 referenced this pull request from a commit in n1k0/talkilla
@n1k0 n1k0 added vendor statics related to #11 e650540
README.md
@@ -10,16 +10,17 @@ Local Development
2. Make sure you have [node installed](http://nodejs.org/).
-3. Install the required node modules:
+3. Install the required node & [bower](http://twitter.github.com/bower/) dependencies:
@tOkeshu Collaborator
tOkeshu added a note

Maybe it comes from the merges, but we decided to not use bower, right?

@n1k0 Collaborator
n1k0 added a note

Yup, let me fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@tOkeshu
Collaborator

I will be the reviewer of record for this one.

n1k0 added some commits
@n1k0 n1k0 updated README.md
- removed references to bower
- add make commands
9ffb28d
@n1k0 n1k0 removed remaining references to bower 49261b7
@n1k0 n1k0 fixed coding standards f1a37dc
@n1k0 n1k0 rethinking app modularization
- The Backbone app is now exposed as a `Talkilla` global, to ease further extensibility.
- The main JavaScript file is now stored under a static/js directory
4bf10e7
static/js/talkilla.js
((1 lines not shown))
+/*global jQuery, Backbone*/
+/* jshint unused: false */
+var Talkilla = (function($, Backbone) {
+ "use strict";
+ var app = {data: {}};
+
+ function login(nick, cb) {
+ $.ajax({
+ type: "POST",
+ url: '/signin',
+ data: {nick: nick},
+ dataType: 'json'
+ })
+ .done(function(auth) {
+ if (!auth.nick)
+ return cb(new Error('joining failed'));
@tOkeshu Collaborator
tOkeshu added a note

It seems we don't trust the API here. What I read is « in case we have a successful response but no nick, we have an error ».
I would expect the server to not return a successful response here but something like a 500 or 409

@n1k0 Collaborator
n1k0 added a note

+1, let me address this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
CONTRIBUTING.md
((9 lines not shown))
+- [Twitter Bootstrap](http://twitter.github.com/bootstrap/)
+- [Backbone](http://backbonejs.org/) (and [underscore](http://underscorejs.org/))
+- [jQuery](http://jquery.com/)
+
+To add a new frontend dependency:
+
+- Store it within the `static/vendor` directory and suffix the filename with its
+ complete version number, eg. `jquery-1.9.1.js`.
+- Include the script using a standard `<script>` tag in the HTML file; take care
+ of the loading order.
+
+Code Modularization
+-------------------
+
+The Talkilla Backbone application is exposed as a `Talkilla` global object.
+
@tOkeshu Collaborator
tOkeshu added a note

I'm not sure this should be part of this pull request. What do think @fqueze and @dmose ?

@n1k0 Collaborator
n1k0 added a note

As a side note it's still WiP

For the records I've asked on IRC to B2G/gaia people, and it seems there's no official convention for modularizing app code, though exposing a global object for an app seems to be pretty much a widespread practice…

All in all, I agree it's a bunch of work for this PR which is already quite big, and right now our app fits in a single file so there isn't much to say about code modularization yet, so +1 for postponing it.

@tOkeshu Collaborator
tOkeshu added a note

My concern is more about CONTRIBUTING.md being modified to explain practices.
If I understand well the goal of this pull request is to bring backbone to the project.
Explaining practices should be in another PR IMHO.

@n1k0 Collaborator
n1k0 added a note

Ah, makes sense. We could use the github wiki for that, what do you think?

Edit: I mean, I'm not sure CONTRIBUTING.md should be that long anyway, and much of it could fit better in developer documentation (/methinks)

@dmose Owner
dmose added a note

Totally agree that we should limit the scope of this PR so that it can land sooner rather than later, primarily for the reason that I think it effectively blocks most of the rest of the user stories.

Separately, I agree that CONTRIBUTING.md is too long; I suspect the simplest way to make it better is just to extract the coding stuff stuff into its own MD file. But let's take this discussion to a future PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@fqueze fqueze commented on the diff
server.js
((18 lines not shown))
nick = findNewNick(nick);
- res.send(200, JSON.stringify({nick: nick, users: users}));
- users.push(nick);
+ users.push({nick: nick});
@fqueze Collaborator
fqueze added a note

The reason why this was sending the reply before pushing the new nick to the users array is that this way I didn't have to filter the user's nick out of the received list of contacts on the front-end side (offering a user to call himself doesn't make sense).

I haven't searched very hard, but I didn't see any code in the front-end here that filters out the user's nick.

@n1k0 Collaborator
n1k0 added a note

I was thinking of adding no link to the user's own entry adn maybe suffixing it with (me)… a bit like what some irc clients do, but now I'm not so sure :/

@tOkeshu Collaborator
tOkeshu added a note

For now there is no UI to call someone, so it's not a bug (yet). We can decide what to do when the feature will be implemented.
For me it's not a blocker.

@fqueze Collaborator
fqueze added a note

So the "As the first user logged in, I see a message that I am the only person logged in, and see an offer to invite friends" story is no longer done, then?

@n1k0 Collaborator
n1k0 added a note

Indeed! I implemented it in other prs but not in this one. I'll be fixing that right now. Should I create a new PR for the fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@tOkeshu
Collaborator

r=tOkeshu conditional on removing the CONTRIBUTING.md patch before you merge.

@n1k0 n1k0 merged commit 444812a into mozilla:master
@n1k0 n1k0 deleted the n1k0:backbone-minimal branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 21, 2013
  1. @n1k0
  2. @n1k0

    indentation, cs

    n1k0 authored
  3. @n1k0
Commits on Mar 22, 2013
  1. @n1k0

    Auth model; mv lib/ vendor/

    n1k0 authored
  2. @n1k0

    merge with fqueze/login

    n1k0 authored
Commits on Mar 25, 2013
  1. @n1k0

    minimal backbone version

    n1k0 authored
  2. @n1k0
Commits on Mar 26, 2013
  1. @n1k0

    sync with master

    n1k0 authored
  2. @n1k0

    removed dependency to bower

    n1k0 authored
    linked statics will be added in another PR
  3. @n1k0
  4. @n1k0
  5. @n1k0

    updated links to static assets

    n1k0 authored
  6. @n1k0
  7. @n1k0
  8. @n1k0
  9. @n1k0
  10. @n1k0

    updated README.md

    n1k0 authored
    - removed references to bower
    - add make commands
Commits on Mar 27, 2013
  1. @n1k0
  2. @n1k0

    fixed coding standards

    n1k0 authored
  3. @n1k0

    rethinking app modularization

    n1k0 authored
    - The Backbone app is now exposed as a `Talkilla` global, to ease further extensibility.
    - The main JavaScript file is now stored under a static/js directory
  4. @n1k0
  5. @n1k0

    lighter CONTRIBUTING.md

    n1k0 authored
This page is out of date. Refresh to see the latest.
View
4 CONTRIBUTING.md
@@ -25,8 +25,8 @@ Testing policy
Review policy
-------------
-* Pull requests that are pair-programmed with at least one committer do not
- require code review, although contributors are encouraged to request it
+* Pull requests that are pair-programmed with at least one committer do not
+ require code review, although contributors are encouraged to request it
if another set of eyes seems important. Pair-programmed merges should
include a sentence like `These commits were paired on by n10k and dmose`.
* Otherwise, pull-requests require code review:
View
11 Makefile
@@ -1,9 +1,16 @@
test: mocha jshint
-mocha:
- @./node_modules/mocha/bin/mocha --reporter spec
+install:
+ @npm install
jshint:
@jshint *.js static test
+mocha:
+ @./node_modules/mocha/bin/mocha --reporter spec
+
+runserver:
+ @env PORT=5000 node app.js
+
.PHONY: test
+
View
7 README.md
@@ -10,16 +10,21 @@ Local Development
2. Make sure you have [node installed](http://nodejs.org/).
-3. Install the required node modules:
+3. Install the required node dependencies:
$ npm install
+ # or alternatively:
+ $ make install
4. Start the server:
$ env PORT=5000 node app.js
+ # or alternatively:
+ $ make runserver
5. Point your web browser to [http://localhost:5000](http://localhost:5000).
+
Unit Tests
----------
View
28 server.js
@@ -21,26 +21,30 @@ function findNewNick(aNick) {
return nickParts[1] + newDigits;
}
+server.get('/users', function(req, res) {
+ res.send(200, JSON.stringify(server.get('users')));
+});
+
server.post('/signin', function(req, res) {
var users = server.get('users');
var nick = req.body.nick;
- while (users.indexOf(nick) !== -1)
+ function exists(nick) {
+ return users.some(function(user) {
+ return user.nick === nick;
+ });
+ }
+ while (exists(nick))
nick = findNewNick(nick);
- res.send(200, JSON.stringify({nick: nick, users: users}));
- users.push(nick);
+ users.push({nick: nick});
@fqueze Collaborator
fqueze added a note

The reason why this was sending the reply before pushing the new nick to the users array is that this way I didn't have to filter the user's nick out of the received list of contacts on the front-end side (offering a user to call himself doesn't make sense).

I haven't searched very hard, but I didn't see any code in the front-end here that filters out the user's nick.

@n1k0 Collaborator
n1k0 added a note

I was thinking of adding no link to the user's own entry adn maybe suffixing it with (me)… a bit like what some irc clients do, but now I'm not so sure :/

@tOkeshu Collaborator
tOkeshu added a note

For now there is no UI to call someone, so it's not a bug (yet). We can decide what to do when the feature will be implemented.
For me it's not a blocker.

@fqueze Collaborator
fqueze added a note

So the "As the first user logged in, I see a message that I am the only person logged in, and see an offer to invite friends" story is no longer done, then?

@n1k0 Collaborator
n1k0 added a note

Indeed! I implemented it in other prs but not in this one. I'll be fixing that right now. Should I create a new PR for the fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
server.set('users', users);
+ res.send(200, JSON.stringify({nick: nick, users: users}));
});
server.post('/signout', function(req, res) {
- var users = server.get('users');
- var pos = users.indexOf(req.body.nick);
- if (pos === -1)
- res.send(404, 'User not logged in');
-
- users.pop(pos);
- server.set('users', users);
-
- res.send(200);
+ server.set('users', server.get('users').filter(function(user) {
+ return user.nick !== req.body.nick;
+ }));
+ res.send(200, JSON.stringify(true));
});
var _listen = server.listen;
View
45 static/index.html
@@ -3,16 +3,43 @@
<head>
<meta charset="utf-8">
<title>Talkilla</title>
- <script type="text/javascript" src="talkilla.js"></script>
+ <style>
+ .hide {display:none;}
+ </style>
+ <link href="vendor/bootstrap-2.1.1/css/bootstrap.css" rel="stylesheet">
+ <link href="vendor/bootstrap-2.1.1/css/bootstrap-responsive.css" rel="stylesheet">
</head>
-
<body>
- <h1 id="title">Welcome to Talkilla!</h1>
- <form id="login" onsubmit="login(); return false;" action="signin" method="post">
- <p>Please enter a nickname to use with Talkilla: <input id="nick" name="nick" type="text">
- <input id="submit" type="submit"></p>
- </form>
- <p id="invite" style="display: none">You are the only person logged in, invite your friends.</p>
- <ul id="friends"></ul>
+ <div class="container-fluid">
+ <div class="row-fluid">
+ <h1>Welcome to Talkilla!</h1>
+ </div>
+ <div class="row-fluid">
+ <div class="span9" id="login">
+ <form action="signin" method="post" id="signin" class="form-inline">
+ <label for="nick">Please enter a nickname to use with Talkilla:</label><br>
+ <div class="input-prepend">
+ <span class="add-on"><i class="icon-user"></i></span>
+ <input class="input-small" placeholder="nickname" id="nick" name="nick" type="text">
+ </div>
+ <input class="btn" id="submit" type="submit" value="Join">
+ </form>
+ <form action="/signout" id="signout" method="post" class="hide">
+ <p>Joined as <strong class="nick"></strong>
+ | <button class="btn" type="submit">sign out</button></p>
+ </form>
+ </div>
+ <div class="span3" id="users">
+ <ul class="nav nav-list">
+ <li class="nav-header">Online users</li>
+ <li>Empty room</li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ <script src="vendor/jquery-1.9.1.js"></script>
+ <script src="vendor/underscore-1.4.4.js"></script>
+ <script src="vendor/backbone-1.0.0.js"></script>
+ <script src="js/talkilla.js"></script>
</body>
</html>
View
148 static/js/talkilla.js
@@ -0,0 +1,148 @@
+/*global jQuery, Backbone*/
+/* jshint unused: false */
+var Talkilla = (function($, Backbone) {
+ "use strict";
+ var app = {data: {}};
+
+ function login(nick, cb) {
+ $.ajax({
+ type: "POST",
+ url: '/signin',
+ data: {nick: nick},
+ dataType: 'json'
+ })
+ .done(function(auth) {
+ return cb(null,
+ new app.User({nick: auth.nick}),
+ new app.UserSet(auth.users));
+ })
+ .fail(function(xhr, textStatus, error) {
+ return cb(error);
+ });
+ }
+
+ function logout(cb) {
+ $.ajax({
+ type: "POST",
+ url: '/signout',
+ data: {nick: app.data.user && app.data.user.get('nick')},
+ dataType: 'json'
+ })
+ .done(function(result) {
+ return cb(null, result);
+ })
+ .fail(function(xhr, textStatus, error) {
+ return cb(error);
+ });
+ }
+
+ app.Router = Backbone.Router.extend({
+ routes: {
+ '': 'index'
+ },
+
+ index: function() {
+ // login form
+ if (this.loginView)
+ this.loginView.undelegateEvents();
+ this.loginView = new app.LoginView(app.data);
+ this.loginView.render();
+
+ // users list
+ if (this.usersView)
+ this.usersView.undelegateEvents();
+ this.usersView = new app.UsersView(app.data);
+ this.usersView.render();
+ }
+ });
+
+ app.User = Backbone.Model.extend({
+ defaults: {nick: undefined}
+ });
+
+ app.UserSet = Backbone.Collection.extend({
+ url: '/users',
+ model: app.User
+ });
+
+ app.UsersView = Backbone.View.extend({
+ el: '#users',
+
+ initialize: function(options) {
+ this.collection = options && options.users;
+ if (this.collection)
+ return this.render();
+ this.collection = new app.UserSet();
+ this.collection.fetch({
+ error: function() {
+ alert('Could not load connected users list');
+ },
+ success: function(users) {
+ this.render();
+ }.bind(this)
+ });
+ },
+
+ render: function() {
+ var $list = this.$el.find('ul');
+ $list.find('li:not([class=nav-header])').remove();
+ this.collection.each(function(user) {
+ $list.append($('<li/>').text(user.get('nick')));
+ });
+ return this;
+ }
+ });
+
+ app.LoginView = Backbone.View.extend({
+ el: '#login',
+
+ events: {
+ 'submit form#signin': 'signin',
+ 'submit form#signout': 'signout'
+ },
+
+ initialize: function(options) {
+ this.user = options && options.user;
+ },
+
+ render: function() {
+ if (!this.user) {
+ this.$el.find('#signin').show();
+ this.$el.find('#signout').hide().find('.nick').text('');
+ } else {
+ this.$el.find('#signin').hide();
+ this.$el.find('#signout').show().find('.nick')
+ .text(this.user.get('nick'));
+ }
+ return this;
+ },
+
+ signin: function(event) {
+ event.preventDefault();
+ var nick = $.trim($(event.currentTarget).find('[name="nick"]').val());
+ if (!nick)
+ return alert('please enter a nickname');
+ login(nick, function(err, user, users) {
+ if (err)
+ return alert(err);
+ app.data.user = user;
+ app.data.users = users;
+ app.router.index();
+ });
+ },
+
+ signout: function(event) {
+ event.preventDefault();
+ logout(function(err) {
+ if (err)
+ return alert(err);
+ app.data.user = app.data.users = undefined;
+ app.router.index();
+ });
+ }
+ });
+
+ app.router = new app.Router();
+ Backbone.history.start();
+ return app;
+})(jQuery, Backbone);
View
28 static/talkilla.js
@@ -1,28 +0,0 @@
-/* jshint unused: false */
-/* XXX shouldn't need the unused above, ditch once we have Backbone/modules? */
-function login() {
- var form = document.getElementById("login");
- var xhr = new XMLHttpRequest();
- xhr.onload = function() {
- if (this.status !== 200) {
- form.style.display = "";
- return;
- }
- var data = JSON.parse(this.responseText);
- document.getElementById("title").textContent = "Welcome " + data.nick + "!";
- if (!data.users.length) {
- document.getElementById("invite").style.display = "";
- return;
- }
- var ul = document.getElementById("friends");
- data.users.forEach(function(user) {
- var li = document.createElement("li");
- li.textContent = user;
- ul.appendChild(li);
- });
- };
-
- xhr.open("POST", "signin", true);
- xhr.send(new FormData(form));
- form.style.display = "none";
-}
View
141 static/vendor/bootstrap-2.1.1/README.md
@@ -1,141 +0,0 @@
-[Twitter Bootstrap](http://twitter.github.com/bootstrap) [![Build Status](https://secure.travis-ci.org/twitter/bootstrap.png)](http://travis-ci.org/twitter/bootstrap)
-=================
-
-This version of Bootstrap is maintained to be only the built version of bootstrap to be used with bower. If you are looking for the full source of bootstrap go to [bootstrap](https://github.com/twitter/bootstrap)
-
-Bootstrap is a sleek, intuitive, and powerful front-end framework for faster and easier web development, created and maintained by [Mark Otto](http://twitter.com/mdo) and [Jacob Thornton](http://twitter.com/fat) at Twitter.
-
-To get started, checkout http://getbootstrap.com!
-
-
-
-Quick start
------------
-
-Clone the repo, `git clone git://github.com/twitter/bootstrap.git`, or [download the latest release](https://github.com/twitter/bootstrap/zipball/master).
-
-
-
-Versioning
-----------
-
-For transparency and insight into our release cycle, and for striving to maintain backward compatibility, Bootstrap will be maintained under the Semantic Versioning guidelines as much as possible.
-
-Releases will be numbered with the following format:
-
-`<major>.<minor>.<patch>`
-
-And constructed with the following guidelines:
-
-* Breaking backward compatibility bumps the major (and resets the minor and patch)
-* New additions without breaking backward compatibility bumps the minor (and resets the patch)
-* Bug fixes and misc changes bumps the patch
-
-For more information on SemVer, please visit http://semver.org/.
-
-
-
-Bug tracker
------------
-
-Have a bug? Please create an issue here on GitHub that conforms with [necolas's guidelines](https://github.com/necolas/issue-guidelines).
-
-https://github.com/twitter/bootstrap/issues
-
-
-
-Twitter account
----------------
-
-Keep up to date on announcements and more by following Bootstrap on Twitter, [@TwBootstrap](http://twitter.com/TwBootstrap).
-
-
-
-Blog
-----
-
-Read more detailed announcements, discussions, and more on [The Official Twitter Bootstrap Blog](http://blog.getbootstrap.com).
-
-
-
-Mailing list
-------------
-
-Have a question? Ask on our mailing list!
-
-twitter-bootstrap@googlegroups.com
-
-http://groups.google.com/group/twitter-bootstrap
-
-
-
-IRC
----
-
-Server: irc.freenode.net
-
-Channel: ##twitter-bootstrap (the double ## is not a typo)
-
-
-
-Developers
-----------
-
-We have included a makefile with convenience methods for working with the Bootstrap library.
-
-+ **dependencies**
-Our makefile depends on you having recess, connect, uglify.js, and jshint installed. To install, just run the following command in npm:
-
-```
-$ npm install recess connect uglify-js jshint -g
-```
-
-+ **build** - `make`
-Runs the recess compiler to rebuild the `/less` files and compiles the docs pages. Requires recess and uglify-js. <a href="http://twitter.github.com/bootstrap/less.html#compiling">Read more in our docs &raquo;</a>
-
-+ **test** - `make test`
-Runs jshint and qunit tests headlessly in [phantomjs](http://code.google.com/p/phantomjs/) (used for ci). Depends on having phantomjs installed.
-
-+ **watch** - `make watch`
-This is a convenience method for watching just Less files and automatically building them whenever you save. Requires the Watchr gem.
-
-
-
-Contributing
-------------
-
-Please submit all pull requests against *-wip branches. If your unit test contains javascript patches or features, you must include relevant unit tests. Thanks!
-
-
-
-Authors
--------
-
-**Mark Otto**
-
-+ http://twitter.com/mdo
-+ http://github.com/markdotto
-
-**Jacob Thornton**
-
-+ http://twitter.com/fat
-+ http://github.com/fat
-
-
-
-Copyright and license
----------------------
-
-Copyright 2012 Twitter, Inc.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this work except in compliance with the License.
-You may obtain a copy of the License in the LICENSE file, or at:
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
View
30 static/vendor/bootstrap-2.1.1/component.json
@@ -1,30 +0,0 @@
-{
- "name": "bootstrap.css",
- "description": "Sleek, intuitive, and powerful front-end framework for faster and easier web development. This is the version that should be available to bower.",
- "version": "2.1.1",
- "keywords": [
- "bootstrap",
- "css",
- "bootstrap.js"
- ],
- "homepage": "http://twitter.github.com/bootstrap/",
- "author": {
- "name": "Twitter Inc."
- },
- "scripts": {
- "test": "make test"
- },
- "repository": {
- "type": "git",
- "url": "git://github.com/bowerjs/bootstrap.git"
- },
- "licenses": [
- {
- "type": "Apache-2.0",
- "url": "http://www.apache.org/licenses/LICENSE-2.0"
- }
- ],
- "readme": "[Twitter Bootstrap](http://twitter.github.com/bootstrap) [![Build Status](https://secure.travis-ci.org/twitter/bootstrap.png)](http://travis-ci.org/twitter/bootstrap)\n=================\n\nBootstrap is a sleek, intuitive, and powerful front-end framework for faster and easier web development, created and maintained by [Mark Otto](http://twitter.com/mdo) and [Jacob Thornton](http://twitter.com/fat) at Twitter.\n\nTo get started, checkout http://getbootstrap.com!\n\n\n\nQuick start\n-----------\n\nClone the repo, `git clone git://github.com/twitter/bootstrap.git`, or [download the latest release](https://github.com/twitter/bootstrap/zipball/master).\n\n\n\nVersioning\n----------\n\nFor transparency and insight into our release cycle, and for striving to maintain backward compatibility, Bootstrap will be maintained under the Semantic Versioning guidelines as much as possible.\n\nReleases will be numbered with the following format:\n\n`<major>.<minor>.<patch>`\n\nAnd constructed with the following guidelines:\n\n* Breaking backward compatibility bumps the major (and resets the minor and patch)\n* New additions without breaking backward compatibility bumps the minor (and resets the patch)\n* Bug fixes and misc changes bumps the patch\n\nFor more information on SemVer, please visit http://semver.org/.\n\n\n\nBug tracker\n-----------\n\nHave a bug? Please create an issue here on GitHub that conforms with [necolas's guidelines](https://github.com/necolas/issue-guidelines).\n\nhttps://github.com/twitter/bootstrap/issues\n\n\n\nTwitter account\n---------------\n\nKeep up to date on announcements and more by following Bootstrap on Twitter, [@TwBootstrap](http://twitter.com/TwBootstrap).\n\n\n\nBlog\n----\n\nRead more detailed announcements, discussions, and more on [The Official Twitter Bootstrap Blog](http://blog.getbootstrap.com).\n\n\n\nMailing list\n------------\n\nHave a question? Ask on our mailing list!\n\ntwitter-bootstrap@googlegroups.com\n\nhttp://groups.google.com/group/twitter-bootstrap\n\n\n\nIRC\n---\n\nServer: irc.freenode.net\n\nChannel: ##twitter-bootstrap (the double ## is not a typo)\n\n\n\nDevelopers\n----------\n\nWe have included a makefile with convenience methods for working with the Bootstrap library.\n\n+ **dependencies**\nOur makefile depends on you having recess, connect, uglify.js, and jshint installed. To install, just run the following command in npm:\n\n```\n$ npm install recess connect uglify-js jshint -g\n```\n\n+ **build** - `make`\nRuns the recess compiler to rebuild the `/less` files and compiles the docs pages. Requires recess and uglify-js. <a href=\"http://twitter.github.com/bootstrap/less.html#compiling\">Read more in our docs &raquo;</a>\n\n+ **test** - `make test`\nRuns jshint and qunit tests headlessly in [phantomjs](http://code.google.com/p/phantomjs/) (used for ci). Depends on having phantomjs installed.\n\n+ **watch** - `make watch`\nThis is a convenience method for watching just Less files and automatically building them whenever you save. Requires the Watchr gem.\n\n\n\nContributing\n------------\n\nPlease submit all pull requests against *-wip branches. If your unit test contains javascript patches or features, you must include relevant unit tests. Thanks!\n\n\n\nAuthors\n-------\n\n**Mark Otto**\n\n+ http://twitter.com/mdo\n+ http://github.com/markdotto\n\n**Jacob Thornton**\n\n+ http://twitter.com/fat\n+ http://github.com/fat\n\n\n\nCopyright and license\n---------------------\n\nCopyright 2012 Twitter, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this work except in compliance with the License.\nYou may obtain a copy of the License in the LICENSE file, or at:\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n",
- "_id": "bootstrap@2.1.1",
- "gitHead": "bede386a1225c6dfc9cb979f24e58cd149097344"
-}
View
15 test/presence_api_test.js
@@ -1,9 +1,9 @@
/* global describe, it, beforeEach, afterEach */
/* jshint expr:true */
-var expect = require('chai').expect;
-var request = require('request');
-var server = require('../server').server;
+var expect = require("chai").expect;
+var request = require("request");
+var server = require("../server").server;
var findNewNick = require("../server").findNewNick;
var connection;
@@ -37,12 +37,12 @@ describe("Server", function() {
it('should have foo logged in', function(done) {
signin('foo', function() {
- expect(server.get('users')).to.eql(['foo']);
+ expect(server.get("users")).to.eql([{nick: "foo"}]);
done();
});
});
- it('should have no users logged in after logging in and out',
+ it('should have no users logged in after logging in and out',
function(done) {
signin('foo', function() {
signout('foo', function() {
@@ -57,7 +57,7 @@ describe("Server", function() {
signin('foo', function(err, res, body) {
var data = JSON.parse(body);
expect(data.nick).to.eql(nick1);
- expect(data.users).to.be.empty;
+ expect(data.users).to.eql([{nick: "foo"}]);
done();
});
});
@@ -98,11 +98,12 @@ describe("Server", function() {
it("should return existing users", function(done) {
var nick1 = "foo";
var nick2 = "bar";
+
signin(nick1, function() {
signin(nick2, function(err, res, body) {
var data = JSON.parse(body);
expect(data.nick).to.eql(nick2);
- expect(data.users).to.eql([nick1]);
+ expect(data.users).to.eql([{nick: nick1}, {nick: nick2}]);
done();
});
});
Something went wrong with that request. Please try again.