Giter Club home page Giter Club logo

haste-server's Introduction

Haste Service

About

Personal fork of haste-server to include several modifications for my needs

  • Updated interface to not cover/block content
  • Ability to upload images/files
  • Ability to store metadata along with the paste/file
  • Compress pastes in datastore
  • Bug fixes
  • Updated library dependencies
  • Shortcuts respond to mac command key

Installation

  1. Download the package, and expand it
  2. Explore the settings inside of config.js, but the defaults should be good
  3. npm install
  4. npm start

Settings

  • host - the host the server runs on (default localhost)
  • port - the port the server runs on (default 7777)
  • keyLength - the length of the keys to user (default 10)
  • maxLength - maximum length of a paste (default none)
  • staticMaxAge - max age for static assets (86400)
  • recompressStaticAssets - whether or not to compile static js assets (true)
  • documents - static documents to serve (ex: http://hastebin.com/about.com) in addition to static assets. These will never expire.
  • storage - storage options (see below)
  • logging - logging preferences
  • keyGenerator - key generator options (see below)
  • rateLimits - settings for rate limiting (see below)

Rate Limiting

When present, the rateLimits option enables built-in rate limiting courtesy of connect-ratelimit. Any of the options supported by that library can be used and set in config.json.

See the README for connect-ratelimit for more information!

Key Generation

Phonetic

Attempts to generate phonetic keys, similar to pwgen

{
  "type": "phonetic"
}

Random

Generates a random key

{
  "type": "random",
  "keyspace": "abcdef"
}

The optional keySpace argument is a string of acceptable characters for the key.

Storage

File

To use file storage (the default) change the storage section in config.js to something like:

{
  "path": "./data",
  "type": "file"
}

Where path represents where you want the files stored

Redis

To use redis storage you must install the redis package in npm, and have redis-server running on the machine.

npm install redis

Once you've done that, your config section should look like:

{
  "type": "redis",
  "host": "localhost",
  "port": 6379,
  "db": 2
}

You can also set an expire option to the number of seconds to expire keys in. This is off by default, but will constantly kick back expirations on each view or post.

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

To use postgres storage you must install the pg package in npm

npm install pg

Once you've done that, your config section should look like:

{
  "type": "postgres",
  "connectionUrl": "postgres://user:password@host:5432/database"
}

You can also just set the environment variable for DATABASE_URL to your database connection url.

You will have to manually add a table to your postgres database:

create table entries (id serial primary key, key varchar(255) not null, value text not null, expiration int, unique(key));

You can also set an expire option to the number of seconds to expire keys in. This is off by default, but will constantly kick back expirations on each view or post.

All of which are optional except type with very logical default values.

Memcached

To use memcached storage you must install the memcache package via npm

npm install memcache

Once you've done that, your config section should look like:

{
  "type": "memcached",
  "host": "127.0.0.1",
  "port": 11211
}

You can also set an expire option to the number of seconds to expire keys in. This behaves just like the redis expirations, but does not push expirations forward on GETs.

All of which are optional except type with very logical default values.

Author

John Crepezzi [email protected]

License

(The MIT License)

Copyright © 2011-2012 John Crepezzi

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 the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

Other components:

  • jQuery: MIT/GPL license
  • highlight.js: Copyright © 2006, Ivan Sagalaev
  • highlightjs-coffeescript: WTFPL - Copyright © 2011, Dmytrii Nagirniak

haste-server's People

Contributors

abn avatar arpsmack avatar bridawson avatar grampajoe avatar gwemox avatar hawur avatar joeykrim avatar klasafgeijerstam avatar lidl avatar naftis avatar neandrake avatar nshontz avatar pangeacake avatar ribesg avatar seejohnrun avatar tfausak avatar wohlstand avatar zaeleus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

haste-server's Issues

Need a way to select which syntax hilighting to use

Perhaps add a dropdown box at the top that allows you to select from the available syntax highlighting.

Maybe have a button next to it that allows you to save your choice so the next time the paste is viewed it uses the syntax highlighting you chose.

Allow extensions on document URLs

Extensions act as a good indicator of file type, so we may either want to allow any extension to be added, or force some extension based on the content-type.

File storage doesn't work

I got multiple problems trying to use file storage. Switched to redis and it works, but you may want to either fix it or remove the feature.
Nice work on this!

Refactor client-side application

The application.js code is a bit tedious to follow and doesn't feel like it's organized very well, especially since new features are continued to be added. This should be cleaned up for better viewing of different types of pastes.

Self-host all js libraries

Right now the main application links to jquery via googleapi. The jquery library should be added to the repo and hosted by the haste server.

Implement URL shortcut feature

By recognizing that the data pasted is a single URL, you could redirect the user to that URL immediately. This would implement URL shortening!

Better paste key generation

Currently it just generates a bunch of random numbers. We should probably hash some form of the content or timestamp and then convert the hash into some legible key.

Keyboard shortcuts are mapped to default browser behaviors

The 'Raw' function is Ctrl/Cmd + Shift + R, which is typically a browser's 'refresh and clear cache' function. The 'Duplicate & Edit' is Ctrl/Cmd + D which is typically 'bookmark this page'.

We should come up with new shortcuts that aren't so typical to overwrite existing browser behavior.

Update redis key/value storage

Store the document in multiple parts using split key names:

"data.{key}" = "{base64 encoded gzipped file}"
"info.{key}" = "{stringified json object containing metadata about the file}"

This prevents having to store the document inside a stringified json object. In the future this would likely make streaming large objects directly to redis easier to implement. This also allows for potentially splitting really large files into multiple entries, a la

"data.0.{key}" = "..."
"data.1.{key}" = "..."

The downside is this means when requesting a file, two database entries have to be queried/pulled, however the keys used are predictable so they could potentially be pulled in a single query (assuming redis supports this).

When querying/storing a file remember to use transactions, even though node is single-threaded.

As part of this, we should also update the current gzipping process to only gzip if the file size is > some threshold. The zip + b64 inflates documents of really small size (probably only restrict non-gzipping to plaintext).

http://stackoverflow.com/questions/7844001/what-is-the-lower-threshold-to-not-perform-http-compression

From that it sounds like we should use deflate/inflate instead of gzip/gunzip for text files (I've not actually looked into the difference yet...), and probably set some threshold at around 256 bytes.

Maybe allow editing

Making the pastes completely immutable kinda sucks. What if you paste something and realize there's a minor typo and want to fix it? You have to duplicate the entire thing and submit it as a new paste?

I guess if we were enforcing short lived pastes that probably wouldn't be a big deal. They would expire and get cleaned up in sort order. But if we want longer lived pastes, then editing seems like a necessity.

We should at least be able to configure whether or not editing is allowed.

Dragging file onto page when not in edit mode won't accept the drop

I think this is because of how the body tag works. When in edit mode a textarea component is taking up the full dimension of the page. When not in edit mode the body tag is only the size of the text pasted.

Might be fixed with adding:

html {overflow-y:hidden; height: 100%;}
body {overflow-y:auto; height: 100%;}

Log file is stored with content-type of application/octet-stream

Dropped a .log file and when redirected to the raw file, was prompted to download file rather than viewing the text. Probably just need better mime-type parsing on file upload.

We should probably also special-case drops of files that have a mime-type of text, instead of redirecting to the raw document, load it to be highlighted/parsed.

Better downloads

Hi

File extension

For example, if you upload Minecraft.exe and then download it, you just get a file with the document key as name. It's not really convenient.

Same for images, would be nice to at least have the format :-)

Better understanding

When sharing a file that isn't text nor image, it would be nice to have a bigger, clearer "download" link.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.