This commit is contained in:
Wohlstand 2017-07-03 23:53:43 +03:00
commit 797f2d9238
15 changed files with 600 additions and 30 deletions

2
.eslintignore Normal file
View File

@ -0,0 +1,2 @@
**/*.min.js
config.js

25
.eslintrc.json Normal file
View File

@ -0,0 +1,25 @@
{
"env": {
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
}

View File

@ -123,6 +123,8 @@ or post.
All of which are optional except `type` with very logical default values. All of which are optional except `type` with very logical default values.
If your Redis server is configured for password authentification, use the `password` field.
### Postgres ### Postgres
To use postgres storage you must install the `pg` package in npm To use postgres storage you must install the `pg` package in npm

View File

@ -15,7 +15,7 @@ To make a new entry, click "New" (or type 'control + n')
## From the Console ## From the Console
Most of the time I want to show you some text, its coming from my current Most of the time I want to show you some text, it's coming from my current
console session. We should make it really easy to take code from the console console session. We should make it really easy to take code from the console
and send it to people. and send it to people.

View File

@ -26,7 +26,7 @@ MemcachedDocumentStore.connect = function(options) {
// Save file in a key // Save file in a key
MemcachedDocumentStore.prototype.set = MemcachedDocumentStore.prototype.set =
function(key, data, callback, skipExpire) { function(key, data, callback, skipExpire) {
MemcachedDocumentStore.client.set(key, data, function(err, reply) { MemcachedDocumentStore.client.set(key, data, function(err) {
err ? callback(false) : callback(true); err ? callback(false) : callback(true);
}, skipExpire ? 0 : this.expire); }, skipExpire ? 0 : this.expire);
}; };

View File

@ -23,7 +23,7 @@ PostgresDocumentStore.prototype = {
key, key,
data, data,
that.expireJS && !skipExpire ? that.expireJS + now : null that.expireJS && !skipExpire ? that.expireJS + now : null
], function (err, result) { ], function (err) {
if (err) { if (err) {
winston.error('error persisting value to postgres', { error: err }); winston.error('error persisting value to postgres', { error: err });
return callback(false); return callback(false);
@ -50,7 +50,7 @@ PostgresDocumentStore.prototype = {
client.query('UPDATE entries SET expiration = $1 WHERE ID = $2', [ client.query('UPDATE entries SET expiration = $1 WHERE ID = $2', [
that.expireJS + now, that.expireJS + now,
result.rows[0].id result.rows[0].id
], function (err, result) { ], function (err) {
if (!err) { if (!err) {
done(); done();
} }

View File

@ -29,7 +29,7 @@ RedisDocumentStore.connect = function(options) {
if (options.password) { if (options.password) {
RedisDocumentStore.client.auth(options.password); RedisDocumentStore.client.auth(options.password);
} }
RedisDocumentStore.client.select(index, function(err, reply) { RedisDocumentStore.client.select(index, function(err) {
if (err) { if (err) {
winston.error( winston.error(
'error connecting to redis index ' + index, 'error connecting to redis index ' + index,
@ -46,7 +46,7 @@ RedisDocumentStore.connect = function(options) {
// Save file in a key // Save file in a key
RedisDocumentStore.prototype.set = function(key, data, callback, skipExpire) { RedisDocumentStore.prototype.set = function(key, data, callback, skipExpire) {
var _this = this; var _this = this;
RedisDocumentStore.client.set(key, data, function(err, reply) { RedisDocumentStore.client.set(key, data, function(err) {
if (err) { if (err) {
callback(false); callback(false);
} }
@ -62,7 +62,7 @@ RedisDocumentStore.prototype.set = function(key, data, callback, skipExpire) {
// Expire a key in expire time if set // Expire a key in expire time if set
RedisDocumentStore.prototype.setExpiration = function(key) { RedisDocumentStore.prototype.setExpiration = function(key) {
if (this.expire) { if (this.expire) {
RedisDocumentStore.client.expire(key, this.expire, function(err, reply) { RedisDocumentStore.client.expire(key, this.expire, function(err) {
if (err) { if (err) {
winston.error('failed to set expiry on key: ' + key); winston.error('failed to set expiry on key: ' + key);
} }

View File

@ -0,0 +1,24 @@
var fs = require('fs');
var DictionaryGenerator = function(options) {
//Options
if (!options) throw Error('No options passed to generator');
if (!options.path) throw Error('No dictionary path specified in options');
//Load dictionary
fs.readFile(options.path, 'utf8', (err, data) => {
if (err) throw err;
this.dictionary = data.split(/[\n\r]+/);
});
};
//Generates a dictionary-based key, of keyLength words
DictionaryGenerator.prototype.createKey = function(keyLength) {
var text = '';
for(var i = 0; i < keyLength; i++)
text += this.dictionary[Math.floor(Math.random() * this.dictionary.length)];
return text;
};
module.exports = DictionaryGenerator;

View File

@ -1,5 +1,5 @@
// Draws inspiration from pwgen and http://tools.arantius.com/password // Draws inspiration from pwgen and http://tools.arantius.com/password
var PhoneticKeyGenerator = function(options) { var PhoneticKeyGenerator = function() {
// No options // No options
}; };

511
package-lock.json generated Normal file
View File

@ -0,0 +1,511 @@
{
"name": "haste",
"version": "0.1.0",
"lockfileVersion": 1,
"dependencies": {
"async": {
"version": "0.1.22",
"resolved": "https://registry.npmjs.org/async/-/async-0.1.22.tgz",
"integrity": "sha1-D8GqoIig4+8Ovi2IMbqw3PiEUGE="
},
"async-cache": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/async-cache/-/async-cache-1.0.0.tgz",
"integrity": "sha1-yH9tgMcrOU7g+QYe3rJNjEtiKto="
},
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"dev": true
},
"bl": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/bl/-/bl-1.0.3.tgz",
"integrity": "sha1-/FQhoo/UImA2w7OJGmaiW8ZNIm4=",
"dependencies": {
"isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
},
"readable-stream": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz",
"integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44="
}
}
},
"brace-expansion": {
"version": "1.1.8",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz",
"integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=",
"dev": true
},
"browser-stdout": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz",
"integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=",
"dev": true
},
"buffer-writer": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-1.0.0.tgz",
"integrity": "sha1-bCnDst6gyeRVofJhoZmkigT4iwg="
},
"busboy": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/busboy/-/busboy-0.2.4.tgz",
"integrity": "sha1-GXfpbh7ohGSWUevfVIypAHWLp/M="
},
"colors": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz",
"integrity": "sha1-JCP+ZnisDF2uiFLl0OW+CMmXq8w="
},
"commander": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz",
"integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=",
"dev": true
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
},
"connect": {
"version": "3.4.1",
"resolved": "https://registry.npmjs.org/connect/-/connect-3.4.1.tgz",
"integrity": "sha1-ohNh0/QJnvdhzabcSpc7seuwo00="
},
"connect-ratelimit": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/connect-ratelimit/-/connect-ratelimit-0.0.7.tgz",
"integrity": "sha1-5uCclQZJ6ElJnKsYcKQVoH9zFWg="
},
"connect-route": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/connect-route/-/connect-route-0.1.5.tgz",
"integrity": "sha1-48IYMZ0uiKiprgsOD+Cacpw5dEo="
},
"core-util-is": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
},
"cycle": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz",
"integrity": "sha1-IegLK+hYD5i0aPN5QwZisEbDStI="
},
"debug": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz",
"integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo="
},
"dicer": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/dicer/-/dicer-0.2.3.tgz",
"integrity": "sha1-8AKBGJpVwjUe+ASQpP6fssWcSTk="
},
"diff": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/diff/-/diff-3.2.0.tgz",
"integrity": "sha1-yc45Okt8vQsFinJck98pkCeGj/k=",
"dev": true
},
"ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
},
"escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
},
"escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
"dev": true
},
"eyes": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz",
"integrity": "sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A="
},
"fd": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/fd/-/fd-0.0.2.tgz",
"integrity": "sha1-4O2yvXqIzIbdnxY5HLqDJBj9h+4="
},
"finalhandler": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-0.4.1.tgz",
"integrity": "sha1-haF8bFmpRxfSYtYSMNSw6+PUoU0="
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
"dev": true
},
"generic-pool": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-2.1.1.tgz",
"integrity": "sha1-rwTcLDJc/Ll1Aj+lK/zpYXp0Nf0="
},
"glob": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz",
"integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=",
"dev": true
},
"graceful-fs": {
"version": "4.1.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
"optional": true
},
"graceful-readlink": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz",
"integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=",
"dev": true
},
"growl": {
"version": "1.9.2",
"resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz",
"integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=",
"dev": true
},
"has-flag": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz",
"integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=",
"dev": true
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"dev": true
},
"inherits": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
},
"json3": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz",
"integrity": "sha1-PAQ0dD35Pi9cQq7nsZvLSDV19OE=",
"dev": true
},
"lodash._baseassign": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz",
"integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=",
"dev": true
},
"lodash._basecopy": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz",
"integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=",
"dev": true
},
"lodash._basecreate": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz",
"integrity": "sha1-G8ZhYU2qf8MRt9A78WgGoCE8+CE=",
"dev": true
},
"lodash._getnative": {
"version": "3.9.1",
"resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz",
"integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=",
"dev": true
},
"lodash._isiterateecall": {
"version": "3.0.9",
"resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz",
"integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=",
"dev": true
},
"lodash.create": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/lodash.create/-/lodash.create-3.1.1.tgz",
"integrity": "sha1-1/KEnw29p+BGgruM1yqwIkYd6+c=",
"dev": true
},
"lodash.isarguments": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz",
"integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=",
"dev": true
},
"lodash.isarray": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz",
"integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=",
"dev": true
},
"lodash.keys": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz",
"integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=",
"dev": true
},
"lru-cache": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.3.1.tgz",
"integrity": "sha1-s632s9hW6VTiw5DmzvIggSRaU9Y="
},
"mime": {
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.3.6.tgz",
"integrity": "sha1-WR2E02U6awtKO5343lqoEI5y5eA="
},
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true
},
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
"dev": true
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"dev": true
},
"mocha": {
"version": "3.4.2",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-3.4.2.tgz",
"integrity": "sha1-0O9NMyEm2/GNDWQMmzgt1IvpdZQ=",
"dev": true,
"dependencies": {
"debug": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.0.tgz",
"integrity": "sha1-vFlryr52F/Edn6FTYe3tVgi4SZs=",
"dev": true
},
"ms": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz",
"integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=",
"dev": true
}
}
},
"ms": {
"version": "0.7.1",
"resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz",
"integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg="
},
"negotiator": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz",
"integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk="
},
"on-finished": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
"integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc="
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"dev": true
},
"packet-reader": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/packet-reader/-/packet-reader-0.2.0.tgz",
"integrity": "sha1-gZ300BC4LV6lZx+KGjrPA5vNdwA="
},
"parseurl": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz",
"integrity": "sha1-yKuMkiO6NIiKpkopeyiFO+wY2lY="
},
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"dev": true
},
"pg": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/pg/-/pg-4.1.1.tgz",
"integrity": "sha1-mEgKz8089qP5Yhyl1FiUFVgqVzI="
},
"pg-connection-string": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-0.1.3.tgz",
"integrity": "sha1-2hhHsglA5C7hSSvq9l1J2RskXfc="
},
"pg-types": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/pg-types/-/pg-types-1.6.0.tgz",
"integrity": "sha1-OHKg8ZkUMCVJf07ipl/a8A1+qLM="
},
"pgpass": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/pgpass/-/pgpass-0.0.3.tgz",
"integrity": "sha1-EuZ+NDsxicLzEgbrycwL7//PkUA="
},
"pkginfo": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.2.3.tgz",
"integrity": "sha1-cjnEKl72wwuPMoQ52bn/cQQkkPg="
},
"process-nextick-args": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz",
"integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M="
},
"readable-stream": {
"version": "1.1.14",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk="
},
"redis": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/redis/-/redis-0.8.1.tgz",
"integrity": "sha1-FZ8hMFmaL3GeRLA/C0t2EvmS/LI="
},
"redis-url": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/redis-url/-/redis-url-0.1.0.tgz",
"integrity": "sha1-TaXlsYG2wMrW4aVcf1Co5u53ebs="
},
"request": {
"version": "2.9.203",
"resolved": "https://registry.npmjs.org/request/-/request-2.9.203.tgz",
"integrity": "sha1-bBcRpUB/uUoRQhlWPkQUW8v0cjo="
},
"semver": {
"version": "4.3.6",
"resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz",
"integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto="
},
"should": {
"version": "11.2.1",
"resolved": "https://registry.npmjs.org/should/-/should-11.2.1.tgz",
"integrity": "sha1-kPVRRVUtAc/CAGZuToGKHJZw7aI=",
"dev": true
},
"should-equal": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/should-equal/-/should-equal-1.0.1.tgz",
"integrity": "sha1-C26VFvJgGp+wuy3MNpr6HH4gCvc=",
"dev": true
},
"should-format": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/should-format/-/should-format-3.0.3.tgz",
"integrity": "sha1-m/yPdPo5IFxT04w01xcwPidxJPE=",
"dev": true
},
"should-type": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/should-type/-/should-type-1.4.0.tgz",
"integrity": "sha1-B1bYzoRt/QmEOmlHcZ36DUz/XPM=",
"dev": true
},
"should-type-adaptors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/should-type-adaptors/-/should-type-adaptors-1.0.1.tgz",
"integrity": "sha1-7+VVPN9oz/ZuXF9RtxLcNRx3vqo=",
"dev": true
},
"should-util": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/should-util/-/should-util-1.0.0.tgz",
"integrity": "sha1-yYzaN0qmsZDfi6h8mInCtNtiAGM=",
"dev": true
},
"split": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz",
"integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8="
},
"st": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/st/-/st-1.1.0.tgz",
"integrity": "sha1-c7ltsLdkTZp4zjg0o+T37G6Hz3Y="
},
"stack-trace": {
"version": "0.0.10",
"resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz",
"integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA="
},
"streamsearch": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz",
"integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo="
},
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
},
"supports-color": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz",
"integrity": "sha1-cqJiiU2dQIuVbKBf83su2KbiotU=",
"dev": true
},
"through": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU="
},
"uglify-js": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-1.3.3.tgz",
"integrity": "sha1-3dPpiqJ/X0flic+z+VzduiYJYZA="
},
"unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
},
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
"utils-merge": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz",
"integrity": "sha1-ApT7kiu5N1FTVBxPcJYjHyh8ivg="
},
"winston": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/winston/-/winston-0.6.2.tgz",
"integrity": "sha1-QUT+JYbNwZphK/jANVkBMskGS9I="
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true
}
}
}

View File

@ -1,5 +1,4 @@
var http = require('http'); var http = require('http');
var url = require('url');
var fs = require('fs'); var fs = require('fs');
var winston = require('winston'); var winston = require('winston');
@ -19,7 +18,10 @@ config.host = process.env.HOST || config.host || 'localhost';
if (config.logging) { if (config.logging) {
try { try {
winston.remove(winston.transports.Console); winston.remove(winston.transports.Console);
} catch(er) { } } catch(e) {
/* was not present */
}
var detail, type; var detail, type;
for (var i = 0; i < config.logging.length; i++) { for (var i = 0; i < config.logging.length; i++) {
detail = config.logging[i]; detail = config.logging[i];
@ -52,16 +54,14 @@ else {
// Compress the static javascript assets // Compress the static javascript assets
if (config.recompressStaticAssets) { if (config.recompressStaticAssets) {
var jsp = require("uglify-js").parser; var jsp = require('uglify-js').parser;
var pro = require("uglify-js").uglify; var pro = require('uglify-js').uglify;
var list = fs.readdirSync('./static'); var list = fs.readdirSync('./static');
for (var i = 0; i < list.length; i++) { for (var j = 0; j < list.length; j++) {
var item = list[i]; var item = list[i];
var orig_code, ast; var orig_code, ast;
if ((item.indexOf('.js') === item.length - 3) && if ((item.indexOf('.js') === item.length - 3) && (item.indexOf('.min.js') === -1)) {
(item.indexOf('.min.js') === -1)) { var dest = item.substring(0, item.length - 3) + '.min' + item.substring(item.length - 3);
dest = item.substring(0, item.length - 3) + '.min' +
item.substring(item.length - 3);
orig_code = fs.readFileSync('./static/' + item, 'utf8'); orig_code = fs.readFileSync('./static/' + item, 'utf8');
ast = jsp.parse(orig_code); ast = jsp.parse(orig_code);
ast = pro.ast_mangle(ast); ast = pro.ast_mangle(ast);
@ -113,17 +113,17 @@ if (config.rateLimits) {
// first look at API calls // first look at API calls
app.use(route(function(router) { app.use(route(function(router) {
// get raw documents - support getting with extension // get raw documents - support getting with extension
router.get('/raw/:id', function(request, response, next) { router.get('/raw/:id', function(request, response) {
var key = request.params.id.split('.')[0]; var key = request.params.id.split('.')[0];
var skipExpire = !!config.documents[key]; var skipExpire = !!config.documents[key];
return documentHandler.handleRawGet(key, response, skipExpire); return documentHandler.handleRawGet(key, response, skipExpire);
}); });
// add documents // add documents
router.post('/documents', function(request, response, next) { router.post('/documents', function(request, response) {
return documentHandler.handlePost(request, response); return documentHandler.handlePost(request, response);
}); });
// get documents // get documents
router.get('/documents/:id', function(request, response, next) { router.get('/documents/:id', function(request, response) {
var key = request.params.id.split('.')[0]; var key = request.params.id.split('.')[0];
var skipExpire = !!config.documents[key]; var skipExpire = !!config.documents[key];
return documentHandler.handleGet(key, response, skipExpire); return documentHandler.handleGet(key, response, skipExpire);

View File

@ -1,3 +1,5 @@
/* global describe, it */
var DocumentHandler = require('../lib/document_handler'); var DocumentHandler = require('../lib/document_handler');
var Generator = require('../lib/key_generators/random'); var Generator = require('../lib/key_generators/random');

View File

@ -1,3 +1,5 @@
/* global it, describe, afterEach */
var RedisDocumentStore = require('../lib/document_stores/redis'); var RedisDocumentStore = require('../lib/document_stores/redis');
var winston = require('winston'); var winston = require('winston');
@ -37,7 +39,7 @@ describe('redis_document_store', function() {
it('should not set an expiration when expiration is off', function(done) { it('should not set an expiration when expiration is off', function(done) {
var store = new RedisDocumentStore({ expire: false }); var store = new RedisDocumentStore({ expire: false });
store.set('hello3', 'world', function(worked) { store.set('hello3', 'world', function() {
RedisDocumentStore.client.ttl('hello3', function(err, res) { RedisDocumentStore.client.ttl('hello3', function(err, res) {
res.should.equal(-1); res.should.equal(-1);
done(); done();

View File

@ -1,3 +1,5 @@
/* global $, hljs, window, document */
///// represents a single document ///// represents a single document
var haste_document = function() { var haste_document = function() {
@ -42,10 +44,10 @@ haste_document.prototype.load = function(key, callback, lang) {
value: high.value, value: high.value,
key: key, key: key,
language: high.language || lang, language: high.language || lang,
lineCount: res.data.split("\n").length lineCount: res.data.split('\n').length
}); });
}, },
error: function(err) { error: function() {
callback(false); callback(false);
} }
}); });
@ -71,7 +73,7 @@ haste_document.prototype.save = function(data, callback) {
value: high.value, value: high.value,
key: res.key, key: res.key,
language: high.language, language: high.language,
lineCount: data.split("\n").length lineCount: data.split('\n').length
}); });
}, },
error: function(res) { error: function(res) {
@ -276,7 +278,7 @@ haste.prototype.configureButtons = function() {
$where: $('#box2 .new'), $where: $('#box2 .new'),
label: 'New', label: 'New',
shortcut: function(evt) { shortcut: function(evt) {
return evt.ctrlKey && evt.keyCode === 78 return evt.ctrlKey && evt.keyCode === 78;
}, },
shortcutDescription: 'control + n', shortcutDescription: 'control + n',
action: function() { action: function() {
@ -331,14 +333,14 @@ haste.prototype.configureButton = function(options) {
} }
}); });
// Show the label // Show the label
options.$where.mouseenter(function(evt) { options.$where.mouseenter(function() {
$('#box3 .label').text(options.label); $('#box3 .label').text(options.label);
$('#box3 .shortcut').text(options.shortcutDescription || ''); $('#box3 .shortcut').text(options.shortcutDescription || '');
$('#box3').show(); $('#box3').show();
$(this).append($('#pointer').remove().show()); $(this).append($('#pointer').remove().show());
}); });
// Hide the label // Hide the label
options.$where.mouseleave(function(evt) { options.$where.mouseleave(function() {
$('#box3').hide(); $('#box3').hide();
$('#pointer').hide(); $('#pointer').hide();
}); });
@ -371,7 +373,7 @@ $(function() {
// For browsers like Internet Explorer // For browsers like Internet Explorer
if (document.selection) { if (document.selection) {
this.focus(); this.focus();
sel = document.selection.createRange(); var sel = document.selection.createRange();
sel.text = myValue; sel.text = myValue;
this.focus(); this.focus();
} }

File diff suppressed because one or more lines are too long