167 Commits
Author SHA1 Message Date
John Crepezzi 844a2efb02 Added support for raw button 2012-01-10 23:06:44 -05:00
John Crepezzi b251978422 Merge pull request #15 from zaeleus/html_escape
Escape document when using the txt extension
2012-01-09 20:43:39 -08:00
John Crepezzi 9fdcd08591 Revert "updated icon set to include "raw/just text""
This reverts commit 31a701d491.
2012-01-09 22:12:00 -05:00
Michael Macias d87c3b7d61 Escape document when using the txt extension 2012-01-08 23:47:07 -06:00
Brian Dawson 31a701d491 updated icon set to include "raw/just text" 2012-01-09 00:41:30 -05:00
John Crepezzi cc65e98940 Added support for phonetic key naming
Closes #7
2012-01-07 11:35:11 -05:00
John Crepezzi a958c66249 Merge pull request #14 from grampajoe/cancelling
Cancellation should only last as long as the handler
2011-12-19 12:42:12 -08:00
Joe Friedl 8c2add94a2 Cancellation should only last as long as the handler 2011-12-19 14:20:22 -06:00
John Crepezzi 71c791c113 Merge pull request #13 from grampajoe/error-messages
Error messages
2011-12-19 11:31:17 -08:00
Joe Friedl b38d2375ee Merge branch 'master' into error-messages 2011-12-19 11:57:23 -06:00
Joe Friedl 6145a938e3 Error messages in the UI 2011-12-19 11:44:12 -06:00
John Crepezzi 7a946f4967 Merge pull request #12 from grampajoe/master
Fixed error in error message.
2011-12-18 17:58:07 -08:00
Joe Friedl 87c935ac47 Fixed error in error message. 2011-12-18 18:51:23 -06:00
John Crepezzi 14a23388a8 Added non-standard but desirable robots.txt 2011-12-16 08:18:04 -05:00
John Crepezzi 44f7ab3f33 Added the ability to retrieve raw documents
Closes #10
2011-12-16 07:57:49 -05:00
John Crepezzi 8add4917d5 Change the line number color 2011-12-15 21:48:48 -05:00
John Crepezzi 3a6b36ebaa Working line number support - just waiting on a final color from @bridawson
[#5]
2011-12-15 21:27:23 -05:00
John Crepezzi 49bb449141 Back button fix 2011-12-15 14:23:09 -05:00
John Crepezzi 8e46ee620f Merge pull request #11 from nshontz/patch-1
Including dependencies for osx and linux for installation
2011-12-15 07:55:03 -08:00
nshontz 907a7c0929 Including dependencies for osx and linux for installation, these are a couple things I ran into while getting set up. 2011-12-15 08:45:28 -07:00
John Crepezzi 242d8475cf Update static/solarized_dark.css 2011-12-12 16:40:47 -05:00
John Crepezzi 8e3bc9826b Merge pull request #8 from muloka/patch-1
Included license information of other included components.
2011-12-05 11:57:15 -08:00
Louis Galipeau 335ae24dc5 Included license information of other included components. 2011-12-05 15:49:41 -04:00
John Crepezzi 2fdcd316f7 Added a favicon 2011-11-29 20:24:53 -05:00
John Crepezzi da407cfbb6 Update about.md for linux xsel 2011-11-29 20:23:30 -05:00
John Crepezzi 0f02d83d24 remove ^L for saving 2011-11-29 20:11:09 -05:00
John Crepezzi 615fedd6c7 Fix doctype 2011-11-29 13:40:13 -05:00
John Crepezzi 4e20ea078f Added html5 doctype 2011-11-29 13:13:10 -05:00
John Crepezzi 15bd62836b Change how twitter link is built 2011-11-29 12:06:49 -05:00
John Crepezzi 8eb1b54615 Added more detail to about page 2011-11-29 12:05:04 -05:00
John Crepezzi 0e292ad21b support .txt type 2011-11-29 10:44:05 -05:00
John Crepezzi 9378f2b2e4 Automatically add file extensions 2011-11-29 10:39:12 -05:00
John Crepezzi 344d1fec7b Add more detail to README 2011-11-29 09:25:22 -05:00
John Crepezzi d1ff598f50 Update about 2011-11-29 09:21:01 -05:00
John Crepezzi 6448139396 Merge branch 'master' of codeplane.com:seejohnrun/haste-server
Conflicts:
	README.md
2011-11-29 09:17:49 -05:00
John Crepezzi 87f5af3194 Clean up README 2011-11-29 09:17:04 -05:00
John Crepezzi 82af7a221a Clean up README 2011-11-29 09:15:16 -05:00
John Crepezzi 01d9337f10 Clean up redis test to exit properly 2011-11-28 20:56:41 -05:00
John Crepezzi 844e664cb5 Added some tests for redis document store 2011-11-28 20:51:04 -05:00
John Crepezzi 68c4fc2534 Update TODO 2011-11-28 19:58:32 -05:00
John Crepezzi 83959a77fc Fix bottom margin issue on box 2011-11-28 19:58:27 -05:00
John Crepezzi 565830214b Start in on the tests 2011-11-28 16:46:59 -05:00
John Crepezzi 43e5667ff9 Remove finished TODO 2011-11-28 14:50:04 -05:00
John Crepezzi f755b675d0 Bump key length to 10 2011-11-28 13:17:13 -05:00
John Crepezzi 9157a0227d Remove clipboard 2011-11-28 13:02:48 -05:00
John Crepezzi 8eca87ce03 Change image 2011-11-28 10:50:33 -05:00
John Crepezzi 2de05d9055 Change expiration to 30 days 2011-11-28 10:37:39 -05:00
John Crepezzi a1ba8b6b71 Added email for brian dawson 2011-11-28 10:35:08 -05:00
John Crepezzi 96b3249b09 Change image colors 2011-11-28 10:32:33 -05:00
John Crepezzi 81c41c0f37 Put in compressed asset 2011-11-28 10:30:54 -05:00
John Crepezzi 52198b97b2 Get rid of the CSS #key .box* nonsense 2011-11-28 09:56:06 -05:00
John Crepezzi 17897e8155 remove static jquery copy 2011-11-28 09:54:31 -05:00
John Crepezzi f651c30981 Merge branch 'master' of codeplane.com:seejohnrun/haste-server
Conflicts:
	TODO.md
2011-11-28 09:48:28 -05:00
John Crepezzi 9e046ba8eb Added the arrow pointer in 2011-11-28 09:42:26 -05:00
John Crepezzi a5459fc29b Added a TODO 2011-11-28 01:29:09 -05:00
John Crepezzi 1ed980150c Fix annoying chrome dual-load bug 2011-11-28 01:27:41 -05:00
John Crepezzi 6e2955d60c Warn on no setExpire in file store 2011-11-28 01:17:46 -05:00
John Crepezzi 92e0f579ca Kick expirations back on view 2011-11-28 01:13:14 -05:00
John Crepezzi cd9bf18d29 Remove a TODO 2011-11-28 00:56:57 -05:00
John Crepezzi 895485e410 Fix highlighting bug 2011-11-28 00:54:24 -05:00
John Crepezzi 29651ebfd5 More about page changes 2011-11-28 00:51:43 -05:00
John Crepezzi 983749e4af Update TODO 2011-11-28 00:47:35 -05:00
John Crepezzi 0ea5b65eba Use about.md instead of about 2011-11-27 23:41:18 -05:00
John Crepezzi 2a3a9046d8 Proper markdown highlighting 2011-11-27 23:39:09 -05:00
John Crepezzi 481155194a Merge branch 'master' of codeplane.com:seejohnrun/haste-server
Conflicts:
	TODO.md
2011-11-27 23:30:20 -05:00
John Crepezzi 0875ba6252 Auto-compress javascript assets 2011-11-27 15:49:17 -05:00
John Crepezzi d3ba2e4b5b Remove TODO 2011-11-27 15:35:46 -05:00
John Crepezzi 4233e58995 Added copy URL functionality 2011-11-27 15:34:09 -05:00
John Crepezzi c4a5184962 Clean up TODO 2011-11-27 14:48:33 -05:00
John Crepezzi 85fac80a6d Put staticCache back in 2011-11-27 14:47:36 -05:00
John Crepezzi 0a0e1636bc Allow the /about page 2011-11-27 14:37:38 -05:00
John Crepezzi b47e5ad2a8 Update TODO 2011-11-27 12:16:06 -05:00
John Crepezzi d262c9f853 use compressed application.js 2011-11-25 10:28:26 -05:00
John Crepezzi fb0c439879 temporarily remove staticCache 2011-11-23 22:01:22 -05:00
John Crepezzi e0941d5ac9 Updated about page 2011-11-23 17:11:55 -05:00
John Crepezzi 591fd456d6 Change application name 2011-11-23 17:09:12 -05:00
John Crepezzi 8281d382e4 on highlight error, return data 2011-11-23 16:58:56 -05:00
John Crepezzi 6285d665ad Expand extension map and catch highlight errors 2011-11-23 16:55:26 -05:00
John Crepezzi 12aa622c2d Clean up the router 2011-11-23 16:34:22 -05:00
John Crepezzi a7aec372d5 extensions work again 2011-11-23 16:32:20 -05:00
John Crepezzi d6468ad5fb Fixed bug that was preventing document lookup 2011-11-23 15:45:28 -05:00
John Crepezzi 607d3eb3ac Remove the static handler 2011-11-23 15:27:02 -05:00
John Crepezzi b598e73d3f Update TODO 2011-11-23 13:19:43 -05:00
John Crepezzi 6906ad4253 Clean up TODO 2011-11-23 13:17:22 -05:00
John Crepezzi 167c7c4adb Use the new router 2011-11-23 13:14:18 -05:00
John Crepezzi 1dbaa54811 CDN assets 2011-11-23 12:28:08 -05:00
John Crepezzi a1803305fb Change hover state for non-enabled 2011-11-23 12:12:01 -05:00
John Crepezzi 62e04cbf5b Merge branch 'master' of codeplane.com:seejohnrun/haste-server 2011-11-23 11:34:31 -05:00
John Crepezzi 7f4cae57f9 Fix document handler regex 2011-11-23 11:34:08 -05:00
John Crepezzi 315333d8eb Merge branch 'master' of codeplane.com:seejohnrun/haste-server 2011-11-23 11:33:02 -05:00
John Crepezzi 2089a14ad7 TODO 2011-11-23 11:32:49 -05:00
John Crepezzi f601d9f159 Implement redesign of key 2011-11-23 11:31:50 -05:00
John Crepezzi ab47aeb88b Fix bug in document handler 2011-11-22 20:38:52 -05:00
John Crepezzi 051a545a55 Move todo to todo.md 2011-11-22 20:34:34 -05:00
John Crepezzi 5d889662ef Added a TODO 2011-11-22 20:30:24 -05:00
John Crepezzi ec0d419c61 Allow forcing of highlight type 2011-11-22 20:29:46 -05:00
John Crepezzi 56bf98daac More robots.txt work 2011-11-22 20:01:09 -05:00
John Crepezzi 2299819781 Added robots.txt 2011-11-22 19:59:03 -05:00
John Crepezzi 5b66695ca6 Update TODO 2011-11-22 16:51:35 -05:00
John Crepezzi f81b7ec593 Update about and TODO 2011-11-22 09:53:02 -05:00
John Crepezzi e403549e13 Added static document loading on start 2011-11-22 09:22:37 -05:00
John Crepezzi 32b4f842b7 serve 404 when not possible key 2011-11-21 23:13:46 -05:00
John Crepezzi 9ed330bdae Make static asset caching an option 2011-11-21 23:00:28 -05:00
John Crepezzi 1382ec47b2 DRY up the static cache 2011-11-21 22:53:50 -05:00
John Crepezzi 83cb68ada2 cache static assets in memory 2011-11-21 22:19:43 -05:00
John Crepezzi e4da28de8a Remove TODO 2011-11-21 22:04:41 -05:00
John Crepezzi 32d49385a1 Remove debug logging 2011-11-21 22:04:12 -05:00
John Crepezzi d0e3e4cd02 Support for redis expiration 2011-11-21 22:03:50 -05:00
John Crepezzi 0f2075fcda Ensure conflict resolution in keyspace 2011-11-21 21:48:09 -05:00
John Crepezzi 4ed87c4ec7 Fix the key 2011-11-21 20:52:35 -05:00
John Crepezzi 025dfcfe26 Remove save when on locked screen 2011-11-21 20:47:29 -05:00
John Crepezzi 39ffbc7f49 Update TODO 2011-11-21 10:18:48 -05:00
John Crepezzi a9e29c2986 Added support for haste maximum size 2011-11-21 10:17:23 -05:00
John Crepezzi 29a600fe87 Fix ^n bug while editing 2011-11-21 10:01:33 -05:00
John Crepezzi 4d56fc0e61 More browser support 2011-11-21 09:59:14 -05:00
John Crepezzi 9fa99fe69d Fixes for Firefox 2011-11-21 09:56:33 -05:00
John Crepezzi 9638baffdb Make twitter posting an option 2011-11-19 01:00:04 -05:00
John Crepezzi 6499ad3190 Clean up animations 2011-11-19 00:53:38 -05:00
John Crepezzi 73be6e31d9 Added TODO 2011-11-19 00:34:23 -05:00
John Crepezzi af02375b7c Show certain options only sometimes 2011-11-19 00:30:14 -05:00
John Crepezzi f54712f9d9 Added twitter functionality 2011-11-19 00:23:53 -05:00
John Crepezzi b9e9bd154c Fix some annoying visual quirks 2011-11-19 00:02:11 -05:00
John Crepezzi a213bdf9da Update TODO 2011-11-18 23:28:53 -05:00
John Crepezzi b6eef4b628 Update README 2011-11-18 20:04:50 -05:00
John Crepezzi bece4598f7 Remove haste client 2011-11-18 20:03:39 -05:00
John Crepezzi 44350ce9e6 Clean up redis store 2011-11-18 19:59:41 -05:00
John Crepezzi 00e2ca8d29 Remove done TODO 2011-11-18 19:57:36 -05:00
John Crepezzi a2d17b28df Remove redundant package dependency 2011-11-18 19:56:09 -05:00
John Crepezzi a1d5f79708 Added Redis store support 2011-11-18 19:55:14 -05:00
John Crepezzi 26c148ff37 Added TODO 2011-11-18 19:10:23 -05:00
John Crepezzi 6c85c23c6d Added README 2011-11-18 18:45:20 -05:00
John Crepezzi 60f412b7bc Added haste to version control 2011-11-18 18:30:31 -05:00
John Crepezzi 01b622821e Added a command key 2011-11-18 18:17:49 -05:00
John Crepezzi a83ae523b4 Catch exceptions 2011-11-18 18:08:04 -05:00
John Crepezzi 83b8f3f52d Generalize store 2011-11-18 18:04:24 -05:00
John Crepezzi fec02cfead Move storage mechanism to new object 2011-11-18 17:54:57 -05:00
John Crepezzi b173cdd144 preparse static elements rather than fs'ing them 2011-11-18 17:36:35 -05:00
John Crepezzi 0fe0306caa Logger configuration 2011-11-18 17:26:25 -05:00
John Crepezzi a6bd69f20a Rename to haste 2011-11-18 17:24:15 -05:00
John Crepezzi fe68e42b90 Don't save blank docs 2011-11-18 17:21:31 -05:00
John Crepezzi 4a435a4be5 Cleanup todo 2011-11-18 17:14:44 -05:00
John Crepezzi f48cc45928 Cleanup and remove TODO that is done 2011-11-18 17:14:03 -05:00
John Crepezzi 7709e12500 Added FS backed 2011-11-18 17:12:28 -05:00
John Crepezzi 93435715f2 Fix loggin 2011-11-18 16:58:21 -05:00
John Crepezzi 6bdd7d7fc5 Host and port made configurable 2011-11-18 16:57:23 -05:00
John Crepezzi b159817a27 Added configuration and made key length configurable 2011-11-18 16:54:16 -05:00
John Crepezzi 0eed33f42f 400 should be 404 2011-11-18 16:50:23 -05:00
John Crepezzi cf384cd0fd Added random keys 2011-11-18 16:45:48 -05:00
John Crepezzi f935ac56c2 Nicer page titles 2011-11-18 16:42:05 -05:00
John Crepezzi d69839b2fb Push state for new documents fixed 2011-11-18 16:37:38 -05:00
John Crepezzi 3acc2eb17d Catch an error 2011-11-18 16:28:09 -05:00
John Crepezzi 7b2d0f549d Remove some finished TODOs 2011-11-18 16:25:53 -05:00
John Crepezzi 8a8b438163 Change uuid to key 2011-11-18 16:25:18 -05:00
John Crepezzi 6597dba36d Handle push state entirely 2011-11-18 16:22:00 -05:00
John Crepezzi 4f00d3c71a Remove url from static_handler.js 2011-11-18 16:00:05 -05:00
John Crepezzi 44d54174ed Push state on doc change 2011-11-18 15:55:01 -05:00
John Crepezzi 13e497993f Separate logic into proper places 2011-11-18 15:51:38 -05:00
John Crepezzi 6bac45efe2 More work on the server 2011-11-18 15:44:28 -05:00
John Crepezzi b35c89a472 Added duplicate functionality 2011-11-18 15:18:38 -05:00
John Crepezzi f22f347d43 Light refactor 2011-11-18 10:49:38 -05:00
John Crepezzi 7756e38595 Document saving almost working 2011-11-18 10:49:00 -05:00
John Crepezzi 7cc30e4b69 ctrl-n for new documents 2011-11-18 10:19:44 -05:00
John Crepezzi c5a551f770 Move to static, rewrite client-JS 2011-11-18 10:17:41 -05:00
John Crepezzi 5b874e3456 Upgrade jquery to remove warnings 2011-11-17 22:47:56 -05:00
John Crepezzi c90561da8e Remove finished todo 2011-11-17 22:45:41 -05:00
John Crepezzi 90161e780d Turn off spellcheck 2011-11-17 22:45:25 -05:00
John Crepezzi 9d0b0c9f21 Things working 2011-11-17 22:44:48 -05:00
30 changed files with 1515 additions and 385 deletions
+6
View File
@@ -0,0 +1,6 @@
npm-debug.log
node_modules
*.swp
*.swo
data
*.DS_Store
+123
View File
@@ -0,0 +1,123 @@
# Haste
Haste is an open-source pastebin software written in node.js, which is easily installable in any network. It can be backed by either redis or filesystem, and has a very easy adapter interface for other stores. A publicly available version can be found at [hastebin.com](http://hastebin.com)
Major design objectives:
* Be really pretty
* Be really simple
* Be easy to set up and use
Haste works really well with a little utility called haste-client, allowing you to do things like:
`cat something | haste`
which will output a URL to share containing the contents of `cat something`'s STDOUT
## Tested Browsers
* Firefox 8
* Chrome 17
* Safari 5.3
## 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)
* `recompressStatisAssets` - 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)
## Key Generation
### Phonetic
Attempts to generate phonetic keys, similar to `pwgen`
``` json
{
"type": "phonetic"
}
```
### Random
Generates a random key
``` json
{
"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:
``` json
{
"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 globall using
`npm install redis --global`
Once you've done that, your config section should look like:
``` json
{
"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.
## Author
John Crepezzi <john.crepezzi@gmail.com>
## License
(The MIT License)
Copyright © 2011 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
+1
View File
@@ -0,0 +1 @@
* add feedback for errors to UI - esp. too long
+54
View File
@@ -0,0 +1,54 @@
# Haste
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.
To make a new entry, click "New" (or type 'control + n')
## From the Console
Most of the time I want to show you some text, its coming from my current console session.
We should make it really easy to take code from the console and send it to people.
`cat something | haste` # http://hastebin.com/1238193
You can even take this a step further, and cut out the last step of copying the URL with:
* osx: `cat something | haste | pbcopy`
* linux: `cat something | haste | xsel`
After running that, the STDOUT output of `cat something` will show up at a URL which has
been conveniently copied to your clipboard.
That's all there is to that, and you can install it with `gem install haste` right now.
* osx: you will need to have an up to date version of Xcode
* linux: you will need to have rubygems and ruby-devel installed
## 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.
## Open Source
Haste can easily be installed behind your network, and its all open source!
* [haste-client](https://github.com/seejohnrun/haste-client)
* [haste-server](https://github.com/seejohnrun/haste-server)
## Author
Code by John Crepezzi <john.crepezzi@gmail.com>
Key Design by Brian Dawson <bridawson@gmail.com>
+38
View File
@@ -0,0 +1,38 @@
{
"host": "localhost",
"port": 7777,
"keyLength": 10,
"maxLength": 400000,
"staticMaxAge": 86400,
"recompressStaticAssets": true,
"logging": [
{
"level": "verbose",
"type": "Console",
"colorize": true
}
],
"keyGenerator": {
"type": "phonetic"
},
"storage": {
"type": "redis",
"host": "localhost",
"port": 6379,
"db": 2,
"expire": 2592000
},
"documents": {
"about": "./about.md"
}
}
-43
View File
@@ -1,43 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>Haste-server by seejohnrun</title>
<link rel="stylesheet" href="stylesheets/styles.css">
<link rel="stylesheet" href="stylesheets/pygment_trac.css">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="wrapper">
<header>
<h1>Haste-server</h1>
<p>open source pastebin written in node.js</p>
<p class="view"><a href="https://github.com/seejohnrun/haste-server">View the Project on GitHub <small>seejohnrun/haste-server</small></a></p>
<ul>
<li><a href="https://github.com/seejohnrun/haste-server/zipball/master">Download <strong>ZIP File</strong></a></li>
<li><a href="https://github.com/seejohnrun/haste-server/tarball/master">Download <strong>TAR Ball</strong></a></li>
<li><a href="https://github.com/seejohnrun/haste-server">Fork On <strong>GitHub</strong></a></li>
</ul>
</header>
<section>
<h1>Pastebin</h1>
<p>haste-server is an open source pastebin. You can see an example at <a href="http://hastebin.com">hastebin.com</a>, and it's easy to install locally.</p>
<h2>GitHub</h2>
<p>Check out the project on <a href="https://github.com/seejohnrun/haste-server">github</a></p>
</section>
<footer>
<p>This project is maintained by <a href="https://github.com/seejohnrun">seejohnrun</a></p>
<p><small>Hosted on GitHub Pages &mdash; Theme by <a href="https://github.com/orderedlist">orderedlist</a></small></p>
</footer>
</div>
<script src="javascripts/scale.fix.js"></script>
</body>
</html>
-17
View File
@@ -1,17 +0,0 @@
var metas = document.getElementsByTagName('meta');
var i;
if (navigator.userAgent.match(/iPhone/i)) {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
}
}
document.addEventListener("gesturestart", gestureStart, false);
}
function gestureStart() {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=0.25, maximum-scale=1.6";
}
}
}
+102
View File
@@ -0,0 +1,102 @@
var winston = require('winston');
// For handling serving stored documents
var DocumentHandler = function(options) {
if (!options) {
options = {};
}
this.keyLength = options.keyLength || DocumentHandler.defaultKeyLength;
this.maxLength = options.maxLength; // none by default
this.store = options.store;
this.keyGenerator = options.keyGenerator;
};
DocumentHandler.defaultKeyLength = 10;
// Handle retrieving a document
DocumentHandler.prototype.handleGet = function(key, response, skipExpire) {
this.store.get(key, function(ret) {
if (ret) {
winston.verbose('retrieved document', { key: key });
response.writeHead(200, { 'content-type': 'application/json' });
response.end(JSON.stringify({ data: ret, key: key }));
}
else {
winston.warn('document not found', { key: key });
response.writeHead(404, { 'content-type': 'application/json' });
response.end(JSON.stringify({ message: 'Document not found.' }));
}
}, skipExpire);
};
// Handle retrieving the raw version of a document
DocumentHandler.prototype.handleRawGet = function(key, response, skipExpire) {
this.store.get(key, function(ret) {
if (ret) {
winston.verbose('retrieved raw document', { key: key });
response.writeHead(200, { 'content-type': 'text/plain' });
response.end(ret);
}
else {
winston.warn('raw document not found', { key: key });
response.writeHead(404, { 'content-type': 'application/json' });
response.end(JSON.stringify({ message: 'Document not found.' }));
}
}, skipExpire);
};
// Handle adding a new Document
DocumentHandler.prototype.handlePost = function(request, response) {
var _this = this;
var buffer = '';
var cancelled = false;
request.on('data', function(data) {
if (!buffer) {
response.writeHead(200, { 'content-type': 'application/json' });
}
buffer += data.toString();
if (_this.maxLength && buffer.length > _this.maxLength) {
cancelled = true;
winston.warn('document >maxLength', { maxLength: _this.maxLength });
response.writeHead(400, { 'content-type': 'application/json' });
response.end(JSON.stringify({ message: 'Document exceeds maximum length.' }));
}
});
request.on('end', function(end) {
if (cancelled) return;
_this.chooseKey(function(key) {
_this.store.set(key, buffer, function(res) {
if (res) {
winston.verbose('added document', { key: key });
response.end(JSON.stringify({ key: key }));
}
else {
winston.verbose('error adding document');
response.writeHead(500, { 'content-type': 'application/json' });
response.end(JSON.stringify({ message: 'Error adding document.' }));
}
});
});
});
request.on('error', function(error) {
winston.error('connection error: ' + error.message);
response.writeHead(500, { 'content-type': 'application/json' });
response.end(JSON.stringify({ message: 'Connection error.' }));
});
};
// Get a random key that hasn't been already used
DocumentHandler.prototype.chooseKey = function(callback) {
var key = this.keyGenerator.createKey(this.keyLength);
var _this = this;
this.store.get(key, function(ret) {
if (ret) {
_this.chooseKey(callback);
} else {
callback(key);
}
});
};
module.exports = DocumentHandler;
+53
View File
@@ -0,0 +1,53 @@
var fs = require('fs');
var winston = require('winston');
var hashlib = require('hashlib');
// For storing in files
// options[type] = file
// options[path] - Where to store
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, skipExpire) {
try {
var _this = this;
fs.mkdir(this.basePath, '700', function() {
fs.writeFile(_this.basePath + '/' + hashlib.md5(key), data, 'utf8', function(err) {
if (err) {
callback(false);
}
else {
callback(true);
if (_this.expire && !skipExpire) {
winston.warn('file store cannot set expirations on keys');
}
}
});
});
} catch(err) {
callback(false);
}
};
// Get data from a file from key
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');
}
}
});
};
module.exports = FileDocumentStore;
+32
View File
@@ -0,0 +1,32 @@
// Draws inspiration from pwgen and http://tools.arantius.com/password
var PhoneticKeyGenerator = function(options) {
// No options
};
// Generate a phonetic key
PhoneticKeyGenerator.prototype.createKey = function(keyLength) {
var text = '';
for (var i = 0; i < keyLength; i++) {
text += (i % 2 == 0) ? this.randConsonant() : this.randVowel();
}
return text;
};
PhoneticKeyGenerator.consonants = 'bcdfghjklmnpqrstvwxy';
PhoneticKeyGenerator.vowels = 'aeiou';
// Get an random vowel
PhoneticKeyGenerator.prototype.randVowel = function() {
return PhoneticKeyGenerator.vowels[
Math.floor(Math.random() * PhoneticKeyGenerator.vowels.length)
];
};
// Get an random consonant
PhoneticKeyGenerator.prototype.randConsonant = function() {
return PhoneticKeyGenerator.consonants[
Math.floor(Math.random() * PhoneticKeyGenerator.consonants.length)
];
};
module.exports = PhoneticKeyGenerator;
+14
View File
@@ -0,0 +1,14 @@
var RandomKeyGenerator = function(options) {
this.keyspace = options.keyspace || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
};
// Generate a random key
RandomKeyGenerator.prototype.createKey = function(keyLength) {
var text = '';
for (var i = 0; i < keyLength; i++) {
text += this.keyspace.charAt(Math.floor(Math.random() * this.keyspace.length));
}
return text;
};
module.exports = RandomKeyGenerator;
+74
View File
@@ -0,0 +1,74 @@
var redis = require('redis');
var winston = require('winston');
var hashlib = require('hashlib');
// For storing in redis
// options[type] = redis
// options[host] - The host to connect to (default localhost)
// options[port] - The port to connect to (default 5379)
// options[db] - The db to use (default 0)
// options[expire] - The time to live for each key set (default never)
var RedisDocumentStore = function(options) {
this.expire = options.expire;
if (!RedisDocumentStore.client) {
RedisDocumentStore.connect(options);
}
};
// Create a connection according to config
RedisDocumentStore.connect = function(options) {
var host = options.host || '127.0.0.1';
var port = options.port || 6379;
var index = options.db || 0;
RedisDocumentStore.client = redis.createClient(port, host);
RedisDocumentStore.client.select(index, function(err, reply) {
if (err) {
winston.error('error connecting to redis index ' + index, { error: err.message });
process.exit(1);
}
else {
winston.info('connected to redis on ' + host + ':' + port + '/' + index);
}
});
};
// Save file in a key
RedisDocumentStore.prototype.set = function(key, data, callback, skipExpire) {
var _this = this;
RedisDocumentStore.client.set(key, data, function(err, reply) {
if (err) {
callback(false);
}
else {
if (!skipExpire) {
_this.setExpiration(key);
}
callback(true);
}
});
};
// Expire a key in expire time if set
RedisDocumentStore.prototype.setExpiration = function(key) {
if (this.expire) {
RedisDocumentStore.client.expire(key, this.expire, function(err, reply) {
if (err) {
winston.error('failed to set expiry on key: ' + key);
}
});
}
};
// Get a file from a key
RedisDocumentStore.prototype.get = function(key, callback, skipExpire) {
var _this = this;
RedisDocumentStore.client.get(key, function(err, reply) {
if (!err && !skipExpire) {
_this.setExpiration(key);
}
callback(err ? false : reply);
});
};
module.exports = RedisDocumentStore;
+52
View File
@@ -0,0 +1,52 @@
{
"name": "haste",
"version": "0.0.1",
"private": true,
"description": "Private Paste",
"keywords": [ "paste", "pastebin" ],
"author": {
"name": "John Crepezzi",
"email": "john.crepezzi@gmail.com",
"url": "http://seejohncode.com/"
},
"main": "haste",
"dependencies": {
"winston": "*",
"hashlib": "*",
"connect": "*",
"uglify-js": "*"
},
"devDependencies": {
"jasmine-node": "*"
},
"bundledDependencies": [],
"engines": {
"node": "*"
},
"bin": {
"haste-server": "./server.js"
},
"files": [ "server.js", "lib", "static" ],
"directories": {
"lib": "./lib"
},
"scripts": {
"start": "node server.js",
"test": "jasmine-node spec"
}
}
-1
View File
@@ -1 +0,0 @@
{"name":"Haste-server","body":"# Pastebin\r\n\r\nhaste-server is an open source pastebin. You can see an example at [hastebin.com](http://hastebin.com), and it's easy to install locally.\r\n\r\n## GitHub\r\n\r\nCheck out the project on [github](https://github.com/seejohnrun/haste-server)","tagline":"open source pastebin written in node.js","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."}
+123
View File
@@ -0,0 +1,123 @@
var http = require('http');
var url = require('url');
var fs = require('fs');
var winston = require('winston');
var connect = require('connect');
var DocumentHandler = require('./lib/document_handler');
// Load the configuration and set some defaults
var config = JSON.parse(fs.readFileSync('config.js', 'utf8'));
config.port = config.port || 7777;
config.host = config.host || 'localhost';
// Set up the logger
if (config.logging) {
try {
winston.remove(winston.transports.Console);
} catch(er) { }
var detail, type;
for (var i = 0; i < config.logging.length; i++) {
detail = config.logging[i];
type = detail.type;
delete detail.type;
winston.add(winston.transports[type], detail);
}
}
// build the store from the config on-demand - so that we don't load it
// for statics
if (!config.storage) {
config.storage = { type: 'file' };
}
if (!config.storage.type) {
config.storage.type = 'file';
}
var Store = require('./lib/' + config.storage.type + '_document_store');
var preferredStore = new Store(config.storage);
// Compress the static javascript assets
if (config.recompressStaticAssets) {
var jsp = require("uglify-js").parser;
var pro = require("uglify-js").uglify;
var list = fs.readdirSync('./static');
for (var i = 0; i < list.length; i++) {
var item = list[i];
var orig_code, ast;
if ((item.indexOf('.js') === item.length - 3) && (item.indexOf('.min.js') === -1)) {
dest = item.substring(0, item.length - 3) + '.min' + item.substring(item.length - 3);
orig_code = fs.readFileSync('./static/' + item, 'utf8');
ast = jsp.parse(orig_code);
ast = pro.ast_mangle(ast);
ast = pro.ast_squeeze(ast);
fs.writeFileSync('./static/' + dest, pro.gen_code(ast), 'utf8');
winston.info('compressed ' + item + ' into ' + dest);
}
}
}
// Send the static documents into the preferred store, skipping expirations
for (var name in config.documents) {
var path = config.documents[name];
fs.readFile(path, 'utf8', function(err, data) {
if (data && !err) {
preferredStore.set(name, data, function(cb) {
winston.info('loaded static document', { name: name, path: path });
}, true);
}
else {
winston.warn('failed to load static document', { name: name, path: path });
}
});
}
// Pick up a key generator
var pwOptions = config.keyGenerator || {};
pwOptions.type = pwOptions.type || 'random';
var gen = require('./lib/key_generators/' + pwOptions.type);
var keyGenerator = new gen(pwOptions);
// Configure the document handler
var documentHandler = new DocumentHandler({
store: preferredStore,
maxLength: config.maxLength,
keyLength: config.keyLength,
keyGenerator: keyGenerator
});
// Set the server up with a static cache
connect.createServer(
// First look for api calls
connect.router(function(app) {
// get raw documents - support getting with extension
app.get('/raw/:id', function(request, response, next) {
var skipExpire = !!config.documents[request.params.id];
var key = request.params.id.split('.')[0];
return documentHandler.handleRawGet(key, response, skipExpire);
});
// add documents
app.post('/documents', function(request, response, next) {
return documentHandler.handlePost(request, response);
});
// get documents
app.get('/documents/:id', function(request, response, next) {
var skipExpire = !!config.documents[request.params.id];
return documentHandler.handleGet(request.params.id, response, skipExpire);
});
}),
// Otherwise, static
connect.staticCache(),
connect.static(__dirname + '/static', { maxAge: config.staticMaxAge }),
// Then we can loop back - and everything else should be a token,
// so route it back to /index.html
connect.router(function(app) {
app.get('/:id', function(request, response, next) {
request.url = request.originalUrl = '/index.html';
next();
});
}),
connect.static(__dirname + '/static', { maxAge: config.staticMaxAge })
).listen(config.port, config.host);
winston.info('listening on ' + config.host + ':' + config.port);
+19
View File
@@ -0,0 +1,19 @@
var DocumentHandler = require('../lib/document_handler');
describe('document_handler', function() {
describe('randomKey', function() {
it('should choose a key of the proper length', function() {
var dh = new DocumentHandler({ keyLength: 6 });
expect(dh.randomKey().length).toBe(6);
});
it('should choose a default key length', function() {
var dh = new DocumentHandler();
expect(dh.keyLength).toBe(DocumentHandler.defaultKeyLength);
});
});
});
+89
View File
@@ -0,0 +1,89 @@
var RedisDocumentStore = require('../lib/redis_document_store');
var winston = require('winston');
winston.remove(winston.transports.Console);
describe('redis_document_store', function() {
/* reconnect to redis on each test */
afterEach(function() {
if (RedisDocumentStore.client) {
RedisDocumentStore.client.quit();
RedisDocumentStore.client = false;
}
});
describe('set', function() {
it('should be able to set a key and have an expiration set', function() {
var store = new RedisDocumentStore({ expire: 10 });
runs(function() {
var _this = this;
store.set('hello1', 'world', function(worked) {
_this.result = worked;
});
});
waitsFor(function() {
return typeof(this.result) === 'boolean';
});
runs(function() {
var _this = this;
RedisDocumentStore.client.ttl('hello1', function(err, res) {
expect(res).toBeGreaterThan(1);
_this.done = true;
});
});
waitsFor(function() {
return this.done;
});
});
it('should not set an expiration when told not to', function() {
var store = new RedisDocumentStore({ expire: 10 });
runs(function() {
var _this = this;
store.set('hello2', 'world', function(worked) {
_this.result = worked;
}, true);
});
waitsFor(function() {
return typeof(this.result) === 'boolean';
});
runs(function() {
var _this = this;
RedisDocumentStore.client.ttl('hello2', function(err, res) {
expect(res).toBe(-1);
_this.done = true;
});
});
waitsFor(function() {
return this.done;
});
});
it('should not set an expiration when expiration is off', function() {
var store = new RedisDocumentStore({ expire: false });
runs(function() {
var _this = this;
store.set('hello3', 'world', function(worked) {
_this.result = worked;
});
});
waitsFor(function() {
return typeof(this.result) === 'boolean';
});
runs(function() {
var _this = this;
RedisDocumentStore.client.ttl('hello3', function(err, res) {
expect(res).toBe(-1);
_this.done = true;
});
});
waitsFor(function() {
return this.done;
});
});
});
});
+168
View File
@@ -0,0 +1,168 @@
body {
background: #002B36;
padding: 20px 50px;
margin: 0px;
}
/* textarea */
textarea {
background: transparent;
border: 0px;
color: #fff;
padding: 0px;
width: 100%;
height: 100%;
font-family: monospace;
outline: none;
resize: none;
font-size: 13px;
}
/* the line numbers */
#linenos {
color: #7d7d7d;
z-index: -1000;
position: absolute;
top: 20px;
left: 0px;
width: 30px; /* 30 to get 20 away from box */
font-size: 13px;
font-family: monospace;
text-align: right;
}
/* code box when locked */
#box {
padding: 0px;
margin: 0px;
width: 100%;
border: 0px;
outline: none;
font-size: 13px;
}
#box code {
padding: 0px;
background: transparent !important; /* don't hide hastebox */
}
/* key */
#key {
position: fixed;
top: 0px;
right: 0px;
z-index: +1000; /* watch out */
}
#box1 {
padding: 5px;
text-align: center;
background: #00222b;
}
#box2 {
background: #08323c;
font-size: 0px;
padding: 0px 5px;
}
#box1 a.logo, #box1 a.logo:visited {
display: inline-block;
background: url(logo.png);
width: 126px;
height: 42px;
}
#box1 a.logo:hover {
background-position: 0 bottom;
}
#box2 .function {
background: url(function-icons.png);
width: 32px;
height: 37px;
display: inline-block;
position: relative;
}
#box2 .link embed {
vertical-align: bottom; /* fix for zeroClipboard style */
}
#box2 .function.enabled:hover {
cursor: hand;
cursor: pointer;
}
#pointer {
display: block;
height: 5px;
width: 10px;
background: url(hover-dropdown-tip.png);
bottom: 0px;
position: absolute;
margin: auto;
left: 0px;
right: 0px;
}
#box3, #messages li {
background: #173e48;
font-family: Helvetica, sans-serif;
font-size: 12px;
line-height: 14px;
padding: 10px 15px;
}
#box3 .label, #messages li {
color: #fff;
font-weight: bold;
}
#box3 .shortcut {
color: #c4dce3;
font-weight: normal;
}
#box2 .function.save { background-position: -5px top; }
#box2 .function.enabled.save { background-position: -5px center; }
#box2 .function.enabled.save:hover { background-position: -5px bottom; }
#box2 .function.new { background-position: -42px top; }
#box2 .function.enabled.new { background-position: -42px center; }
#box2 .function.enabled.new:hover { background-position: -42px bottom; }
#box2 .function.duplicate { background-position: -79px top; }
#box2 .function.enabled.duplicate { background-position: -79px center; }
#box2 .function.enabled.duplicate:hover { background-position: -79px bottom; }
#box2 .function.raw { background-position: -116px top; }
#box2 .function.enabled.raw { background-position: -116px center; }
#box2 .function.enabled.raw:hover { background-position: -116px bottom; }
#box2 .function.twitter { background-position: -153px top; }
#box2 .function.enabled.twitter { background-position: -153px center; }
#box2 .function.enabled.twitter:hover { background-position: -153px bottom; }
#messages {
position:fixed;
top:0px;
right:138px;
margin:0;
padding:0;
width:400px;
}
#messages li {
background:rgba(23,62,72,0.8);
margin:0 auto;
list-style:none;
}
#messages li.error {
background:rgba(102,8,0,0.8);
}
+395
View File
@@ -0,0 +1,395 @@
///// represents a single document
var haste_document = function() {
this.locked = false;
};
// Escapes HTML tag characters
haste_document.prototype.htmlEscape = function(s) {
return s
.replace(/&/g, '&amp;')
.replace(/>/g, '&gt;')
.replace(/</g, '&lt;')
.replace(/"/g, '&quot;');
};
// Get this document from the server and lock it here
haste_document.prototype.load = function(key, callback, lang) {
var _this = this;
$.ajax('/documents/' + key, {
type: 'get',
dataType: 'json',
success: function(res) {
_this.locked = true;
_this.key = key;
_this.data = res.data;
try {
var high;
if (lang === 'txt') {
high = { value: _this.htmlEscape(res.data) };
}
else if (lang) {
high = hljs.highlight(lang, res.data);
}
else {
high = hljs.highlightAuto(res.data);
}
} catch(err) {
// failed highlight, fall back on auto
high = hljs.highlightAuto(res.data);
}
callback({
value: high.value,
key: key,
language: high.language || lang,
lineCount: res.data.split("\n").length
});
},
error: function(err) {
callback(false);
}
});
};
// Save this document to the server and lock it here
haste_document.prototype.save = function(data, callback) {
if (this.locked) {
return false;
}
this.data = data;
var _this = this;
$.ajax('/documents', {
type: 'post',
data: data,
dataType: 'json',
success: function(res) {
_this.locked = true;
_this.key = res.key;
var high = hljs.highlightAuto(data);
callback(null, {
value: high.value,
key: res.key,
language: high.language,
lineCount: data.split("\n").length
});
},
error: function(res) {
try {
callback($.parseJSON(res.responseText));
}
catch (e) {
callback({message: 'Something went wrong!'});
}
}
});
};
///// represents the paste application
var haste = function(appName, options) {
this.appName = appName;
this.$textarea = $('textarea');
this.$box = $('#box');
this.$code = $('#box code');
this.$linenos = $('#linenos');
this.options = options;
this.configureShortcuts();
this.configureButtons();
// If twitter is disabled, hide the button
if (!options.twitter) {
$('#box2 .twitter').hide();
}
};
// Set the page title - include the appName
haste.prototype.setTitle = function(ext) {
var title = ext ? this.appName + ' - ' + ext : this.appName;
document.title = title;
};
// Show a message box
haste.prototype.showMessage = function(msg, cls) {
var msgBox = $('<li class="'+(cls || 'info')+'">'+msg+'</li>');
$('#messages').prepend(msgBox);
setTimeout(function() {
msgBox.slideUp('fast', function() { $(this).remove(); });
}, 3000);
};
// Show the light key
haste.prototype.lightKey = function() {
this.configureKey(['new', 'save']);
};
// Show the full key
haste.prototype.fullKey = function() {
this.configureKey(['new', 'duplicate', 'twitter', 'raw']);
};
// Set the key up for certain things to be enabled
haste.prototype.configureKey = function(enable) {
var $this, i = 0;
$('#box2 .function').each(function() {
$this = $(this);
for (i = 0; i < enable.length; i++) {
if ($this.hasClass(enable[i])) {
$this.addClass('enabled');
return true;
}
}
$this.removeClass('enabled');
});
};
// Remove the current document (if there is one)
// and set up for a new one
haste.prototype.newDocument = function(hideHistory) {
this.$box.hide();
this.doc = new haste_document();
if (!hideHistory) {
window.history.pushState(null, this.appName, '/');
}
this.setTitle();
this.lightKey();
this.$textarea.val('').show('fast', function() {
this.focus();
});
this.removeLineNumbers();
};
// Map of common extensions
// Note: this list does not need to include anything that IS its extension,
// due to the behavior of lookupTypeByExtension and lookupExtensionByType
// Note: optimized for lookupTypeByExtension
haste.extensionMap = {
rb: 'ruby', py: 'python', pl: 'perl', php: 'php', scala: 'scala', go: 'go',
xml: 'xml', html: 'xml', htm: 'xml', css: 'css', js: 'javascript', vbs: 'vbscript',
lua: 'lua', pas: 'delphi', java: 'java', cpp: 'cpp', cc: 'cpp', m: 'objectivec',
vala: 'vala', cs: 'cs', sql: 'sql', sm: 'smalltalk', lisp: 'lisp', ini: 'ini',
diff: 'diff', bash: 'bash', sh: 'bash', tex: 'tex', erl: 'erlang', hs: 'haskell',
md: 'markdown', txt: ''
};
// Look up the extension preferred for a type
// If not found, return the type itself - which we'll place as the extension
haste.prototype.lookupExtensionByType = function(type) {
for (var key in haste.extensionMap) {
if (haste.extensionMap[key] === type) return key;
}
return type;
};
// Look up the type for a given extension
// If not found, return the extension - which we'll attempt to use as the type
haste.prototype.lookupTypeByExtension = function(ext) {
return haste.extensionMap[ext] || ext;
};
// Add line numbers to the document
// For the specified number of lines
haste.prototype.addLineNumbers = function(lineCount) {
var h = '';
for (var i = 0; i < lineCount; i++) {
h += (i + 1).toString() + '<br/>';
}
$('#linenos').html(h);
};
// Remove the line numbers
haste.prototype.removeLineNumbers = function() {
$('#linenos').html('&gt;');
};
// Load a document and show it
haste.prototype.loadDocument = function(key) {
// Split the key up
var parts = key.split('.', 2);
// Ask for what we want
var _this = this;
_this.doc = new haste_document();
_this.doc.load(parts[0], function(ret) {
if (ret) {
_this.$code.html(ret.value);
_this.setTitle(ret.key);
_this.fullKey();
_this.$textarea.val('').hide();
_this.$box.show().focus();
_this.addLineNumbers(ret.lineCount);
}
else {
_this.newDocument();
}
}, this.lookupTypeByExtension(parts[1]));
};
// Duplicate the current document - only if locked
haste.prototype.duplicateDocument = function() {
if (this.doc.locked) {
var currentData = this.doc.data;
this.newDocument();
this.$textarea.val(currentData);
}
};
// Lock the current document
haste.prototype.lockDocument = function() {
var _this = this;
this.doc.save(this.$textarea.val(), function(err, ret) {
if (err) {
_this.showMessage(err.message, 'error');
}
else if (ret) {
_this.$code.html(ret.value);
_this.setTitle(ret.key);
var file = '/' + ret.key;
if (ret.language) {
file += '.' + _this.lookupExtensionByType(ret.language);
}
window.history.pushState(null, _this.appName + '-' + ret.key, file);
_this.fullKey();
_this.$textarea.val('').hide();
_this.$box.show().focus();
_this.addLineNumbers(ret.lineCount);
}
});
};
haste.prototype.configureButtons = function() {
var _this = this;
this.buttons = [
{
$where: $('#box2 .save'),
label: 'Save',
shortcutDescription: 'control + s',
shortcut: function(evt) {
return evt.ctrlKey && (evt.keyCode === 83);
},
action: function() {
if (_this.$textarea.val().replace(/^\s+|\s+$/g, '') !== '') {
_this.lockDocument();
}
}
},
{
$where: $('#box2 .new'),
label: 'New',
shortcut: function(evt) {
return evt.ctrlKey && evt.keyCode === 78
},
shortcutDescription: 'control + n',
action: function() {
_this.newDocument(!_this.doc.key);
}
},
{
$where: $('#box2 .duplicate'),
label: 'Duplicate & Edit',
shortcut: function(evt) {
return _this.doc.locked && evt.ctrlKey && evt.keyCode === 68;
},
shortcutDescription: 'control + d',
action: function() {
_this.duplicateDocument();
}
},
{
$where: $('#box2 .raw'),
label: 'Just Text',
shortcut: function(evt) {
return evt.ctrlKey && evt.shiftKey && evt.keyCode === 82;
},
shortcutDescription: 'control + shift + r',
action: function() {
window.open('/raw/' + _this.doc.key);
}
},
{
$where: $('#box2 .twitter'),
label: 'Twitter',
shortcut: function(evt) {
return _this.options.twitter && _this.doc.locked && evt.ctrlKey && evt.keyCode == 84;
},
shortcutDescription: 'control + t',
action: function() {
window.open('https://twitter.com/share?url=' + encodeURI(window.location.href));
}
}
];
for (var i = 0; i < this.buttons.length; i++) {
this.configureButton(this.buttons[i]);
}
};
haste.prototype.configureButton = function(options) {
// Handle the click action
options.$where.click(function(evt) {
evt.preventDefault();
if (!options.clickDisabled && $(this).hasClass('enabled')) {
options.action();
}
});
// Show the label
options.$where.mouseenter(function(evt) {
$('#box3 .label').text(options.label);
$('#box3 .shortcut').text(options.shortcutDescription || '');
$('#box3').show();
$(this).append($('#pointer').remove().show());
});
// Hide the label
options.$where.mouseleave(function(evt) {
$('#box3').hide();
$('#pointer').hide();
});
};
// Configure keyboard shortcuts for the textarea
haste.prototype.configureShortcuts = function() {
var _this = this;
$(document.body).keydown(function(evt) {
var button;
for (var i = 0 ; i < _this.buttons.length; i++) {
button = _this.buttons[i];
if (button.shortcut && button.shortcut(evt)) {
evt.preventDefault();
button.action();
return;
}
}
});
};
///// Tab behavior in the textarea - 2 spaces per tab
$(function() {
$('textarea').keydown(function(evt) {
if (evt.keyCode === 9) {
evt.preventDefault();
var myValue = ' ';
// http://stackoverflow.com/questions/946534/insert-text-into-textarea-with-jquery
// For browsers like Internet Explorer
if (document.selection) {
this.focus();
sel = document.selection.createRange();
sel.text = myValue;
this.focus();
}
// Mozilla and Webkit
else if (this.selectionStart || this.selectionStart == '0') {
var startPos = this.selectionStart;
var endPos = this.selectionEnd;
var scrollTop = this.scrollTop;
this.value = this.value.substring(0, startPos) + myValue +
this.value.substring(endPos,this.value.length);
this.focus();
this.selectionStart = startPos + myValue.length;
this.selectionEnd = startPos + myValue.length;
this.scrollTop = scrollTop;
}
else {
this.value += myValue;
this.focus();
}
}
});
});
+1
View File
File diff suppressed because one or more lines are too long
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

+1
View File
File diff suppressed because one or more lines are too long
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

+68
View File
@@ -0,0 +1,68 @@
<html>
<head>
<title>hastebin</title>
<link rel="stylesheet" type="text/css" href="solarized_dark.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="highlight.min.js"></script>
<script type="text/javascript" src="application.min.js"></script>
<meta name="robots" content="noindex,nofollow"/>
<script type="text/javascript">
var app = null;
// Handle pops
var handlePop = function(evt) {
var path = evt.target.location.pathname;
if (path === '/') { app.newDocument(true); }
else { app.loadDocument(path.substring(1, path.length)); }
};
// Set up the pop state to handle loads, skipping the first load
// to make chrome behave like others:
// http://code.google.com/p/chromium/issues/detail?id=63040
setTimeout(function() {
window.onpopstate = function(evt) {
try { handlePop(evt); } catch(err) { /* not loaded yet */ }
};
}, 1000);
// Construct app and load initial path
$(function() {
app = new haste('hastebin', { twitter: true });
handlePop({ target: window });
});
</script>
</head>
<body>
<ul id="messages"></ul>
<div id="key">
<div id="pointer" style="display:none;"></div>
<div id="box1">
<a href="/about.md" class="logo"></a>
</div>
<div id="box2">
<div class="save function"></div>
<div class="new function"></div>
<div class="duplicate function"></div>
<div class="raw function"></div>
<div class="twitter function"></div>
</div>
<div id="box3" style="display:none;">
<div class="label"></div>
<div class="shortcut"></div>
</div>
</div>
<div id="linenos"></div>
<pre id="box" style="display:none;" tabindex="0"><code></code></pre>
<textarea spellcheck="false" style="display:none;"></textarea>
</body>
</html>
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

+4
View File
@@ -0,0 +1,4 @@
User-agent: *
Disallow: /*
Allow: /?okparam=
Allow: /$
+98
View File
@@ -0,0 +1,98 @@
/*
Orginal Style from ethanschoonover.com/solarized (c) Jeremy Hull <sourdrums@gmail.com>
*/
pre code {
display: block; padding: 0.5em;
background: #002b36; color: #92a0a0;
}
pre .comment,
pre .template_comment,
pre .diff .header,
pre .doctype,
pre .lisp .string,
pre .javadoc {
color: #586e75;
font-style: italic;
}
pre .keyword,
pre .css .rule .keyword,
pre .winutils,
pre .javascript .title,
pre .method,
pre .addition,
pre .css .tag,
pre .lisp .title {
color: #859900;
}
pre .number,
pre .command,
pre .string,
pre .tag .value,
pre .phpdoc,
pre .tex .formula,
pre .regexp,
pre .hexcolor {
color: #2aa198;
}
pre .title,
pre .localvars,
pre .function .title,
pre .chunk,
pre .decorator,
pre .builtin,
pre .built_in,
pre .lisp .title,
pre .identifier,
pre .title .keymethods,
pre .id,
pre .header {
color: #268bd2;
}
pre .tag .title,
pre .rules .property,
pre .django .tag .keyword {
font-weight: bold;
}
pre .attribute,
pre .variable,
pre .instancevar,
pre .lisp .body,
pre .smalltalk .number,
pre .constant,
pre .class .title,
pre .parent,
pre .haskell .label {
color: #b58900;
}
pre .preprocessor,
pre .pi,
pre .shebang,
pre .symbol,
pre .diff .change,
pre .special,
pre .keymethods,
pre .attr_selector,
pre .important,
pre .subst,
pre .cdata {
color: #cb4b16;
}
pre .deletion {
color: #dc322f;
}
pre .tex .formula,
pre .code {
background: #073642;
}
-69
View File
@@ -1,69 +0,0 @@
.highlight { background: #ffffff; }
.highlight .c { color: #999988; font-style: italic } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { font-weight: bold } /* Keyword */
.highlight .o { font-weight: bold } /* Operator */
.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */
.highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */
.highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #999999 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #800080; font-weight: bold; } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { font-weight: bold } /* Keyword.Constant */
.highlight .kd { font-weight: bold } /* Keyword.Declaration */
.highlight .kn { font-weight: bold } /* Keyword.Namespace */
.highlight .kp { font-weight: bold } /* Keyword.Pseudo */
.highlight .kr { font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #009999 } /* Literal.Number */
.highlight .s { color: #d14 } /* Literal.String */
.highlight .na { color: #008080 } /* Name.Attribute */
.highlight .nb { color: #0086B3 } /* Name.Builtin */
.highlight .nc { color: #445588; font-weight: bold } /* Name.Class */
.highlight .no { color: #008080 } /* Name.Constant */
.highlight .ni { color: #800080 } /* Name.Entity */
.highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #990000; font-weight: bold } /* Name.Function */
.highlight .nn { color: #555555 } /* Name.Namespace */
.highlight .nt { color: #000080 } /* Name.Tag */
.highlight .nv { color: #008080 } /* Name.Variable */
.highlight .ow { font-weight: bold } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mf { color: #009999 } /* Literal.Number.Float */
.highlight .mh { color: #009999 } /* Literal.Number.Hex */
.highlight .mi { color: #009999 } /* Literal.Number.Integer */
.highlight .mo { color: #009999 } /* Literal.Number.Oct */
.highlight .sb { color: #d14 } /* Literal.String.Backtick */
.highlight .sc { color: #d14 } /* Literal.String.Char */
.highlight .sd { color: #d14 } /* Literal.String.Doc */
.highlight .s2 { color: #d14 } /* Literal.String.Double */
.highlight .se { color: #d14 } /* Literal.String.Escape */
.highlight .sh { color: #d14 } /* Literal.String.Heredoc */
.highlight .si { color: #d14 } /* Literal.String.Interpol */
.highlight .sx { color: #d14 } /* Literal.String.Other */
.highlight .sr { color: #009926 } /* Literal.String.Regex */
.highlight .s1 { color: #d14 } /* Literal.String.Single */
.highlight .ss { color: #990073 } /* Literal.String.Symbol */
.highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */
.highlight .vc { color: #008080 } /* Name.Variable.Class */
.highlight .vg { color: #008080 } /* Name.Variable.Global */
.highlight .vi { color: #008080 } /* Name.Variable.Instance */
.highlight .il { color: #009999 } /* Literal.Number.Integer.Long */
.type-csharp .highlight .k { color: #0000FF }
.type-csharp .highlight .kt { color: #0000FF }
.type-csharp .highlight .nf { color: #000000; font-weight: normal }
.type-csharp .highlight .nc { color: #2B91AF }
.type-csharp .highlight .nn { color: #000000 }
.type-csharp .highlight .s { color: #A31515 }
.type-csharp .highlight .sc { color: #A31515 }
-255
View File
@@ -1,255 +0,0 @@
@import url(https://fonts.googleapis.com/css?family=Lato:300italic,700italic,300,700);
body {
padding:50px;
font:14px/1.5 Lato, "Helvetica Neue", Helvetica, Arial, sans-serif;
color:#777;
font-weight:300;
}
h1, h2, h3, h4, h5, h6 {
color:#222;
margin:0 0 20px;
}
p, ul, ol, table, pre, dl {
margin:0 0 20px;
}
h1, h2, h3 {
line-height:1.1;
}
h1 {
font-size:28px;
}
h2 {
color:#393939;
}
h3, h4, h5, h6 {
color:#494949;
}
a {
color:#39c;
font-weight:400;
text-decoration:none;
}
a small {
font-size:11px;
color:#777;
margin-top:-0.6em;
display:block;
}
.wrapper {
width:860px;
margin:0 auto;
}
blockquote {
border-left:1px solid #e5e5e5;
margin:0;
padding:0 0 0 20px;
font-style:italic;
}
code, pre {
font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal;
color:#333;
font-size:12px;
}
pre {
padding:8px 15px;
background: #f8f8f8;
border-radius:5px;
border:1px solid #e5e5e5;
overflow-x: auto;
}
table {
width:100%;
border-collapse:collapse;
}
th, td {
text-align:left;
padding:5px 10px;
border-bottom:1px solid #e5e5e5;
}
dt {
color:#444;
font-weight:700;
}
th {
color:#444;
}
img {
max-width:100%;
}
header {
width:270px;
float:left;
position:fixed;
}
header ul {
list-style:none;
height:40px;
padding:0;
background: #eee;
background: -moz-linear-gradient(top, #f8f8f8 0%, #dddddd 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd));
background: -webkit-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
background: -o-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
background: -ms-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
background: linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
border-radius:5px;
border:1px solid #d2d2d2;
box-shadow:inset #fff 0 1px 0, inset rgba(0,0,0,0.03) 0 -1px 0;
width:270px;
}
header li {
width:89px;
float:left;
border-right:1px solid #d2d2d2;
height:40px;
}
header ul a {
line-height:1;
font-size:11px;
color:#999;
display:block;
text-align:center;
padding-top:6px;
height:40px;
}
strong {
color:#222;
font-weight:700;
}
header ul li + li {
width:88px;
border-left:1px solid #fff;
}
header ul li + li + li {
border-right:none;
width:89px;
}
header ul a strong {
font-size:14px;
display:block;
color:#222;
}
section {
width:500px;
float:right;
padding-bottom:50px;
}
small {
font-size:11px;
}
hr {
border:0;
background:#e5e5e5;
height:1px;
margin:0 0 20px;
}
footer {
width:270px;
float:left;
position:fixed;
bottom:50px;
}
@media print, screen and (max-width: 960px) {
div.wrapper {
width:auto;
margin:0;
}
header, section, footer {
float:none;
position:static;
width:auto;
}
header {
padding-right:320px;
}
section {
border:1px solid #e5e5e5;
border-width:1px 0;
padding:20px 0;
margin:0 0 20px;
}
header a small {
display:inline;
}
header ul {
position:absolute;
right:50px;
top:52px;
}
}
@media print, screen and (max-width: 720px) {
body {
word-wrap:break-word;
}
header {
padding:0;
}
header ul, header p.view {
position:static;
}
pre, code {
word-wrap:normal;
}
}
@media print, screen and (max-width: 480px) {
body {
padding:15px;
}
header ul {
display:none;
}
}
@media print {
body {
padding:0.4in;
font-size:12pt;
color:#444;
}
}