Git Product home page Git Product logo

angular-xmpp's Introduction

angular-xmpp

This is a library, that provides styleable UI Elements for XMPP over Websockets using xmpp-ftw and angular-xmpp-services.

diagram;

Demo app

Try here: https://buddycloud.org For testing, open the "login" dropdown and click "sign in". At the moment username and password are prefilled. You can play with a real account with real data.

Known bugs: search is not working at the moment

Screenshot bootstrap design

Let's see the directives

bootstrap design

But it can look totaly different

depending on your design skills (conversjs clone - prove of concept) convers clone

getting started

bower install angular-xmpp

To see the buddycloud example (screenshot) open

bower_components/angular-xmpp/bin/index.html

in your browser.

connect to server

To connect to the xmpp server we need an [xmpp-ftw server](You will maybe find something like tha://github.com/xmpp-ftw/xmpp-ftw-demo/). You can install that on your localhost. To make buddycloud working read this posting !!!

host: xmpp-ftw server address

defaultdomain: if the is no "@"sign in the login name the defaultdomain will be added.

<xmpp host="https://prod.buddycloud.com"  defaultdomain="laos.buddycloud.com" > </xmpp>

The default domain is also nessessary if you allow anonymous logins.

The directives

login + roster

<xmpp host="https://prod.buddycloud.com">
    <xmpplogin defaultdomain="laos.buddycloud.com"></xmpplogin>
    <xmpproster></xmpproster>
</xmpp>

plunker (no styling)
plunker (bootstrap styling)

include the chat

angular.module("XmppApp", ["AngularXmpp", 'templates-app'])
      .controller("page", function($scope) {
        $scope.openchat = function(jid) {
          console.log("openchat", jid, $scope.chat);
          $scope.chat.openchat(jid);
        }
        $scope.initchat = function(chat) {
          $scope.chat = chat;
        }
      });
<xmpp host="https://prod.buddycloud.com" >
      <xmpplogin></xmpplogin>
      <xmpproster onopenchat="openchat(jid)"></xmpproster>
      <xmppminichat oninit="initchat(scope)"></xmppminichat>
</xmpp>

plunker (default styling)

use your own template

Use the attribute 'template-url' to replace the html template by your own html. Here a small example how to start.

<xmpproster onopenchat="openchat(jid)" template-url="roster.html"></xmpproster>

plunker

It's very handy to use the build in angular json formatter.

<pre>{{xmpp.model.roster|json}}</pre>

You also can use a json-formatter plugin to observe the model as in this example:

plunker

example xmpp muc

Say hello to the developers hangout.

<xmpp host="https://prod.buddycloud.com" defauldomain="laos.buddycloud.com" anonymous="true">
    <xmppmuc room="[email protected]" nick="guest"></xmppmuc>
</xmpp>

plunker (explore the model)
plunker (simple template)

example xmpp buddycloud

<xmpp host="https://prod.buddycloud.com">
    <xmpplogin></xmpplogin>
    <buddycloud node="/user/[email protected]/posts">
        <buddycloud-stream></buddycloud-stream>
    </buddycloud>
</xmpp>

plunker (working example)
plunker (model + post field )

Combine with your project

Buddycloud events

<input ng-mode="node"/>
<buddycloud node="node" onchangenode="nodechangedinsidedirective(node)">
    <buddycloud-stream></buddycloud-stream>
</buddycloud>

In your controller

...
$scope.node="/user/[email protected]/posts";
$scope.nodechangedinsidedirective=function(node){
    //change hashtag or whatever
}

Styling

The templates include all the javascript that has to be done and tries to keep the html simple. Your part is to give them a style.

What is it about?

If you are good in design, but don't like javascript programming, here is your starting point.

Dynamic Json

All the information the stream needs is in json object, that looks like in this plunker. http://plnkr.co/edit/hysY7CLfUngw2nRivI2j?p=preview

At

tree[0].entry.atom.content.content

you find the text of a message.

The HTML

The next plunker shows you the buddycloud stream.

http://plnkr.co/edit/qd7tIpQT2zvuhE9wsMbP?p=preview

You can edit the file "stream.tmp.html" to change the the output. If you don't like bootstrap, change the style to ioncic for example or build a fance SVG version.

how to start more serious

git clone https://github.com/robotnic/angular-xmpp

directory structure

The structure comes from ng-boilerplate. All the angular factorys are in a seperate project called angular-xmpp-services.

js, html and less lives together and build a directive

├── app.js
├── buddycloud
│   ├── buddycloud.js
│   └── buddycloud.less
├── buddycloud-nodelist
│   ├── buddycloud-nodelist.js
│   ├── nodelist.less
│   └── template.tpl.html
....
├── minichat
│   ├── minichat.js
│   ├── minichat.less
│   └── template.tpl.html
├── navbar
│   └── template.tpl.html
├── xmppcore
│   └── xmppcore.js

grunt

If you want to make changes to this repository. You have to run the grunt task builder.

grunt watch --force

The result is in the "build" folder

If you are happy with your work run

grunt compile

This will make more optimation.

angular-xmpp's People

Contributors

lloydwatkin avatar robotnic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-xmpp's Issues

search

activate jabber search - or what ever search is available.

no login button

If there is no connection to the server, there is no loginbuttin.
A test "connection..." should apear.

Content format

At the moment markdown text is rendered. There is no metainformation about the used format.

Specification needed.

deep link

It's possible to address the node in the url, but not an item.

Photo Albums

  • upload images
  • manage image paths in a pubsub node

Problem: User can't create pubsub (pep) node.

A list of albums could also be a pubsub node.

Use Cases

The usecases have to be definded

  • Facebook clone
  • Communication system for an intranet website
  • Addon to existing websites with tiny ui

URLS are messy

https://angular-demo.buddycloud.org/#/user/[email protected]/posts

would be nicer as

site/<channel>

eg: https://angular-demo.buddycloud.org/[email protected]

I believe the try_files $uri $uri/ /index.html; will mean you can loose the hash and be better indexed too.

Cookie based login

If the browser page is reloaded, the user has to login again. A cookie based session reopen is needed.
Also to make unified login for rest and xmpp a cookie based mechanism is needed.

Avatar

vCard is not implemented

project structure

Build Process

At the moment there is no build process and every file has to have it's own script tag. A minimizer also is missing. The project is growing and needs better structure. For building and testing we need automatisation.

ng-boilerplate?
any suggestions?

App or Lib

At the moment there are lots of angular directives for ui components that talk to factorys.
The factorys are talking to the xmpp layer und the directives generate html for the ui componentes.
There is one app the "index.html"

The goal is to make a lib that many different apps can use.
But what's part of the app and what's part of the lib?

Principles

Every action has a reaction. The reaction happens immediately. On an Ideal xmpp network the action and reaction on target screens happen at the same time.

http://youtu.be/V-0Av59JbO4?t=8s

API

login

This is the userinterface for login. If there is a session based login, this is not needed.

<xmpplogin></xmpplogin>

It has two text fields and a register checkbox.

Contacts

This directive displays contacts and online status. It send's a broadcast to rootscope for opening a chat window.

<xmpproster></xmpproster>

Chat

Small facebook like direct messaging. It's listening to broadcast in root scope.

<xmppminichat></xmppminichat>

(the name of the directive is stupid)

Multiuser chat

<xmppmuc node="[email protected]"></xmppmuc>

Buddycloud

It's like facebook timeline or github issue list.

<buddycloud ng-if="selectednode.node"  node="/user/[email protected]/posts" changenode="open(node)"></buddycloud>

Buddycloud Roster

This is not implemented

<buddycloudroster ng-if="selectednode.node"  node="/user/[email protected]/posts" changenode="open(node)"></buddycloudroster>

Combination of buddycloud nodes and roster. The UI does:

  • shows Online/Offline Users status
  • Message Counter for users
  • Message Counter for Nodes
  • Open chat window
  • Open Node associated to the user
  • Open Map

Like

There is a simple like system. Every jid is allowed to like once. Likers are public.
At the moment this is implemented with a buggy node bot that does not run stable and
does not have a db backend. All data are in memory and if the app crashes it starts with no data.

There is a quickhack at
https://github.com/robotnic/likebot/blob/master/index.js
json structures are traveling stringifyd inside normal messages.
If there is a xmpp guru. How to do that thing?

<like id="123XZEEEE$RFGGGGFFDDSS§$§§2223"></like>

Styling

This is not implemented

<buddycloud template="'beautytemplate.html'"></buddycloud>

to make comple new style
<buddycloud templatedir="styles/black/"></buddycloud>

It's possible to style the UI in a complete new way without javascript programming.
ng-click="goforit"

Translate

angular-translate is ok. This is not implemented.

Configurations

This is not implemented
<xmppconfig
websocket="http://laos.buddycloud.com"
auth="sessionbased"

Post websites

If a link is postet, a crawler should make a summary of the page, with image.
Youtube links would be very nice.

install on buddycloud-vm

install

The angular-xmpp client has no server component. It's possible to use nginx to serve these files

Install in buddycloud-vm

cd /opt 
bower install angular-xmpp 

or

git clone [email protected]:robotnic/angular-xmpp.git

nginx configuration

server { 
  server_name buddycloud.dev;
  listen 80;
  location /api/ {
      proxy_pass http://127.0.0.1:9123/; 
  } 
  location / { 
     proxy_pass http://127.0.0.1:3000/; 
     proxy_http_version 1.1; 
     proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection "upgrade"; 
 } 
 location /bin/ { 
     root /opt/bower_components/angular-xmpp/;
 }
} 

restart nginx

/etc/init.d/nginx restart  

open the client

http://localhost:3000/bin

Post images

It should be possible to post images to the timeline.

likes

I made a XmppLike directive.

To enable the like module, the likebot must be startet.
See https://github.com/robotnic/likebot

The likebot is experimental, has no database backend und connection is not stable.
If you know how to write a stable bot, you are welcome.

At the moment the bot uses {blabla:4} to communicat.
This messages should not apear in the users inbox.
Maybe iq protocol would be better (never done that)

Jabber → XMPP

"Jabber" is owned by CISCO so really shouldn't be used in the project anywhere :)

ui-router

Project gets more complex, time for ui-router

  • history
  • views
  • code structure

remove ui from lib

Maybe like this

angular-xmpp: factorys
angular-xmpp-ui: directives, controllers
angular-xmpp-bootstrap: bootstrap design for components.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.