38 Commits

Author SHA1 Message Date
John Crepezzi
467f9a53b2 Added jsonp support
Closes #47
2013-12-04 12:13:17 -05:00
John Crepezzi
7a08960414 Merge branch 'master' of github.com:seejohnrun/haste-server 2013-11-24 11:54:34 -05:00
John Crepezzi
89909747f1 Don't depend on err.message for redis errors [#49] 2013-11-24 11:54:01 -05:00
John Crepezzi
202e695e07 Remove GA from index.html on Master 2013-10-31 08:44:33 -04:00
John Crepezzi
48e8e79659 Remove support from README 2013-08-13 13:06:37 -04:00
John Crepezzi
abb49f2cf3 update about.md 2013-03-12 21:59:10 -04:00
John Crepezzi
d1cd2a5213 Proper 2013-01-11 10:00:35 -08:00
John Crepezzi
27317844e0 Remove nl 2013-01-11 09:57:10 -08:00
John Crepezzi
ee74e2fa90 Merge branch 'production' of github.com:seejohnrun/haste-server into production 2012-12-29 18:15:45 -05:00
John Crepezzi
5d8bd2e6f8 Merge branch 'master' into production 2012-12-29 18:15:32 -05:00
John Crepezzi
cd4c7aeab8 Merge pull request #37 from naftis/patch-1
Bugfix to solarized_dark.css
2012-12-28 07:10:36 -08:00
naftis
e37c3cf1b9 Bugfix to solarized_dark.css
Fixed bug with font-style: italic and WebKit.
WebKit makes line-height bigger, when italic is used.
2012-12-28 16:11:21 +02:00
John Crepezzi
8858bab985 Merge branch 'master' into production 2012-12-23 10:54:15 -05:00
John Crepezzi
afb0c332cc Added shift modifier to twitter shortcut
Closes #29
2012-12-23 10:53:53 -05:00
John Crepezzi
82c58c5c0c Merge branch 'master' into production 2012-12-19 08:18:14 -05:00
John Crepezzi
46bdd27431 Fix for type name ;)
Closes #28
2012-12-19 08:17:52 -05:00
John Crepezzi
1adfba1a37 Merge branch 'master' into production 2012-12-19 08:13:36 -05:00
John Crepezzi
54e55b1b0d Added JSON to extension map (JS)
Closes #28
2012-12-19 08:12:08 -05:00
John Crepezzi
08d37cc7f7 Added support section 2012-10-22 14:40:52 -04:00
John Crepezzi
aa781957e8 Update Copyright 2012-09-27 13:46:27 -04:00
John Crepezzi
c00477c93c Update Copyright 2012-09-27 13:46:09 -04:00
John Crepezzi
035f09ac05 GA 2012-09-27 13:43:53 -04:00
John Crepezzi
36e00bb29e Remove 'localhost' references 2012-09-27 12:03:52 -04:00
John Crepezzi
10623873e8 Allow host setting by ENV 2012-09-27 12:01:00 -04:00
John Crepezzi
e536ba1019 Move to an available npm version 2012-09-27 11:56:49 -04:00
John Crepezzi
85fc36d710 Update npm version 2012-09-27 11:56:15 -04:00
John Crepezzi
5d5ae164f3 Set up node engine version 2012-09-27 11:54:40 -04:00
John Crepezzi
79309c75df Bump version to 0.1.0 2012-09-27 11:51:15 -04:00
John Crepezzi
4b58c8d356 Added more loggin 2012-09-27 11:50:56 -04:00
John Crepezzi
8f0d6260b0 change how redistogo install works 2012-09-27 11:50:12 -04:00
John Crepezzi
93a83a35da Logging 2012-09-27 11:47:23 -04:00
John Crepezzi
4efc5d47d9 Allow redistogo 2012-09-27 11:46:53 -04:00
John Crepezzi
ff8ef54e34 Procfile 2012-09-27 11:38:14 -04:00
John Crepezzi
814a49812a Update server config path 2012-09-19 14:28:52 -04:00
John Crepezzi
e0610bc1be Fix multiple document loading
Closes #32
2012-08-13 11:33:20 -04:00
John Crepezzi
962976c204 Pad the right 2012-06-22 15:33:07 -04:00
John Crepezzi
16080bdc16 Update description - preparing for npm push 2012-04-21 23:49:39 -04:00
John Crepezzi
20ce741341 Fix indentation 2012-04-07 23:51:48 -04:00
12 changed files with 115 additions and 91 deletions

1
Procfile Normal file
View File

@@ -0,0 +1 @@
web: node server.js

View File

@@ -134,7 +134,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 +142,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

View File

@@ -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

View File

@@ -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

View File

@@ -15,12 +15,23 @@ var DocumentHandler = function(options) {
DocumentHandler.defaultKeyLength = 10; DocumentHandler.defaultKeyLength = 10;
// Handle retrieving a document // Handle retrieving a document
DocumentHandler.prototype.handleGet = function(key, response, skipExpire) { DocumentHandler.prototype.handleGet = function(key, callback, response, skipExpire) {
this.store.get(key, function(ret) { this.store.get(key, function(ret) {
if (ret) { if (ret) {
winston.verbose('retrieved document', { key: key }); winston.verbose('retrieved document', { key: key });
var responseData = JSON.stringify({ data: ret, key: key });
if (callback) {
if (callback.match(/^[a-z0-9]+$/i)) {
response.writeHead(200, { 'content-type': 'application/javascript' });
response.end(callback + '(' + responseData + ');');
} else {
response.writeHead(400, { 'content-type': 'application/json' });
response.end(JSON.stringify({ message: 'invalid callback function name' }));
}
} else {
response.writeHead(200, { 'content-type': 'application/json' }); response.writeHead(200, { 'content-type': 'application/json' });
response.end(JSON.stringify({ data: ret, key: key })); response.end(responseData);
}
} }
else { else {
winston.warn('document not found', { key: key }); winston.warn('document not found', { key: key });

View File

@@ -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);
} }
}; };
@@ -25,7 +29,7 @@ RedisDocumentStore.connect = function(options) {
if (err) { if (err) {
winston.error( winston.error(
'error connecting to redis index ' + index, 'error connecting to redis index ' + index,
{ error: err.message } { error: err }
); );
process.exit(1); process.exit(1);
} }

View File

@@ -1,52 +1,47 @@
{ {
"name": "haste", "name": "haste",
"version": "0.0.1", "version": "0.1.0",
"private": true, "private": true,
"description": "Private Pastebin Server",
"description": "Private Paste", "keywords": [
"paste",
"keywords": [ "paste", "pastebin" ], "pastebin"
],
"author": { "author": {
"name": "John Crepezzi", "name": "John Crepezzi",
"email": "john.crepezzi@gmail.com", "email": "john.crepezzi@gmail.com",
"url": "http://seejohncode.com/" "url": "http://seejohncode.com/"
}, },
"main": "haste", "main": "haste",
"dependencies": { "dependencies": {
"winston": "*", "winston": "0.6.2",
"connect": "< 2", "connect": "1.9.2",
"uglify-js": "*" "redis-url": "0.1.0",
"redis": "0.8.1",
"uglify-js": "1.3.3"
}, },
"devDependencies": { "devDependencies": {
"mocha": "*", "mocha": "*",
"should": "*" "should": "*"
}, },
"bundledDependencies": [], "bundledDependencies": [],
"engines": { "engines": {
"node": "*" "node": "0.8.10",
"npm": "1.1.49"
}, },
"bin": { "bin": {
"haste-server": "./server.js" "haste-server": "./server.js"
}, },
"files": [
"files": [ "server.js", "lib", "static" ], "server.js",
"lib",
"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/*"
} }
} }

View File

@@ -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 });
if (data) {
preferredStore.set(name, data, function(cb) { preferredStore.set(name, data, function(cb) {
winston.info('loaded static document', { name: name, path: path }); winston.debug('loaded static document', { success: cb });
}, true); }, true);
} }
else { else {
winston.warn( winston.warn('failed to load static document', { name: name, path: path });
'failed to load static document',
{ name: name, path: path }
);
} }
});
} }
// Pick up a key generator // Pick up a key generator
@@ -108,8 +116,10 @@ connect.createServer(
// get documents // get documents
app.get('/documents/:id', function(request, response, next) { app.get('/documents/:id', function(request, response, next) {
var skipExpire = !!config.documents[request.params.id]; var skipExpire = !!config.documents[request.params.id];
var parsedUrl = url.parse(request.url, true);
return documentHandler.handleGet( return documentHandler.handleGet(
request.params.id, request.params.id,
parsedUrl.query.callback,
response, response,
skipExpire skipExpire
); );

View File

@@ -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 {

View File

@@ -168,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
@@ -308,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));
} }

File diff suppressed because one or more lines are too long

View File

@@ -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,