mirror of
https://github.com/atlanticbiomedical/biomedjs.git
synced 2025-07-02 00:47:26 -04:00
latest changes
This commit is contained in:
111
app/controllers/posts.js
Normal file
111
app/controllers/posts.js
Normal file
@ -0,0 +1,111 @@
|
||||
|
||||
var mongoose = require('mongoose'),
|
||||
Post = mongoose.model('Post');
|
||||
|
||||
var md5 = require('MD5');
|
||||
var fs = require('fs');
|
||||
|
||||
var log = require('log4node');
|
||||
|
||||
exports.index = function(req, res) {
|
||||
log.info('posts.index');
|
||||
var query = Post.find()
|
||||
.populate('author', 'name')
|
||||
.sort('-createdOn')
|
||||
.exec(function(err, results) {
|
||||
if (err) {
|
||||
res.json(500, err);
|
||||
} else {
|
||||
res.json(results);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
exports.get = function(req, res, next) {
|
||||
var id = req.param('post_id');
|
||||
Post.findById(id)
|
||||
.exec(function(err, post) {
|
||||
if (err) return next(err);
|
||||
if (!post) return next(new Error('Failed to load post ' + id));
|
||||
|
||||
res.json(post);
|
||||
});
|
||||
};
|
||||
|
||||
exports.create = function(req, res, next) {
|
||||
log.info('posts.create %j', req.body);
|
||||
|
||||
var post = new Post({
|
||||
title: req.body.title,
|
||||
preview: req.body.preview,
|
||||
details: req.body.details,
|
||||
image: req.body.image,
|
||||
gallery: req.body.gallery,
|
||||
status: req.body.status,
|
||||
createdOn: req.body.createdOn,
|
||||
postedOn: req.body.postedOn,
|
||||
author: req.user
|
||||
});
|
||||
|
||||
return post.save(function(err) {
|
||||
if (err) log.error("Error: %s", err);
|
||||
|
||||
return res.json(post);
|
||||
});
|
||||
};
|
||||
|
||||
exports.update = function(req, res, next) {
|
||||
var id = req.param('post_id');
|
||||
|
||||
console.log('updating post');
|
||||
|
||||
return Post.findById(id, function(err, post) {
|
||||
post.title = req.body.title;
|
||||
post.preview = req.body.preview;
|
||||
post.details = req.body.details;
|
||||
post.image = req.body.image;
|
||||
post.gallery = req.body.gallery;
|
||||
post.status = req.body.status;
|
||||
post.postedOn = req.body.postedOn;
|
||||
|
||||
return post.save(function(err) {
|
||||
if (err)
|
||||
log.error("Error: %s", err);
|
||||
|
||||
return res.json(post);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
exports.destroy = function(req, res, next) {
|
||||
var id = req.param('post_id');
|
||||
log.info('posts.destroy %s', id);
|
||||
|
||||
return Post.findById(id, function(err, post) {
|
||||
post.deleted = true;
|
||||
|
||||
return post.save(function(err) {
|
||||
if (err)
|
||||
log.error("Error: %s", err);
|
||||
|
||||
return res.json(post);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
exports.upload = function(req, res, next) {
|
||||
var path = req.files.file.path;
|
||||
|
||||
fs.readFile(path, function(err, data) {
|
||||
var hash = md5(data);
|
||||
|
||||
fs.writeFile('/srv/biomed-site/images/' + hash, data, function(err) {
|
||||
if (err)
|
||||
log.error("Error: %s", err);
|
||||
|
||||
return res.json({
|
||||
filename: hash
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
25
app/controllers/site.js
Normal file
25
app/controllers/site.js
Normal file
@ -0,0 +1,25 @@
|
||||
var mongoose = require('mongoose'),
|
||||
Post = mongoose.model('Post');
|
||||
|
||||
module.exports = function(piler) {
|
||||
return {
|
||||
index: function(req, res, next) {
|
||||
host = String(req.headers['x-forwarded-host']);
|
||||
host = host.split(':')[0];
|
||||
|
||||
if (host != 'site.atlb.co') {
|
||||
return next();
|
||||
}
|
||||
|
||||
if (!req.user) {
|
||||
req.session.redirectUrl = req.url
|
||||
}
|
||||
|
||||
var path = req.path.slice(1);
|
||||
|
||||
res.render('site.jade', {
|
||||
css: piler.css.renderTags()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -204,6 +204,6 @@ var blacklist = [
|
||||
"chris.sewell@atlanticbiomedical.com",
|
||||
"devel@atlanticbiomedical.com",
|
||||
"dobie@atlanticbiomedical.com",
|
||||
"akirayasha@gmail.com",
|
||||
// "akirayasha@gmail.com",
|
||||
"receipts@atlanticbiomedical.com",
|
||||
];
|
||||
|
17
app/model/posts.js
Normal file
17
app/model/posts.js
Normal file
@ -0,0 +1,17 @@
|
||||
var mongoose = require('mongoose'),
|
||||
Schema = mongoose.Schema,
|
||||
ObjectId = Schema.ObjectId;
|
||||
|
||||
var postSchema = new Schema({
|
||||
title: { type: String },
|
||||
preview: { type: String },
|
||||
details: { type: String },
|
||||
image: { type: String },
|
||||
gallery: [{ type: String }],
|
||||
status: { type: String },
|
||||
createdOn: { type: Date },
|
||||
postedOn: { type: Date },
|
||||
author: { type: ObjectId, ref: 'User' }
|
||||
});
|
||||
|
||||
var Post = module.exports = mongoose.model('Post', postSchema);
|
@ -19,7 +19,7 @@ html(lang="en", ng-app="biomed", ng-controller="biomed.PageCtrl")
|
||||
i.icon-thumbs-down
|
||||
| Incident
|
||||
li
|
||||
a(href='http://atlanticbiomedical.com/ticket/', target='_blank')
|
||||
a(href='http://jira.devwr.com:9090/servicedesk/customer/portal/2', target='_blank')
|
||||
i.icon-fire
|
||||
| Tickets
|
||||
li
|
||||
@ -54,6 +54,11 @@ html(lang="en", ng-app="biomed", ng-controller="biomed.PageCtrl")
|
||||
i.icon-wrench
|
||||
| Workorders
|
||||
|
||||
li(data-match-route='/posts.*', ng-show="accountHasPermission('system.admin')")
|
||||
a(href='/posts')
|
||||
i.icon-wrench
|
||||
| Posts
|
||||
|
||||
li(data-match-route='/admin.*', ng-show="accountHasPermission('system.admin')")
|
||||
a(href='/admin')
|
||||
i.icon-wrench
|
||||
|
53
app/views/site.jade
Normal file
53
app/views/site.jade
Normal file
@ -0,0 +1,53 @@
|
||||
doctype 5
|
||||
html(lang="en", ng-app="site", ng-controller="site.PageCtrl")
|
||||
head
|
||||
title Atlantic Biomedical
|
||||
!{css}
|
||||
link(rel='stylesheet', href='/css/site.css')
|
||||
meta(name='viewport', content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0')
|
||||
body
|
||||
script(type='text/javascript', src='//ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular.js')
|
||||
script(type='text/javascript', src='//ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular-resource.js')
|
||||
script(type='text/javascript', src='//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js')
|
||||
script(type='text/javascript', src='/site/dropzone.js')
|
||||
script(type='text/javascript', src='/site/app.js')
|
||||
|
||||
error-panel
|
||||
.navbar
|
||||
.navbar-inner
|
||||
a.brand(href='/', target='_self') Atlantic Biomedical
|
||||
progress-panel
|
||||
|
||||
.container-fluid(ng-hide='saved')
|
||||
h1 New Post
|
||||
|
||||
|
||||
form
|
||||
.control-group
|
||||
label.control-label Title
|
||||
.controls
|
||||
input.input-xlarge(ng-model='model.title')
|
||||
|
||||
.control-group
|
||||
label.control-label Body
|
||||
.controls
|
||||
textarea.input-xlarge(ng-model='model.preview')
|
||||
|
||||
.control-group
|
||||
label.control-label Header Image
|
||||
.controls
|
||||
.dropzone(dropzone='titleImageOptions')
|
||||
|
||||
.control-group
|
||||
label.control-label Gallery
|
||||
.controls
|
||||
.dropzone(dropzone='galleryImageOptions')
|
||||
|
||||
.control-group
|
||||
.controls
|
||||
button.btn.btn-primary(ng-click='save()', type='button') Save
|
||||
|
||||
|
||||
.container-fluid(ng-show='saved')
|
||||
h1.msg Your post has been saved
|
||||
button.btn.btn-primary(ng-click='refresh()', type='button') Start new Post
|
@ -27,6 +27,8 @@ module.exports = function(app, passport) {
|
||||
log.setPrefix("[%d] %l ");
|
||||
log.info("User Logged In: %s %s", user.name.first, user.name.last);
|
||||
|
||||
res.cookie('atlbid', JSON.stringify(user._id), {signed:true});
|
||||
|
||||
if (req.session.redirectUrl) {
|
||||
redirectUrl = req.session.redirectUrl;
|
||||
req.session.redirectUrl = null;
|
||||
|
@ -10,7 +10,7 @@ module.exports = function(app, config, passport, piler) {
|
||||
|
||||
app.configure(function() {
|
||||
// cookieParser should be above session
|
||||
app.use(express.cookieParser());
|
||||
app.use(express.cookieParser("atlbsecret"));
|
||||
|
||||
// bodyParser should be above methodOverride
|
||||
app.use(express.bodyParser());
|
||||
@ -37,4 +37,4 @@ module.exports = function(app, config, passport, piler) {
|
||||
// // enable live update in development mode.
|
||||
// piler.liveUpdate();
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ module.exports = function(app, auth, piler, calendar, directory, config) {
|
||||
piler.addJsFile("/js/lib/bootstrap-datepicker.js");
|
||||
piler.addJsFile("/js/lib/dialog.js");
|
||||
piler.addJsFile("/js/lib/select2.js");
|
||||
piler.addJsFile("/js/lib/dropzone.js");
|
||||
piler.addJsFile("/js/app.js");
|
||||
piler.addJsFile("/js/controllers.js");
|
||||
piler.addJsFile("/js/directives.js");
|
||||
@ -21,6 +22,14 @@ module.exports = function(app, auth, piler, calendar, directory, config) {
|
||||
|
||||
app.all('/api/*', auth.requiresApiAccess);
|
||||
|
||||
var posts = require('../app/controllers/posts');
|
||||
app.get('/api/posts', posts.index);
|
||||
app.get('/api/posts/:post_id', posts.get);
|
||||
app.post('/api/posts', posts.create);
|
||||
app.post('/api/posts/upload', posts.upload);
|
||||
app.post('/api/posts/:post_id', posts.update);
|
||||
app.del('/api/posts/:post_id', posts.destroy);
|
||||
|
||||
var clients = require('../app/controllers/clients');
|
||||
app.get('/api/clients', clients.index);
|
||||
app.get('/api/clients/frequencies', clients.frequencies);
|
||||
@ -60,6 +69,8 @@ module.exports = function(app, auth, piler, calendar, directory, config) {
|
||||
var clock = require('../app/controllers/clock')(piler);
|
||||
app.post('/api/clock', clock.post);
|
||||
|
||||
var site = require('../app/controllers/site')(piler);
|
||||
|
||||
var login = require('../app/controllers/login')(piler);
|
||||
app.get('/login', login.login);
|
||||
app.get('/login/error', login.error);
|
||||
@ -67,6 +78,6 @@ module.exports = function(app, auth, piler, calendar, directory, config) {
|
||||
|
||||
var home = require('../app/controllers/home')(piler);
|
||||
|
||||
app.get('/', tags.index, auth.requiresUiLogin, clock.index, home.index);
|
||||
app.get('*', tags.index, auth.requiresUiLogin, clock.index, home.index);
|
||||
app.get('/', tags.index, auth.requiresUiLogin, clock.index, site.index, home.index);
|
||||
app.get('*', tags.index, auth.requiresUiLogin, clock.index, site.index, home.index);
|
||||
};
|
||||
|
1
node_modules/MD5/.npmignore
generated
vendored
Normal file
1
node_modules/MD5/.npmignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules/mocha
|
4
node_modules/MD5/.travis.yml
generated
vendored
Normal file
4
node_modules/MD5/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.6
|
||||
- 0.8
|
27
node_modules/MD5/LICENSE
generated
vendored
Normal file
27
node_modules/MD5/LICENSE
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
Copyright © 2011-2012, Paul Vorbach.
|
||||
Copyright © 2009, Jeff Mott.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
* Neither the name Crypto-JS nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
103
node_modules/MD5/README.md
generated
vendored
Normal file
103
node_modules/MD5/README.md
generated
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
# MD5
|
||||
|
||||
[](http://travis-ci.org/pvorb/node-md5)
|
||||
|
||||
a JavaScript function for hashing messages with MD5.
|
||||
|
||||
**Warning:** This is the source repository for the npm package
|
||||
[MD5](http://search.npmjs.org/#/MD5), not [md5](http://search.npmjs.org/#/md5).
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
You can use this package on the server side as well as the client side.
|
||||
|
||||
### [Node.js](http://nodejs.org/):
|
||||
|
||||
```
|
||||
npm install MD5
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
~~~ javascript
|
||||
md5(message)
|
||||
~~~
|
||||
|
||||
* `message` -- `String` or `Buffer`
|
||||
* returns `String`
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
~~~ javascript
|
||||
var md5 = require('MD5');
|
||||
|
||||
console.log(md5('message'));
|
||||
~~~
|
||||
|
||||
This will print the following
|
||||
|
||||
~~~
|
||||
78e731027d8fd50ed642340b7c9a63b3
|
||||
~~~
|
||||
|
||||
It supports buffers, too
|
||||
|
||||
~~~ javascript
|
||||
var fs = require('fs');
|
||||
var md5 = require('MD5');
|
||||
|
||||
fs.readFile('example.txt', function(err, buf) {
|
||||
console.log(md5(buf));
|
||||
});
|
||||
~~~
|
||||
|
||||
|
||||
## Bugs and Issues
|
||||
|
||||
If you encounter any bugs or issues, feel free to open an issue at
|
||||
[github](https://github.com/pvorb/node-md5/issues).
|
||||
|
||||
|
||||
## Credits
|
||||
|
||||
This package is based on the work of Jeff Mott, who did a pure JS implementation
|
||||
of the MD5 algorithm that was published by Ronald L. Rivest in 1991. I needed a
|
||||
npm package of the algorithm, so I used Jeff’s implementation for this package.
|
||||
The original implementation can be found in the
|
||||
[CryptoJS](http://code.google.com/p/crypto-js/) project.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
~~~
|
||||
Copyright © 2011-2012, Paul Vorbach.
|
||||
Copyright © 2009, Jeff Mott.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
* Neither the name Crypto-JS nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
~~~
|
160
node_modules/MD5/md5.js
generated
vendored
Normal file
160
node_modules/MD5/md5.js
generated
vendored
Normal file
@ -0,0 +1,160 @@
|
||||
(function(){
|
||||
var crypt = require('crypt'),
|
||||
utf8 = require('charenc').utf8,
|
||||
bin = require('charenc').bin,
|
||||
|
||||
// The core
|
||||
md5 = function (message, options) {
|
||||
// Convert to byte array
|
||||
if (message.constructor == String)
|
||||
if (options && options.encoding === 'binary')
|
||||
message = bin.stringToBytes(message);
|
||||
else
|
||||
message = utf8.stringToBytes(message);
|
||||
else if (typeof Buffer != 'undefined' &&
|
||||
typeof Buffer.isBuffer == 'function' && Buffer.isBuffer(message))
|
||||
message = Array.prototype.slice.call(message, 0);
|
||||
else if (!Array.isArray(message))
|
||||
message = message.toString();
|
||||
// else, assume byte array already
|
||||
|
||||
var m = crypt.bytesToWords(message),
|
||||
l = message.length * 8,
|
||||
a = 1732584193,
|
||||
b = -271733879,
|
||||
c = -1732584194,
|
||||
d = 271733878;
|
||||
|
||||
// Swap endian
|
||||
for (var i = 0; i < m.length; i++) {
|
||||
m[i] = ((m[i] << 8) | (m[i] >>> 24)) & 0x00FF00FF |
|
||||
((m[i] << 24) | (m[i] >>> 8)) & 0xFF00FF00;
|
||||
}
|
||||
|
||||
// Padding
|
||||
m[l >>> 5] |= 0x80 << (l % 32);
|
||||
m[(((l + 64) >>> 9) << 4) + 14] = l;
|
||||
|
||||
// Method shortcuts
|
||||
var FF = md5._ff,
|
||||
GG = md5._gg,
|
||||
HH = md5._hh,
|
||||
II = md5._ii;
|
||||
|
||||
for (var i = 0; i < m.length; i += 16) {
|
||||
|
||||
var aa = a,
|
||||
bb = b,
|
||||
cc = c,
|
||||
dd = d;
|
||||
|
||||
a = FF(a, b, c, d, m[i+ 0], 7, -680876936);
|
||||
d = FF(d, a, b, c, m[i+ 1], 12, -389564586);
|
||||
c = FF(c, d, a, b, m[i+ 2], 17, 606105819);
|
||||
b = FF(b, c, d, a, m[i+ 3], 22, -1044525330);
|
||||
a = FF(a, b, c, d, m[i+ 4], 7, -176418897);
|
||||
d = FF(d, a, b, c, m[i+ 5], 12, 1200080426);
|
||||
c = FF(c, d, a, b, m[i+ 6], 17, -1473231341);
|
||||
b = FF(b, c, d, a, m[i+ 7], 22, -45705983);
|
||||
a = FF(a, b, c, d, m[i+ 8], 7, 1770035416);
|
||||
d = FF(d, a, b, c, m[i+ 9], 12, -1958414417);
|
||||
c = FF(c, d, a, b, m[i+10], 17, -42063);
|
||||
b = FF(b, c, d, a, m[i+11], 22, -1990404162);
|
||||
a = FF(a, b, c, d, m[i+12], 7, 1804603682);
|
||||
d = FF(d, a, b, c, m[i+13], 12, -40341101);
|
||||
c = FF(c, d, a, b, m[i+14], 17, -1502002290);
|
||||
b = FF(b, c, d, a, m[i+15], 22, 1236535329);
|
||||
|
||||
a = GG(a, b, c, d, m[i+ 1], 5, -165796510);
|
||||
d = GG(d, a, b, c, m[i+ 6], 9, -1069501632);
|
||||
c = GG(c, d, a, b, m[i+11], 14, 643717713);
|
||||
b = GG(b, c, d, a, m[i+ 0], 20, -373897302);
|
||||
a = GG(a, b, c, d, m[i+ 5], 5, -701558691);
|
||||
d = GG(d, a, b, c, m[i+10], 9, 38016083);
|
||||
c = GG(c, d, a, b, m[i+15], 14, -660478335);
|
||||
b = GG(b, c, d, a, m[i+ 4], 20, -405537848);
|
||||
a = GG(a, b, c, d, m[i+ 9], 5, 568446438);
|
||||
d = GG(d, a, b, c, m[i+14], 9, -1019803690);
|
||||
c = GG(c, d, a, b, m[i+ 3], 14, -187363961);
|
||||
b = GG(b, c, d, a, m[i+ 8], 20, 1163531501);
|
||||
a = GG(a, b, c, d, m[i+13], 5, -1444681467);
|
||||
d = GG(d, a, b, c, m[i+ 2], 9, -51403784);
|
||||
c = GG(c, d, a, b, m[i+ 7], 14, 1735328473);
|
||||
b = GG(b, c, d, a, m[i+12], 20, -1926607734);
|
||||
|
||||
a = HH(a, b, c, d, m[i+ 5], 4, -378558);
|
||||
d = HH(d, a, b, c, m[i+ 8], 11, -2022574463);
|
||||
c = HH(c, d, a, b, m[i+11], 16, 1839030562);
|
||||
b = HH(b, c, d, a, m[i+14], 23, -35309556);
|
||||
a = HH(a, b, c, d, m[i+ 1], 4, -1530992060);
|
||||
d = HH(d, a, b, c, m[i+ 4], 11, 1272893353);
|
||||
c = HH(c, d, a, b, m[i+ 7], 16, -155497632);
|
||||
b = HH(b, c, d, a, m[i+10], 23, -1094730640);
|
||||
a = HH(a, b, c, d, m[i+13], 4, 681279174);
|
||||
d = HH(d, a, b, c, m[i+ 0], 11, -358537222);
|
||||
c = HH(c, d, a, b, m[i+ 3], 16, -722521979);
|
||||
b = HH(b, c, d, a, m[i+ 6], 23, 76029189);
|
||||
a = HH(a, b, c, d, m[i+ 9], 4, -640364487);
|
||||
d = HH(d, a, b, c, m[i+12], 11, -421815835);
|
||||
c = HH(c, d, a, b, m[i+15], 16, 530742520);
|
||||
b = HH(b, c, d, a, m[i+ 2], 23, -995338651);
|
||||
|
||||
a = II(a, b, c, d, m[i+ 0], 6, -198630844);
|
||||
d = II(d, a, b, c, m[i+ 7], 10, 1126891415);
|
||||
c = II(c, d, a, b, m[i+14], 15, -1416354905);
|
||||
b = II(b, c, d, a, m[i+ 5], 21, -57434055);
|
||||
a = II(a, b, c, d, m[i+12], 6, 1700485571);
|
||||
d = II(d, a, b, c, m[i+ 3], 10, -1894986606);
|
||||
c = II(c, d, a, b, m[i+10], 15, -1051523);
|
||||
b = II(b, c, d, a, m[i+ 1], 21, -2054922799);
|
||||
a = II(a, b, c, d, m[i+ 8], 6, 1873313359);
|
||||
d = II(d, a, b, c, m[i+15], 10, -30611744);
|
||||
c = II(c, d, a, b, m[i+ 6], 15, -1560198380);
|
||||
b = II(b, c, d, a, m[i+13], 21, 1309151649);
|
||||
a = II(a, b, c, d, m[i+ 4], 6, -145523070);
|
||||
d = II(d, a, b, c, m[i+11], 10, -1120210379);
|
||||
c = II(c, d, a, b, m[i+ 2], 15, 718787259);
|
||||
b = II(b, c, d, a, m[i+ 9], 21, -343485551);
|
||||
|
||||
a = (a + aa) >>> 0;
|
||||
b = (b + bb) >>> 0;
|
||||
c = (c + cc) >>> 0;
|
||||
d = (d + dd) >>> 0;
|
||||
}
|
||||
|
||||
return crypt.endian([a, b, c, d]);
|
||||
};
|
||||
|
||||
// Auxiliary functions
|
||||
md5._ff = function (a, b, c, d, x, s, t) {
|
||||
var n = a + (b & c | ~b & d) + (x >>> 0) + t;
|
||||
return ((n << s) | (n >>> (32 - s))) + b;
|
||||
};
|
||||
md5._gg = function (a, b, c, d, x, s, t) {
|
||||
var n = a + (b & d | c & ~d) + (x >>> 0) + t;
|
||||
return ((n << s) | (n >>> (32 - s))) + b;
|
||||
};
|
||||
md5._hh = function (a, b, c, d, x, s, t) {
|
||||
var n = a + (b ^ c ^ d) + (x >>> 0) + t;
|
||||
return ((n << s) | (n >>> (32 - s))) + b;
|
||||
};
|
||||
md5._ii = function (a, b, c, d, x, s, t) {
|
||||
var n = a + (c ^ (b | ~d)) + (x >>> 0) + t;
|
||||
return ((n << s) | (n >>> (32 - s))) + b;
|
||||
};
|
||||
|
||||
// Package private blocksize
|
||||
md5._blocksize = 16;
|
||||
md5._digestsize = 16;
|
||||
|
||||
module.exports = function (message, options) {
|
||||
if(typeof message == 'undefined')
|
||||
return;
|
||||
|
||||
var digestbytes = crypt.wordsToBytes(md5(message, options));
|
||||
return options && options.asBytes ? digestbytes :
|
||||
options && options.asString ? bin.bytesToString(digestbytes) :
|
||||
crypt.bytesToHex(digestbytes);
|
||||
};
|
||||
|
||||
})();
|
27
node_modules/MD5/node_modules/charenc/LICENSE.mkd
generated
vendored
Normal file
27
node_modules/MD5/node_modules/charenc/LICENSE.mkd
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
Copyright © 2011, Paul Vorbach. All rights reserved.
|
||||
Copyright © 2009, Jeff Mott. All rights reserved.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
* Neither the name Crypto-JS nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1
node_modules/MD5/node_modules/charenc/README.js
generated
vendored
Normal file
1
node_modules/MD5/node_modules/charenc/README.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
**enc** provides crypto character encoding utilities.
|
33
node_modules/MD5/node_modules/charenc/charenc.js
generated
vendored
Normal file
33
node_modules/MD5/node_modules/charenc/charenc.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
var charenc = {
|
||||
// UTF-8 encoding
|
||||
utf8: {
|
||||
// Convert a string to a byte array
|
||||
stringToBytes: function(str) {
|
||||
return charenc.bin.stringToBytes(unescape(encodeURIComponent(str)));
|
||||
},
|
||||
|
||||
// Convert a byte array to a string
|
||||
bytesToString: function(bytes) {
|
||||
return decodeURIComponent(escape(charenc.bin.bytesToString(bytes)));
|
||||
}
|
||||
},
|
||||
|
||||
// Binary encoding
|
||||
bin: {
|
||||
// Convert a string to a byte array
|
||||
stringToBytes: function(str) {
|
||||
for (var bytes = [], i = 0; i < str.length; i++)
|
||||
bytes.push(str.charCodeAt(i) & 0xFF);
|
||||
return bytes;
|
||||
},
|
||||
|
||||
// Convert a byte array to a string
|
||||
bytesToString: function(bytes) {
|
||||
for (var str = [], i = 0; i < bytes.length; i++)
|
||||
str.push(String.fromCharCode(bytes[i]));
|
||||
return str.join('');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = charenc;
|
35
node_modules/MD5/node_modules/charenc/package.json
generated
vendored
Normal file
35
node_modules/MD5/node_modules/charenc/package.json
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"author": {
|
||||
"name": "Paul Vorbach",
|
||||
"email": "paul@vorb.de",
|
||||
"url": "http://vorb.de"
|
||||
},
|
||||
"name": "charenc",
|
||||
"description": "character encoding utilities",
|
||||
"tags": [
|
||||
"utf8",
|
||||
"binary",
|
||||
"byte",
|
||||
"string"
|
||||
],
|
||||
"version": "0.0.1",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/pvorb/node-charenc.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/pvorb/node-charenc/issues"
|
||||
},
|
||||
"main": "charenc.js",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"readme": "**enc** provides crypto character encoding utilities.\n",
|
||||
"readmeFilename": "README.js",
|
||||
"_id": "charenc@0.0.1",
|
||||
"dist": {
|
||||
"shasum": "d4291c42dd3dc8e34b853a7fcc1ae4da45df1d5e"
|
||||
},
|
||||
"_from": "charenc@>= 0.0.1",
|
||||
"_resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.1.tgz"
|
||||
}
|
27
node_modules/MD5/node_modules/crypt/LICENSE.mkd
generated
vendored
Normal file
27
node_modules/MD5/node_modules/crypt/LICENSE.mkd
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
Copyright © 2011, Paul Vorbach. All rights reserved.
|
||||
Copyright © 2009, Jeff Mott. All rights reserved.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
* Neither the name Crypto-JS nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1
node_modules/MD5/node_modules/crypt/README.mkd
generated
vendored
Normal file
1
node_modules/MD5/node_modules/crypt/README.mkd
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
**crypt** provides utilities for encryption and hashing
|
96
node_modules/MD5/node_modules/crypt/crypt.js
generated
vendored
Normal file
96
node_modules/MD5/node_modules/crypt/crypt.js
generated
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
(function() {
|
||||
var base64map
|
||||
= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
|
||||
|
||||
crypt = {
|
||||
// Bit-wise rotation left
|
||||
rotl: function(n, b) {
|
||||
return (n << b) | (n >>> (32 - b));
|
||||
},
|
||||
|
||||
// Bit-wise rotation right
|
||||
rotr: function(n, b) {
|
||||
return (n << (32 - b)) | (n >>> b);
|
||||
},
|
||||
|
||||
// Swap big-endian to little-endian and vice versa
|
||||
endian: function(n) {
|
||||
// If number given, swap endian
|
||||
if (n.constructor == Number) {
|
||||
return crypt.rotl(n, 8) & 0x00FF00FF | crypt.rotl(n, 24) & 0xFF00FF00;
|
||||
}
|
||||
|
||||
// Else, assume array and swap all items
|
||||
for (var i = 0; i < n.length; i++)
|
||||
n[i] = crypt.endian(n[i]);
|
||||
return n;
|
||||
},
|
||||
|
||||
// Generate an array of any length of random bytes
|
||||
randomBytes: function(n) {
|
||||
for (var bytes = []; n > 0; n--)
|
||||
bytes.push(Math.floor(Math.random() * 256));
|
||||
return bytes;
|
||||
},
|
||||
|
||||
// Convert a byte array to big-endian 32-bit words
|
||||
bytesToWords: function(bytes) {
|
||||
for (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8)
|
||||
words[b >>> 5] |= bytes[i] << (24 - b % 32);
|
||||
return words;
|
||||
},
|
||||
|
||||
// Convert big-endian 32-bit words to a byte array
|
||||
wordsToBytes: function(words) {
|
||||
for (var bytes = [], b = 0; b < words.length * 32; b += 8)
|
||||
bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);
|
||||
return bytes;
|
||||
},
|
||||
|
||||
// Convert a byte array to a hex string
|
||||
bytesToHex: function(bytes) {
|
||||
for (var hex = [], i = 0; i < bytes.length; i++) {
|
||||
hex.push((bytes[i] >>> 4).toString(16));
|
||||
hex.push((bytes[i] & 0xF).toString(16));
|
||||
}
|
||||
return hex.join('');
|
||||
},
|
||||
|
||||
// Convert a hex string to a byte array
|
||||
hexToBytes: function(hex) {
|
||||
for (var bytes = [], c = 0; c < hex.length; c += 2)
|
||||
bytes.push(parseInt(hex.substr(c, 2), 16));
|
||||
return bytes;
|
||||
},
|
||||
|
||||
// Convert a byte array to a base-64 string
|
||||
bytesToBase64: function(bytes) {
|
||||
for (var base64 = [], i = 0; i < bytes.length; i += 3) {
|
||||
var triplet = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];
|
||||
for (var j = 0; j < 4; j++)
|
||||
if (i * 8 + j * 6 <= bytes.length * 8)
|
||||
base64.push(base64map.charAt((triplet >>> 6 * (3 - j)) & 0x3F));
|
||||
else
|
||||
base64.push('=');
|
||||
}
|
||||
return base64.join('');
|
||||
},
|
||||
|
||||
// Convert a base-64 string to a byte array
|
||||
base64ToBytes: function(base64) {
|
||||
// Remove non-base-64 characters
|
||||
base64 = base64.replace(/[^A-Z0-9+\/]/ig, '');
|
||||
|
||||
for (var bytes = [], i = 0, imod4 = 0; i < base64.length;
|
||||
imod4 = ++i % 4) {
|
||||
if (imod4 == 0) continue;
|
||||
bytes.push(((base64map.indexOf(base64.charAt(i - 1))
|
||||
& (Math.pow(2, -2 * imod4 + 8) - 1)) << (imod4 * 2))
|
||||
| (base64map.indexOf(base64.charAt(i)) >>> (6 - imod4 * 2)));
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = crypt;
|
||||
})();
|
33
node_modules/MD5/node_modules/crypt/package.json
generated
vendored
Normal file
33
node_modules/MD5/node_modules/crypt/package.json
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"author": {
|
||||
"name": "Paul Vorbach",
|
||||
"email": "paul@vorb.de",
|
||||
"url": "http://vorb.de"
|
||||
},
|
||||
"name": "crypt",
|
||||
"description": "utilities for encryption and hashing",
|
||||
"tags": [
|
||||
"hash",
|
||||
"security"
|
||||
],
|
||||
"version": "0.0.1",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/pvorb/node-crypt.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/pvorb/node-crypt/issues"
|
||||
},
|
||||
"main": "crypt.js",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"readme": "**crypt** provides utilities for encryption and hashing\n",
|
||||
"readmeFilename": "README.mkd",
|
||||
"_id": "crypt@0.0.1",
|
||||
"dist": {
|
||||
"shasum": "ef6e6a956f1a6b3f3e43054fa842078ad48935d3"
|
||||
},
|
||||
"_from": "crypt@>= 0.0.1",
|
||||
"_resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.1.tgz"
|
||||
}
|
52
node_modules/MD5/package.json
generated
vendored
Normal file
52
node_modules/MD5/package.json
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
{
|
||||
"author": {
|
||||
"name": "Paul Vorbach",
|
||||
"email": "paul@vorb.de",
|
||||
"url": "http://vorb.de"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "salba"
|
||||
}
|
||||
],
|
||||
"name": "MD5",
|
||||
"description": "native js function for hashing messages with MD5",
|
||||
"tags": [
|
||||
"md5",
|
||||
"hash",
|
||||
"encryption",
|
||||
"native",
|
||||
"message digest"
|
||||
],
|
||||
"version": "1.2.1",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/pvorb/node-md5.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/pvorb/node-md5/issues"
|
||||
},
|
||||
"main": "md5.js",
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"charenc": ">= 0.0.1",
|
||||
"crypt": ">= 0.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "~ 1.4.2"
|
||||
},
|
||||
"optionalDependencies": {},
|
||||
"readme": "# MD5\n\n[](http://travis-ci.org/pvorb/node-md5)\n\na JavaScript function for hashing messages with MD5.\n\n**Warning:** This is the source repository for the npm package\n[MD5](http://search.npmjs.org/#/MD5), not [md5](http://search.npmjs.org/#/md5).\n\n\n## Installation\n\nYou can use this package on the server side as well as the client side.\n\n### [Node.js](http://nodejs.org/):\n\n```\nnpm install MD5\n```\n\n\n## API\n\n~~~ javascript\nmd5(message)\n~~~\n\n * `message` -- `String` or `Buffer`\n * returns `String`\n\n\n## Usage\n\n~~~ javascript\nvar md5 = require('MD5');\n\nconsole.log(md5('message'));\n~~~\n\nThis will print the following\n\n~~~\n78e731027d8fd50ed642340b7c9a63b3\n~~~\n\nIt supports buffers, too\n\n~~~ javascript\nvar fs = require('fs');\nvar md5 = require('MD5');\n\nfs.readFile('example.txt', function(err, buf) {\n console.log(md5(buf));\n});\n~~~\n\n\n## Bugs and Issues\n\nIf you encounter any bugs or issues, feel free to open an issue at\n[github](https://github.com/pvorb/node-md5/issues).\n\n\n## Credits\n\nThis package is based on the work of Jeff Mott, who did a pure JS implementation\nof the MD5 algorithm that was published by Ronald L. Rivest in 1991. I needed a\nnpm package of the algorithm, so I used Jeff’s implementation for this package.\nThe original implementation can be found in the\n[CryptoJS](http://code.google.com/p/crypto-js/) project.\n\n\n## License\n\n~~~\nCopyright © 2011-2012, Paul Vorbach.\nCopyright © 2009, Jeff Mott.\n\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification,\nare permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n* Redistributions in binary form must reproduce the above copyright notice, this\n list of conditions and the following disclaimer in the documentation and/or\n other materials provided with the distribution.\n* Neither the name Crypto-JS nor the names of its contributors may be used to\n endorse or promote products derived from this software without specific prior\n written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n~~~\n",
|
||||
"readmeFilename": "README.md",
|
||||
"_id": "MD5@1.2.1",
|
||||
"dist": {
|
||||
"shasum": "423e4afa1636df9e027fb4bb23f0b75e118d6054"
|
||||
},
|
||||
"_from": "MD5@",
|
||||
"_resolved": "https://registry.npmjs.org/MD5/-/MD5-1.2.1.tgz"
|
||||
}
|
34
node_modules/MD5/test.js
generated
vendored
Normal file
34
node_modules/MD5/test.js
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
var md5 = require('./md5.js');
|
||||
var assert = require('assert');
|
||||
|
||||
describe('MD5', function () {
|
||||
it('should return the expected MD5 hash for "message"', function () {
|
||||
assert.equal('78e731027d8fd50ed642340b7c9a63b3', md5('message'));
|
||||
});
|
||||
|
||||
it('should not return the same hash for random numbers twice', function () {
|
||||
var msg1 = Math.floor((Math.random() * 100000) + 1) + (new Date).getTime();
|
||||
var msg2 = Math.floor((Math.random() * 100000) + 1) + (new Date).getTime();
|
||||
|
||||
if (msg1 !== msg2)
|
||||
assert.notEqual(md5(msg1), md5(msg2));
|
||||
else
|
||||
assert.equal(md5(msg1), md5(msg1));
|
||||
});
|
||||
|
||||
it('should support Node.js Buffers', function() {
|
||||
var buffer = new Buffer('message áßäöü', 'utf8');
|
||||
|
||||
assert.equal(md5(buffer), md5('message áßäöü'));
|
||||
})
|
||||
|
||||
it('should be able to use a binary encoded string', function () {
|
||||
var hash1 = md5('abc', { asString: true });
|
||||
var hash2 = md5(hash1 + 'a', { asString: true, encoding : 'binary' });
|
||||
var hash3 = md5(hash1 + 'a', { encoding : 'binary' });
|
||||
// console.log('hash1', hash1);
|
||||
// console.log('hash2', hash2);
|
||||
// console.log('hash3', hash3);
|
||||
assert.equal(hash3, '131f0ac52813044f5110e4aec638c169');
|
||||
});
|
||||
});
|
2
node_modules/node-uuid/.npmignore
generated
vendored
Normal file
2
node_modules/node-uuid/.npmignore
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
.DS_Store
|
2
node_modules/node-uuid/LICENSE.md
generated
vendored
Normal file
2
node_modules/node-uuid/LICENSE.md
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
Copyright (c) 2010-2012 Robert Kieffer
|
||||
MIT License - http://opensource.org/licenses/mit-license.php
|
207
node_modules/node-uuid/README.md
generated
vendored
Normal file
207
node_modules/node-uuid/README.md
generated
vendored
Normal file
@ -0,0 +1,207 @@
|
||||
# node-uuid
|
||||
|
||||
Simple, fast generation of [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDS.
|
||||
|
||||
Features:
|
||||
|
||||
* Generate RFC4122 version 1 or version 4 UUIDs
|
||||
* Runs in node.js and all browsers.
|
||||
* Registered as a [ComponentJS](https://github.com/component/component) [component](https://github.com/component/component/wiki/Components) ('broofa/node-uuid').
|
||||
* Cryptographically strong random # generation on supporting platforms
|
||||
* 1.1K minified and gzip'ed (Want something smaller? Check this [crazy shit](https://gist.github.com/982883) out! )
|
||||
* [Annotated source code](http://broofa.github.com/node-uuid/docs/uuid.html)
|
||||
|
||||
## Getting Started
|
||||
|
||||
Install it in your browser:
|
||||
|
||||
```html
|
||||
<script src="uuid.js"></script>
|
||||
```
|
||||
|
||||
Or in node.js:
|
||||
|
||||
```
|
||||
npm install node-uuid
|
||||
```
|
||||
|
||||
```javascript
|
||||
var uuid = require('node-uuid');
|
||||
```
|
||||
|
||||
Then create some ids ...
|
||||
|
||||
```javascript
|
||||
// Generate a v1 (time-based) id
|
||||
uuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'
|
||||
|
||||
// Generate a v4 (random) id
|
||||
uuid.v4(); // -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### uuid.v1([`options` [, `buffer` [, `offset`]]])
|
||||
|
||||
Generate and return a RFC4122 v1 (timestamp-based) UUID.
|
||||
|
||||
* `options` - (Object) Optional uuid state to apply. Properties may include:
|
||||
|
||||
* `node` - (Array) Node id as Array of 6 bytes (per 4.1.6). Default: Randomly generated ID. See note 1.
|
||||
* `clockseq` - (Number between 0 - 0x3fff) RFC clock sequence. Default: An internally maintained clockseq is used.
|
||||
* `msecs` - (Number | Date) Time in milliseconds since unix Epoch. Default: The current time is used.
|
||||
* `nsecs` - (Number between 0-9999) additional time, in 100-nanosecond units. Ignored if `msecs` is unspecified. Default: internal uuid counter is used, as per 4.2.1.2.
|
||||
|
||||
* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.
|
||||
* `offset` - (Number) Starting index in `buffer` at which to begin writing.
|
||||
|
||||
Returns `buffer`, if specified, otherwise the string form of the UUID
|
||||
|
||||
Notes:
|
||||
|
||||
1. The randomly generated node id is only guaranteed to stay constant for the lifetime of the current JS runtime. (Future versions of this module may use persistent storage mechanisms to extend this guarantee.)
|
||||
|
||||
Example: Generate string UUID with fully-specified options
|
||||
|
||||
```javascript
|
||||
uuid.v1({
|
||||
node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
|
||||
clockseq: 0x1234,
|
||||
msecs: new Date('2011-11-01').getTime(),
|
||||
nsecs: 5678
|
||||
}); // -> "710b962e-041c-11e1-9234-0123456789ab"
|
||||
```
|
||||
|
||||
Example: In-place generation of two binary IDs
|
||||
|
||||
```javascript
|
||||
// Generate two ids in an array
|
||||
var arr = new Array(32); // -> []
|
||||
uuid.v1(null, arr, 0); // -> [02 a2 ce 90 14 32 11 e1 85 58 0b 48 8e 4f c1 15]
|
||||
uuid.v1(null, arr, 16); // -> [02 a2 ce 90 14 32 11 e1 85 58 0b 48 8e 4f c1 15 02 a3 1c b0 14 32 11 e1 85 58 0b 48 8e 4f c1 15]
|
||||
|
||||
// Optionally use uuid.unparse() to get stringify the ids
|
||||
uuid.unparse(buffer); // -> '02a2ce90-1432-11e1-8558-0b488e4fc115'
|
||||
uuid.unparse(buffer, 16) // -> '02a31cb0-1432-11e1-8558-0b488e4fc115'
|
||||
```
|
||||
|
||||
### uuid.v4([`options` [, `buffer` [, `offset`]]])
|
||||
|
||||
Generate and return a RFC4122 v4 UUID.
|
||||
|
||||
* `options` - (Object) Optional uuid state to apply. Properties may include:
|
||||
|
||||
* `random` - (Number[16]) Array of 16 numbers (0-255) to use in place of randomly generated values
|
||||
* `rng` - (Function) Random # generator to use. Set to one of the built-in generators - `uuid.mathRNG` (all platforms), `uuid.nodeRNG` (node.js only), `uuid.whatwgRNG` (WebKit only) - or a custom function that returns an array[16] of byte values.
|
||||
|
||||
* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.
|
||||
* `offset` - (Number) Starting index in `buffer` at which to begin writing.
|
||||
|
||||
Returns `buffer`, if specified, otherwise the string form of the UUID
|
||||
|
||||
Example: Generate string UUID with fully-specified options
|
||||
|
||||
```javascript
|
||||
uuid.v4({
|
||||
random: [
|
||||
0x10, 0x91, 0x56, 0xbe, 0xc4, 0xfb, 0xc1, 0xea,
|
||||
0x71, 0xb4, 0xef, 0xe1, 0x67, 0x1c, 0x58, 0x36
|
||||
]
|
||||
});
|
||||
// -> "109156be-c4fb-41ea-b1b4-efe1671c5836"
|
||||
```
|
||||
|
||||
Example: Generate two IDs in a single buffer
|
||||
|
||||
```javascript
|
||||
var buffer = new Array(32); // (or 'new Buffer' in node.js)
|
||||
uuid.v4(null, buffer, 0);
|
||||
uuid.v4(null, buffer, 16);
|
||||
```
|
||||
|
||||
### uuid.parse(id[, buffer[, offset]])
|
||||
### uuid.unparse(buffer[, offset])
|
||||
|
||||
Parse and unparse UUIDs
|
||||
|
||||
* `id` - (String) UUID(-like) string
|
||||
* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written. Default: A new Array or Buffer is used
|
||||
* `offset` - (Number) Starting index in `buffer` at which to begin writing. Default: 0
|
||||
|
||||
Example parsing and unparsing a UUID string
|
||||
|
||||
```javascript
|
||||
var bytes = uuid.parse('797ff043-11eb-11e1-80d6-510998755d10'); // -> <Buffer 79 7f f0 43 11 eb 11 e1 80 d6 51 09 98 75 5d 10>
|
||||
var string = uuid.unparse(bytes); // -> '797ff043-11eb-11e1-80d6-510998755d10'
|
||||
```
|
||||
|
||||
### uuid.noConflict()
|
||||
|
||||
(Browsers only) Set `uuid` property back to it's previous value.
|
||||
|
||||
Returns the node-uuid object.
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
var myUuid = uuid.noConflict();
|
||||
myUuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'
|
||||
```
|
||||
|
||||
## Deprecated APIs
|
||||
|
||||
Support for the following v1.2 APIs is available in v1.3, but is deprecated and will be removed in the next major version.
|
||||
|
||||
### uuid([format [, buffer [, offset]]])
|
||||
|
||||
uuid() has become uuid.v4(), and the `format` argument is now implicit in the `buffer` argument. (i.e. if you specify a buffer, the format is assumed to be binary).
|
||||
|
||||
### uuid.BufferClass
|
||||
|
||||
The class of container created when generating binary uuid data if no buffer argument is specified. This is expected to go away, with no replacement API.
|
||||
|
||||
## Testing
|
||||
|
||||
In node.js
|
||||
|
||||
```
|
||||
> cd test
|
||||
> node test.js
|
||||
```
|
||||
|
||||
In Browser
|
||||
|
||||
```
|
||||
open test/test.html
|
||||
```
|
||||
|
||||
### Benchmarking
|
||||
|
||||
Requires node.js
|
||||
|
||||
```
|
||||
npm install uuid uuid-js
|
||||
node benchmark/benchmark.js
|
||||
```
|
||||
|
||||
For a more complete discussion of node-uuid performance, please see the `benchmark/README.md` file, and the [benchmark wiki](https://github.com/broofa/node-uuid/wiki/Benchmark)
|
||||
|
||||
For browser performance [checkout the JSPerf tests](http://jsperf.com/node-uuid-performance).
|
||||
|
||||
## Release notes
|
||||
|
||||
### 1.4.0
|
||||
|
||||
* Improved module context detection
|
||||
* Removed public RNG functions
|
||||
|
||||
### 1.3.2
|
||||
|
||||
* Improve tests and handling of v1() options (Issue #24)
|
||||
* Expose RNG option to allow for perf testing with different generators
|
||||
|
||||
### 1.3.0
|
||||
|
||||
* Support for version 1 ids, thanks to [@ctavan](https://github.com/ctavan)!
|
||||
* Support for node.js crypto API
|
||||
* De-emphasizing performance in favor of a) cryptographic quality PRNGs where available and b) more manageable code
|
53
node_modules/node-uuid/benchmark/README.md
generated
vendored
Normal file
53
node_modules/node-uuid/benchmark/README.md
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
# node-uuid Benchmarks
|
||||
|
||||
### Results
|
||||
|
||||
To see the results of our benchmarks visit https://github.com/broofa/node-uuid/wiki/Benchmark
|
||||
|
||||
### Run them yourself
|
||||
|
||||
node-uuid comes with some benchmarks to measure performance of generating UUIDs. These can be run using node.js. node-uuid is being benchmarked against some other uuid modules, that are available through npm namely `uuid` and `uuid-js`.
|
||||
|
||||
To prepare and run the benchmark issue;
|
||||
|
||||
```
|
||||
npm install uuid uuid-js
|
||||
node benchmark/benchmark.js
|
||||
```
|
||||
|
||||
You'll see an output like this one:
|
||||
|
||||
```
|
||||
# v4
|
||||
nodeuuid.v4(): 854700 uuids/second
|
||||
nodeuuid.v4('binary'): 788643 uuids/second
|
||||
nodeuuid.v4('binary', buffer): 1336898 uuids/second
|
||||
uuid(): 479386 uuids/second
|
||||
uuid('binary'): 582072 uuids/second
|
||||
uuidjs.create(4): 312304 uuids/second
|
||||
|
||||
# v1
|
||||
nodeuuid.v1(): 938086 uuids/second
|
||||
nodeuuid.v1('binary'): 683060 uuids/second
|
||||
nodeuuid.v1('binary', buffer): 1644736 uuids/second
|
||||
uuidjs.create(1): 190621 uuids/second
|
||||
```
|
||||
|
||||
* The `uuid()` entries are for Nikhil Marathe's [uuid module](https://bitbucket.org/nikhilm/uuidjs) which is a wrapper around the native libuuid library.
|
||||
* The `uuidjs()` entries are for Patrick Negri's [uuid-js module](https://github.com/pnegri/uuid-js) which is a pure javascript implementation based on [UUID.js](https://github.com/LiosK/UUID.js) by LiosK.
|
||||
|
||||
If you want to get more reliable results you can run the benchmark multiple times and write the output into a log file:
|
||||
|
||||
```
|
||||
for i in {0..9}; do node benchmark/benchmark.js >> benchmark/bench_0.4.12.log; done;
|
||||
```
|
||||
|
||||
If you're interested in how performance varies between different node versions, you can issue the above command multiple times.
|
||||
|
||||
You can then use the shell script `bench.sh` provided in this directory to calculate the averages over all benchmark runs and draw a nice plot:
|
||||
|
||||
```
|
||||
(cd benchmark/ && ./bench.sh)
|
||||
```
|
||||
|
||||
This assumes you have [gnuplot](http://www.gnuplot.info/) and [ImageMagick](http://www.imagemagick.org/) installed. You'll find a nice `bench.png` graph in the `benchmark/` directory then.
|
174
node_modules/node-uuid/benchmark/bench.gnu
generated
vendored
Normal file
174
node_modules/node-uuid/benchmark/bench.gnu
generated
vendored
Normal file
@ -0,0 +1,174 @@
|
||||
#!/opt/local/bin/gnuplot -persist
|
||||
#
|
||||
#
|
||||
# G N U P L O T
|
||||
# Version 4.4 patchlevel 3
|
||||
# last modified March 2011
|
||||
# System: Darwin 10.8.0
|
||||
#
|
||||
# Copyright (C) 1986-1993, 1998, 2004, 2007-2010
|
||||
# Thomas Williams, Colin Kelley and many others
|
||||
#
|
||||
# gnuplot home: http://www.gnuplot.info
|
||||
# faq, bugs, etc: type "help seeking-assistance"
|
||||
# immediate help: type "help"
|
||||
# plot window: hit 'h'
|
||||
set terminal postscript eps noenhanced defaultplex \
|
||||
leveldefault color colortext \
|
||||
solid linewidth 1.2 butt noclip \
|
||||
palfuncparam 2000,0.003 \
|
||||
"Helvetica" 14
|
||||
set output 'bench.eps'
|
||||
unset clip points
|
||||
set clip one
|
||||
unset clip two
|
||||
set bar 1.000000 front
|
||||
set border 31 front linetype -1 linewidth 1.000
|
||||
set xdata
|
||||
set ydata
|
||||
set zdata
|
||||
set x2data
|
||||
set y2data
|
||||
set timefmt x "%d/%m/%y,%H:%M"
|
||||
set timefmt y "%d/%m/%y,%H:%M"
|
||||
set timefmt z "%d/%m/%y,%H:%M"
|
||||
set timefmt x2 "%d/%m/%y,%H:%M"
|
||||
set timefmt y2 "%d/%m/%y,%H:%M"
|
||||
set timefmt cb "%d/%m/%y,%H:%M"
|
||||
set boxwidth
|
||||
set style fill empty border
|
||||
set style rectangle back fc lt -3 fillstyle solid 1.00 border lt -1
|
||||
set style circle radius graph 0.02, first 0, 0
|
||||
set dummy x,y
|
||||
set format x "% g"
|
||||
set format y "% g"
|
||||
set format x2 "% g"
|
||||
set format y2 "% g"
|
||||
set format z "% g"
|
||||
set format cb "% g"
|
||||
set angles radians
|
||||
unset grid
|
||||
set key title ""
|
||||
set key outside left top horizontal Right noreverse enhanced autotitles columnhead nobox
|
||||
set key noinvert samplen 4 spacing 1 width 0 height 0
|
||||
set key maxcolumns 2 maxrows 0
|
||||
unset label
|
||||
unset arrow
|
||||
set style increment default
|
||||
unset style line
|
||||
set style line 1 linetype 1 linewidth 2.000 pointtype 1 pointsize default pointinterval 0
|
||||
unset style arrow
|
||||
set style histogram clustered gap 2 title offset character 0, 0, 0
|
||||
unset logscale
|
||||
set offsets graph 0.05, 0.15, 0, 0
|
||||
set pointsize 1.5
|
||||
set pointintervalbox 1
|
||||
set encoding default
|
||||
unset polar
|
||||
unset parametric
|
||||
unset decimalsign
|
||||
set view 60, 30, 1, 1
|
||||
set samples 100, 100
|
||||
set isosamples 10, 10
|
||||
set surface
|
||||
unset contour
|
||||
set clabel '%8.3g'
|
||||
set mapping cartesian
|
||||
set datafile separator whitespace
|
||||
unset hidden3d
|
||||
set cntrparam order 4
|
||||
set cntrparam linear
|
||||
set cntrparam levels auto 5
|
||||
set cntrparam points 5
|
||||
set size ratio 0 1,1
|
||||
set origin 0,0
|
||||
set style data points
|
||||
set style function lines
|
||||
set xzeroaxis linetype -2 linewidth 1.000
|
||||
set yzeroaxis linetype -2 linewidth 1.000
|
||||
set zzeroaxis linetype -2 linewidth 1.000
|
||||
set x2zeroaxis linetype -2 linewidth 1.000
|
||||
set y2zeroaxis linetype -2 linewidth 1.000
|
||||
set ticslevel 0.5
|
||||
set mxtics default
|
||||
set mytics default
|
||||
set mztics default
|
||||
set mx2tics default
|
||||
set my2tics default
|
||||
set mcbtics default
|
||||
set xtics border in scale 1,0.5 mirror norotate offset character 0, 0, 0
|
||||
set xtics norangelimit
|
||||
set xtics ()
|
||||
set ytics border in scale 1,0.5 mirror norotate offset character 0, 0, 0
|
||||
set ytics autofreq norangelimit
|
||||
set ztics border in scale 1,0.5 nomirror norotate offset character 0, 0, 0
|
||||
set ztics autofreq norangelimit
|
||||
set nox2tics
|
||||
set noy2tics
|
||||
set cbtics border in scale 1,0.5 mirror norotate offset character 0, 0, 0
|
||||
set cbtics autofreq norangelimit
|
||||
set title ""
|
||||
set title offset character 0, 0, 0 font "" norotate
|
||||
set timestamp bottom
|
||||
set timestamp ""
|
||||
set timestamp offset character 0, 0, 0 font "" norotate
|
||||
set rrange [ * : * ] noreverse nowriteback # (currently [8.98847e+307:-8.98847e+307] )
|
||||
set autoscale rfixmin
|
||||
set autoscale rfixmax
|
||||
set trange [ * : * ] noreverse nowriteback # (currently [-5.00000:5.00000] )
|
||||
set autoscale tfixmin
|
||||
set autoscale tfixmax
|
||||
set urange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] )
|
||||
set autoscale ufixmin
|
||||
set autoscale ufixmax
|
||||
set vrange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] )
|
||||
set autoscale vfixmin
|
||||
set autoscale vfixmax
|
||||
set xlabel ""
|
||||
set xlabel offset character 0, 0, 0 font "" textcolor lt -1 norotate
|
||||
set x2label ""
|
||||
set x2label offset character 0, 0, 0 font "" textcolor lt -1 norotate
|
||||
set xrange [ * : * ] noreverse nowriteback # (currently [-0.150000:3.15000] )
|
||||
set autoscale xfixmin
|
||||
set autoscale xfixmax
|
||||
set x2range [ * : * ] noreverse nowriteback # (currently [0.00000:3.00000] )
|
||||
set autoscale x2fixmin
|
||||
set autoscale x2fixmax
|
||||
set ylabel ""
|
||||
set ylabel offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270
|
||||
set y2label ""
|
||||
set y2label offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270
|
||||
set yrange [ 0.00000 : 1.90000e+06 ] noreverse nowriteback # (currently [:] )
|
||||
set autoscale yfixmin
|
||||
set autoscale yfixmax
|
||||
set y2range [ * : * ] noreverse nowriteback # (currently [0.00000:1.90000e+06] )
|
||||
set autoscale y2fixmin
|
||||
set autoscale y2fixmax
|
||||
set zlabel ""
|
||||
set zlabel offset character 0, 0, 0 font "" textcolor lt -1 norotate
|
||||
set zrange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] )
|
||||
set autoscale zfixmin
|
||||
set autoscale zfixmax
|
||||
set cblabel ""
|
||||
set cblabel offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270
|
||||
set cbrange [ * : * ] noreverse nowriteback # (currently [8.98847e+307:-8.98847e+307] )
|
||||
set autoscale cbfixmin
|
||||
set autoscale cbfixmax
|
||||
set zero 1e-08
|
||||
set lmargin -1
|
||||
set bmargin -1
|
||||
set rmargin -1
|
||||
set tmargin -1
|
||||
set pm3d explicit at s
|
||||
set pm3d scansautomatic
|
||||
set pm3d interpolate 1,1 flush begin noftriangles nohidden3d corners2color mean
|
||||
set palette positive nops_allcF maxcolors 0 gamma 1.5 color model RGB
|
||||
set palette rgbformulae 7, 5, 15
|
||||
set colorbox default
|
||||
set colorbox vertical origin screen 0.9, 0.2, 0 size screen 0.05, 0.6, 0 front bdefault
|
||||
set loadpath
|
||||
set fontpath
|
||||
set fit noerrorvariables
|
||||
GNUTERM = "aqua"
|
||||
plot 'bench_results.txt' using 2:xticlabel(1) w lp lw 2, '' using 3:xticlabel(1) w lp lw 2, '' using 4:xticlabel(1) w lp lw 2, '' using 5:xticlabel(1) w lp lw 2, '' using 6:xticlabel(1) w lp lw 2, '' using 7:xticlabel(1) w lp lw 2, '' using 8:xticlabel(1) w lp lw 2, '' using 9:xticlabel(1) w lp lw 2
|
||||
# EOF
|
34
node_modules/node-uuid/benchmark/bench.sh
generated
vendored
Executable file
34
node_modules/node-uuid/benchmark/bench.sh
generated
vendored
Executable file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
# for a given node version run:
|
||||
# for i in {0..9}; do node benchmark.js >> bench_0.6.2.log; done;
|
||||
|
||||
PATTERNS=('nodeuuid.v1()' "nodeuuid.v1('binary'," 'nodeuuid.v4()' "nodeuuid.v4('binary'," "uuid()" "uuid('binary')" 'uuidjs.create(1)' 'uuidjs.create(4)' '140byte')
|
||||
FILES=(node_uuid_v1_string node_uuid_v1_buf node_uuid_v4_string node_uuid_v4_buf libuuid_v4_string libuuid_v4_binary uuidjs_v1_string uuidjs_v4_string 140byte_es)
|
||||
INDICES=(2 3 2 3 2 2 2 2 2)
|
||||
VERSIONS=$( ls bench_*.log | sed -e 's/^bench_\([0-9\.]*\)\.log/\1/' | tr "\\n" " " )
|
||||
TMPJOIN="tmp_join"
|
||||
OUTPUT="bench_results.txt"
|
||||
|
||||
for I in ${!FILES[*]}; do
|
||||
F=${FILES[$I]}
|
||||
P=${PATTERNS[$I]}
|
||||
INDEX=${INDICES[$I]}
|
||||
echo "version $F" > $F
|
||||
for V in $VERSIONS; do
|
||||
(VAL=$( grep "$P" bench_$V.log | LC_ALL=en_US awk '{ sum += $'$INDEX' } END { print sum/NR }' ); echo $V $VAL) >> $F
|
||||
done
|
||||
if [ $I == 0 ]; then
|
||||
cat $F > $TMPJOIN
|
||||
else
|
||||
join $TMPJOIN $F > $OUTPUT
|
||||
cp $OUTPUT $TMPJOIN
|
||||
fi
|
||||
rm $F
|
||||
done
|
||||
|
||||
rm $TMPJOIN
|
||||
|
||||
gnuplot bench.gnu
|
||||
convert -density 200 -resize 800x560 -flatten bench.eps bench.png
|
||||
rm bench.eps
|
34
node_modules/node-uuid/benchmark/benchmark-native.c
generated
vendored
Normal file
34
node_modules/node-uuid/benchmark/benchmark-native.c
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
Test performance of native C UUID generation
|
||||
|
||||
To Compile: cc -luuid benchmark-native.c -o benchmark-native
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <uuid/uuid.h>
|
||||
|
||||
int main() {
|
||||
uuid_t myid;
|
||||
char buf[36+1];
|
||||
int i;
|
||||
struct timeval t;
|
||||
double start, finish;
|
||||
|
||||
gettimeofday(&t, NULL);
|
||||
start = t.tv_sec + t.tv_usec/1e6;
|
||||
|
||||
int n = 2e5;
|
||||
for (i = 0; i < n; i++) {
|
||||
uuid_generate(myid);
|
||||
uuid_unparse(myid, buf);
|
||||
}
|
||||
|
||||
gettimeofday(&t, NULL);
|
||||
finish = t.tv_sec + t.tv_usec/1e6;
|
||||
double dur = finish - start;
|
||||
|
||||
printf("%d uuids/sec", (int)(n/dur));
|
||||
return 0;
|
||||
}
|
84
node_modules/node-uuid/benchmark/benchmark.js
generated
vendored
Normal file
84
node_modules/node-uuid/benchmark/benchmark.js
generated
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
try {
|
||||
var nodeuuid = require('../uuid');
|
||||
} catch (e) {
|
||||
console.error('node-uuid require failed - skipping tests');
|
||||
}
|
||||
|
||||
try {
|
||||
var uuid = require('uuid');
|
||||
} catch (e) {
|
||||
console.error('uuid require failed - skipping tests');
|
||||
}
|
||||
|
||||
try {
|
||||
var uuidjs = require('uuid-js');
|
||||
} catch (e) {
|
||||
console.error('uuid-js require failed - skipping tests');
|
||||
}
|
||||
|
||||
var N = 5e5;
|
||||
|
||||
function rate(msg, t) {
|
||||
console.log(msg + ': ' +
|
||||
(N / (Date.now() - t) * 1e3 | 0) +
|
||||
' uuids/second');
|
||||
}
|
||||
|
||||
console.log('# v4');
|
||||
|
||||
// node-uuid - string form
|
||||
if (nodeuuid) {
|
||||
for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4();
|
||||
rate('nodeuuid.v4() - using node.js crypto RNG', t);
|
||||
|
||||
for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4({rng: nodeuuid.mathRNG});
|
||||
rate('nodeuuid.v4() - using Math.random() RNG', t);
|
||||
|
||||
for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4('binary');
|
||||
rate('nodeuuid.v4(\'binary\')', t);
|
||||
|
||||
var buffer = new nodeuuid.BufferClass(16);
|
||||
for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4('binary', buffer);
|
||||
rate('nodeuuid.v4(\'binary\', buffer)', t);
|
||||
}
|
||||
|
||||
// libuuid - string form
|
||||
if (uuid) {
|
||||
for (var i = 0, t = Date.now(); i < N; i++) uuid();
|
||||
rate('uuid()', t);
|
||||
|
||||
for (var i = 0, t = Date.now(); i < N; i++) uuid('binary');
|
||||
rate('uuid(\'binary\')', t);
|
||||
}
|
||||
|
||||
// uuid-js - string form
|
||||
if (uuidjs) {
|
||||
for (var i = 0, t = Date.now(); i < N; i++) uuidjs.create(4);
|
||||
rate('uuidjs.create(4)', t);
|
||||
}
|
||||
|
||||
// 140byte.es
|
||||
for (var i = 0, t = Date.now(); i < N; i++) 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,function(s,r){r=Math.random()*16|0;return (s=='x'?r:r&0x3|0x8).toString(16)});
|
||||
rate('140byte.es_v4', t);
|
||||
|
||||
console.log('');
|
||||
console.log('# v1');
|
||||
|
||||
// node-uuid - v1 string form
|
||||
if (nodeuuid) {
|
||||
for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1();
|
||||
rate('nodeuuid.v1()', t);
|
||||
|
||||
for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1('binary');
|
||||
rate('nodeuuid.v1(\'binary\')', t);
|
||||
|
||||
var buffer = new nodeuuid.BufferClass(16);
|
||||
for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1('binary', buffer);
|
||||
rate('nodeuuid.v1(\'binary\', buffer)', t);
|
||||
}
|
||||
|
||||
// uuid-js - v1 string form
|
||||
if (uuidjs) {
|
||||
for (var i = 0, t = Date.now(); i < N; i++) uuidjs.create(1);
|
||||
rate('uuidjs.create(1)', t);
|
||||
}
|
18
node_modules/node-uuid/component.json
generated
vendored
Normal file
18
node_modules/node-uuid/component.json
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "node-uuid",
|
||||
"repo": "broofa/node-uuid",
|
||||
"description": "Rigorous implementation of RFC4122 (v1 and v4) UUIDs.",
|
||||
"version": "1.4.0",
|
||||
"author": "Robert Kieffer <robert@broofa.com>",
|
||||
"contributors": [
|
||||
{"name": "Christoph Tavan <dev@tavan.de>", "github": "https://github.com/ctavan"}
|
||||
],
|
||||
"keywords": ["uuid", "guid", "rfc4122"],
|
||||
"dependencies": {},
|
||||
"development": {},
|
||||
"main": "uuid.js",
|
||||
"scripts": [
|
||||
"uuid.js"
|
||||
],
|
||||
"license": "MIT"
|
||||
}
|
35
node_modules/node-uuid/package.json
generated
vendored
Normal file
35
node_modules/node-uuid/package.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
63
node_modules/node-uuid/test/compare_v1.js
generated
vendored
Normal file
63
node_modules/node-uuid/test/compare_v1.js
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
var assert = require('assert'),
|
||||
nodeuuid = require('../uuid'),
|
||||
uuidjs = require('uuid-js'),
|
||||
libuuid = require('uuid').generate,
|
||||
util = require('util'),
|
||||
exec = require('child_process').exec,
|
||||
os = require('os');
|
||||
|
||||
// On Mac Os X / macports there's only the ossp-uuid package that provides uuid
|
||||
// On Linux there's uuid-runtime which provides uuidgen
|
||||
var uuidCmd = os.type() === 'Darwin' ? 'uuid -1' : 'uuidgen -t';
|
||||
|
||||
function compare(ids) {
|
||||
console.log(ids);
|
||||
for (var i = 0; i < ids.length; i++) {
|
||||
var id = ids[i].split('-');
|
||||
id = [id[2], id[1], id[0]].join('');
|
||||
ids[i] = id;
|
||||
}
|
||||
var sorted = ([].concat(ids)).sort();
|
||||
|
||||
if (sorted.toString() !== ids.toString()) {
|
||||
console.log('Warning: sorted !== ids');
|
||||
} else {
|
||||
console.log('everything in order!');
|
||||
}
|
||||
}
|
||||
|
||||
// Test time order of v1 uuids
|
||||
var ids = [];
|
||||
while (ids.length < 10e3) ids.push(nodeuuid.v1());
|
||||
|
||||
var max = 10;
|
||||
console.log('node-uuid:');
|
||||
ids = [];
|
||||
for (var i = 0; i < max; i++) ids.push(nodeuuid.v1());
|
||||
compare(ids);
|
||||
|
||||
console.log('');
|
||||
console.log('uuidjs:');
|
||||
ids = [];
|
||||
for (var i = 0; i < max; i++) ids.push(uuidjs.create(1).toString());
|
||||
compare(ids);
|
||||
|
||||
console.log('');
|
||||
console.log('libuuid:');
|
||||
ids = [];
|
||||
var count = 0;
|
||||
var last = function() {
|
||||
compare(ids);
|
||||
}
|
||||
var cb = function(err, stdout, stderr) {
|
||||
ids.push(stdout.substring(0, stdout.length-1));
|
||||
count++;
|
||||
if (count < max) {
|
||||
return next();
|
||||
}
|
||||
last();
|
||||
};
|
||||
var next = function() {
|
||||
exec(uuidCmd, cb);
|
||||
};
|
||||
next();
|
17
node_modules/node-uuid/test/test.html
generated
vendored
Normal file
17
node_modules/node-uuid/test/test.html
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
div {
|
||||
font-family: monospace;
|
||||
font-size: 8pt;
|
||||
}
|
||||
div.log {color: #444;}
|
||||
div.warn {color: #550;}
|
||||
div.error {color: #800; font-weight: bold;}
|
||||
</style>
|
||||
<script src="../uuid.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script src="./test.js"></script>
|
||||
</body>
|
||||
</html>
|
228
node_modules/node-uuid/test/test.js
generated
vendored
Normal file
228
node_modules/node-uuid/test/test.js
generated
vendored
Normal file
@ -0,0 +1,228 @@
|
||||
if (!this.uuid) {
|
||||
// node.js
|
||||
uuid = require('../uuid');
|
||||
}
|
||||
|
||||
//
|
||||
// x-platform log/assert shims
|
||||
//
|
||||
|
||||
function _log(msg, type) {
|
||||
type = type || 'log';
|
||||
|
||||
if (typeof(document) != 'undefined') {
|
||||
document.write('<div class="' + type + '">' + msg.replace(/\n/g, '<br />') + '</div>');
|
||||
}
|
||||
if (typeof(console) != 'undefined') {
|
||||
var color = {
|
||||
log: '\033[39m',
|
||||
warn: '\033[33m',
|
||||
error: '\033[31m'
|
||||
};
|
||||
console[type](color[type] + msg + color.log);
|
||||
}
|
||||
}
|
||||
|
||||
function log(msg) {_log(msg, 'log');}
|
||||
function warn(msg) {_log(msg, 'warn');}
|
||||
function error(msg) {_log(msg, 'error');}
|
||||
|
||||
function assert(res, msg) {
|
||||
if (!res) {
|
||||
error('FAIL: ' + msg);
|
||||
} else {
|
||||
log('Pass: ' + msg);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Unit tests
|
||||
//
|
||||
|
||||
// Verify ordering of v1 ids created with explicit times
|
||||
var TIME = 1321644961388; // 2011-11-18 11:36:01.388-08:00
|
||||
|
||||
function compare(name, ids) {
|
||||
ids = ids.map(function(id) {
|
||||
return id.split('-').reverse().join('-');
|
||||
}).sort();
|
||||
var sorted = ([].concat(ids)).sort();
|
||||
|
||||
assert(sorted.toString() == ids.toString(), name + ' have expected order');
|
||||
}
|
||||
|
||||
// Verify ordering of v1 ids created using default behavior
|
||||
compare('uuids with current time', [
|
||||
uuid.v1(),
|
||||
uuid.v1(),
|
||||
uuid.v1(),
|
||||
uuid.v1(),
|
||||
uuid.v1()
|
||||
]);
|
||||
|
||||
// Verify ordering of v1 ids created with explicit times
|
||||
compare('uuids with time option', [
|
||||
uuid.v1({msecs: TIME - 10*3600*1000}),
|
||||
uuid.v1({msecs: TIME - 1}),
|
||||
uuid.v1({msecs: TIME}),
|
||||
uuid.v1({msecs: TIME + 1}),
|
||||
uuid.v1({msecs: TIME + 28*24*3600*1000})
|
||||
]);
|
||||
|
||||
assert(
|
||||
uuid.v1({msecs: TIME}) != uuid.v1({msecs: TIME}),
|
||||
'IDs created at same msec are different'
|
||||
);
|
||||
|
||||
// Verify throw if too many ids created
|
||||
var thrown = false;
|
||||
try {
|
||||
uuid.v1({msecs: TIME, nsecs: 10000});
|
||||
} catch (e) {
|
||||
thrown = true;
|
||||
}
|
||||
assert(thrown, 'Exception thrown when > 10K ids created in 1 ms');
|
||||
|
||||
// Verify clock regression bumps clockseq
|
||||
var uidt = uuid.v1({msecs: TIME});
|
||||
var uidtb = uuid.v1({msecs: TIME - 1});
|
||||
assert(
|
||||
parseInt(uidtb.split('-')[3], 16) - parseInt(uidt.split('-')[3], 16) === 1,
|
||||
'Clock regression by msec increments the clockseq'
|
||||
);
|
||||
|
||||
// Verify clock regression bumps clockseq
|
||||
var uidtn = uuid.v1({msecs: TIME, nsecs: 10});
|
||||
var uidtnb = uuid.v1({msecs: TIME, nsecs: 9});
|
||||
assert(
|
||||
parseInt(uidtnb.split('-')[3], 16) - parseInt(uidtn.split('-')[3], 16) === 1,
|
||||
'Clock regression by nsec increments the clockseq'
|
||||
);
|
||||
|
||||
// Verify explicit options produce expected id
|
||||
var id = uuid.v1({
|
||||
msecs: 1321651533573,
|
||||
nsecs: 5432,
|
||||
clockseq: 0x385c,
|
||||
node: [ 0x61, 0xcd, 0x3c, 0xbb, 0x32, 0x10 ]
|
||||
});
|
||||
assert(id == 'd9428888-122b-11e1-b85c-61cd3cbb3210', 'Explicit options produce expected id');
|
||||
|
||||
// Verify adjacent ids across a msec boundary are 1 time unit apart
|
||||
var u0 = uuid.v1({msecs: TIME, nsecs: 9999});
|
||||
var u1 = uuid.v1({msecs: TIME + 1, nsecs: 0});
|
||||
|
||||
var before = u0.split('-')[0], after = u1.split('-')[0];
|
||||
var dt = parseInt(after, 16) - parseInt(before, 16);
|
||||
assert(dt === 1, 'Ids spanning 1ms boundary are 100ns apart');
|
||||
|
||||
//
|
||||
// Test parse/unparse
|
||||
//
|
||||
|
||||
id = '00112233445566778899aabbccddeeff';
|
||||
assert(uuid.unparse(uuid.parse(id.substr(0,10))) ==
|
||||
'00112233-4400-0000-0000-000000000000', 'Short parse');
|
||||
assert(uuid.unparse(uuid.parse('(this is the uuid -> ' + id + id)) ==
|
||||
'00112233-4455-6677-8899-aabbccddeeff', 'Dirty parse');
|
||||
|
||||
//
|
||||
// Perf tests
|
||||
//
|
||||
|
||||
var generators = {
|
||||
v1: uuid.v1,
|
||||
v4: uuid.v4
|
||||
};
|
||||
|
||||
var UUID_FORMAT = {
|
||||
v1: /[0-9a-f]{8}-[0-9a-f]{4}-1[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i,
|
||||
v4: /[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i
|
||||
};
|
||||
|
||||
var N = 1e4;
|
||||
|
||||
// Get %'age an actual value differs from the ideal value
|
||||
function divergence(actual, ideal) {
|
||||
return Math.round(100*100*(actual - ideal)/ideal)/100;
|
||||
}
|
||||
|
||||
function rate(msg, t) {
|
||||
log(msg + ': ' + (N / (Date.now() - t) * 1e3 | 0) + ' uuids\/second');
|
||||
}
|
||||
|
||||
for (var version in generators) {
|
||||
var counts = {}, max = 0;
|
||||
var generator = generators[version];
|
||||
var format = UUID_FORMAT[version];
|
||||
|
||||
log('\nSanity check ' + N + ' ' + version + ' uuids');
|
||||
for (var i = 0, ok = 0; i < N; i++) {
|
||||
id = generator();
|
||||
if (!format.test(id)) {
|
||||
throw Error(id + ' is not a valid UUID string');
|
||||
}
|
||||
|
||||
if (id != uuid.unparse(uuid.parse(id))) {
|
||||
assert(fail, id + ' is not a valid id');
|
||||
}
|
||||
|
||||
// Count digits for our randomness check
|
||||
if (version == 'v4') {
|
||||
var digits = id.replace(/-/g, '').split('');
|
||||
for (var j = digits.length-1; j >= 0; j--) {
|
||||
var c = digits[j];
|
||||
max = Math.max(max, counts[c] = (counts[c] || 0) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check randomness for v4 UUIDs
|
||||
if (version == 'v4') {
|
||||
// Limit that we get worried about randomness. (Purely empirical choice, this!)
|
||||
var limit = 2*100*Math.sqrt(1/N);
|
||||
|
||||
log('\nChecking v4 randomness. Distribution of Hex Digits (% deviation from ideal)');
|
||||
|
||||
for (var i = 0; i < 16; i++) {
|
||||
var c = i.toString(16);
|
||||
var bar = '', n = counts[c], p = Math.round(n/max*100|0);
|
||||
|
||||
// 1-3,5-8, and D-F: 1:16 odds over 30 digits
|
||||
var ideal = N*30/16;
|
||||
if (i == 4) {
|
||||
// 4: 1:1 odds on 1 digit, plus 1:16 odds on 30 digits
|
||||
ideal = N*(1 + 30/16);
|
||||
} else if (i >= 8 && i <= 11) {
|
||||
// 8-B: 1:4 odds on 1 digit, plus 1:16 odds on 30 digits
|
||||
ideal = N*(1/4 + 30/16);
|
||||
} else {
|
||||
// Otherwise: 1:16 odds on 30 digits
|
||||
ideal = N*30/16;
|
||||
}
|
||||
var d = divergence(n, ideal);
|
||||
|
||||
// Draw bar using UTF squares (just for grins)
|
||||
var s = n/max*50 | 0;
|
||||
while (s--) bar += '=';
|
||||
|
||||
assert(Math.abs(d) < limit, c + ' |' + bar + '| ' + counts[c] + ' (' + d + '% < ' + limit + '%)');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Perf tests
|
||||
for (var version in generators) {
|
||||
log('\nPerformance testing ' + version + ' UUIDs');
|
||||
var generator = generators[version];
|
||||
var buf = new uuid.BufferClass(16);
|
||||
|
||||
for (var i = 0, t = Date.now(); i < N; i++) generator();
|
||||
rate('uuid.' + version + '()', t);
|
||||
|
||||
for (var i = 0, t = Date.now(); i < N; i++) generator('binary');
|
||||
rate('uuid.' + version + '(\'binary\')', t);
|
||||
|
||||
for (var i = 0, t = Date.now(); i < N; i++) generator('binary', buf);
|
||||
rate('uuid.' + version + '(\'binary\', buffer)', t);
|
||||
}
|
245
node_modules/node-uuid/uuid.js
generated
vendored
Normal file
245
node_modules/node-uuid/uuid.js
generated
vendored
Normal file
@ -0,0 +1,245 @@
|
||||
// uuid.js
|
||||
//
|
||||
// Copyright (c) 2010-2012 Robert Kieffer
|
||||
// MIT License - http://opensource.org/licenses/mit-license.php
|
||||
|
||||
(function() {
|
||||
var _global = this;
|
||||
|
||||
// Unique ID creation requires a high quality random # generator. We feature
|
||||
// detect to determine the best RNG source, normalizing to a function that
|
||||
// returns 128-bits of randomness, since that's what's usually required
|
||||
var _rng;
|
||||
|
||||
// Node.js crypto-based RNG - http://nodejs.org/docs/v0.6.2/api/crypto.html
|
||||
//
|
||||
// Moderately fast, high quality
|
||||
if (typeof(require) == 'function') {
|
||||
try {
|
||||
var _rb = require('crypto').randomBytes;
|
||||
_rng = _rb && function() {return _rb(16);};
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
if (!_rng && _global.crypto && crypto.getRandomValues) {
|
||||
// WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto
|
||||
//
|
||||
// Moderately fast, high quality
|
||||
var _rnds8 = new Uint8Array(16);
|
||||
_rng = function whatwgRNG() {
|
||||
crypto.getRandomValues(_rnds8);
|
||||
return _rnds8;
|
||||
};
|
||||
}
|
||||
|
||||
if (!_rng) {
|
||||
// Math.random()-based (RNG)
|
||||
//
|
||||
// If all else fails, use Math.random(). It's fast, but is of unspecified
|
||||
// quality.
|
||||
var _rnds = new Array(16);
|
||||
_rng = function() {
|
||||
for (var i = 0, r; i < 16; i++) {
|
||||
if ((i & 0x03) === 0) r = Math.random() * 0x100000000;
|
||||
_rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;
|
||||
}
|
||||
|
||||
return _rnds;
|
||||
};
|
||||
}
|
||||
|
||||
// Buffer class to use
|
||||
var BufferClass = typeof(Buffer) == 'function' ? Buffer : Array;
|
||||
|
||||
// Maps for number <-> hex string conversion
|
||||
var _byteToHex = [];
|
||||
var _hexToByte = {};
|
||||
for (var i = 0; i < 256; i++) {
|
||||
_byteToHex[i] = (i + 0x100).toString(16).substr(1);
|
||||
_hexToByte[_byteToHex[i]] = i;
|
||||
}
|
||||
|
||||
// **`parse()` - Parse a UUID into it's component bytes**
|
||||
function parse(s, buf, offset) {
|
||||
var i = (buf && offset) || 0, ii = 0;
|
||||
|
||||
buf = buf || [];
|
||||
s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) {
|
||||
if (ii < 16) { // Don't overflow!
|
||||
buf[i + ii++] = _hexToByte[oct];
|
||||
}
|
||||
});
|
||||
|
||||
// Zero out remaining bytes if string was short
|
||||
while (ii < 16) {
|
||||
buf[i + ii++] = 0;
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
// **`unparse()` - Convert UUID byte array (ala parse()) into a string**
|
||||
function unparse(buf, offset) {
|
||||
var i = offset || 0, bth = _byteToHex;
|
||||
return bth[buf[i++]] + bth[buf[i++]] +
|
||||
bth[buf[i++]] + bth[buf[i++]] + '-' +
|
||||
bth[buf[i++]] + bth[buf[i++]] + '-' +
|
||||
bth[buf[i++]] + bth[buf[i++]] + '-' +
|
||||
bth[buf[i++]] + bth[buf[i++]] + '-' +
|
||||
bth[buf[i++]] + bth[buf[i++]] +
|
||||
bth[buf[i++]] + bth[buf[i++]] +
|
||||
bth[buf[i++]] + bth[buf[i++]];
|
||||
}
|
||||
|
||||
// **`v1()` - Generate time-based UUID**
|
||||
//
|
||||
// Inspired by https://github.com/LiosK/UUID.js
|
||||
// and http://docs.python.org/library/uuid.html
|
||||
|
||||
// random #'s we need to init node and clockseq
|
||||
var _seedBytes = _rng();
|
||||
|
||||
// Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
|
||||
var _nodeId = [
|
||||
_seedBytes[0] | 0x01,
|
||||
_seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5]
|
||||
];
|
||||
|
||||
// Per 4.2.2, randomize (14 bit) clockseq
|
||||
var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff;
|
||||
|
||||
// Previous uuid creation time
|
||||
var _lastMSecs = 0, _lastNSecs = 0;
|
||||
|
||||
// See https://github.com/broofa/node-uuid for API details
|
||||
function v1(options, buf, offset) {
|
||||
var i = buf && offset || 0;
|
||||
var b = buf || [];
|
||||
|
||||
options = options || {};
|
||||
|
||||
var clockseq = options.clockseq != null ? options.clockseq : _clockseq;
|
||||
|
||||
// UUID timestamps are 100 nano-second units since the Gregorian epoch,
|
||||
// (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
|
||||
// time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
|
||||
// (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
|
||||
var msecs = options.msecs != null ? options.msecs : new Date().getTime();
|
||||
|
||||
// Per 4.2.1.2, use count of uuid's generated during the current clock
|
||||
// cycle to simulate higher resolution clock
|
||||
var nsecs = options.nsecs != null ? options.nsecs : _lastNSecs + 1;
|
||||
|
||||
// Time since last uuid creation (in msecs)
|
||||
var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000;
|
||||
|
||||
// Per 4.2.1.2, Bump clockseq on clock regression
|
||||
if (dt < 0 && options.clockseq == null) {
|
||||
clockseq = clockseq + 1 & 0x3fff;
|
||||
}
|
||||
|
||||
// Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
|
||||
// time interval
|
||||
if ((dt < 0 || msecs > _lastMSecs) && options.nsecs == null) {
|
||||
nsecs = 0;
|
||||
}
|
||||
|
||||
// Per 4.2.1.2 Throw error if too many uuids are requested
|
||||
if (nsecs >= 10000) {
|
||||
throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec');
|
||||
}
|
||||
|
||||
_lastMSecs = msecs;
|
||||
_lastNSecs = nsecs;
|
||||
_clockseq = clockseq;
|
||||
|
||||
// Per 4.1.4 - Convert from unix epoch to Gregorian epoch
|
||||
msecs += 12219292800000;
|
||||
|
||||
// `time_low`
|
||||
var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
|
||||
b[i++] = tl >>> 24 & 0xff;
|
||||
b[i++] = tl >>> 16 & 0xff;
|
||||
b[i++] = tl >>> 8 & 0xff;
|
||||
b[i++] = tl & 0xff;
|
||||
|
||||
// `time_mid`
|
||||
var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff;
|
||||
b[i++] = tmh >>> 8 & 0xff;
|
||||
b[i++] = tmh & 0xff;
|
||||
|
||||
// `time_high_and_version`
|
||||
b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
|
||||
b[i++] = tmh >>> 16 & 0xff;
|
||||
|
||||
// `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
|
||||
b[i++] = clockseq >>> 8 | 0x80;
|
||||
|
||||
// `clock_seq_low`
|
||||
b[i++] = clockseq & 0xff;
|
||||
|
||||
// `node`
|
||||
var node = options.node || _nodeId;
|
||||
for (var n = 0; n < 6; n++) {
|
||||
b[i + n] = node[n];
|
||||
}
|
||||
|
||||
return buf ? buf : unparse(b);
|
||||
}
|
||||
|
||||
// **`v4()` - Generate random UUID**
|
||||
|
||||
// See https://github.com/broofa/node-uuid for API details
|
||||
function v4(options, buf, offset) {
|
||||
// Deprecated - 'format' argument, as supported in v1.2
|
||||
var i = buf && offset || 0;
|
||||
|
||||
if (typeof(options) == 'string') {
|
||||
buf = options == 'binary' ? new BufferClass(16) : null;
|
||||
options = null;
|
||||
}
|
||||
options = options || {};
|
||||
|
||||
var rnds = options.random || (options.rng || _rng)();
|
||||
|
||||
// Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
||||
rnds[6] = (rnds[6] & 0x0f) | 0x40;
|
||||
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
||||
|
||||
// Copy bytes to buffer, if provided
|
||||
if (buf) {
|
||||
for (var ii = 0; ii < 16; ii++) {
|
||||
buf[i + ii] = rnds[ii];
|
||||
}
|
||||
}
|
||||
|
||||
return buf || unparse(rnds);
|
||||
}
|
||||
|
||||
// Export public API
|
||||
var uuid = v4;
|
||||
uuid.v1 = v1;
|
||||
uuid.v4 = v4;
|
||||
uuid.parse = parse;
|
||||
uuid.unparse = unparse;
|
||||
uuid.BufferClass = BufferClass;
|
||||
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// Publish as AMD module
|
||||
define(function() {return uuid;});
|
||||
} else if (typeof(module) != 'undefined' && module.exports) {
|
||||
// Publish as node.js module
|
||||
module.exports = uuid;
|
||||
} else {
|
||||
// Publish as global (in browsers)
|
||||
var _previousRoot = _global.uuid;
|
||||
|
||||
// **`noConflict()` - (browser only) to reset global 'uuid' var**
|
||||
uuid.noConflict = function() {
|
||||
_global.uuid = _previousRoot;
|
||||
return uuid;
|
||||
};
|
||||
|
||||
_global.uuid = uuid;
|
||||
}
|
||||
}).call(this);
|
56
package.json
56
package.json
@ -1,27 +1,29 @@
|
||||
{
|
||||
"name": "biomed-portal",
|
||||
"version": "0.0.1",
|
||||
"author": "Dobie Wollert",
|
||||
"description": "Atlantic Biomedical Portal",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"express": "",
|
||||
"mongoose": "",
|
||||
"mongoose-pureautoinc": "",
|
||||
"passport": "",
|
||||
"passport-google-oauth": "",
|
||||
"piler": "",
|
||||
"less": "",
|
||||
"socket.io": "",
|
||||
"jade": "",
|
||||
"googleapis": "",
|
||||
"sprintf": "",
|
||||
"emailjs": "",
|
||||
"moment": "",
|
||||
"async": "",
|
||||
"passport-oauth": ""
|
||||
},
|
||||
"devDependencies": {
|
||||
"supervisor": ""
|
||||
}
|
||||
}
|
||||
{
|
||||
"name": "biomed-portal",
|
||||
"version": "0.0.1",
|
||||
"author": "Dobie Wollert",
|
||||
"description": "Atlantic Biomedical Portal",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"express": "",
|
||||
"mongoose": "",
|
||||
"mongoose-pureautoinc": "",
|
||||
"passport": "",
|
||||
"passport-google-oauth": "",
|
||||
"piler": "",
|
||||
"less": "",
|
||||
"socket.io": "",
|
||||
"jade": "",
|
||||
"googleapis": "",
|
||||
"sprintf": "",
|
||||
"emailjs": "",
|
||||
"moment": "",
|
||||
"async": "",
|
||||
"passport-oauth": "",
|
||||
"node-uuid": "~1.4.1",
|
||||
"MD5": "~1.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"supervisor": ""
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@
|
||||
|
||||
.navbar-inner {
|
||||
background-color: @navbarSecondaryBackground;
|
||||
min-height: auto;
|
||||
min-height: 40px;
|
||||
}
|
||||
|
||||
.nav > li {
|
||||
@ -75,4 +75,4 @@
|
||||
color: @navbarSecondaryLinkColorActive;
|
||||
background-color: @navbarSecondaryLinkBackgroundActive;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
|
||||
body {
|
||||
background-image: url('/img/bodyBg.png');
|
||||
min-width: 980px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
@ -115,4 +116,4 @@ body::-webkit-scrollbar-corner {
|
||||
-moz-box-shadow: inset 1px 1px 0 rgba(0,0,0,.14);
|
||||
-webkit-box-shadow: inset 1px 1px 0 rgba(0,0,0,.14);
|
||||
box-shadow: inset 1px 1px 0 rgba(0,0,0,.14);
|
||||
}
|
||||
}
|
||||
|
@ -43,4 +43,4 @@
|
||||
// Sprite icons path
|
||||
// -------------------------
|
||||
@iconSpritePath: "/img/glyphicons-halflings.png";
|
||||
@iconWhiteSpritePath: "/img/glyphicons-halflings-white.png";
|
||||
@iconWhiteSpritePath: "/img/glyphicons-halflings-white.png";
|
||||
|
@ -305,3 +305,417 @@ header {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* The MIT License */
|
||||
.dropzone,
|
||||
.dropzone *,
|
||||
.dropzone-previews,
|
||||
.dropzone-previews * {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.dropzone {
|
||||
position: relative;
|
||||
border: 1px solid rgba(0,0,0,0.08);
|
||||
background: rgba(0,0,0,0.02);
|
||||
padding: 1em;
|
||||
}
|
||||
.dropzone.dz-clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
.dropzone.dz-clickable .dz-message,
|
||||
.dropzone.dz-clickable .dz-message span {
|
||||
cursor: pointer;
|
||||
}
|
||||
.dropzone.dz-clickable * {
|
||||
cursor: default;
|
||||
}
|
||||
.dropzone .dz-message {
|
||||
opacity: 1;
|
||||
-ms-filter: none;
|
||||
filter: none;
|
||||
}
|
||||
.dropzone.dz-drag-hover {
|
||||
border-color: rgba(0,0,0,0.15);
|
||||
background: rgba(0,0,0,0.04);
|
||||
}
|
||||
.dropzone.dz-started .dz-message {
|
||||
display: none;
|
||||
}
|
||||
.dropzone .dz-preview,
|
||||
.dropzone-previews .dz-preview {
|
||||
background: rgba(255,255,255,0.8);
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
margin: 17px;
|
||||
vertical-align: top;
|
||||
border: 1px solid #acacac;
|
||||
padding: 6px 6px 6px 6px;
|
||||
}
|
||||
.dropzone .dz-preview.dz-file-preview [data-dz-thumbnail],
|
||||
.dropzone-previews .dz-preview.dz-file-preview [data-dz-thumbnail] {
|
||||
display: none;
|
||||
}
|
||||
.dropzone .dz-preview .dz-details,
|
||||
.dropzone-previews .dz-preview .dz-details {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
position: relative;
|
||||
background: #ebebeb;
|
||||
padding: 5px;
|
||||
margin-bottom: 22px;
|
||||
}
|
||||
.dropzone .dz-preview .dz-details .dz-filename,
|
||||
.dropzone-previews .dz-preview .dz-details .dz-filename {
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
}
|
||||
.dropzone .dz-preview .dz-details img,
|
||||
.dropzone-previews .dz-preview .dz-details img {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
.dropzone .dz-preview .dz-details .dz-size,
|
||||
.dropzone-previews .dz-preview .dz-details .dz-size {
|
||||
position: absolute;
|
||||
bottom: -28px;
|
||||
left: 3px;
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
}
|
||||
.dropzone .dz-preview.dz-error .dz-error-mark,
|
||||
.dropzone-previews .dz-preview.dz-error .dz-error-mark {
|
||||
display: block;
|
||||
}
|
||||
.dropzone .dz-preview.dz-success .dz-success-mark,
|
||||
.dropzone-previews .dz-preview.dz-success .dz-success-mark {
|
||||
display: block;
|
||||
}
|
||||
.dropzone .dz-preview:hover .dz-details img,
|
||||
.dropzone-previews .dz-preview:hover .dz-details img {
|
||||
display: none;
|
||||
}
|
||||
.dropzone .dz-preview .dz-success-mark,
|
||||
.dropzone-previews .dz-preview .dz-success-mark,
|
||||
.dropzone .dz-preview .dz-error-mark,
|
||||
.dropzone-previews .dz-preview .dz-error-mark {
|
||||
display: none;
|
||||
position: absolute;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
font-size: 30px;
|
||||
text-align: center;
|
||||
right: -10px;
|
||||
top: -10px;
|
||||
}
|
||||
.dropzone .dz-preview .dz-success-mark,
|
||||
.dropzone-previews .dz-preview .dz-success-mark {
|
||||
color: #8cc657;
|
||||
}
|
||||
.dropzone .dz-preview .dz-error-mark,
|
||||
.dropzone-previews .dz-preview .dz-error-mark {
|
||||
color: #ee162d;
|
||||
}
|
||||
.dropzone .dz-preview .dz-progress,
|
||||
.dropzone-previews .dz-preview .dz-progress {
|
||||
position: absolute;
|
||||
top: 100px;
|
||||
left: 6px;
|
||||
right: 6px;
|
||||
height: 6px;
|
||||
background: #d7d7d7;
|
||||
display: none;
|
||||
}
|
||||
.dropzone .dz-preview .dz-progress .dz-upload,
|
||||
.dropzone-previews .dz-preview .dz-progress .dz-upload {
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 0%;
|
||||
background-color: #8cc657;
|
||||
}
|
||||
.dropzone .dz-preview.dz-processing .dz-progress,
|
||||
.dropzone-previews .dz-preview.dz-processing .dz-progress {
|
||||
display: block;
|
||||
}
|
||||
.dropzone .dz-preview .dz-error-message,
|
||||
.dropzone-previews .dz-preview .dz-error-message {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: -5px;
|
||||
left: -20px;
|
||||
background: rgba(245,245,245,0.8);
|
||||
padding: 8px 10px;
|
||||
color: #800;
|
||||
min-width: 140px;
|
||||
max-width: 500px;
|
||||
z-index: 500;
|
||||
}
|
||||
.dropzone .dz-preview:hover.dz-error .dz-error-message,
|
||||
.dropzone-previews .dz-preview:hover.dz-error .dz-error-message {
|
||||
display: block;
|
||||
}
|
||||
.dropzone {
|
||||
border: 1px solid rgba(0,0,0,0.03);
|
||||
min-height: 360px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
background: rgba(0,0,0,0.03);
|
||||
padding: 23px;
|
||||
}
|
||||
.dropzone .dz-default.dz-message {
|
||||
opacity: 1;
|
||||
-ms-filter: none;
|
||||
filter: none;
|
||||
-webkit-transition: opacity 0.3s ease-in-out;
|
||||
-moz-transition: opacity 0.3s ease-in-out;
|
||||
-o-transition: opacity 0.3s ease-in-out;
|
||||
-ms-transition: opacity 0.3s ease-in-out;
|
||||
transition: opacity 0.3s ease-in-out;
|
||||
background-image: url("/img/spritemap.png");
|
||||
background-repeat: no-repeat;
|
||||
background-position: 0 0;
|
||||
position: absolute;
|
||||
width: 428px;
|
||||
height: 123px;
|
||||
margin-left: -214px;
|
||||
margin-top: -61.5px;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
}
|
||||
@media all and (-webkit-min-device-pixel-ratio:1.5),(min--moz-device-pixel-ratio:1.5),(-o-min-device-pixel-ratio:1.5/1),(min-device-pixel-ratio:1.5),(min-resolution:138dpi),(min-resolution:1.5dppx) {
|
||||
.dropzone .dz-default.dz-message {
|
||||
background-image: url("/img/spritemap@2x.png");
|
||||
-webkit-background-size: 428px 406px;
|
||||
-moz-background-size: 428px 406px;
|
||||
background-size: 428px 406px;
|
||||
}
|
||||
}
|
||||
.dropzone .dz-default.dz-message span {
|
||||
display: none;
|
||||
}
|
||||
.dropzone.dz-square .dz-default.dz-message {
|
||||
background-position: 0 -123px;
|
||||
width: 268px;
|
||||
margin-left: -134px;
|
||||
height: 174px;
|
||||
margin-top: -87px;
|
||||
}
|
||||
.dropzone.dz-drag-hover .dz-message {
|
||||
opacity: 0.15;
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=15)";
|
||||
filter: alpha(opacity=15);
|
||||
}
|
||||
.dropzone.dz-started .dz-message {
|
||||
display: block;
|
||||
opacity: 0;
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
|
||||
filter: alpha(opacity=0);
|
||||
}
|
||||
.dropzone .dz-preview,
|
||||
.dropzone-previews .dz-preview {
|
||||
-webkit-box-shadow: 1px 1px 4px rgba(0,0,0,0.16);
|
||||
box-shadow: 1px 1px 4px rgba(0,0,0,0.16);
|
||||
font-size: 14px;
|
||||
}
|
||||
.dropzone .dz-preview.dz-image-preview:hover .dz-details img,
|
||||
.dropzone-previews .dz-preview.dz-image-preview:hover .dz-details img {
|
||||
display: block;
|
||||
opacity: 0.1;
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=10)";
|
||||
filter: alpha(opacity=10);
|
||||
}
|
||||
.dropzone .dz-preview.dz-success .dz-success-mark,
|
||||
.dropzone-previews .dz-preview.dz-success .dz-success-mark {
|
||||
opacity: 1;
|
||||
-ms-filter: none;
|
||||
filter: none;
|
||||
}
|
||||
.dropzone .dz-preview.dz-error .dz-error-mark,
|
||||
.dropzone-previews .dz-preview.dz-error .dz-error-mark {
|
||||
opacity: 1;
|
||||
-ms-filter: none;
|
||||
filter: none;
|
||||
}
|
||||
.dropzone .dz-preview.dz-error .dz-progress .dz-upload,
|
||||
.dropzone-previews .dz-preview.dz-error .dz-progress .dz-upload {
|
||||
background: #ee1e2d;
|
||||
}
|
||||
.dropzone .dz-preview .dz-error-mark,
|
||||
.dropzone-previews .dz-preview .dz-error-mark,
|
||||
.dropzone .dz-preview .dz-success-mark,
|
||||
.dropzone-previews .dz-preview .dz-success-mark {
|
||||
display: block;
|
||||
opacity: 0;
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
|
||||
filter: alpha(opacity=0);
|
||||
-webkit-transition: opacity 0.4s ease-in-out;
|
||||
-moz-transition: opacity 0.4s ease-in-out;
|
||||
-o-transition: opacity 0.4s ease-in-out;
|
||||
-ms-transition: opacity 0.4s ease-in-out;
|
||||
transition: opacity 0.4s ease-in-out;
|
||||
background-image: url("/img/spritemap.png");
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
@media all and (-webkit-min-device-pixel-ratio:1.5),(min--moz-device-pixel-ratio:1.5),(-o-min-device-pixel-ratio:1.5/1),(min-device-pixel-ratio:1.5),(min-resolution:138dpi),(min-resolution:1.5dppx) {
|
||||
.dropzone .dz-preview .dz-error-mark,
|
||||
.dropzone-previews .dz-preview .dz-error-mark,
|
||||
.dropzone .dz-preview .dz-success-mark,
|
||||
.dropzone-previews .dz-preview .dz-success-mark {
|
||||
background-image: url("/img/spritemap@2x.png");
|
||||
-webkit-background-size: 428px 406px;
|
||||
-moz-background-size: 428px 406px;
|
||||
background-size: 428px 406px;
|
||||
}
|
||||
}
|
||||
.dropzone .dz-preview .dz-error-mark span,
|
||||
.dropzone-previews .dz-preview .dz-error-mark span,
|
||||
.dropzone .dz-preview .dz-success-mark span,
|
||||
.dropzone-previews .dz-preview .dz-success-mark span {
|
||||
display: none;
|
||||
}
|
||||
.dropzone .dz-preview .dz-error-mark,
|
||||
.dropzone-previews .dz-preview .dz-error-mark {
|
||||
background-position: -268px -123px;
|
||||
}
|
||||
.dropzone .dz-preview .dz-success-mark,
|
||||
.dropzone-previews .dz-preview .dz-success-mark {
|
||||
background-position: -268px -163px;
|
||||
}
|
||||
.dropzone .dz-preview .dz-progress .dz-upload,
|
||||
.dropzone-previews .dz-preview .dz-progress .dz-upload {
|
||||
-webkit-animation: loading 0.4s linear infinite;
|
||||
-moz-animation: loading 0.4s linear infinite;
|
||||
-o-animation: loading 0.4s linear infinite;
|
||||
-ms-animation: loading 0.4s linear infinite;
|
||||
animation: loading 0.4s linear infinite;
|
||||
-webkit-transition: width 0.3s ease-in-out;
|
||||
-moz-transition: width 0.3s ease-in-out;
|
||||
-o-transition: width 0.3s ease-in-out;
|
||||
-ms-transition: width 0.3s ease-in-out;
|
||||
transition: width 0.3s ease-in-out;
|
||||
-webkit-border-radius: 2px;
|
||||
border-radius: 2px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 0%;
|
||||
height: 100%;
|
||||
background-image: url("/img/spritemap.png");
|
||||
background-repeat: repeat-x;
|
||||
background-position: 0px -400px;
|
||||
}
|
||||
@media all and (-webkit-min-device-pixel-ratio:1.5),(min--moz-device-pixel-ratio:1.5),(-o-min-device-pixel-ratio:1.5/1),(min-device-pixel-ratio:1.5),(min-resolution:138dpi),(min-resolution:1.5dppx) {
|
||||
.dropzone .dz-preview .dz-progress .dz-upload,
|
||||
.dropzone-previews .dz-preview .dz-progress .dz-upload {
|
||||
background-image: url("/img/spritemap@2x.png");
|
||||
-webkit-background-size: 428px 406px;
|
||||
-moz-background-size: 428px 406px;
|
||||
background-size: 428px 406px;
|
||||
}
|
||||
}
|
||||
.dropzone .dz-preview.dz-success .dz-progress,
|
||||
.dropzone-previews .dz-preview.dz-success .dz-progress {
|
||||
display: block;
|
||||
opacity: 0;
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
|
||||
filter: alpha(opacity=0);
|
||||
-webkit-transition: opacity 0.4s ease-in-out;
|
||||
-moz-transition: opacity 0.4s ease-in-out;
|
||||
-o-transition: opacity 0.4s ease-in-out;
|
||||
-ms-transition: opacity 0.4s ease-in-out;
|
||||
transition: opacity 0.4s ease-in-out;
|
||||
}
|
||||
.dropzone .dz-preview .dz-error-message,
|
||||
.dropzone-previews .dz-preview .dz-error-message {
|
||||
display: block;
|
||||
opacity: 0;
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
|
||||
filter: alpha(opacity=0);
|
||||
-webkit-transition: opacity 0.3s ease-in-out;
|
||||
-moz-transition: opacity 0.3s ease-in-out;
|
||||
-o-transition: opacity 0.3s ease-in-out;
|
||||
-ms-transition: opacity 0.3s ease-in-out;
|
||||
transition: opacity 0.3s ease-in-out;
|
||||
}
|
||||
.dropzone .dz-preview:hover.dz-error .dz-error-message,
|
||||
.dropzone-previews .dz-preview:hover.dz-error .dz-error-message {
|
||||
opacity: 1;
|
||||
-ms-filter: none;
|
||||
filter: none;
|
||||
}
|
||||
.dropzone a.dz-remove,
|
||||
.dropzone-previews a.dz-remove {
|
||||
background-image: -webkit-linear-gradient(top, #fafafa, #eee);
|
||||
background-image: -moz-linear-gradient(top, #fafafa, #eee);
|
||||
background-image: -o-linear-gradient(top, #fafafa, #eee);
|
||||
background-image: -ms-linear-gradient(top, #fafafa, #eee);
|
||||
background-image: linear-gradient(to bottom, #fafafa, #eee);
|
||||
-webkit-border-radius: 2px;
|
||||
border-radius: 2px;
|
||||
border: 1px solid #eee;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
padding: 4px 5px;
|
||||
text-align: center;
|
||||
color: #aaa;
|
||||
margin-top: 26px;
|
||||
}
|
||||
.dropzone a.dz-remove:hover,
|
||||
.dropzone-previews a.dz-remove:hover {
|
||||
color: #666;
|
||||
}
|
||||
@-moz-keyframes loading {
|
||||
from {
|
||||
background-position: 0 -400px;
|
||||
}
|
||||
to {
|
||||
background-position: -7px -400px;
|
||||
}
|
||||
}
|
||||
@-webkit-keyframes loading {
|
||||
from {
|
||||
background-position: 0 -400px;
|
||||
}
|
||||
to {
|
||||
background-position: -7px -400px;
|
||||
}
|
||||
}
|
||||
@-o-keyframes loading {
|
||||
from {
|
||||
background-position: 0 -400px;
|
||||
}
|
||||
to {
|
||||
background-position: -7px -400px;
|
||||
}
|
||||
}
|
||||
@keyframes loading {
|
||||
from {
|
||||
background-position: 0 -400px;
|
||||
}
|
||||
to {
|
||||
background-position: -7px -400px;
|
||||
}
|
||||
}
|
||||
|
42
public/css/site.css
Normal file
42
public/css/site.css
Normal file
@ -0,0 +1,42 @@
|
||||
body {
|
||||
min-width: initial;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100% !important;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
button {
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
textarea {
|
||||
width: 100% !important;
|
||||
height: 300px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.dropzone {
|
||||
min-height: initial !important;
|
||||
}
|
||||
|
||||
.dz-message {
|
||||
background-image: none !important;
|
||||
position: initial !important;
|
||||
width: initial !important;
|
||||
height: initial !important;
|
||||
margin-left: initial !important;
|
||||
margin-top: initial !important;
|
||||
}
|
||||
|
||||
.dz-message span {
|
||||
display: block !important;
|
||||
font-size: 24px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
h1.msg {
|
||||
text-align: center;
|
||||
}
|
BIN
public/img/spritemap.png
Normal file
BIN
public/img/spritemap.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
BIN
public/img/spritemap@2x.png
Normal file
BIN
public/img/spritemap@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 35 KiB |
@ -73,6 +73,18 @@ angular.module('biomed', ['biomed.filters', 'biomed.services', 'biomed.directive
|
||||
templateUrl: '/partials/techs/schedule.html',
|
||||
controller: biomed.TechScheduleCtrl
|
||||
})
|
||||
.when('/posts', {
|
||||
templateUrl: '/partials/posts/index.html',
|
||||
controller: biomed.PostIndexCtrl
|
||||
})
|
||||
.when('/posts/add', {
|
||||
templateUrl: '/partials/posts/add.html',
|
||||
controller: biomed.PostAddCtrl
|
||||
})
|
||||
.when('/posts/:id', {
|
||||
templateUrl: '/partials/posts/edit.html',
|
||||
controller: biomed.PostEditCtrl
|
||||
})
|
||||
.when('/admin', {
|
||||
templateUrl: '/partials/users/index.html',
|
||||
controller: biomed.UsersIndexCtrl,
|
||||
|
@ -174,13 +174,206 @@ biomed.UsersIndexCtrl = function($scope, $filter, $routeParams, $location, Users
|
||||
|
||||
biomed.UserClockCtrl = function($scope, $routeParams, Users) {
|
||||
Users.index({userid: $routeParams.id}, function(result) {
|
||||
console.log(result);
|
||||
$scope.tech = result[0];
|
||||
});
|
||||
|
||||
$scope.clocks = Users.clocks($routeParams);
|
||||
};
|
||||
|
||||
biomed.PostIndexCtrl = function($scope, $routeParams, Posts, LocationBinder) {
|
||||
$scope.loading = true;
|
||||
|
||||
$scope.posts = Posts.index(function() {
|
||||
$scope.loading = false;
|
||||
});
|
||||
};
|
||||
|
||||
biomed.PostAddCtrl = function($scope, Posts, $location) {
|
||||
|
||||
$scope.model = {
|
||||
gallery: []
|
||||
};
|
||||
|
||||
$scope.titleImageOptions = {
|
||||
options: {
|
||||
url: '/api/posts/upload',
|
||||
maxFiles: 1,
|
||||
addRemoveLinks: true
|
||||
},
|
||||
eventHandlers: {
|
||||
success: function(file, response) {
|
||||
console.log('adding file');
|
||||
$scope.$apply(function() {
|
||||
$scope.model.image = response.filename;
|
||||
});
|
||||
},
|
||||
removedfile: function(file) {
|
||||
console.log('removing file');
|
||||
$scope.$apply(function() {
|
||||
$scope.model.image = undefined;
|
||||
});
|
||||
},
|
||||
maxfilesexceeded: function(file) {
|
||||
this.removeAllFiles();
|
||||
this.addFile(file);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var galleryImages = {};
|
||||
|
||||
$scope.galleryImageOptions = {
|
||||
options: {
|
||||
url: '/api/posts/upload',
|
||||
addRemoveLinks: true
|
||||
},
|
||||
eventHandlers: {
|
||||
success: function(file, response) {
|
||||
console.log('Adding File');
|
||||
file.filename = response.filename;
|
||||
|
||||
if (galleryImages[file.filename]) {
|
||||
galleryImages[file.filename]++;
|
||||
this.removeFile(file);
|
||||
} else {
|
||||
galleryImages[file.filename] = 1;
|
||||
}
|
||||
},
|
||||
removedfile: function(file) {
|
||||
console.log('Removing File');
|
||||
galleryImages[file.filename]--;
|
||||
|
||||
if (galleryImages[file.filename] <= 0) {
|
||||
delete galleryImages[file.filename];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var save = function(status) {
|
||||
$scope.model.gallery = Object.keys(galleryImages);
|
||||
$scope.model.status = status;
|
||||
$scope.model.createdOn = new Date();
|
||||
|
||||
if (status === 'posted') {
|
||||
$scope.model.postedOn = new Date();
|
||||
}
|
||||
|
||||
Posts.create($scope.model, function(result) {
|
||||
$location.path("/posts/" + result._id);
|
||||
});
|
||||
}
|
||||
|
||||
$scope.saveAsDraft = function() {
|
||||
save('draft');
|
||||
};
|
||||
|
||||
$scope.saveAsPosted = function() {
|
||||
save('posted');
|
||||
};
|
||||
};
|
||||
|
||||
biomed.PostEditCtrl = function($scope, Posts, $routeParams, $location) {
|
||||
var galleryImages = {};
|
||||
|
||||
$scope.model = Posts.get($routeParams, function() {
|
||||
$scope.loading = false;
|
||||
|
||||
if ($scope.model.image) {
|
||||
$scope.existingTitleImages = [$scope.model.image];
|
||||
}
|
||||
|
||||
$scope.existingGalleryImages = $scope.model.gallery;
|
||||
for (var i = 0; i < $scope.model.gallery.length; i++) {
|
||||
galleryImages[$scope.model.gallery[i]] = 1;
|
||||
}
|
||||
});
|
||||
|
||||
$scope.titleImageOptions = {
|
||||
options: {
|
||||
url: '/api/posts/upload',
|
||||
maxFiles: 1,
|
||||
addRemoveLinks: true,
|
||||
existing: []
|
||||
},
|
||||
eventHandlers: {
|
||||
success: function(file, response) {
|
||||
console.log('adding file');
|
||||
$scope.$apply(function() {
|
||||
$scope.model.image = response.filename;
|
||||
});
|
||||
},
|
||||
removedfile: function(file) {
|
||||
console.log('removing file');
|
||||
$scope.$apply(function() {
|
||||
$scope.model.image = undefined;
|
||||
});
|
||||
},
|
||||
maxfilesexceeded: function(file) {
|
||||
this.removeAllFiles();
|
||||
this.addFile(file);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$scope.galleryImageOptions = {
|
||||
options: {
|
||||
url: '/api/posts/upload',
|
||||
addRemoveLinks: true,
|
||||
existing: []
|
||||
},
|
||||
eventHandlers: {
|
||||
success: function(file, response) {
|
||||
console.log('Adding File');
|
||||
file.filename = response.filename;
|
||||
|
||||
if (galleryImages[file.filename]) {
|
||||
galleryImages[file.filename]++;
|
||||
this.removeFile(file);
|
||||
} else {
|
||||
galleryImages[file.filename] = 1;
|
||||
}
|
||||
},
|
||||
removedfile: function(file) {
|
||||
console.log('Removing File');
|
||||
galleryImages[file.filename]--;
|
||||
|
||||
if (galleryImages[file.filename] <= 0) {
|
||||
delete galleryImages[file.filename];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var save = function(status) {
|
||||
$scope.model.gallery = Object.keys(galleryImages);
|
||||
$scope.model.status = status;
|
||||
|
||||
if (status === 'posted') {
|
||||
$scope.model.postedOn = new Date();
|
||||
} else {
|
||||
$scope.model.postedOn = null;
|
||||
}
|
||||
|
||||
Posts.update({id: $scope.model._id}, $scope.model, function(result) {
|
||||
$location.path("/posts/");
|
||||
});
|
||||
}
|
||||
|
||||
$scope.saveAsDraft = function() {
|
||||
save('draft');
|
||||
};
|
||||
|
||||
$scope.saveAsPosted = function() {
|
||||
save('posted');
|
||||
};
|
||||
|
||||
$scope.saveAsArchived = function() {
|
||||
save('archived');
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
biomed.ClientIndexCtrl = function($scope, $filter, $routeParams, Clients, LocationBinder) {
|
||||
$scope.loading = true;
|
||||
|
||||
@ -347,7 +540,7 @@ biomed.ClientEditCtrl = function($scope, $routeParams, Clients) {
|
||||
}
|
||||
|
||||
$scope.toggleFrequency = function(frequency, month) {
|
||||
if (accountHasPermission('system.edit')) {
|
||||
if ($scope.accountHasPermission('system.edit')) {
|
||||
$scope.master.frequencies[frequency][month] =! $scope.master.frequencies[frequency][month];
|
||||
Clients.update({id: $scope.master._id}, $scope.master, function() {
|
||||
updatePms();
|
||||
@ -822,7 +1015,6 @@ biomed.PageCtrl = function($scope, $dialog, Account) {
|
||||
};
|
||||
|
||||
$scope.accountHasPermission = function(perm) {
|
||||
console.log($scope);
|
||||
if ($scope.account && $scope.account.perms) {
|
||||
return $scope.account.perms.indexOf(perm) > -1;
|
||||
}
|
||||
|
@ -787,4 +787,36 @@ angular.module('biomed.directives', [])
|
||||
};
|
||||
}
|
||||
};
|
||||
})
|
||||
.directive('dropzone', function() {
|
||||
return {
|
||||
scope: {
|
||||
dropzone: '=',
|
||||
existing: '='
|
||||
},
|
||||
controller: function($scope, $element, $attrs) {
|
||||
var config, dropzone;
|
||||
config = $scope.dropzone;
|
||||
|
||||
dropzone = new Dropzone($element[0], config.options);
|
||||
angular.forEach(config.eventHandlers, function (handler, event) {
|
||||
dropzone.on(event, handler);
|
||||
});
|
||||
|
||||
$scope.$watch('existing', function() {
|
||||
var existing = $scope.existing;
|
||||
|
||||
console.log(dropzone);
|
||||
|
||||
if (existing) {
|
||||
for (var i = 0; i < existing.length; i++) {
|
||||
var file = { name: existing[i], size: 0, accepted: true, filename: existing[i] };
|
||||
dropzone.options.addedfile.call(dropzone, file);
|
||||
dropzone.options.thumbnail.call(dropzone, file, "http://atlanticbiomedical.com/images/" + existing[i]);
|
||||
dropzone.files.push(file);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
1874
public/js/lib/dropzone.js
Normal file
1874
public/js/lib/dropzone.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -13,6 +13,17 @@ angular.module('biomed.services', [])
|
||||
tags: { method: 'GET', params: { id: 0, cmd: 'tags' }, isArray: true }
|
||||
});
|
||||
})
|
||||
.factory("Posts", function($resource) {
|
||||
return $resource('/api/posts/:id',
|
||||
{ id: "@id" },
|
||||
{
|
||||
index: { method: 'GET', params: {}, isArray: true },
|
||||
get: { method: 'GET', params: { id: 0} },
|
||||
create: { method: 'POST', params: {} },
|
||||
update: { method: 'POST', params: { id: 0} },
|
||||
destroy: { method: 'DELETE', params: { id: 0 } },
|
||||
});
|
||||
})
|
||||
.factory("Workorders", function($resource) {
|
||||
return $resource('/api/workorders/:id',
|
||||
{ id: "@id" },
|
||||
|
61
public/partials/posts/add.html
Normal file
61
public/partials/posts/add.html
Normal file
@ -0,0 +1,61 @@
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="/posts"><i class="icon-briefcase"></i> Posts</a><span class="divider"></span><li>
|
||||
<li class="active">New Post<li>
|
||||
</ul>
|
||||
<header>
|
||||
<h1>New Post</h1>
|
||||
</header>
|
||||
|
||||
<div class="form">
|
||||
<div class="form-section">
|
||||
<div class="section-label">Post</div>
|
||||
<div class="section-container">
|
||||
<div class="form-editor">
|
||||
<div class="control-group">
|
||||
<label class="control-label">Title</label>
|
||||
<div class="controls">
|
||||
<input ng-model="model.title" class="input-xlarge">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">Body</label>
|
||||
<div class="controls">
|
||||
<textarea ng-model="model.preview" class="input-xlarge"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">Extended</label>
|
||||
<div class="controls">
|
||||
<textarea ng-model="model.details" class="input-xlarge"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-section">
|
||||
<div class="section-label">Images</div>
|
||||
<div class="section-container">
|
||||
<div class="form-editor">
|
||||
<div class="control-group">
|
||||
<label class="control-label">Title Image</label>
|
||||
<div class="controls">
|
||||
<div class="dropzone" dropzone="titleImageOptions"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">Gallery</label>
|
||||
<div class="controls">
|
||||
<div class="dropzone" dropzone="galleryImageOptions"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-section">
|
||||
<div class="section-label"> </div>
|
||||
<div class="section-container">
|
||||
<button ng-click="saveAsDraft()" type="button" class="btn btn-primary">Save as Draft</button>
|
||||
<button ng-click="saveAsPosted()" type="button" class="btn">Save as Posted</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
62
public/partials/posts/edit.html
Normal file
62
public/partials/posts/edit.html
Normal file
@ -0,0 +1,62 @@
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="/posts"><i class="icon-briefcase"></i> Posts</a><span class="divider"></span><li>
|
||||
<li class="active">New Post<li>
|
||||
</ul>
|
||||
<header>
|
||||
<h1>Edit Post</h1>
|
||||
</header>
|
||||
|
||||
<div class="form">
|
||||
<div class="form-section">
|
||||
<div class="section-label">Post</div>
|
||||
<div class="section-container">
|
||||
<div class="form-editor">
|
||||
<div class="control-group">
|
||||
<label class="control-label">Title</label>
|
||||
<div class="controls">
|
||||
<input ng-model="model.title" class="input-xlarge">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">Body</label>
|
||||
<div class="controls">
|
||||
<textarea ng-model="model.preview" class="input-xlarge"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">Extended</label>
|
||||
<div class="controls">
|
||||
<textarea ng-model="model.details" class="input-xlarge"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-section">
|
||||
<div class="section-label">Images</div>
|
||||
<div class="section-container">
|
||||
<div class="form-editor">
|
||||
<div class="control-group">
|
||||
<label class="control-label">Title Image</label>
|
||||
<div class="controls">
|
||||
<div class="dropzone" dropzone="titleImageOptions" existing="existingTitleImages"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">Gallery</label>
|
||||
<div class="controls">
|
||||
<div class="dropzone" dropzone="galleryImageOptions" existing="existingGalleryImages"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-section">
|
||||
<div class="section-label"> </div>
|
||||
<div class="section-container">
|
||||
<button ng-click="saveAsDraft()" type="button" class="btn btn-primary">Save as Draft</button>
|
||||
<button ng-click="saveAsPosted()" type="button" class="btn">Save as Posted</button>
|
||||
<button ng-click="saveAsArchived()" type="button" class="btn">Save as Archived</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
41
public/partials/posts/index.html
Normal file
41
public/partials/posts/index.html
Normal file
@ -0,0 +1,41 @@
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="/posts"><i class="icon-briefcase"></i> Posts</a><li>
|
||||
</ul>
|
||||
<header>
|
||||
<h1>Posts</h1>
|
||||
</header>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<div class="toolbelt">
|
||||
<a href="/posts/add" class="btn btn-primary">Create new Post</a>
|
||||
</div>
|
||||
<table class="biomed-table" infinite-scroll="addItems()" can-load="canLoad" threshold="300">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 5%">Title</th>
|
||||
<th style="width: 5%">Author</th>
|
||||
<th style="width: 5%">Created on</th>
|
||||
<th style="width: 5%">Posted on</th>
|
||||
<th style="width: 5%">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-show="loading"><td colspan="4" class="table-loading"><i class="loader"></i></td></tr>
|
||||
<tr ng-hide="loading || posts.length"><td colspan="4" class="table-message">There is no information to display.</td></tr>
|
||||
<tr ng-hide="loading" ng-repeat="post in posts">
|
||||
<td>
|
||||
<a href="/posts/{{post._id}}">
|
||||
<span ng-show="post.title">{{post.title}}</span>
|
||||
<span ng-hide="post.title"><i>Missing Title</i></span>
|
||||
</a>
|
||||
</td>
|
||||
<td>{{post.author.name.first}} {{post.author.name.last}}</td>
|
||||
<td>{{post.createdOn | date:'medium'}}</td>
|
||||
<td>{{post.postedOn | date:'medium'}}</td>
|
||||
<td>{{post.status}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
@ -21,7 +21,7 @@
|
||||
<tr>
|
||||
<th colspan="2"></th>
|
||||
<th colspan="5">Groups</th>
|
||||
<th colspan="5">Permissions</th>
|
||||
<th colspan="6">Permissions</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="width: 15%">Name</th>
|
||||
@ -35,11 +35,12 @@
|
||||
<th style="width: 5%">Tags</th>
|
||||
<th style="width: 5%">Messages</th>
|
||||
<th style="width: 5%">Edit</th>
|
||||
<th style="width: 5%">Site</th>
|
||||
<th style="width: 5%">Admin</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-show="loading"><td colspan="11" class="table-loading"><i class="loader"></i></td></tr>
|
||||
<tr ng-show="loading"><td colspan="13" class="table-loading"><i class="loader"></i></td></tr>
|
||||
<tr ng-hide="loading || users.length"><td colspan="11" class="table-message">There is no information to display.</td></tr>
|
||||
<tr ng-hide="loading" ng-repeat="user in users">
|
||||
<td class="name"><a href="/admin/users/{{user._id}}">{{user.name.first}} {{user.name.last}}</a> <span class="new" ng-show="isNew(user)">NEW</span></td>
|
||||
@ -54,6 +55,7 @@
|
||||
<td class="{{ checkPerm(user, 'system.tags') }}"><a ng-click="togglePerm(user, 'system.tags')"><i ng-class="{ 'icon-ok': checkPerm(user, 'system.tags'), 'icon-remove': !checkPerm(user, 'system.tags')}"></i></a></td>
|
||||
<td class="{{ checkPerm(user, 'messages.receive') }}"><a ng-click="togglePerm(user, 'messages.receive')"><i ng-class="{ 'icon-ok': checkPerm(user, 'messages.receive'), 'icon-remove': !checkPerm(user, 'messages.receive')}"></i></a></td>
|
||||
<td class="{{ checkPerm(user, 'system.edit') }}"><a ng-click="togglePerm(user, 'system.edit')"><i ng-class="{ 'icon-ok': checkPerm(user, 'system.edit'), 'icon-remove': !checkPerm(user, 'system.edit')}"></i></a></td>
|
||||
<td class="{{ checkPerm(user, 'system.site') }}"><a ng-click="togglePerm(user, 'system.site')"><i ng-class="{ 'icon-ok': checkPerm(user, 'system.site'), 'icon-remove': !checkPerm(user, 'system.site')}"></i></a></td>
|
||||
<td class="{{ checkPerm(user, 'system.admin') }}"><a ng-click="togglePerm(user, 'system.admin')"><i ng-class="{ 'icon-ok': checkPerm(user, 'system.admin'), 'icon-remove': !checkPerm(user, 'system.admin')}"></i></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
126
public/site/app.js
Normal file
126
public/site/app.js
Normal file
@ -0,0 +1,126 @@
|
||||
site = {};
|
||||
|
||||
|
||||
angular.module('site', ['ngResource'])
|
||||
.factory("Posts", function($resource) {
|
||||
return $resource('/api/posts/:id',
|
||||
{ id: "@id" },
|
||||
{
|
||||
index: { method: 'GET', params: {}, isArray: true },
|
||||
get: { method: 'GET', params: { id: 0} },
|
||||
create: { method: 'POST', params: {} },
|
||||
update: { method: 'POST', params: { id: 0} },
|
||||
destroy: { method: 'DELETE', params: { id: 0 } },
|
||||
});
|
||||
})
|
||||
.directive('dropzone', function() {
|
||||
return {
|
||||
scope: {
|
||||
dropzone: '=',
|
||||
existing: '='
|
||||
},
|
||||
controller: function($scope, $element, $attrs) {
|
||||
var config, dropzone;
|
||||
config = $scope.dropzone;
|
||||
|
||||
dropzone = new Dropzone($element[0], config.options);
|
||||
angular.forEach(config.eventHandlers, function (handler, event) {
|
||||
dropzone.on(event, handler);
|
||||
});
|
||||
|
||||
$scope.$watch('existing', function() {
|
||||
var existing = $scope.existing;
|
||||
|
||||
console.log(dropzone);
|
||||
|
||||
if (existing) {
|
||||
for (var i = 0; i < existing.length; i++) {
|
||||
var file = { name: existing[i], size: 0, accepted: true, filename: existing[i] };
|
||||
dropzone.options.addedfile.call(dropzone, file);
|
||||
dropzone.options.thumbnail.call(dropzone, file, "http://atlanticbiomedical.com/images/" + existing[i]);
|
||||
dropzone.files.push(file);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
site.PageCtrl = function($scope, Posts, $location) {
|
||||
|
||||
$scope.model = {
|
||||
gallery: []
|
||||
};
|
||||
|
||||
$scope.titleImageOptions = {
|
||||
options: {
|
||||
url: '/api/posts/upload',
|
||||
maxFiles: 1,
|
||||
addRemoveLinks: true
|
||||
},
|
||||
eventHandlers: {
|
||||
success: function(file, response) {
|
||||
console.log('adding file');
|
||||
$scope.$apply(function() {
|
||||
$scope.model.image = response.filename;
|
||||
});
|
||||
},
|
||||
removedfile: function(file) {
|
||||
console.log('removing file');
|
||||
$scope.$apply(function() {
|
||||
$scope.model.image = undefined;
|
||||
});
|
||||
},
|
||||
maxfilesexceeded: function(file) {
|
||||
this.removeAllFiles();
|
||||
this.addFile(file);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var galleryImages = {};
|
||||
|
||||
$scope.galleryImageOptions = {
|
||||
options: {
|
||||
url: '/api/posts/upload',
|
||||
addRemoveLinks: true
|
||||
},
|
||||
eventHandlers: {
|
||||
success: function(file, response) {
|
||||
console.log('Adding File');
|
||||
file.filename = response.filename;
|
||||
|
||||
if (galleryImages[file.filename]) {
|
||||
galleryImages[file.filename]++;
|
||||
this.removeFile(file);
|
||||
} else {
|
||||
galleryImages[file.filename] = 1;
|
||||
}
|
||||
},
|
||||
removedfile: function(file) {
|
||||
console.log('Removing File');
|
||||
galleryImages[file.filename]--;
|
||||
|
||||
if (galleryImages[file.filename] <= 0) {
|
||||
delete galleryImages[file.filename];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$scope.save = function() {
|
||||
$scope.model.gallery = Object.keys(galleryImages);
|
||||
$scope.model.status = "draft";
|
||||
$scope.model.createdOn = new Date();
|
||||
|
||||
Posts.create($scope.model, function(result) {
|
||||
$scope.saved = true;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.refresh = function() {
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
|
1874
public/site/dropzone.js
Normal file
1874
public/site/dropzone.js
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user