This repository has been archived by the owner on Nov 29, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed 'archived_PhantRepos/phant-manager-sparkfun/' content from c…
…ommit 3222228 git-subtree-dir: archived_PhantRepos/phant-manager-sparkfun git-subtree-split: 322222868bdd7e5bbdc114f28045be7496d56451
- Loading branch information
0 parents
commit 5ad05f1
Showing
84 changed files
with
59,427 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#!/usr/bin/env node | ||
|
||
var http = require('http'), | ||
HttpManager = require('../index'), | ||
keychain = require('phant-keychain-hex'), | ||
Meta = require('phant-meta-test'), | ||
Phant = require('phant'); | ||
|
||
var keys = keychain({ | ||
publicSalt: process.env.PHANT_PUBLIC_SALT || 'public salt', | ||
privateSalt: process.env.PHANT_PRIVATE_SALT || 'private salt' | ||
}); | ||
|
||
var meta = Meta(); | ||
|
||
var httpManager = HttpManager({ | ||
metadata: meta, | ||
keychain: keys, | ||
validator: Phant.Validator({ | ||
metadata: meta | ||
}), | ||
notifiers: [{ | ||
name: 'Test', | ||
expect: function(type) { | ||
if(type === 'create') { | ||
return { name: 'Name', to: 'Email Address' }; | ||
} | ||
}, | ||
create: function(options, stream, cb) { | ||
|
||
var expected = this.expect('create'); | ||
|
||
for(var key in expected) { | ||
|
||
if(! options[key]) { | ||
return cb('Could not send email. Missing: ' + expected[key]); | ||
} | ||
|
||
} | ||
|
||
cb(null); | ||
|
||
} | ||
}] | ||
}); | ||
|
||
var server = http.createServer(function(req, res) { | ||
|
||
httpManager.call(this, req, res); | ||
|
||
if(res.headersSent) { | ||
return; | ||
} | ||
|
||
if(req.url.match(/^\/output\//)) { | ||
|
||
res.writeHead(200, { | ||
'Content-Type': 'application/json' | ||
}); | ||
|
||
var data = []; | ||
|
||
if(req.url.match(/stats.json$/)) { | ||
|
||
return res.end(JSON.stringify({ | ||
used: 48 * 1024 * 1024, | ||
remaining: 2 * 1024 * 1024, | ||
cap: 50 * 1024 * 1024, | ||
pageCount: 5 | ||
})); | ||
|
||
} | ||
|
||
for(var i=0; i < 120; i++) { | ||
|
||
data.push({ | ||
areallylongfield: 'baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', | ||
temp: 98.6, | ||
wind: '30mph', | ||
rain: '0.1 in', | ||
humidity: '30%', | ||
high: i, | ||
low: 20, | ||
timestamp: (new Date()).toISOString() | ||
}); | ||
|
||
} | ||
|
||
res.end(JSON.stringify(data)); | ||
|
||
} | ||
|
||
}); | ||
|
||
server.listen(process.env.PHANT_PORT || 8080); | ||
console.log('dev server started on port ' + (process.env.PHANT_PORT || 8080)); | ||
|
||
process.on('exit', function() { | ||
server.close(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"directory": "third_party" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules | ||
third_party | ||
bower_components | ||
*.swo | ||
*.swp | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"curly": true, | ||
"eqeqeq": true, | ||
"immed": true, | ||
"latedef": "nofunc", | ||
"newcap": true, | ||
"noarg": true, | ||
"sub": true, | ||
"undef": true, | ||
"unused": "vars", | ||
"boss": true, | ||
"eqnull": true, | ||
"node": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
language: node_js | ||
node_js: | ||
- '0.10' | ||
before_script: | ||
- npm install -g grunt-cli | ||
notifications: | ||
email: | ||
recipients: | ||
- [email protected] | ||
on_success: change | ||
on_failure: change |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
'use strict'; | ||
|
||
module.exports = function(grunt) { | ||
// Show elapsed time at the end | ||
require('time-grunt')(grunt); | ||
// Load all grunt tasks | ||
require('load-grunt-tasks')(grunt); | ||
|
||
// Project configuration. | ||
grunt.initConfig({ | ||
nodeunit: { | ||
files: ['test/**/*_test.js'] | ||
}, | ||
jshint: { | ||
options: { | ||
jshintrc: '.jshintrc', | ||
reporter: require('jshint-stylish') | ||
}, | ||
gruntfile: { | ||
src: 'Gruntfile.js' | ||
}, | ||
app: { | ||
src: 'index.js' | ||
}, | ||
routes: { | ||
src: 'routes/*.js' | ||
} | ||
}, | ||
watch: { | ||
less: { | ||
files: 'less/*.less', | ||
tasks: ['less'] | ||
}, | ||
gruntfile: { | ||
files: '<%= jshint.gruntfile.src %>', | ||
tasks: ['jshint:gruntfile'] | ||
}, | ||
app: { | ||
files: '<%= jshint.app.src %>', | ||
tasks: ['nodeunit', 'jshint:app'] | ||
}, | ||
routes: { | ||
files: 'routes/*.js', | ||
tasks: ['nodeunit', 'jshint:routes'] | ||
}, | ||
publicjs: { | ||
files: 'public/js/src/**/*.js', | ||
tasks: ['concat', 'uglify'] | ||
} | ||
}, | ||
bower: { | ||
install: { | ||
options: { | ||
cleanTargetDir: true, | ||
install: true, | ||
targetDir: './bower_components' | ||
} | ||
} | ||
}, | ||
less: { | ||
development: { | ||
files: { | ||
"public/css/phant.css": "less/phant.less", | ||
"public/css/svg.css": "less/svg.less" | ||
} | ||
}, | ||
production: { | ||
options: { | ||
cleancss: true, | ||
sourceMap: true | ||
}, | ||
files: { | ||
"public/css/phant.min.css": "less/phant.less", | ||
"public/css/svg.min.css": "less/svg.less" | ||
} | ||
} | ||
}, | ||
shell: { | ||
serve: { | ||
options: { | ||
stdout: true | ||
}, | ||
command: './.bin/dev' | ||
} | ||
}, | ||
concat: { | ||
dist: { | ||
src: [ | ||
'third_party/jquery/dist/jquery.js', | ||
'third_party/ubilabs-geocomplete/jquery.geocomplete.js', | ||
'third_party/bootstrap/dist/js/bootstrap.js', | ||
'third_party/bootstrap-tagsinput/src/bootstrap-tagsinput.js', | ||
'third_party/bootbox/bootbox.js', | ||
'third_party/handlebars/handlebars.js', | ||
'third_party/leaflet/dist/leaflet-src.js', | ||
'third_party/leaflet.markercluster/dist/leaflet.markercluster-src.js', | ||
'public/js/src/mows.js', | ||
'public/js/src/map.js', | ||
'public/js/src/config.js', | ||
'public/js/src/form.js', | ||
'public/js/src/stream.js' | ||
], | ||
dest: 'public/js/phant-manager.js', | ||
} | ||
}, | ||
concurrent: { | ||
dev: { | ||
tasks: ['less', 'concat', 'uglify', 'watch', 'shell:serve'] | ||
}, | ||
options: { | ||
logConcurrentOutput: true | ||
} | ||
}, | ||
jsbeautifier: { | ||
files: [ | ||
'Gruntfile.js', | ||
'index.js', | ||
'routes/*.js', | ||
'test/*.js' | ||
], | ||
options: { | ||
js: { | ||
indentChar: ' ', | ||
indentSize: 2 | ||
} | ||
}, | ||
}, | ||
uglify: { | ||
dest: { | ||
files: { | ||
'public/js/phant-manager.min.js': '<%= concat.dist.src %>' | ||
} | ||
} | ||
} | ||
}); | ||
|
||
grunt.registerTask('default', ['jsbeautifier', 'bower', 'jshint', 'less', 'concat', 'uglify', 'nodeunit']); | ||
grunt.registerTask('dev', ['bower', 'concurrent:dev']); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# phant-manager-sparkfun | ||
|
||
the fork of [phant-manager-http](https://github.com/sparkfun/phant-manager-sparkfun) that is currently hosted at [data.sparkfun.com](http://data.sparkfun.com). | ||
|
||
<<<<<<< HEAD | ||
## Setting up a dev environment | ||
|
||
$ node -v | ||
v0.10.26 | ||
$ npm install -g grunt-cli | ||
$ git clone [email protected]:sparkfun/phant-manager-sparkfun.git | ||
$ cd phant-manager-sparkfun | ||
$ git remote add upstream [email protected]:sparkfun/phant-manager-http.git | ||
$ npm install | ||
$ grunt dev | ||
======= | ||
## Using phant-manager-http with phant | ||
This section outlines how to quickly get this package up and running with the **phant** module. | ||
|
||
### Configure | ||
|
||
* open: https://data.sparkfun.com/config | ||
* under **Add Manager** select **HTTP**. This will add a new section below called **Manager - HTTP** | ||
* modify any other settings you desire. Likely this is OK as-is to get started | ||
* select **Download Package**. Avoid **Publish to NPM** unless you know what you are doing. | ||
* unpack the downloaded package | ||
|
||
### Install | ||
|
||
* go to the package you downloaded: `cd phantconfig-custom`. | ||
* do: `npm install` | ||
|
||
### Run | ||
This example assumes you configured the module to use port `8080`. If you have changed the HTTP port, replace `8080` with the port you chose. | ||
|
||
* do: `npm start` | ||
* open: http://localhost:8080/ | ||
>>>>>>> 5fa71244e5621e0335dc944c451b822cb9312ba3 | ||
## Contributing | ||
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/). | ||
|
||
## License | ||
Copyright (c) 2014 SparkFun Electronics. Licensed under the GPL v3 license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"name": "phant-manager-sparkfun", | ||
"version": "0.1.0", | ||
"authors": [ | ||
{ | ||
"name": "Todd Treece", | ||
"email": "[email protected]", | ||
"homepage": "http://uniontownlabs.org" | ||
} | ||
], | ||
"description": "phant-manager-http", | ||
"main": "index.js", | ||
"keywords": [ | ||
"sparkfun", | ||
"data", | ||
"internet", | ||
"of", | ||
"things", | ||
"IoT" | ||
], | ||
"license": "GPL-3.0", | ||
"homepage": "https://github.com/sparkfun/phant-manager-sparkfun", | ||
"private": true, | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
"bower_components", | ||
"public/bower_components", | ||
"third_party", | ||
"test", | ||
"tests" | ||
], | ||
"dependencies": { | ||
"bootstrap": "~3.1.1", | ||
"handlebars": "~1.3.0", | ||
"ubilabs-geocomplete": "~1.5.1", | ||
"bootbox": "~4.3.0", | ||
"leaflet": "~0.7.3", | ||
"leaflet.markercluster": "~0.4.0", | ||
"bootstrap-tagsinput": "TimSchlechter/bootstrap-tagsinput#master" | ||
} | ||
} |
Oops, something went wrong.