Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
844a2efb02 | ||
|
|
b251978422 | ||
|
|
9fdcd08591 | ||
|
|
d87c3b7d61 | ||
|
|
31a701d491 | ||
|
|
cc65e98940 | ||
|
|
a958c66249 | ||
|
|
8c2add94a2 | ||
|
|
71c791c113 | ||
|
|
b38d2375ee | ||
|
|
6145a938e3 | ||
|
|
7a946f4967 | ||
|
|
87c935ac47 | ||
|
|
14a23388a8 | ||
|
|
44f7ab3f33 | ||
|
|
8add4917d5 | ||
|
|
3a6b36ebaa | ||
|
|
49bb449141 | ||
|
|
8e46ee620f | ||
|
|
907a7c0929 | ||
|
|
242d8475cf | ||
|
|
8e3bc9826b | ||
|
|
335ae24dc5 | ||
|
|
2fdcd316f7 | ||
|
|
da407cfbb6 | ||
|
|
0f02d83d24 | ||
|
|
615fedd6c7 | ||
|
|
4e20ea078f | ||
|
|
15bd62836b | ||
|
|
8eb1b54615 | ||
|
|
0e292ad21b | ||
|
|
9378f2b2e4 | ||
|
|
344d1fec7b | ||
|
|
d1ff598f50 | ||
|
|
6448139396 | ||
|
|
87f5af3194 | ||
|
|
82af7a221a | ||
|
|
01d9337f10 | ||
|
|
844e664cb5 | ||
|
|
68c4fc2534 | ||
|
|
83959a77fc | ||
|
|
565830214b | ||
|
|
43e5667ff9 | ||
|
|
f755b675d0 | ||
|
|
9157a0227d | ||
|
|
8eca87ce03 | ||
|
|
2de05d9055 | ||
|
|
a1ba8b6b71 | ||
|
|
96b3249b09 | ||
|
|
81c41c0f37 | ||
|
|
52198b97b2 | ||
|
|
17897e8155 | ||
|
|
f651c30981 | ||
|
|
9e046ba8eb | ||
|
|
a5459fc29b | ||
|
|
1ed980150c | ||
|
|
6e2955d60c | ||
|
|
92e0f579ca | ||
|
|
cd9bf18d29 | ||
|
|
895485e410 | ||
|
|
29651ebfd5 | ||
|
|
983749e4af | ||
|
|
0ea5b65eba | ||
|
|
2a3a9046d8 | ||
|
|
481155194a | ||
|
|
0875ba6252 | ||
|
|
d3ba2e4b5b | ||
|
|
4233e58995 | ||
|
|
c4a5184962 | ||
|
|
85fac80a6d | ||
|
|
0a0e1636bc | ||
|
|
b47e5ad2a8 | ||
|
|
d262c9f853 | ||
|
|
fb0c439879 | ||
|
|
e0941d5ac9 | ||
|
|
591fd456d6 | ||
|
|
8281d382e4 | ||
|
|
6285d665ad | ||
|
|
12aa622c2d | ||
|
|
a7aec372d5 | ||
|
|
d6468ad5fb | ||
|
|
607d3eb3ac | ||
|
|
b598e73d3f | ||
|
|
6906ad4253 | ||
|
|
167c7c4adb | ||
|
|
1dbaa54811 | ||
|
|
a1803305fb | ||
|
|
62e04cbf5b | ||
|
|
7f4cae57f9 | ||
|
|
315333d8eb | ||
|
|
2089a14ad7 | ||
|
|
f601d9f159 | ||
|
|
ab47aeb88b | ||
|
|
051a545a55 | ||
|
|
5d889662ef | ||
|
|
ec0d419c61 | ||
|
|
56bf98daac | ||
|
|
2299819781 | ||
|
|
5b66695ca6 | ||
|
|
f81b7ec593 | ||
|
|
e403549e13 | ||
|
|
32b4f842b7 | ||
|
|
9ed330bdae | ||
|
|
1382ec47b2 | ||
|
|
83cb68ada2 | ||
|
|
e4da28de8a | ||
|
|
32d49385a1 | ||
|
|
d0e3e4cd02 | ||
|
|
0f2075fcda | ||
|
|
4ed87c4ec7 | ||
|
|
025dfcfe26 | ||
|
|
39ffbc7f49 | ||
|
|
a9e29c2986 | ||
|
|
29a600fe87 | ||
|
|
4d56fc0e61 | ||
|
|
9fa99fe69d | ||
|
|
9638baffdb | ||
|
|
6499ad3190 | ||
|
|
73be6e31d9 | ||
|
|
af02375b7c | ||
|
|
f54712f9d9 | ||
|
|
b9e9bd154c | ||
|
|
a213bdf9da | ||
|
|
b6eef4b628 | ||
|
|
bece4598f7 | ||
|
|
44350ce9e6 | ||
|
|
00e2ca8d29 | ||
|
|
a2d17b28df | ||
|
|
a1d5f79708 | ||
|
|
26c148ff37 | ||
|
|
6c85c23c6d | ||
|
|
60f412b7bc | ||
|
|
01b622821e | ||
|
|
a83ae523b4 | ||
|
|
83b8f3f52d | ||
|
|
fec02cfead | ||
|
|
b173cdd144 | ||
|
|
0fe0306caa | ||
|
|
a6bd69f20a | ||
|
|
fe68e42b90 | ||
|
|
4a435a4be5 | ||
|
|
f48cc45928 | ||
|
|
7709e12500 | ||
|
|
93435715f2 | ||
|
|
6bdd7d7fc5 | ||
|
|
b159817a27 | ||
|
|
0eed33f42f | ||
|
|
cf384cd0fd | ||
|
|
f935ac56c2 | ||
|
|
d69839b2fb | ||
|
|
3acc2eb17d | ||
|
|
7b2d0f549d | ||
|
|
8a8b438163 | ||
|
|
6597dba36d | ||
|
|
4f00d3c71a | ||
|
|
44d54174ed | ||
|
|
13e497993f | ||
|
|
6bac45efe2 | ||
|
|
b35c89a472 | ||
|
|
f22f347d43 | ||
|
|
7756e38595 | ||
|
|
7cc30e4b69 | ||
|
|
c5a551f770 | ||
|
|
5b874e3456 | ||
|
|
c90561da8e | ||
|
|
90161e780d | ||
|
|
9d0b0c9f21 |
@@ -0,0 +1,6 @@
|
|||||||
|
npm-debug.log
|
||||||
|
node_modules
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
data
|
||||||
|
*.DS_Store
|
||||||
@@ -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
|
||||||
@@ -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>
|
||||||
@@ -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
@@ -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 — Theme by <a href="https://github.com/orderedlist">orderedlist</a></small></p>
|
|
||||||
</footer>
|
|
||||||
</div>
|
|
||||||
<script src="javascripts/scale.fix.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -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";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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;
|
||||||
@@ -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;
|
||||||
@@ -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;
|
||||||
@@ -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;
|
||||||
@@ -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;
|
||||||
@@ -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 +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."}
|
|
||||||
@@ -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);
|
||||||
@@ -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);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
@@ -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;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
@@ -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, '&')
|
||||||
|
.replace(/>/g, '>')
|
||||||
|
.replace(/</g, '<')
|
||||||
|
.replace(/"/g, '"');
|
||||||
|
};
|
||||||
|
|
||||||
|
// 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('>');
|
||||||
|
};
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
Vendored
+1
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 |
Vendored
+1
File diff suppressed because one or more lines are too long
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
@@ -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>
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 4.6 KiB |
@@ -0,0 +1,4 @@
|
|||||||
|
User-agent: *
|
||||||
|
Disallow: /*
|
||||||
|
Allow: /?okparam=
|
||||||
|
Allow: /$
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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 }
|
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user