Go to file
Rick Carlino 278133332d Merge pull request #244 from FarmBot/gradients
add gradient to landing page so its less drab
2016-04-03 13:13:55 -05:00
app Merge pull request #244 from FarmBot/gradients 2016-04-03 13:13:55 -05:00
bin Finished base app 2014-03-12 06:42:11 -07:00
config Added /api/public_key endpoint for verification of JWTs 2016-03-23 11:41:58 -05:00
db Change `iss` to point to servers URL 2016-03-24 10:02:48 -05:00
lib Haikunate users first bot 2016-03-30 08:41:22 -05:00
log Gitignore change 2014-04-10 06:31:37 -07:00
public Removing certain asset management gems for frontend decoupling 2015-11-24 13:01:43 -05:00
spec New way of handling devices 2016-03-25 08:48:31 -05:00
vendor/assets Added foundation and high voltage. Readme updates, too. 2014-03-31 06:31:38 -07:00
.DS_Store Done with controller for sequence creation - now to make fixes for hound 2015-01-12 07:14:18 -06:00
.gitignore Added /api/public_key endpoint for verification of JWTs 2016-03-23 11:41:58 -05:00
.hound.yml WIP, browserify 2015-09-22 12:17:06 -05:00
.ruby-gemset rename application from `dss` to `farmbot` 2015-03-09 05:31:05 -05:00
.ruby-version WIP, browserify 2015-09-22 12:17:06 -05:00
.travis.yml Typo in Travis.yml 2015-09-28 10:43:21 -05:00
CONTRIBUTING.md Create CONTRIBUTING.md 2015-09-18 22:48:44 -07:00
Gemfile New way of handling devices 2016-03-25 08:48:31 -05:00
Gemfile.lock New way of handling devices 2016-03-25 08:48:31 -05:00
LICENSE Spruce up the README 2015-08-19 10:37:13 -05:00
README.md Update docs wrt. server provisioning. 2016-04-03 00:05:36 -05:00
Rakefile Cruft removal, part I 2015-10-20 13:03:42 -05:00
api_docs.md Routine deploy for Jun 18 2015 2015-06-18 09:00:59 -05:00
api_docs.md.erb API examples 2015-06-10 07:13:41 -05:00
config.ru Added foundation and high voltage. Readme updates, too. 2014-03-31 06:31:38 -07:00

README.md

Code Climate Test Coverage Build Status

Do I need this?

This repository is intended for software developers who wish to modify the Farmbot Web App. If you are not a developer, you are highly encouraged to use the publicly available web app.

If you are a developer interested in contributing or would like to provision your own server, you are in the right place.

Farmbot Web App

LATEST STABLE VERSION IS HERE

This Repo is the Web based side of FarmBot. It allows users to control the device from their web browser. We're getting closer to launch, but it this is an unstable pre-alpha repo.

Developer setup

  1. git clone git@github.com:FarmBot/farmbot-web-app.git
  2. cd farmbot-web-app
  3. Install MongoDB
  4. Start Mongo if you have not already done so. (typically via the mongod command)
  5. bundle install
  6. rails s
  7. Go to http://localhost:3000

Provisioning your own with Dokku

  1. Create a fresh Ubuntu 14 server with Dokku (or just use DigitalOcean)
  2. Upgrade to the latest version of Dokku (especially if you are on DigitalOcean- their version is out of date)
  3. Install dokku-haproxy plugin: ssh root@YOUR_SERVER dokku plugin:install https://github.com/256dpi/dokku-haproxy.git
  4. Deploy: git push dokku@YOUR_SERVER:mqtt
  5. Point to correct host/port: ssh dokku@MQTT_SERVER config:set mqtt PORT=3002 DOKKU_NGINX_PORT=3002 WEB_APP_URL=WEBAPP_URL_HERE
  6. Expose MQTT port: ssh dokku@MQTT_SERVER ports:add mqtt 1883 web 1883

Config Settings (important)

Here are some of the configuration options you must set when provisioning a new server:

  • Encryption keys: Encryption keys will be autogenerated if not present. They can be reset using rake keys:generate. If ENV['RSA_KEY'] is set, it will be used in place of the *.pem files. Useful for environments like Heroku, where file system access is not allowed.
  • ENV['MONGO_URL']: URL pointing to running MongoDB instance.
  • ENV['DEVISE_SECRET']: Used for devise. Use rake secret to generate a new value.
  • ENV['MQTT_URL']: URL of running MQTT gateway. This is required so that Farmbot can know where to connect when given an authorization token.

The frontend (and asset management) are very much in a transitional state. We're experimenting with Gulp as an alternative

We can't fix issues we don't know about. Please submit an issue if you are having trouble installing on your local machine.

Running Specs

Please run them before submitting pull requests.

  • bundle exec rspec spec

Generating an API token

You must pass a token string into most HTTP requests under the Authorization: request header.

Here's what a response looks like when you request a token:

{
    "token": {
        "unencoded": {
            "sub": "test123@test.com",
            "iat": 1459109728,
            "jti": "922a5a0d-0b3a-4767-9318-1e41ae600352",
            "iss": "http://localhost:3000/",
            "exp": 1459455328,
            "mqtt": "localhost",
            "bot": "aa7bb37f-5ba3-4654-b2e4-58ed5746508c"
        },
        "encoded":
        // THE IMPORTANT PART IS HERE!!:
         "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJ0ZXN0MTIzQHRlc3QuY29tIiwiaWF0IjoxNDU5MTA5NzI4LCJqdGkiOiI5MjJhNWEwZC0wYjNhLTQ3NjctOTMxOC0xZTQxYWU2MDAzNTIiLCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjMwMDAvIiwiZXhwIjoxNDU5NDU1MzI4LCJtcXR0IjoibG9jYWxob3N0IiwiYm90IjoiYWE3YmIzN2YtNWJhMy00NjU0LWIyZTQtNThlZDU3NDY1MDhjIn0.KpkNGR9YH68AF3iHP48GormqXzspBJrDGm23aMFGyL_eRIN8iKzy4gw733SaJgFjmebJOqZkz3cly9P5ZpCKwlaxAyn9RvfjQgFcUK0mywWAAvKp5lHfOFLhBBGICTW1r4HcZBgY1zTzVBw4BqS4zM7Y0BAAsflYRdl4dDRG_236p9ETCj0MSYxFagfLLLq0W63943jSJtNwv_nzfqi3TTi0xASB14k5vYMzUDXrC-Z2iBdgmwAYUZUVTi2HsfzkIkRcTZGE7l-rF6lvYKIiKpYx23x_d7xGjnQb8hqbDmLDRXZJnSBY3zGY7oEURxncGBMUp4F_Yaf3ftg4Ry7CiA"
    }
}

Important: The response is provided as JSON for human readability. For you Authorization header, you will only be using data.token.encoded. In this example, it's the string starting with eyJ0eXAiOiJ...

Via CURL

curl -H "Content-Type: application/json" \
     -X POST \
     -d '{"user":{"email":"test123@test.com","password":"password123"}}' \
     https://my.farmbot.io/api/tokens

Via JQuery

Since the API supports CORS, you can generate your token right in the browser.

Here's an example:

$.ajax({
    url: "https://my.farmbot.io/api/tokens",
    type: "POST",
    data: JSON.stringify({user: {email: 'admin@admin.com', password: 'password123'}}),
    contentType: "application/json"
})
.then(function(data){
  // You can now use your token:
  var MY_SHINY_TOKEN = data.token.encoded;
});

How to Contribute

  • Pull requests are always appreciated, but please
    • Write tests.
    • Follow the Ruby Community Style Guide.
    • Raise issues. We love to know about issues. Even the issues you think are only relevant to your setup. Just submit issues if you have issues.