Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Backbone.xmpp #263

Closed
wants to merge 20 commits into from

3 participants

@ggozad

Backbone.xmpp allows using XMPP PubSub nodes for syncing your Backbone models/collections, providing real-time updates. Using it in the context of todomvc many users can collaboratively manage the todo list with different browsers in real time.

I have adapted the Backbone version to work with it, resulting in a very small diff from the original, mostly to connect to the server. Instructions on setting up a server are inside Readme.md. Let me know if you are interested in this, will be happy to provide more info/adapt if necessary!

labs/architecture-examples/backbone.xmpp/README.md
@@ -0,0 +1,33 @@
+Introduction
+------------
+
+This is a demo of the TodoMVC app using [Backbone.xmpp](http://github.com/ggozad/Backbone.xmpp).
+
+Backbone.xmpp allows use to use XMPP PubSub nodes for syncing your Backbone models/collections, providing real-time updates.
+
+
+Installation of the XMPP server (ejabberd)
+------------------------------------------
+
+In the `server` directory scripts are included to help you build and configure an XMPP server without too much hussle. You will need to have erlang and python installed to compile it for your platform. Specify the path to the erlang binary by changing the `erlang-path` variable in the `buildout.cfg` file.
@sindresorhus Owner

Any reason you can't just install the ejabberd binary?

Installing erlang and ejabberd from source took like forever.

@ggozad
ggozad added a note

Only because the default settings do not include BOSH (the layer that allows XMPP to be run over HTTP). I can indeed just keep the config template and ask the user to overwrite ejabberd.cfg in her installation, but that does not necessary make it easy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
labs/architecture-examples/backbone.xmpp/README.md
((6 lines not shown))
+Backbone.xmpp allows use to use XMPP PubSub nodes for syncing your Backbone models/collections, providing real-time updates.
+
+
+Installation of the XMPP server (ejabberd)
+------------------------------------------
+
+In the `server` directory scripts are included to help you build and configure an XMPP server without too much hussle. You will need to have erlang and python installed to compile it for your platform. Specify the path to the erlang binary by changing the `erlang-path` variable in the `buildout.cfg` file.
+
+ cd server
+ python bootstrap.py
+ ./bin/buildout
+
+Once buildout completes, you should have a compiled ejabberd.
+Proceed by setting up the `admin` user:
+
+ ./bin/ejabberdctl register admin localhost admin
@sindresorhus Owner

When running this I got:

Failed RPC connection to the node ejabberd@localhost: nodedown

?

@ggozad
ggozad added a note

You need to be running ejabberd. Will amend README.

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

View of all changes upon the original Backbone app: ggozad@fa2a5ba...9c7bd32

@ggozad

@sindresorhus if you think it's easier to install ejabberd from the installer and copy over the ejabberd.cfg it's trivial for me to make the change. Can you try it out and let me know? You only need the generated etc/ejabberd.cfg

@sindresorhus

It's just that it took my Mac almost half an hour to compile both erland and ejabberd. I think a developer would always choose the hard and short way over the long way. So, yes, I would prefer that.

@sindresorhus sindresorhus commented on the diff
labs/architecture-examples/backbone.xmpp/index.html
((12 lines not shown))
+<body>
+ <section id="todoapp">
+ <header id="header">
+ <h1>todos</h1>
+ <input id="new-todo" placeholder="What needs to be done?" autofocus>
+ </header>
+ <section id="main">
+ <input id="toggle-all" type="checkbox">
+ <label for="toggle-all">Mark all as complete</label>
+ <ul id="todo-list"></ul>
+ </section>
+ <footer id="footer"></footer>
+ </section>
+ <div id="info">
+ <p>Double-click to edit a todo</p>
+ <p>Written by <a href="https://github.com/addyosmani">Addy Osmani</a></p>
@sindresorhus Owner

Add your name, like Adopted to use XMPP ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
...ecture-examples/backbone.xmpp/js/collections/todos.js
((29 lines not shown))
+ // GUID in the database. This generates the next order number for new items.
+ nextOrder: function() {
+ if ( !this.length ) {
+ return 1;
+ }
+ return this.last().get('order') + 1;
+ },
+
+ // Todos are sorted by their original insertion order.
+ comparator: function( todo ) {
+ return todo.get('order');
+ }
+ });
+
+ // Create our global collection of **Todos**.
+ app.Todos = new TodoList(); app.Todos = new TodoList();
@sindresorhus Owner

deja vu

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

Found one bug. It does not sync right away when deleting a todo, must add a todo for it to sync.

Other than that, it works perfectly :)

  • Can you add a few words in the readme why XMPP is great for this kind a thing and why and where people should consider using it?

  • Can you include this link in the readme to show how easy and little code that is required to add XMPP support to an existing app? ggozad@fa2a5ba...9c7bd32

@ggozad

@sindresorhus Ah right, will look into that, I need to adapt the localStorage version slightly.

Yiorgis Goza... added some commits
Yiorgis Gozadinos Indicate how to setup user/domain for ejabberd with installer d388b05
Yiorgis Gozadinos Handle remove on the collection so that when a model is destroyed fro…
…m another user, the todo view is removed
85ca759
Yiorgis Gozadinos shameless credit 0a98ac2
Yiorgis Gozadinos typo f0729d7
Yiorgis Gozadinos update docs 8824fa7
@ggozad

@sindresorhus let me know if I missed something, think it should be ok ;)

@sindresorhus

Will do a final review later today.

@addyosmani What do you think? I think this is a interesting one.
Can be loosely compared to Meteor and Derby realtime stuff.

@addyosmani
Owner

As long as it meets our specs I would be happy with a merge. I also think it would fit in well with the real-time group of apps we've been focusing on lately.

@sindresorhus sindresorhus closed this pull request from a commit
Yiorgis Gozadinos Close GH-263: Backbone.xmpp. 32bbe54
@sindresorhus

Lgtm. Landed. Thanks :)

One question. Would it be possible to host it somewhere so we could link to a live demo?

@ggozad

@sindresorhus Thank you for your excellent review and comments! I will look into providing XMPP for the demo.
The problem would be that you would need to proxy the BOSH requests to XMPP. So say things going to http://addyosmani.github.com/todomvc/labs/architecture-examples/backbone.xmpp/http-bind
would need to be rewritten to http://myserver:5280/http-bind
I am not sure if this is possible with github-pages...
If you want you can find me on irc and discuss...

@addyosmani
Owner

@ggozad as per other apps, we're also happy to link out to your own hosting/server (if you have one) where you might like to host the app. We've found github-pages quite limited when it comes to anything realtime so whatever you think might work best :)

@ggozad

@addyosmani Ah that makes it much easier, I will take the task then and do it as soon as I can get some time to configure a server...

@addyosmani
Owner

Excellent. Thank you!

(happy to tweet out about this awesome new addition as soon as we have it hosted) :)

@johnnyt johnnyt referenced this pull request from a commit
@johnnyt johnnyt Merge branch 'master' into amber
* master: (88 commits)
  Upgrade site to Bootstrap 2.1
  Add .gitattributes to make sure we never get CRLF into the repo
  Correct readme typo. Fixes #270
  Make Backbone.xmpp demo to link to todomcv.crypho.com
  Add Backbone.xmpp to the site and readme
  Close GH-263: Backbone.xmpp.
  Updating version number ahead of tag.
  fix broken link to unlicense.org in README
  Minor wording change to watch. Falling in line with Twitter bootstrap.
  Minor wording change and update to retweet button to include counts.
  Minor cleanup
  Emberjs app: Make sure the app isn't initialized before doc ready. Fixes #249
  Convert almost all apps to trigger editing mode on `<label>` instead of `.view`
  Site: Name fix
  Spine app: Remove old unused CSS file
  Forgot to update Knockback src files
  Backbone app: Add base.js
  Remove Broke.js
  Remove all trailing whitespace and add EOF newlines
  Convert from .select() to .focus()
  ...
88171a4
@gustaff-weldon gustaff-weldon referenced this pull request from a commit in gustaff-weldon/todomvc
Yiorgis Gozadinos Close GH-263: Backbone.xmpp. e42d030
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 10, 2012
  1. Copy over backbone app

    Yiorgis Gozadinos authored
  2. Use base libs

    Yiorgis Gozadinos authored
  3. Add Backbone.xmpp & deps

    Yiorgis Gozadinos authored
  4. Connect to xmpp, setup nodes on startup

    Yiorgis Gozadinos authored
  5. fix js order

    Yiorgis Gozadinos authored
Commits on Aug 11, 2012
  1. Use latest strophe

    Yiorgis Gozadinos authored
  2. Do things in the right order, after we are connected to XMPP

    Yiorgis Gozadinos authored
  3. Add buildout to build ejabberd

    Yiorgis Gozadinos authored
  4. Make BOSH url a setting

    Yiorgis Gozadinos authored
  5. Merge branch 'ejabberd' into Backbone.xmpp

    Yiorgis Gozadinos authored
Commits on Aug 13, 2012
  1. Readme with instructions

    Yiorgis Gozadinos authored
  2. Use ejabberd 2.1.11

    Yiorgis Gozadinos authored
Commits on Aug 14, 2012
  1. First start ejabberd, then add admin

    Yiorgis Gozadinos authored
  2. Give the user the option to use the installer

    Yiorgis Gozadinos authored
  3. Indicate how to setup user/domain for ejabberd with installer

    Yiorgis Gozadinos authored
  4. Handle remove on the collection so that when a model is destroyed fro…

    Yiorgis Gozadinos authored
    …m another user, the todo view is removed
  5. shameless credit

    Yiorgis Gozadinos authored
  6. typo

    Yiorgis Gozadinos authored
  7. update docs

    Yiorgis Gozadinos authored
Something went wrong with that request. Please try again.