<commit_before># openHAB Cloud

openHAB Cloud is a companion cloud service and backend for the openHAB open-source home automation software.
The openHAB Cloud backend provides secure remote access and enables openHAB users to remotely monitor,
control and steer their homes through the internet, collect device statistics of their openHABs, receive
notifications on their mobile devices or collect and visualize data etc.
The main core features of openHAB Cloud are an user-management frontend, secure remote access, remote proxy-access, device registry & management, messaging services and data management & persistence.
The openHAB Cloud also serves as core backend integration point for cloud-based features (e.g. IFTTT) and
provides an OAuth2 application enablement.


## Functional Architecture ##



![FunctionalArchitecture](/docs/FunctionalArchitecture_openHAB-cloud_v1.0.png)



## Getting started


openHAB Cloud is mainly based on the following frameworks and technologies:


* [Node.js](https://nodejs.org/en/) - Server-side Javascript-framework
* [Express.js](http://expressjs.com/) - Web application framework for Node.js
* [Nginx](https://www.nginx.com/resources/wiki/) - Web server & reverse proxy
* [MongoDB](https://www.mongodb.com/) - NoSQL database
* [redis](http://redis.io) - Session Manager & data structure server
* [Socket.IO](http://socket.io/) - Bi-directional communication between web clients and servers


### <a name="quickStart"></a> Quick start ###

Installing openHAB Cloud on Linux (ubuntu).


First, we need to make sure that the list of packages and dependencies
from all repositories are up-to-date:

```
sudo apt-get update
sudo apt-get upgrade
```

We need to install redis, mongoDB, Nginx and Python:

```
sudo apt-get install build-essential redis-server mongodb nginx python
```

Now you need install git and clone the openHAB Cloud repository to your
preferred directory (here: ubuntu) with the following commands:

```
apt-get install git
cd /home/YOUR-DIR/
git clone https://github.com/openhab/openhab-cloud.git
```


Clone the openhabcloud repository and after the completed checkout you should have the directory in your chosen folder:
```
ls -al
total 32
drwxr-xr-x  5 ubuntu ubuntu 4096 Jun  4 17:06 .
drwxr-xr-x  3 root   root   4096 Jun  4 12:34 ..
-rw-r--r--  1 ubuntu ubuntu  220 Apr  9  2014 .bash_logout
-rw-r--r--  1 ubuntu ubuntu 3637 Apr  9  2014 .bashrc
drwx------  2 ubuntu ubuntu 4096 Jun  4 16:30 .cache
drwxr-xr-x 13 root   root   4096 Jun  4 17:06 openhabcloud
-rw-r--r--  1 ubuntu ubuntu  675 Apr  9  2014 .profile
drwx------  2 ubuntu ubuntu 4096 Jun  4 12:34 .ssh
```


Now we need to change into the openhabcloud directory and check if node is installed:

```
node --version
```


If you see the node version, you are fine to continue.

To run openHAB Cloud you need to install the required software bundles/stacks:

```
cd openhabcloud
```
```
npm install
```

and all the module dependencies from **package.json** will be resolved and needed packages installed.






openHAB Cloud uses redis for session management.
To learn more about redis please read [here](http://redis.io).

To check if redis is installed correctly and running we run this command:

```
redis-cli ping
```
Redis will answer with PONG if all is fine.


Now you can run openHAB Cloud by the following command:
```
sudo node app.js
```

Point your webbrowser to:
```
http://localhost:3000
```

You should be ready with your openHAB Cloud installation!


#### <a name="setupNginx"></a>Setting up Nginx ####
Optionally you can also setup Nginx as webserver:

For this we have to configure nginx as webserver and copy the openHAB Cloud nginx config, overriding the default config:
```
sudo cp /home/ubuntu/openhabcloud/etc/nginx_openhabcloud.conf /etc/nginx/sites-available/default
```

Change the following lines to match your installation.
Point `server_name` to your IP/DNS.

```
cd /etc/nginx/sites-enabled
sudo vi default
```

```
server {
#listen *:443;
listen *:80;
#ssl on;
# ssl_certificate /etc/nginx/ssl/YOUR-KEY.crt;
# ssl_certificate_key /etc/nginx/ssl/YOUR-KEY.key;
#ssl_certificate /etc/nginx/ssl/YOUR-CER.crt;
#ssl_certificate_key /etc/nginx/ssl/YOUR-KEY.key;

server_name YOUR-DNS-NAME;

#if ( $scheme = "http" ) {
#    rewrite ^/(.*)$    https://$host/$1 permanent;
#}

charset utf-8;

access_log /var/log/nginx/openhabcloud.org-access.log;
error_log /var/log/nginx/openhabcloud-error.log;
client_max_body_size 300m;

location /css {
    alias  /home/ubuntu/openhabcloud/public/css;
    }
location /js {
    alias /home/ubuntu/openhabcloud/public/js;
    }
location /img {
    alias /home/ubuntu/openhabcloud/public/img;
    }
location /bootstrap {
    alias /home/ubuntu/openhabcloud/public/bootstrap;
    }
location /font-icons {
    alias /home/ubuntu/openhabcloud/public/font-icons;
    }
location /fonts {
    alias /home/ubuntu/openhabcloud/public/fonts;
    }
location /js-plugin {
    alias /home/ubuntu/openhabcloud/public/js-plugin;
    }<commit_msg>staff js-plugin 404 error fix (#132)<commit_after># openHAB Cloud

openHAB Cloud is a companion cloud service and backend for the openHAB open-source home automation software.
The openHAB Cloud backend provides secure remote access and enables openHAB users to remotely monitor,
control and steer their homes through the internet, collect device statistics of their openHABs, receive
notifications on their mobile devices or collect and visualize data etc.
The main core features of openHAB Cloud are an user-management frontend, secure remote access, remote proxy-access, device registry & management, messaging services and data management & persistence.
The openHAB Cloud also serves as core backend integration point for cloud-based features (e.g. IFTTT) and
provides an OAuth2 application enablement.


## Functional Architecture ##



![FunctionalArchitecture](/docs/FunctionalArchitecture_openHAB-cloud_v1.0.png)



## Getting started


openHAB Cloud is mainly based on the following frameworks and technologies:


* [Node.js](https://nodejs.org/en/) - Server-side Javascript-framework
* [Express.js](http://expressjs.com/) - Web application framework for Node.js
* [Nginx](https://www.nginx.com/resources/wiki/) - Web server & reverse proxy
* [MongoDB](https://www.mongodb.com/) - NoSQL database
* [redis](http://redis.io) - Session Manager & data structure server
* [Socket.IO](http://socket.io/) - Bi-directional communication between web clients and servers


### <a name="quickStart"></a> Quick start ###

Installing openHAB Cloud on Linux (ubuntu).


First, we need to make sure that the list of packages and dependencies
from all repositories are up-to-date:

```
sudo apt-get update
sudo apt-get upgrade
```

We need to install redis, mongoDB, Nginx and Python:

```
sudo apt-get install build-essential redis-server mongodb nginx python
```

Now you need install git and clone the openHAB Cloud repository to your
preferred directory (here: ubuntu) with the following commands:

```
apt-get install git
cd /home/YOUR-DIR/
git clone https://github.com/openhab/openhab-cloud.git
```


Clone the openhabcloud repository and after the completed checkout you should have the directory in your chosen folder:
```
ls -al
total 32
drwxr-xr-x  5 ubuntu ubuntu 4096 Jun  4 17:06 .
drwxr-xr-x  3 root   root   4096 Jun  4 12:34 ..
-rw-r--r--  1 ubuntu ubuntu  220 Apr  9  2014 .bash_logout
-rw-r--r--  1 ubuntu ubuntu 3637 Apr  9  2014 .bashrc
drwx------  2 ubuntu ubuntu 4096 Jun  4 16:30 .cache
drwxr-xr-x 13 root   root   4096 Jun  4 17:06 openhabcloud
-rw-r--r--  1 ubuntu ubuntu  675 Apr  9  2014 .profile
drwx------  2 ubuntu ubuntu 4096 Jun  4 12:34 .ssh
```


Now we need to change into the openhabcloud directory and check if node is installed:

```
node --version
```


If you see the node version, you are fine to continue.

To run openHAB Cloud you need to install the required software bundles/stacks:

```
cd openhabcloud
```
```
npm install
```

and all the module dependencies from **package.json** will be resolved and needed packages installed.






openHAB Cloud uses redis for session management.
To learn more about redis please read [here](http://redis.io).

To check if redis is installed correctly and running we run this command:

```
redis-cli ping
```
Redis will answer with PONG if all is fine.


Now you can run openHAB Cloud by the following command:
```
sudo node app.js
```

Point your webbrowser to:
```
http://localhost:3000
```

You should be ready with your openHAB Cloud installation!


#### <a name="setupNginx"></a>Setting up Nginx ####
Optionally you can also setup Nginx as webserver:

For this we have to configure nginx as webserver and copy the openHAB Cloud nginx config, overriding the default config:
```
sudo cp /home/ubuntu/openhabcloud/etc/nginx_openhabcloud.conf /etc/nginx/sites-available/default
```

Change the following lines to match your installation.
Point `server_name` to your IP/DNS.

```
cd /etc/nginx/sites-enabled
sudo vi default
```

```
server {
#listen *:443;
listen *:80;
#ssl on;
# ssl_certificate /etc/nginx/ssl/YOUR-KEY.crt;
# ssl_certificate_key /etc/nginx/ssl/YOUR-KEY.key;
#ssl_certificate /etc/nginx/ssl/YOUR-CER.crt;
#ssl_certificate_key /etc/nginx/ssl/YOUR-KEY.key;

server_name YOUR-DNS-NAME;

#if ( $scheme = "http" ) {
#    rewrite ^/(.*)$    https://$host/$1 permanent;
#}

charset utf-8;

access_log /var/log/nginx/openhabcloud.org-access.log;
error_log /var/log/nginx/openhabcloud-error.log;
client_max_body_size 300m;

location /css {
    alias  /home/ubuntu/openhabcloud/public/css;
    }
location /js {
    alias /home/ubuntu/openhabcloud/public/js;
    }
location /img {
    alias /home/ubuntu/openhabcloud/public/img;
    }
location /bootstrap {
    alias /home/ubuntu/openhabcloud/public/bootstrap;
    }
location /font-icons {
    alias /home/ubuntu/openhabcloud/public/font-icons;
    }
location /fonts {
    alias /home/ubuntu/openhabcloud/public/fonts;
    }
location /js-plugin {
    alias /home/ubuntu/openhabcloud/public/js-plugin;
    }
location /staff/js-plugin {
    alias /home/ubuntu/openhabcloud/public/js-plugin;
    }
{'fraction_non_alphanumeric': 0.10430839002267574, 'fraction_numerical': 0.01991521246179631, 'mean_word_length': 3.8535885167464117, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 10, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6826072', 'n_tokens_mistral': 3504, 'n_tokens_neox': 3107, 'n_words': 1133}