Commit f651c309 authored by John Crepezzi's avatar John Crepezzi
Browse files

Merge branch 'master' of codeplane.com:seejohnrun/haste-server

Conflicts:
	TODO.md
parents 9e046ba8 a5459fc2
Loading
Loading
Loading
Loading
+3 −14
Original line number Diff line number Diff line
# TODO
* cache headers for static assets (and on document GET)
# TODO for OSS
* tests
* fix that chrome bug where it loads the doc twice
* expand extension map
* kick expiration back by increment on each view
* Add file extensions ourselves to push state
* Proper markdown highlighting
* Better about page text
* Collapse CSS rules to get rid of the #key .box1 nonsense

* add feedback for errors to UI - esp. too long
* make sure file store still functions appropriately

# shared version only
* some way to do announcements easily (and use for ads)
* start using CDNs for most assets (optional)


# with brian's design
* add feedback for errors to UI - esp. too long
* add link to about page
* copy URL to clipboard button
+18 −2
Original line number Diff line number Diff line
# Haste

<b>Sharing code is a good thing</b>, and it should be _really_ easy to do it.
Sharing code is a good thing, and it should be _really_ easy to do it.
A lot of times, I want to show you something I'm seeing - and that's where we use pastebins.

Haste is the prettiest, easist to use pastebin ever made.

## Basic Usage

Type what you want me to see, click "Save", and then copy the URL.  Send that URL
to someone and they'll see what you see.

## From the Console

Most of the time I want to show you some text, its coming from my current console session.
@@ -21,6 +26,17 @@ been conveniently copied to your clipboard.

That's all there is to that, and you can install it with `gem install haste` right now.

## Duration

Pastes will stay for 30 days from their last view.

## Privacy

While the contents of hastebin.com are not directly crawled by any search robot that
obeys "robots.txt", there should be no great expectation of privacy.  Post things at your
own risk. Not responsible for any loss of data or removed pastes.

## Author

John Crepezzi <john.crepezzi@gmail.com>
Code by John Crepezzi <john.crepezzi@gmail.com>
Key Design by Brian Dawson
+3 −1
Original line number Diff line number Diff line
@@ -7,7 +7,9 @@

  "maxLength": 400000,

  "cacheStaticAssets": false,
  "staticMaxAge": 86400,

  "recompressStaticAssets": true,

  "logging": [
    {
+2 −2
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ var DocumentHandler = function(options) {
};

// Handle retrieving a document
DocumentHandler.prototype.handleGet = function(key, response) {
DocumentHandler.prototype.handleGet = function(key, response, skipExpire) {
  this.store.get(key, function(ret) {
    if (ret) {
      winston.verbose('retrieved document', { key: key });
@@ -23,7 +23,7 @@ DocumentHandler.prototype.handleGet = function(key, response) {
      response.writeHead(404, { 'content-type': 'application/json' });
      response.end(JSON.stringify({ message: 'document not found' }));
    }
  });
  }, skipExpire);
};

// Handle adding a new Document
+10 −2
Original line number Diff line number Diff line
@@ -9,10 +9,11 @@ var hashlib = require('hashlib');

var FileDocumentStore = function(options) {
  this.basePath = options.path || './data';
  this.expire = options.expire;
};

// Save data in a file, key as md5 - since we don't know what we could be passed here
FileDocumentStore.prototype.set = function(key, data, callback) {
FileDocumentStore.prototype.set = function(key, data, callback, skipExpire) {
  try {
    var _this = this;
    fs.mkdir(this.basePath, '700', function() {
@@ -22,6 +23,9 @@ FileDocumentStore.prototype.set = function(key, data, callback) {
        }
        else {
          callback(true);
          if (_this.expire && !skipExpire) {
            winston.warn('file store cannot set expirations on keys'); 
          }
        }
      });
    });
@@ -31,13 +35,17 @@ FileDocumentStore.prototype.set = function(key, data, callback) {
};

// Get data from a file from key
FileDocumentStore.prototype.get = function(key, callback) {
FileDocumentStore.prototype.get = function(key, callback, skipExpire) {
  var _this = this;
  fs.readFile(this.basePath + '/' + hashlib.md5(key), 'utf8', function(err, data) {
    if (err) {
      callback(false);
    }
    else {
      callback(data);
      if (_this.expire && !skipExpire) {
        winston.warn('file store cannot set expirations on keys'); 
      }
    }
  });
};
Loading