Compare commits
40 Commits
no_npm
...
toggle_key
Author | SHA1 | Date | |
---|---|---|---|
|
2c466d069b | ||
|
abb49f2cf3 | ||
|
d1cd2a5213 | ||
|
27317844e0 | ||
|
ee74e2fa90 | ||
|
5d8bd2e6f8 | ||
|
cd4c7aeab8 | ||
|
e37c3cf1b9 | ||
|
8858bab985 | ||
|
afb0c332cc | ||
|
82c58c5c0c | ||
|
46bdd27431 | ||
|
1adfba1a37 | ||
|
54e55b1b0d | ||
|
08d37cc7f7 | ||
|
aa781957e8 | ||
|
c00477c93c | ||
|
035f09ac05 | ||
|
36e00bb29e | ||
|
10623873e8 | ||
|
e536ba1019 | ||
|
85fc36d710 | ||
|
5d5ae164f3 | ||
|
79309c75df | ||
|
4b58c8d356 | ||
|
8f0d6260b0 | ||
|
93a83a35da | ||
|
4efc5d47d9 | ||
|
ff8ef54e34 | ||
|
814a49812a | ||
|
e0610bc1be | ||
|
962976c204 | ||
|
16080bdc16 | ||
|
20ce741341 | ||
|
13bb094fb3 | ||
|
b43a55ffda | ||
|
45cbdcce70 | ||
|
1950cc8db0 | ||
|
90cfe0ec57 | ||
|
87e28548b9 |
33
README.md
33
README.md
@@ -20,6 +20,14 @@ to do things like:
|
|||||||
which will output a URL to share containing the contents of `cat something`'s
|
which will output a URL to share containing the contents of `cat something`'s
|
||||||
STDOUT. Check the README there for more details and usages.
|
STDOUT. Check the README there for more details and usages.
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
Please consider paying what you feel this project is worth:
|
||||||
|
|
||||||
|
<a href="https://www.stripeme.com/pay/1r2f">
|
||||||
|
<img alt="Pay" src="https://www.stripeme.com/pay.jpg" />
|
||||||
|
</a>
|
||||||
|
|
||||||
## Tested Browsers
|
## Tested Browsers
|
||||||
|
|
||||||
* Firefox 8
|
* Firefox 8
|
||||||
@@ -55,7 +63,7 @@ Attempts to generate phonetic keys, similar to `pwgen`
|
|||||||
|
|
||||||
``` json
|
``` json
|
||||||
{
|
{
|
||||||
"type": "phonetic"
|
"type": "phonetic"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -65,7 +73,7 @@ Generates a random key
|
|||||||
|
|
||||||
``` json
|
``` json
|
||||||
{
|
{
|
||||||
"type": "random",
|
"type": "random",
|
||||||
"keyspace": "abcdef"
|
"keyspace": "abcdef"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -82,8 +90,8 @@ something like:
|
|||||||
|
|
||||||
``` json
|
``` json
|
||||||
{
|
{
|
||||||
"path": "./data",
|
"path": "./data",
|
||||||
"type": "file"
|
"type": "file"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -99,10 +107,10 @@ Once you've done that, your config section should look like:
|
|||||||
|
|
||||||
``` json
|
``` json
|
||||||
{
|
{
|
||||||
"type": "redis",
|
"type": "redis",
|
||||||
"host": "localhost",
|
"host": "localhost",
|
||||||
"port": 6379,
|
"port": 6379,
|
||||||
"db": 2
|
"db": 2
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -122,9 +130,9 @@ Once you've done that, your config section should look like:
|
|||||||
|
|
||||||
``` json
|
``` json
|
||||||
{
|
{
|
||||||
"type": "memcached",
|
"type": "memcached",
|
||||||
"host": "127.0.0.1",
|
"host": "127.0.0.1",
|
||||||
"port": 11211
|
"port": 11211
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -134,7 +142,6 @@ forward on GETs.
|
|||||||
|
|
||||||
All of which are optional except `type` with very logical default values.
|
All of which are optional except `type` with very logical default values.
|
||||||
|
|
||||||
|
|
||||||
## Author
|
## Author
|
||||||
|
|
||||||
John Crepezzi <john.crepezzi@gmail.com>
|
John Crepezzi <john.crepezzi@gmail.com>
|
||||||
@@ -143,7 +150,7 @@ John Crepezzi <john.crepezzi@gmail.com>
|
|||||||
|
|
||||||
(The MIT License)
|
(The MIT License)
|
||||||
|
|
||||||
Copyright © 2011 John Crepezzi
|
Copyright © 2011-2012 John Crepezzi
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
this software and associated documentation files (the ‘Software’), to deal in
|
this software and associated documentation files (the ‘Software’), to deal in
|
||||||
|
3
about.md
3
about.md
@@ -38,7 +38,8 @@ right now.
|
|||||||
|
|
||||||
## Duration
|
## Duration
|
||||||
|
|
||||||
Pastes will stay for 30 days from their last view.
|
Pastes will stay for 30 days from their last view. They may be removed earlier
|
||||||
|
and without notice.
|
||||||
|
|
||||||
## Privacy
|
## Privacy
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
|
|
||||||
"host": "localhost",
|
"host": "0.0.0.0",
|
||||||
"port": 7777,
|
"port": 7777,
|
||||||
|
|
||||||
"keyLength": 10,
|
"keyLength": 10,
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
"storage": {
|
"storage": {
|
||||||
"type": "redis",
|
"type": "redis",
|
||||||
"host": "localhost",
|
"host": "0.0.0.0",
|
||||||
"port": 6379,
|
"port": 6379,
|
||||||
"db": 2,
|
"db": 2,
|
||||||
"expire": 2592000
|
"expire": 2592000
|
||||||
|
@@ -8,9 +8,13 @@ var winston = require('winston');
|
|||||||
// options[db] - The db to use (default 0)
|
// options[db] - The db to use (default 0)
|
||||||
// options[expire] - The time to live for each key set (default never)
|
// options[expire] - The time to live for each key set (default never)
|
||||||
|
|
||||||
var RedisDocumentStore = function(options) {
|
var RedisDocumentStore = function(options, client) {
|
||||||
this.expire = options.expire;
|
this.expire = options.expire;
|
||||||
if (!RedisDocumentStore.client) {
|
if (client) {
|
||||||
|
winston.info('using predefined redis client');
|
||||||
|
RedisDocumentStore.client = client;
|
||||||
|
} else if (!RedisDocumentStore.client) {
|
||||||
|
winston.info('configuring redis');
|
||||||
RedisDocumentStore.connect(options);
|
RedisDocumentStore.connect(options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
87
package.json
87
package.json
@@ -1,52 +1,47 @@
|
|||||||
{
|
{
|
||||||
|
"name": "haste",
|
||||||
"name": "haste",
|
"version": "0.1.0",
|
||||||
"version": "0.0.1",
|
"private": true,
|
||||||
|
"description": "Private Pastebin Server",
|
||||||
"private": true,
|
"keywords": [
|
||||||
|
"paste",
|
||||||
"description": "Private Paste",
|
"pastebin"
|
||||||
|
],
|
||||||
"keywords": [ "paste", "pastebin" ],
|
"author": {
|
||||||
|
"name": "John Crepezzi",
|
||||||
"author": {
|
"email": "john.crepezzi@gmail.com",
|
||||||
"name": "John Crepezzi",
|
"url": "http://seejohncode.com/"
|
||||||
"email": "john.crepezzi@gmail.com",
|
},
|
||||||
"url": "http://seejohncode.com/"
|
"main": "haste",
|
||||||
},
|
"dependencies": {
|
||||||
|
"winston": "0.6.2",
|
||||||
"main": "haste",
|
"connect": "1.9.2",
|
||||||
|
"redis-url": "0.1.0",
|
||||||
"dependencies": {
|
"redis": "0.8.1",
|
||||||
"winston": "*",
|
"uglify-js": "1.3.3"
|
||||||
"connect": "*",
|
},
|
||||||
"uglify-js": "*"
|
"devDependencies": {
|
||||||
},
|
|
||||||
|
|
||||||
"devDependencies": {
|
|
||||||
"mocha": "*",
|
"mocha": "*",
|
||||||
"should": "*"
|
"should": "*"
|
||||||
},
|
},
|
||||||
|
"bundledDependencies": [],
|
||||||
"bundledDependencies": [],
|
"engines": {
|
||||||
|
"node": "0.8.10",
|
||||||
"engines": {
|
"npm": "1.1.49"
|
||||||
"node": "*"
|
},
|
||||||
},
|
"bin": {
|
||||||
|
"haste-server": "./server.js"
|
||||||
"bin": {
|
},
|
||||||
"haste-server": "./server.js"
|
"files": [
|
||||||
},
|
"server.js",
|
||||||
|
"lib",
|
||||||
"files": [ "server.js", "lib", "static" ],
|
"static"
|
||||||
|
],
|
||||||
"directories": {
|
"directories": {
|
||||||
"lib": "./lib"
|
"lib": "./lib"
|
||||||
},
|
},
|
||||||
|
"scripts": {
|
||||||
"scripts": {
|
"start": "node server.js",
|
||||||
"start": "node server.js",
|
|
||||||
"test": "mocha -r should spec/*"
|
"test": "mocha -r should spec/*"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
46
server.js
46
server.js
@@ -8,9 +8,9 @@ var connect = require('connect');
|
|||||||
var DocumentHandler = require('./lib/document_handler');
|
var DocumentHandler = require('./lib/document_handler');
|
||||||
|
|
||||||
// Load the configuration and set some defaults
|
// Load the configuration and set some defaults
|
||||||
var config = JSON.parse(fs.readFileSync('config.js', 'utf8'));
|
var config = JSON.parse(fs.readFileSync('./config.js', 'utf8'));
|
||||||
config.port = config.port || 7777;
|
config.port = process.env.PORT || config.port || 7777;
|
||||||
config.host = config.host || 'localhost';
|
config.host = process.env.HOST || config.host || 'localhost';
|
||||||
|
|
||||||
// Set up the logger
|
// Set up the logger
|
||||||
if (config.logging) {
|
if (config.logging) {
|
||||||
@@ -34,8 +34,18 @@ if (!config.storage) {
|
|||||||
if (!config.storage.type) {
|
if (!config.storage.type) {
|
||||||
config.storage.type = 'file';
|
config.storage.type = 'file';
|
||||||
}
|
}
|
||||||
var Store = require('./lib/document_stores/' + config.storage.type);
|
|
||||||
var preferredStore = new Store(config.storage);
|
var Store, preferredStore;
|
||||||
|
|
||||||
|
if (process.env.REDISTOGO_URL) {
|
||||||
|
var redisClient = require('redis-url').connect(process.env.REDISTOGO_URL);
|
||||||
|
Store = require('./lib/document_stores/redis');
|
||||||
|
preferredStore = new Store(config.storage, redisClient);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Store = require('./lib/document_stores/' + config.storage.type);
|
||||||
|
preferredStore = new Store(config.storage);
|
||||||
|
}
|
||||||
|
|
||||||
// Compress the static javascript assets
|
// Compress the static javascript assets
|
||||||
if (config.recompressStaticAssets) {
|
if (config.recompressStaticAssets) {
|
||||||
@@ -60,21 +70,19 @@ if (config.recompressStaticAssets) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send the static documents into the preferred store, skipping expirations
|
// Send the static documents into the preferred store, skipping expirations
|
||||||
|
var path, data;
|
||||||
for (var name in config.documents) {
|
for (var name in config.documents) {
|
||||||
var path = config.documents[name];
|
path = config.documents[name];
|
||||||
fs.readFile(path, 'utf8', function(err, data) {
|
data = fs.readFileSync(path, 'utf8');
|
||||||
if (data && !err) {
|
winston.info('loading static document', { name: name, path: path });
|
||||||
preferredStore.set(name, data, function(cb) {
|
if (data) {
|
||||||
winston.info('loaded static document', { name: name, path: path });
|
preferredStore.set(name, data, function(cb) {
|
||||||
}, true);
|
winston.debug('loaded static document', { success: cb });
|
||||||
}
|
}, true);
|
||||||
else {
|
}
|
||||||
winston.warn(
|
else {
|
||||||
'failed to load static document',
|
winston.warn('failed to load static document', { name: name, path: path });
|
||||||
{ name: name, path: path }
|
}
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pick up a key generator
|
// Pick up a key generator
|
||||||
|
@@ -42,6 +42,7 @@ textarea {
|
|||||||
border: 0px;
|
border: 0px;
|
||||||
outline: none;
|
outline: none;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
|
padding-right: 360px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#box code {
|
#box code {
|
||||||
|
@@ -62,6 +62,7 @@ haste_document.prototype.save = function(data, callback) {
|
|||||||
type: 'post',
|
type: 'post',
|
||||||
data: data,
|
data: data,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
|
contentType: 'application/json; charset=utf-8',
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
_this.locked = true;
|
_this.locked = true;
|
||||||
_this.key = res.key;
|
_this.key = res.key;
|
||||||
@@ -167,7 +168,7 @@ haste.extensionMap = {
|
|||||||
lua: 'lua', pas: 'delphi', java: 'java', cpp: 'cpp', cc: 'cpp', m: 'objectivec',
|
lua: 'lua', pas: 'delphi', java: 'java', cpp: 'cpp', cc: 'cpp', m: 'objectivec',
|
||||||
vala: 'vala', cs: 'cs', sql: 'sql', sm: 'smalltalk', lisp: 'lisp', ini: 'ini',
|
vala: 'vala', cs: 'cs', sql: 'sql', sm: 'smalltalk', lisp: 'lisp', ini: 'ini',
|
||||||
diff: 'diff', bash: 'bash', sh: 'bash', tex: 'tex', erl: 'erlang', hs: 'haskell',
|
diff: 'diff', bash: 'bash', sh: 'bash', tex: 'tex', erl: 'erlang', hs: 'haskell',
|
||||||
md: 'markdown', txt: '', coffee: 'coffee'
|
md: 'markdown', txt: '', coffee: 'coffee', json: 'javascript'
|
||||||
};
|
};
|
||||||
|
|
||||||
// Look up the extension preferred for a type
|
// Look up the extension preferred for a type
|
||||||
@@ -307,9 +308,9 @@ haste.prototype.configureButtons = function() {
|
|||||||
$where: $('#box2 .twitter'),
|
$where: $('#box2 .twitter'),
|
||||||
label: 'Twitter',
|
label: 'Twitter',
|
||||||
shortcut: function(evt) {
|
shortcut: function(evt) {
|
||||||
return _this.options.twitter && _this.doc.locked && evt.ctrlKey && evt.keyCode == 84;
|
return _this.options.twitter && _this.doc.locked && evt.shiftKey && evt.ctrlKey && evt.keyCode == 84;
|
||||||
},
|
},
|
||||||
shortcutDescription: 'control + t',
|
shortcutDescription: 'control + shift + t',
|
||||||
action: function() {
|
action: function() {
|
||||||
window.open('https://twitter.com/share?url=' + encodeURI(window.location.href));
|
window.open('https://twitter.com/share?url=' + encodeURI(window.location.href));
|
||||||
}
|
}
|
||||||
@@ -361,6 +362,11 @@ haste.prototype.configureShortcuts = function() {
|
|||||||
///// Tab behavior in the textarea - 2 spaces per tab
|
///// Tab behavior in the textarea - 2 spaces per tab
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
|
var $key = $('#key');
|
||||||
|
$(document).click(function () {
|
||||||
|
$key.fadeToggle();
|
||||||
|
});
|
||||||
|
|
||||||
$('textarea').keydown(function(evt) {
|
$('textarea').keydown(function(evt) {
|
||||||
if (evt.keyCode === 9) {
|
if (evt.keyCode === 9) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
2
static/application.min.js
vendored
2
static/application.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -7,7 +7,7 @@
|
|||||||
<link rel="stylesheet" type="text/css" href="solarized_dark.css"/>
|
<link rel="stylesheet" type="text/css" href="solarized_dark.css"/>
|
||||||
<link rel="stylesheet" type="text/css" href="application.css"/>
|
<link rel="stylesheet" type="text/css" href="application.css"/>
|
||||||
|
|
||||||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
|
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
|
||||||
<script type="text/javascript" src="highlight.min.js"></script>
|
<script type="text/javascript" src="highlight.min.js"></script>
|
||||||
<script type="text/javascript" src="application.min.js"></script>
|
<script type="text/javascript" src="application.min.js"></script>
|
||||||
|
|
||||||
@@ -63,6 +63,17 @@
|
|||||||
<pre id="box" style="display:none;" tabindex="0"><code></code></pre>
|
<pre id="box" style="display:none;" tabindex="0"><code></code></pre>
|
||||||
<textarea spellcheck="false" style="display:none;"></textarea>
|
<textarea spellcheck="false" style="display:none;"></textarea>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var _gaq = _gaq || [];
|
||||||
|
_gaq.push(['_setAccount', 'UA-27329119-1']);
|
||||||
|
_gaq.push(['_trackPageview']);
|
||||||
|
(function() {
|
||||||
|
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||||
|
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||||
|
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@@ -17,6 +17,8 @@ pre .lisp .string,
|
|||||||
pre .javadoc {
|
pre .javadoc {
|
||||||
color: #586e75;
|
color: #586e75;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
|
display: inline-block;
|
||||||
|
line-height: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre .keyword,
|
pre .keyword,
|
||||||
|
Reference in New Issue
Block a user