Compare commits
No commits in common. "master" and "gh-pages" have entirely different histories.
28 changed files with 385 additions and 3657 deletions
|
|
@ -1,8 +0,0 @@
|
|||
Dockerfile
|
||||
.git
|
||||
npm-debug.log
|
||||
node_modules
|
||||
*.swp
|
||||
*.swo
|
||||
data
|
||||
*.DS_Store
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
name: ci
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ['**']
|
||||
tags: ['**']
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
uses: infra/ci-snippets/.forgejo/workflows/docker-build.yml@master
|
||||
secrets: inherit
|
||||
8
.gitignore
vendored
8
.gitignore
vendored
|
|
@ -1,8 +0,0 @@
|
|||
npm-debug.log
|
||||
node_modules
|
||||
*.swp
|
||||
*.swo
|
||||
data
|
||||
*.DS_Store
|
||||
static/dist
|
||||
/haste-server
|
||||
58
Dockerfile
58
Dockerfile
|
|
@ -1,58 +0,0 @@
|
|||
FROM node:26-alpine@sha256:aadf416b2cdce311a8811ba3f0608a61b77dbf997500e2eafe781b51f6a0b019 AS frontend
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
COPY package.json package-lock.json webpack.config.js ./
|
||||
RUN npm ci
|
||||
|
||||
COPY frontend ./frontend
|
||||
RUN npm run build
|
||||
|
||||
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.10.0 AS xx
|
||||
FROM --platform=$BUILDPLATFORM golang:1.27.4-alpine AS build
|
||||
ARG TARGETPLATFORM
|
||||
ARG GOPROXY
|
||||
COPY --from=xx / /
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
COPY go.mod ./
|
||||
RUN go mod download
|
||||
|
||||
COPY . .
|
||||
COPY --from=frontend /src/static/dist ./static/dist
|
||||
|
||||
RUN CGO_ENABLED=0 GOOS=linux xx-go build -ldflags "-w -s" -o /out/haste-server .
|
||||
|
||||
FROM jonasled.dev/infra/images/scratch-rootless:latest@sha256:9e291c85277e40987bdbc84af228b4b40db5c24e1634d047465e2198ed9302e8
|
||||
ENV GIN_MODE=release
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY --from=build /out/haste-server ./haste-server
|
||||
COPY ./static ./static
|
||||
COPY --from=frontend /src/static/dist ./static/dist
|
||||
COPY ./about.md ./about.md
|
||||
|
||||
ENV STORAGE_TYPE=redis \
|
||||
STORAGE_HOST=127.0.0.1 \
|
||||
STORAGE_PORT=6379 \
|
||||
STORAGE_EXPIRE_SECONDS=2592000 \
|
||||
STORAGE_DB=2 \
|
||||
HOST=0.0.0.0 \
|
||||
PORT=7777 \
|
||||
KEY_LENGTH=10 \
|
||||
MAX_LENGTH=400000 \
|
||||
STATIC_MAX_AGE=86400 \
|
||||
KEYGENERATOR_TYPE=phonetic \
|
||||
RATELIMITS_NORMAL_TOTAL_REQUESTS=500 \
|
||||
RATELIMITS_NORMAL_EVERY_MILLISECONDS=60000 \
|
||||
# comma separated list for the whitelisted \
|
||||
RATELIMITS_WHITELIST=example1.whitelist,example2.whitelist \
|
||||
# comma separated list for the blacklisted \
|
||||
RATELIMITS_BLACKLIST=example1.blacklist,example2.blacklist \
|
||||
DOCUMENTS=about=./about.md
|
||||
|
||||
EXPOSE ${PORT}
|
||||
STOPSIGNAL SIGINT
|
||||
CMD ["./haste-server"]
|
||||
1
Procfile
1
Procfile
|
|
@ -1 +0,0 @@
|
|||
web: ./haste-server
|
||||
207
README.md
207
README.md
|
|
@ -1,207 +0,0 @@
|
|||
# Haste
|
||||
|
||||
Haste is an open-source pastebin software written in Go, which is easily
|
||||
installable in any network. It is backed by redis in this version. 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](https://github.com/seejohnrun/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. Check the README there for more details and usages.
|
||||
|
||||
## Tested Browsers
|
||||
|
||||
* Firefox 8
|
||||
* Chrome 17
|
||||
* Safari 5.3
|
||||
|
||||
## Installation
|
||||
|
||||
1. Download the package, and expand it
|
||||
2. Explore the environment variables below, but the defaults should be good
|
||||
3. `go build`
|
||||
4. `./haste-server`
|
||||
|
||||
## Settings
|
||||
|
||||
Haste is configured entirely through environment variables - see the
|
||||
[Docker Configuration](#configuration) section below for the full list.
|
||||
|
||||
* `HOST` - the host the server runs on (default localhost)
|
||||
* `PORT` - the port the server runs on (default 7777)
|
||||
* `KEY_LENGTH` - the length of the keys to use (default 10)
|
||||
* `MAX_LENGTH` - maximum length of a paste (default 400000)
|
||||
* `STATIC_MAX_AGE` - max age for static assets (86400)
|
||||
* `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)
|
||||
* `KEYGENERATOR_*` - key generator options (see below)
|
||||
* `RATELIMITS_*` - settings for rate limiting (see below)
|
||||
|
||||
## Rate Limiting
|
||||
|
||||
Built-in rate limiting can be enabled through the `RATELIMITS_*` environment
|
||||
variables (see below). By default no limits are enforced.
|
||||
|
||||
## 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
|
||||
|
||||
### Redis
|
||||
|
||||
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.
|
||||
|
||||
If your Redis server is configured for password authentification, use the `password` field. `REDISTOGO_URL` is also supported for URL-based Redis deployments.
|
||||
|
||||
Only the Redis backend is implemented in this Go version.
|
||||
|
||||
## Docker
|
||||
|
||||
### Build image
|
||||
|
||||
```bash
|
||||
docker build --tag haste-server .
|
||||
```
|
||||
|
||||
### Run container
|
||||
|
||||
For this example we will run haste-server, and connect it to a redis server
|
||||
|
||||
```bash
|
||||
docker run --name haste-server-container --env STORAGE_TYPE=redis --env STORAGE_HOST=redis-server --env STORAGE_PORT=6379 haste-server
|
||||
```
|
||||
|
||||
### Use docker-compose example
|
||||
|
||||
There is an example `docker-compose.yml` which runs haste-server together with redis
|
||||
|
||||
```bash
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
The docker image is configured using environmental variables as you can see in the example above.
|
||||
|
||||
Here is a list of all the environment variables
|
||||
|
||||
### Storage
|
||||
|
||||
| Name | Default value | Description |
|
||||
| :--------------------: | :-----------: | :-----------------------------------------------------------------------------------------------------------: |
|
||||
| STORAGE_TYPE | redis | Storage type. Only `redis` is supported by this Go backend. |
|
||||
| STORAGE_HOST | 127.0.0.1 | Redis host. |
|
||||
| STORAGE_PORT | 6379 | Redis port. |
|
||||
| STORAGE_EXPIRE_SECONDS | 2592000 | Number of seconds to expire keys in. |
|
||||
| STORAGE_DB | 2 | Redis database index. |
|
||||
| STORAGE_PASSWORD | | Redis password. |
|
||||
|
||||
### Basics
|
||||
|
||||
| Name | Default value | Description |
|
||||
| :----------------------: | :--------------: | :---------------------------------------------------------------------------------------: |
|
||||
| HOST | 0.0.0.0 | The hostname which the server answers on |
|
||||
| PORT | 7777 | The port on which the server is running |
|
||||
| KEY_LENGTH | 10 | the length of the keys to user |
|
||||
| MAX_LENGTH | 400000 | maximum length of a paste |
|
||||
| STATIC_MAX_AGE | 86400 | max age for static assets |
|
||||
| RECOMPRESS_STATIC_ASSETS | true | whether or not to compile static js assets |
|
||||
| KEYGENERATOR_TYPE | phonetic | Type of key generator. Acceptable values: "phonetic", or "random" |
|
||||
| KEYGENERATOR_KEYSPACE | | keySpace argument is a string of acceptable characters |
|
||||
| DOCUMENTS | about=./about.md | Comma separated list of static documents to serve. ex: \n about=./about.md,home=./home.md |
|
||||
|
||||
### Rate limits
|
||||
|
||||
| Name | Default value | Description |
|
||||
| :----------------------------------: | :-----------------------------------: | :--------------------------------------------------------------------------------------: |
|
||||
| RATELIMITS_NORMAL_TOTAL_REQUESTS | 500 | By default anyone uncategorized will be subject to 500 requests in the defined timespan. |
|
||||
| RATELIMITS_NORMAL_EVERY_MILLISECONDS | 60000 | The timespan to allow the total requests for uncategorized users |
|
||||
| RATELIMITS_WHITELIST_TOTAL_REQUESTS | | By default client names in the whitelist will not have their requests limited. |
|
||||
| RATELIMITS_WHITELIST_EVERY_SECONDS | | By default client names in the whitelist will not have their requests limited. |
|
||||
| RATELIMITS_WHITELIST | example1.whitelist,example2.whitelist | Comma separated list of the clients which are in the whitelist pool |
|
||||
| RATELIMITS_BLACKLIST_TOTAL_REQUESTS | | By default client names in the blacklist will be subject to 0 requests per hours. |
|
||||
| RATELIMITS_BLACKLIST_EVERY_SECONDS | | By default client names in the blacklist will be subject to 0 requests per hours |
|
||||
| RATELIMITS_BLACKLIST | example1.blacklist,example2.blacklist | Comma separated list of the clients which are in the blacklistpool. |
|
||||
|
||||
## Author
|
||||
|
||||
John Crepezzi <john.crepezzi@gmail.com>
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright © 2011-2012 John Crepezzi
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the ‘Software’), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
||||
|
||||
### Other components:
|
||||
|
||||
* jQuery: MIT/GPL license
|
||||
* highlight.js: Copyright © 2006, Ivan Sagalaev
|
||||
* highlightjs-coffeescript: WTFPL - Copyright © 2011, Dmytrii Nagirniak
|
||||
62
about.md
62
about.md
|
|
@ -1,62 +0,0 @@
|
|||
# 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, easiest 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, it's 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` # https://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`
|
||||
* windows: check out [WinHaste](https://github.com/ajryan/WinHaste)
|
||||
|
||||
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. They may be removed earlier
|
||||
and without notice.
|
||||
|
||||
## 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 it's 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>
|
||||
Original Design by Brian Dawson <bridawson@gmail.com>
|
||||
Design by Colin Keany
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
version: '3.0'
|
||||
services:
|
||||
haste-server:
|
||||
build: .
|
||||
environment:
|
||||
- STORAGE_TYPE=redis
|
||||
- STORAGE_HOST=redis
|
||||
- STORAGE_PORT=6379
|
||||
- STORAGE_DB=0
|
||||
ports:
|
||||
- 7777:7777
|
||||
redis:
|
||||
image: redis:latest
|
||||
|
|
@ -1,366 +0,0 @@
|
|||
import $ from 'jquery';
|
||||
|
||||
/* global hljs, window, document */
|
||||
|
||||
///// 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() {
|
||||
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',
|
||||
contentType: 'text/plain; charset=utf-8',
|
||||
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', sql: 'sql', sm: 'smalltalk', lisp: 'lisp', ini: 'ini',
|
||||
diff: 'diff', bash: 'bash', sh: 'bash', tex: 'tex', erl: 'erlang', hs: 'haskell',
|
||||
md: 'markdown', txt: '', coffee: 'coffee', swift: 'swift'
|
||||
};
|
||||
|
||||
// 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.location.href = '/raw/' + _this.doc.key;
|
||||
}
|
||||
},
|
||||
{
|
||||
$where: $('#box2 .twitter'),
|
||||
label: 'Twitter',
|
||||
shortcut: function(evt) {
|
||||
return _this.options.twitter && _this.doc.locked && evt.shiftKey && evt.ctrlKey && evt.keyCode == 84;
|
||||
},
|
||||
shortcutDescription: 'control + shift + 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() {
|
||||
$('#box3 .label').text(options.label);
|
||||
$('#box3 .shortcut').text(options.shortcutDescription || '');
|
||||
$('#box3').show();
|
||||
$(this).append($('#pointer').remove().show());
|
||||
});
|
||||
// Hide the label
|
||||
options.$where.mouseleave(function() {
|
||||
$('#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;
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export { haste_document, haste };
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
import $ from 'jquery';
|
||||
import { haste } from './haste';
|
||||
|
||||
/* global window, document */
|
||||
|
||||
var app = null;
|
||||
|
||||
// Handle pops
|
||||
function handlePop(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 });
|
||||
});
|
||||
|
||||
///// 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();
|
||||
var 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();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
12
go.mod
12
go.mod
|
|
@ -1,12 +0,0 @@
|
|||
module haste-server
|
||||
|
||||
go 1.26.0
|
||||
|
||||
require github.com/redis/go-redis/v9 v9.23.0
|
||||
|
||||
require (
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
go.uber.org/atomic v1.12.0 // indirect
|
||||
golang.org/x/sys v0.48.0 // indirect
|
||||
)
|
||||
24
go.sum
24
go.sum
|
|
@ -1,24 +0,0 @@
|
|||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
||||
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/redis/go-redis/v9 v9.16.0 h1:OotgqgLSRCmzfqChbQyG1PHC3tLNR89DG4jdOERSEP4=
|
||||
github.com/redis/go-redis/v9 v9.16.0/go.mod h1:u410H11HMLoB+TP67dz8rL9s6QW2j76l0//kSOd3370=
|
||||
github.com/redis/go-redis/v9 v9.21.0 h1:FPBE4hhbAke+TLmcY3WkpbDffJEomdqPn3HYiqAtL9E=
|
||||
github.com/redis/go-redis/v9 v9.21.0/go.mod h1:v/M13XI1PVCDcm01VtPFOADfZtHf8YW3baQf57KlIkA=
|
||||
github.com/redis/go-redis/v9 v9.22.0 h1:laDvpYXTJtZLloinw1fA5Kqd6HAEH2XKxOkG/PDq2F0=
|
||||
github.com/redis/go-redis/v9 v9.22.0/go.mod h1:y2g0Wj8rQvuK0ELM+oxSudcLtC09JScs98I/X9gRWY4=
|
||||
github.com/redis/go-redis/v9 v9.23.0 h1:/TTVdJa8BRNsybwwGGnmiYktHNlUXtbOQxlWpHBPL3s=
|
||||
github.com/redis/go-redis/v9 v9.23.0/go.mod h1:EWP2UUk+XDaI1s5nQB5mablZN6vccXlmBQTyfnF87D0=
|
||||
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
|
||||
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
go.uber.org/atomic v1.12.0 h1:BvcXdFKuviU4fTL/f+SxdQ5qJX/Jix8pAkgdUcb3XOE=
|
||||
go.uber.org/atomic v1.12.0/go.mod h1:I6c4cg+6HCxRjfjSsYtApoFILnpc0CGUdGkXVqbYVNk=
|
||||
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
||||
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
43
index.html
Normal file
43
index.html
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<!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>
|
||||
17
javascripts/scale.fix.js
Normal file
17
javascripts/scale.fix.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
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";
|
||||
}
|
||||
}
|
||||
}
|
||||
774
main.go
774
main.go
|
|
@ -1,774 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"embed"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
mathrand "math/rand"
|
||||
"mime"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
//go:embed static/*
|
||||
var embeddedStatic embed.FS
|
||||
|
||||
type Config struct {
|
||||
Host string
|
||||
Port int
|
||||
KeyLength int
|
||||
MaxLength int
|
||||
StaticMaxAge int
|
||||
KeyGenerator KeyGeneratorConfig
|
||||
RateLimits RateLimitsConfig
|
||||
Storage StorageConfig
|
||||
Documents map[string]string
|
||||
}
|
||||
|
||||
type KeyGeneratorConfig struct {
|
||||
Type string
|
||||
Keyspace string
|
||||
Path string
|
||||
}
|
||||
|
||||
type RateLimitsConfig struct {
|
||||
Whitelist []string
|
||||
Blacklist []string
|
||||
Categories map[string]RateLimitBucket
|
||||
}
|
||||
|
||||
type RateLimitBucket struct {
|
||||
TotalRequests int
|
||||
Every int
|
||||
}
|
||||
|
||||
type StorageConfig struct {
|
||||
Type string
|
||||
Host string
|
||||
Port int
|
||||
Expire int
|
||||
DB int
|
||||
Password string
|
||||
}
|
||||
|
||||
type DocumentStore interface {
|
||||
Get(ctx context.Context, key string, skipExpire bool) (string, bool, error)
|
||||
Set(ctx context.Context, key, value string, skipExpire bool) error
|
||||
}
|
||||
|
||||
type RedisStore struct {
|
||||
client *redis.Client
|
||||
expire time.Duration
|
||||
}
|
||||
|
||||
func NewRedisStore(cfg StorageConfig) (*RedisStore, error) {
|
||||
if rawURL := os.Getenv("REDISTOGO_URL"); rawURL != "" {
|
||||
opts, err := redis.ParseURL(rawURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
client := redis.NewClient(opts)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
if err := client.Ping(ctx).Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
store := &RedisStore{
|
||||
client: client,
|
||||
expire: time.Duration(cfg.Expire) * time.Second,
|
||||
}
|
||||
log.Printf("connected to redis via REDISTOGO_URL")
|
||||
return store, nil
|
||||
}
|
||||
|
||||
host := cfg.Host
|
||||
if host == "" {
|
||||
host = "127.0.0.1"
|
||||
}
|
||||
port := cfg.Port
|
||||
if port == 0 {
|
||||
port = 6379
|
||||
}
|
||||
|
||||
client := redis.NewClient(&redis.Options{
|
||||
Addr: fmt.Sprintf("%s:%d", host, port),
|
||||
Password: cfg.Password,
|
||||
DB: cfg.DB,
|
||||
})
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
if err := client.Ping(ctx).Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
store := &RedisStore{
|
||||
client: client,
|
||||
expire: time.Duration(cfg.Expire) * time.Second,
|
||||
}
|
||||
log.Printf("connected to redis on %s:%d/%d", host, port, cfg.DB)
|
||||
return store, nil
|
||||
}
|
||||
|
||||
func (s *RedisStore) Get(ctx context.Context, key string, skipExpire bool) (string, bool, error) {
|
||||
val, err := s.client.Get(ctx, key).Result()
|
||||
if errors.Is(err, redis.Nil) {
|
||||
return "", false, nil
|
||||
}
|
||||
if err != nil {
|
||||
return "", false, err
|
||||
}
|
||||
if !skipExpire && s.expire > 0 {
|
||||
go s.client.Expire(context.Background(), key, s.expire)
|
||||
}
|
||||
return val, true, nil
|
||||
}
|
||||
|
||||
func (s *RedisStore) Set(ctx context.Context, key, value string, skipExpire bool) error {
|
||||
if err := s.client.Set(ctx, key, value, 0).Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
if !skipExpire && s.expire > 0 {
|
||||
go s.client.Expire(context.Background(), key, s.expire)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type KeyGenerator interface {
|
||||
CreateKey(length int) string
|
||||
}
|
||||
|
||||
type RandomKeyGenerator struct {
|
||||
keyspace string
|
||||
}
|
||||
|
||||
func (g RandomKeyGenerator) CreateKey(length int) string {
|
||||
if g.keyspace == "" {
|
||||
g.keyspace = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||
}
|
||||
var b strings.Builder
|
||||
for i := 0; i < length; i++ {
|
||||
b.WriteByte(g.keyspace[mathrand.Intn(len(g.keyspace))])
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
type PhoneticKeyGenerator struct{}
|
||||
|
||||
func (g PhoneticKeyGenerator) CreateKey(length int) string {
|
||||
const vowels = "aeiou"
|
||||
const consonants = "bcdfghjklmnpqrstvwxyz"
|
||||
start := mathrand.Intn(2)
|
||||
var b strings.Builder
|
||||
for i := 0; i < length; i++ {
|
||||
if i%2 == start {
|
||||
b.WriteByte(consonants[mathrand.Intn(len(consonants))])
|
||||
continue
|
||||
}
|
||||
b.WriteByte(vowels[mathrand.Intn(len(vowels))])
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
type DictionaryKeyGenerator struct {
|
||||
words []string
|
||||
}
|
||||
|
||||
func (g DictionaryKeyGenerator) CreateKey(length int) string {
|
||||
var b strings.Builder
|
||||
for i := 0; i < length; i++ {
|
||||
b.WriteString(g.words[mathrand.Intn(len(g.words))])
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
cfg Config
|
||||
store DocumentStore
|
||||
keyGenerator KeyGenerator
|
||||
rateLimiter *RateLimiter
|
||||
staticDocs map[string]struct{}
|
||||
staticDir string
|
||||
}
|
||||
|
||||
func main() {
|
||||
seedMathRand()
|
||||
|
||||
cfg := loadConfig()
|
||||
|
||||
if cfg.Storage.Type == "" {
|
||||
cfg.Storage.Type = "redis"
|
||||
}
|
||||
if cfg.Storage.Type != "redis" {
|
||||
log.Fatalf("unsupported storage type %q: only redis is implemented in the Go backend", cfg.Storage.Type)
|
||||
}
|
||||
|
||||
store, err := NewRedisStore(cfg.Storage)
|
||||
if err != nil {
|
||||
log.Fatalf("connect redis: %v", err)
|
||||
}
|
||||
|
||||
keyGenerator, err := newKeyGenerator(cfg.KeyGenerator)
|
||||
if err != nil {
|
||||
log.Fatalf("configure key generator: %v", err)
|
||||
}
|
||||
|
||||
srv := &Server{
|
||||
cfg: cfg,
|
||||
store: store,
|
||||
keyGenerator: keyGenerator,
|
||||
rateLimiter: NewRateLimiter(cfg.RateLimits),
|
||||
staticDocs: make(map[string]struct{}, len(cfg.Documents)),
|
||||
staticDir: filepath.Join(".", "static"),
|
||||
}
|
||||
|
||||
if err := srv.loadStaticDocuments(); err != nil {
|
||||
log.Fatalf("load static documents: %v", err)
|
||||
}
|
||||
|
||||
address := net.JoinHostPort(cfg.Host, strconv.Itoa(cfg.Port))
|
||||
log.Printf("listening on %s", address)
|
||||
serve := &http.Server{
|
||||
Addr: address,
|
||||
Handler: srv.routes(),
|
||||
ReadHeaderTimeout: 5 * time.Second,
|
||||
}
|
||||
|
||||
if err := serve.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||
log.Fatalf("listen: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func seedMathRand() {
|
||||
var seedBytes [8]byte
|
||||
if _, err := rand.Read(seedBytes[:]); err == nil {
|
||||
var seed int64
|
||||
for _, b := range seedBytes {
|
||||
seed = (seed << 8) | int64(b)
|
||||
}
|
||||
mathrand.Seed(seed)
|
||||
return
|
||||
}
|
||||
mathrand.Seed(time.Now().UnixNano())
|
||||
}
|
||||
|
||||
func loadConfig() Config {
|
||||
cfg := Config{
|
||||
Host: "localhost",
|
||||
Port: 7777,
|
||||
KeyLength: 10,
|
||||
MaxLength: 400000,
|
||||
StaticMaxAge: 86400,
|
||||
KeyGenerator: KeyGeneratorConfig{Type: "random"},
|
||||
RateLimits: RateLimitsConfig{Categories: map[string]RateLimitBucket{}},
|
||||
Storage: StorageConfig{Type: "redis", Host: "localhost", Port: 6379},
|
||||
Documents: map[string]string{},
|
||||
}
|
||||
|
||||
applyEnvOverrides(&cfg)
|
||||
return cfg
|
||||
}
|
||||
|
||||
func applyEnvOverrides(cfg *Config) {
|
||||
if v := os.Getenv("HOST"); v != "" {
|
||||
cfg.Host = v
|
||||
}
|
||||
if v := os.Getenv("PORT"); v != "" {
|
||||
cfg.Port = atoiDefault(v, cfg.Port)
|
||||
}
|
||||
if v := os.Getenv("KEY_LENGTH"); v != "" {
|
||||
cfg.KeyLength = atoiDefault(v, cfg.KeyLength)
|
||||
}
|
||||
if v := os.Getenv("MAX_LENGTH"); v != "" {
|
||||
cfg.MaxLength = atoiDefault(v, cfg.MaxLength)
|
||||
}
|
||||
if v := os.Getenv("STATIC_MAX_AGE"); v != "" {
|
||||
cfg.StaticMaxAge = atoiDefault(v, cfg.StaticMaxAge)
|
||||
}
|
||||
if v := os.Getenv("KEYGENERATOR_TYPE"); v != "" {
|
||||
cfg.KeyGenerator.Type = v
|
||||
}
|
||||
if v := os.Getenv("KEY_GENERATOR_KEYSPACE"); v != "" {
|
||||
cfg.KeyGenerator.Keyspace = v
|
||||
}
|
||||
if v := os.Getenv("STORAGE_TYPE"); v != "" {
|
||||
cfg.Storage.Type = v
|
||||
}
|
||||
if v := os.Getenv("STORAGE_HOST"); v != "" {
|
||||
cfg.Storage.Host = v
|
||||
}
|
||||
if v := os.Getenv("STORAGE_PORT"); v != "" {
|
||||
cfg.Storage.Port = atoiDefault(v, cfg.Storage.Port)
|
||||
}
|
||||
if v := os.Getenv("STORAGE_EXPIRE_SECONDS"); v != "" {
|
||||
cfg.Storage.Expire = atoiDefault(v, cfg.Storage.Expire)
|
||||
}
|
||||
if v := os.Getenv("STORAGE_DB"); v != "" {
|
||||
cfg.Storage.DB = atoiDefault(v, cfg.Storage.DB)
|
||||
}
|
||||
if v := os.Getenv("STORAGE_PASSWORD"); v != "" {
|
||||
cfg.Storage.Password = v
|
||||
}
|
||||
if v := os.Getenv("DOCUMENTS"); v != "" {
|
||||
cfg.Documents = parseDocuments(v)
|
||||
}
|
||||
applyRateLimitEnv(cfg)
|
||||
}
|
||||
|
||||
func applyRateLimitEnv(cfg *Config) {
|
||||
normal := cfg.RateLimits.Categories["normal"]
|
||||
if v := os.Getenv("RATE_LIMITS_NORMAL_TOTAL_REQUESTS"); v != "" {
|
||||
normal.TotalRequests = atoiDefault(v, normal.TotalRequests)
|
||||
}
|
||||
if v := os.Getenv("RATE_LIMITS_NORMAL_EVERY_MILLISECONDS"); v != "" {
|
||||
normal.Every = atoiDefault(v, normal.Every)
|
||||
}
|
||||
if normal.TotalRequests > 0 && normal.Every > 0 {
|
||||
cfg.RateLimits.Categories["normal"] = normal
|
||||
}
|
||||
if v := os.Getenv("RATE_LIMITS_WHITELIST"); v != "" {
|
||||
cfg.RateLimits.Whitelist = splitTrimmed(v)
|
||||
}
|
||||
if v := os.Getenv("RATE_LIMITS_BLACKLIST"); v != "" {
|
||||
cfg.RateLimits.Blacklist = splitTrimmed(v)
|
||||
}
|
||||
whitelist := cfg.RateLimits.Categories["whitelist"]
|
||||
if v := os.Getenv("RATE_LIMITS_WHITELIST_TOTAL_REQUESTS"); v != "" {
|
||||
whitelist.TotalRequests = atoiDefault(v, whitelist.TotalRequests)
|
||||
}
|
||||
if v := os.Getenv("RATE_LIMITS_WHITELIST_EVERY_MILLISECONDS"); v != "" {
|
||||
whitelist.Every = atoiDefault(v, whitelist.Every)
|
||||
}
|
||||
if whitelist.TotalRequests > 0 && whitelist.Every > 0 {
|
||||
cfg.RateLimits.Categories["whitelist"] = whitelist
|
||||
}
|
||||
blacklist := cfg.RateLimits.Categories["blacklist"]
|
||||
if v := os.Getenv("RATE_LIMITS_BLACKLIST_TOTAL_REQUESTS"); v != "" {
|
||||
blacklist.TotalRequests = atoiDefault(v, blacklist.TotalRequests)
|
||||
}
|
||||
if v := os.Getenv("RATE_LIMITS_BLACKLIST_EVERY_MILLISECONDS"); v != "" {
|
||||
blacklist.Every = atoiDefault(v, blacklist.Every)
|
||||
}
|
||||
if blacklist.TotalRequests > 0 && blacklist.Every > 0 {
|
||||
cfg.RateLimits.Categories["blacklist"] = blacklist
|
||||
}
|
||||
}
|
||||
|
||||
func newKeyGenerator(cfg KeyGeneratorConfig) (KeyGenerator, error) {
|
||||
switch cfg.Type {
|
||||
case "", "random":
|
||||
return RandomKeyGenerator{keyspace: cfg.Keyspace}, nil
|
||||
case "phonetic":
|
||||
return PhoneticKeyGenerator{}, nil
|
||||
case "dictionary":
|
||||
if cfg.Path == "" {
|
||||
return nil, errors.New("dictionary key generator requires path")
|
||||
}
|
||||
data, err := os.ReadFile(cfg.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
words := strings.Fields(string(data))
|
||||
if len(words) == 0 {
|
||||
return nil, errors.New("dictionary file is empty")
|
||||
}
|
||||
return DictionaryKeyGenerator{words: words}, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported key generator %q", cfg.Type)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) loadStaticDocuments() error {
|
||||
ctx := context.Background()
|
||||
for name, path := range s.cfg.Documents {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s: %w", path, err)
|
||||
}
|
||||
if err := s.store.Set(ctx, name, string(data), true); err != nil {
|
||||
return fmt.Errorf("store %s: %w", name, err)
|
||||
}
|
||||
s.staticDocs[name] = struct{}{}
|
||||
log.Printf("loaded static document %s from %s", name, path)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Server) routes() http.Handler {
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/documents", s.handleDocumentsPost)
|
||||
mux.HandleFunc("/documents/", s.handleDocumentsGet)
|
||||
mux.HandleFunc("/raw/", s.handleRawGet)
|
||||
mux.Handle("/", s)
|
||||
if s.rateLimiter != nil {
|
||||
return s.rateLimiter.Middleware(mux)
|
||||
}
|
||||
return mux
|
||||
}
|
||||
|
||||
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodGet && r.Method != http.MethodHead {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
path := strings.TrimPrefix(r.URL.Path, "/")
|
||||
if path == "" {
|
||||
s.serveIndex(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
if s.tryServeStatic(w, r, path) {
|
||||
return
|
||||
}
|
||||
|
||||
if !strings.Contains(path, "/") {
|
||||
s.serveIndex(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
|
||||
func (s *Server) tryServeStatic(w http.ResponseWriter, r *http.Request, path string) bool {
|
||||
cleanPath := filepath.Clean(path)
|
||||
if strings.HasPrefix(cleanPath, "..") {
|
||||
http.NotFound(w, r)
|
||||
return true
|
||||
}
|
||||
localPath := filepath.Join(s.staticDir, cleanPath)
|
||||
if info, err := os.Stat(localPath); err == nil && !info.IsDir() {
|
||||
s.serveDiskFile(w, r, localPath)
|
||||
return true
|
||||
}
|
||||
|
||||
if file, err := embeddedStatic.Open(filepath.ToSlash(filepath.Join("static", cleanPath))); err == nil {
|
||||
_ = file.Close()
|
||||
s.serveEmbeddedFile(w, r, filepath.ToSlash(filepath.Join("static", cleanPath)))
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *Server) serveIndex(w http.ResponseWriter, r *http.Request) {
|
||||
indexPath := filepath.Join(s.staticDir, "index.html")
|
||||
if _, err := os.Stat(indexPath); err == nil {
|
||||
s.serveDiskFile(w, r, indexPath)
|
||||
return
|
||||
}
|
||||
s.serveEmbeddedFile(w, r, "static/index.html")
|
||||
}
|
||||
|
||||
func (s *Server) serveDiskFile(w http.ResponseWriter, r *http.Request, path string) {
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
info, err := file.Stat()
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
setStaticHeaders(w, path, s.cfg.StaticMaxAge)
|
||||
http.ServeContent(w, r, info.Name(), info.ModTime(), file)
|
||||
}
|
||||
|
||||
func (s *Server) serveEmbeddedFile(w http.ResponseWriter, r *http.Request, path string) {
|
||||
data, err := embeddedStatic.ReadFile(path)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
setStaticHeaders(w, path, s.cfg.StaticMaxAge)
|
||||
if ctype := mime.TypeByExtension(filepath.Ext(path)); ctype != "" {
|
||||
w.Header().Set("Content-Type", ctype)
|
||||
}
|
||||
http.ServeContent(w, r, filepath.Base(path), time.Time{}, strings.NewReader(string(data)))
|
||||
}
|
||||
|
||||
func setStaticHeaders(w http.ResponseWriter, path string, maxAge int) {
|
||||
if maxAge > 0 {
|
||||
w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%d", maxAge))
|
||||
}
|
||||
if strings.HasSuffix(path, ".css") {
|
||||
w.Header().Set("Content-Type", "text/css; charset=utf-8")
|
||||
}
|
||||
if strings.HasSuffix(path, ".js") {
|
||||
w.Header().Set("Content-Type", "application/javascript; charset=utf-8")
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) handleDocumentsPost(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/documents" {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
if r.Method != http.MethodPost {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
body, err := s.readPostBody(r)
|
||||
if err != nil {
|
||||
writeJSON(w, http.StatusInternalServerError, map[string]string{"message": "Connection error."})
|
||||
return
|
||||
}
|
||||
if s.cfg.MaxLength > 0 && len(body) > s.cfg.MaxLength {
|
||||
writeJSON(w, http.StatusBadRequest, map[string]string{"message": "Document exceeds maximum length."})
|
||||
return
|
||||
}
|
||||
|
||||
key, err := s.chooseKey(r.Context())
|
||||
if err != nil {
|
||||
writeJSON(w, http.StatusInternalServerError, map[string]string{"message": "Error adding document."})
|
||||
return
|
||||
}
|
||||
if err := s.store.Set(r.Context(), key, body, false); err != nil {
|
||||
writeJSON(w, http.StatusInternalServerError, map[string]string{"message": "Error adding document."})
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]string{"key": key})
|
||||
}
|
||||
|
||||
func (s *Server) handleDocumentsGet(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodGet && r.Method != http.MethodHead {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
key := documentKey(strings.TrimPrefix(r.URL.Path, "/documents/"))
|
||||
skipExpire := s.isStaticDoc(key)
|
||||
val, ok, err := s.store.Get(r.Context(), key, skipExpire)
|
||||
if err != nil || !ok {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
if r.Method != http.MethodHead {
|
||||
_ = json.NewEncoder(w).Encode(map[string]string{"message": "Document not found."})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
if r.Method == http.MethodHead {
|
||||
return
|
||||
}
|
||||
_ = json.NewEncoder(w).Encode(map[string]string{"data": val, "key": key})
|
||||
}
|
||||
|
||||
func (s *Server) handleRawGet(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodGet && r.Method != http.MethodHead {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
key := documentKey(strings.TrimPrefix(r.URL.Path, "/raw/"))
|
||||
skipExpire := s.isStaticDoc(key)
|
||||
val, ok, err := s.store.Get(r.Context(), key, skipExpire)
|
||||
if err != nil || !ok {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
if r.Method != http.MethodHead {
|
||||
_ = json.NewEncoder(w).Encode(map[string]string{"message": "Document not found."})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/plain; charset=UTF-8")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
if r.Method != http.MethodHead {
|
||||
_, _ = io.WriteString(w, val)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) readPostBody(r *http.Request) (string, error) {
|
||||
contentType := r.Header.Get("Content-Type")
|
||||
mediaType, _, _ := mime.ParseMediaType(contentType)
|
||||
if mediaType == "multipart/form-data" {
|
||||
if err := r.ParseMultipartForm(int64(s.cfg.MaxLength) + 1024); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return r.FormValue("data"), nil
|
||||
}
|
||||
data, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(data), nil
|
||||
}
|
||||
|
||||
func (s *Server) chooseKey(ctx context.Context) (string, error) {
|
||||
for i := 0; i < 64; i++ {
|
||||
key := s.keyGenerator.CreateKey(s.cfg.KeyLength)
|
||||
if _, exists, err := s.store.Get(ctx, key, true); err != nil {
|
||||
return "", err
|
||||
} else if !exists {
|
||||
return key, nil
|
||||
}
|
||||
}
|
||||
return "", errors.New("failed to allocate unique key")
|
||||
}
|
||||
|
||||
func (s *Server) isStaticDoc(key string) bool {
|
||||
_, ok := s.staticDocs[key]
|
||||
return ok
|
||||
}
|
||||
|
||||
func documentKey(path string) string {
|
||||
parts := strings.SplitN(path, ".", 2)
|
||||
return parts[0]
|
||||
}
|
||||
|
||||
func writeJSON(w http.ResponseWriter, status int, payload any) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(status)
|
||||
_ = json.NewEncoder(w).Encode(payload)
|
||||
}
|
||||
|
||||
type RateLimiter struct {
|
||||
cfg RateLimitsConfig
|
||||
mu sync.Mutex
|
||||
counters map[string]*rateCounter
|
||||
}
|
||||
|
||||
type rateCounter struct {
|
||||
count int
|
||||
expires time.Time
|
||||
}
|
||||
|
||||
func NewRateLimiter(cfg RateLimitsConfig) *RateLimiter {
|
||||
if len(cfg.Categories) == 0 {
|
||||
return nil
|
||||
}
|
||||
return &RateLimiter{
|
||||
cfg: cfg,
|
||||
counters: map[string]*rateCounter{},
|
||||
}
|
||||
}
|
||||
|
||||
func (r *RateLimiter) Middleware(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
category, bucket, enabled := r.bucketFor(req)
|
||||
if enabled {
|
||||
ip := clientIP(req)
|
||||
if !r.allow(category, ip, bucket) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusTooManyRequests)
|
||||
_ = json.NewEncoder(w).Encode(map[string]string{"message": "Rate limit exceeded."})
|
||||
return
|
||||
}
|
||||
}
|
||||
next.ServeHTTP(w, req)
|
||||
})
|
||||
}
|
||||
|
||||
func (r *RateLimiter) bucketFor(req *http.Request) (string, RateLimitBucket, bool) {
|
||||
ip := clientIP(req)
|
||||
if contains(r.cfg.Blacklist, ip) {
|
||||
if bucket, ok := r.cfg.Categories["blacklist"]; ok && bucket.TotalRequests > 0 && bucket.Every > 0 {
|
||||
return "blacklist", bucket, true
|
||||
}
|
||||
}
|
||||
if contains(r.cfg.Whitelist, ip) {
|
||||
if bucket, ok := r.cfg.Categories["whitelist"]; ok && bucket.TotalRequests > 0 && bucket.Every > 0 {
|
||||
return "whitelist", bucket, true
|
||||
}
|
||||
}
|
||||
bucket, ok := r.cfg.Categories["normal"]
|
||||
if !ok || bucket.TotalRequests <= 0 || bucket.Every <= 0 {
|
||||
return "", RateLimitBucket{}, false
|
||||
}
|
||||
return "normal", bucket, true
|
||||
}
|
||||
|
||||
func (r *RateLimiter) allow(category, ip string, bucket RateLimitBucket) bool {
|
||||
now := time.Now()
|
||||
key := category + ":" + ip
|
||||
window := time.Duration(bucket.Every) * time.Millisecond
|
||||
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
counter, ok := r.counters[key]
|
||||
if !ok || now.After(counter.expires) {
|
||||
r.counters[key] = &rateCounter{count: 1, expires: now.Add(window)}
|
||||
return true
|
||||
}
|
||||
if counter.count >= bucket.TotalRequests {
|
||||
return false
|
||||
}
|
||||
counter.count++
|
||||
return true
|
||||
}
|
||||
|
||||
func clientIP(r *http.Request) string {
|
||||
host, _, err := net.SplitHostPort(r.RemoteAddr)
|
||||
if err == nil {
|
||||
return host
|
||||
}
|
||||
return r.RemoteAddr
|
||||
}
|
||||
|
||||
func atoiDefault(v string, fallback int) int {
|
||||
parsed, err := strconv.Atoi(v)
|
||||
if err != nil {
|
||||
return fallback
|
||||
}
|
||||
return parsed
|
||||
}
|
||||
|
||||
func splitTrimmed(v string) []string {
|
||||
parts := strings.Split(v, ",")
|
||||
out := make([]string, 0, len(parts))
|
||||
for _, part := range parts {
|
||||
part = strings.TrimSpace(part)
|
||||
if part != "" {
|
||||
out = append(out, part)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func contains(values []string, target string) bool {
|
||||
for _, value := range values {
|
||||
if value == target {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func parseDocuments(v string) map[string]string {
|
||||
docs := map[string]string{}
|
||||
for _, entry := range strings.Split(v, ",") {
|
||||
entry = strings.TrimSpace(entry)
|
||||
if entry == "" {
|
||||
continue
|
||||
}
|
||||
parts := strings.SplitN(entry, "=", 2)
|
||||
if len(parts) != 2 {
|
||||
continue
|
||||
}
|
||||
key := strings.TrimSpace(parts[0])
|
||||
value := strings.TrimSpace(parts[1])
|
||||
if key != "" && value != "" {
|
||||
docs[key] = value
|
||||
}
|
||||
}
|
||||
return docs
|
||||
}
|
||||
1685
package-lock.json
generated
1685
package-lock.json
generated
File diff suppressed because it is too large
Load diff
20
package.json
20
package.json
|
|
@ -1,20 +0,0 @@
|
|||
{
|
||||
"name": "haste-frontend",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"description": "Frontend assets for the haste pastebin server",
|
||||
"keywords": [
|
||||
"paste",
|
||||
"pastebin"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "webpack --mode production"
|
||||
},
|
||||
"dependencies": {
|
||||
"jquery": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"webpack": "^5.108.4",
|
||||
"webpack-cli": "^7.2.1"
|
||||
}
|
||||
}
|
||||
1
params.json
Normal file
1
params.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"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."}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:recommended"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,159 +0,0 @@
|
|||
html, body {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #002B36;
|
||||
margin: 0;
|
||||
font-family: sans-serif;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
/* textarea */
|
||||
|
||||
textarea {
|
||||
background: #002B36;
|
||||
border: 0px;
|
||||
color: #fff;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-family: monospace;
|
||||
outline: none;
|
||||
resize: none;
|
||||
font-size: 13px;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
padding: 20px 20px 80px 0;
|
||||
}
|
||||
|
||||
.logo a:hover svg path {
|
||||
fill: #fff;
|
||||
}
|
||||
|
||||
/* the line numbers */
|
||||
|
||||
#linenos {
|
||||
color: #7d7d7d;
|
||||
z-index: -1000;
|
||||
font-size: 13px;
|
||||
font-family: monospace;
|
||||
text-align: right;
|
||||
user-select: none;
|
||||
padding: 20px 20px 80px 20px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* code box when locked */
|
||||
|
||||
#box {
|
||||
padding: 20px 20px 20px 0;
|
||||
margin: 0px;
|
||||
width: 100%;
|
||||
border: 0px;
|
||||
outline: none;
|
||||
font-size: 13px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
#box code {
|
||||
padding: 0px;
|
||||
background: transparent !important; /* don't hide hastebox */
|
||||
}
|
||||
|
||||
/* key */
|
||||
|
||||
#key {
|
||||
z-index: +1000; /* watch out */
|
||||
}
|
||||
|
||||
button {
|
||||
font-size: 14px;
|
||||
color: #929EA4;
|
||||
background: transparent;
|
||||
outline: none;
|
||||
border: none;
|
||||
padding: 4px 10px;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
button.enabled {
|
||||
color: #FFF;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.button-wrap .label {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: -36px;
|
||||
left: 50%;
|
||||
margin-left: -46px;
|
||||
text-align: center;
|
||||
background: #15191b;
|
||||
color: #fff;
|
||||
padding: 8px;
|
||||
border-radius: 3px;
|
||||
font-size: 12px;
|
||||
width: 76px;
|
||||
}
|
||||
|
||||
.button-wrap .label.label--small {
|
||||
margin-left: -30px;
|
||||
width: 44px;
|
||||
}
|
||||
|
||||
.button-wrap:hover .label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.menu {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: #002B36;
|
||||
}
|
||||
|
||||
.menu-actions {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 600px) {
|
||||
.logo, .label {
|
||||
display: none !important;
|
||||
}
|
||||
.menu {
|
||||
padding: 24px 12px !important;
|
||||
}
|
||||
.menu-actions {
|
||||
width: 100%;
|
||||
}
|
||||
.menu-actions button {
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
}
|
||||
.menu-actions .button-wrap {
|
||||
flex: auto;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.9 KiB |
6
static/highlight.min.js
vendored
6
static/highlight.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -1,74 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
|
||||
<title>hastebin</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="stylesheet" type="text/css" href="solarized_dark.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="application.css"/>
|
||||
|
||||
<script type="text/javascript" src="highlight.min.js"></script>
|
||||
<script type="text/javascript" src="dist/bundle.js"></script>
|
||||
|
||||
<meta name="robots" content="noindex,nofollow"/>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<ul id="messages"></ul>
|
||||
|
||||
<div style="display: flex; flex-direction: column; height: 100%; width: 100%;">
|
||||
<div style="display: flex; flex: auto;">
|
||||
<div id="linenos"></div>
|
||||
<pre id="box" style="display:none; flex: auto;" class="hljs" tabindex="0"><code></code></pre>
|
||||
<textarea spellcheck="false" style="display:none;"></textarea>
|
||||
</div>
|
||||
|
||||
<div id="key" class="menu" style="display: flex; padding: 16px;">
|
||||
<div class="logo" style="flex: auto; display: flex; align-items: center;">
|
||||
<div class="button-wrap" style="position: relative;">
|
||||
<span class="label label--small">About</span>
|
||||
<a href="/about.md" style="display: flex">
|
||||
<svg width="75" height="15" viewBox="0 0 75 15" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M4.11643 8.40057C4.12283 7.28196 4.7876 6.61719 5.77837 6.61719C6.78192 6.61719 7.36359 7.26278 7.3572 8.35582V14H10.4829V7.74219C10.4893 5.51776 9.13419 4.05398 7.06956 4.05398C5.59939 4.05398 4.56388 4.77628 4.12283 5.98438H4.01416V0.909091H0.990723V14H4.11643V8.40057Z" fill="#73848C"/>
|
||||
<path d="M15.2018 14.1662C16.5697 14.1662 17.5158 13.6357 18.0527 12.6321H18.1294V14H21.0697V7.3267C21.0697 5.24929 19.2224 4.05398 16.7231 4.05398C14.0832 4.05398 12.5875 5.38352 12.3382 7.1733L15.221 7.27557C15.3552 6.64915 15.873 6.26562 16.6976 6.26562C17.4646 6.26562 17.9504 6.63636 17.9504 7.29474V7.3267C17.9504 7.92756 17.2984 8.0554 15.6237 8.20241C13.6358 8.36861 11.9739 9.10369 11.9739 11.277C11.9739 13.2202 13.3226 14.1662 15.2018 14.1662ZM16.167 12.1207C15.4447 12.1207 14.9334 11.7756 14.9334 11.1236C14.9334 10.4908 15.432 10.1072 16.3204 9.97301C16.9021 9.88991 17.618 9.76207 17.9696 9.5767V10.5099C17.9696 11.4687 17.1642 12.1207 16.167 12.1207Z" fill="#73848C"/>
|
||||
<path d="M31.5527 7.17969C31.3865 5.23651 29.7949 4.05398 27.1358 4.05398C24.4767 4.05398 22.7828 5.21094 22.7956 7.17969C22.7828 8.68821 23.748 9.6598 25.7104 10.0241L27.4234 10.3501C28.2352 10.5099 28.606 10.7656 28.6187 11.2003C28.606 11.6925 28.0562 12.0185 27.2572 12.0185C26.3687 12.0185 25.7679 11.6349 25.6337 10.919L22.5463 10.9957C22.77 12.9389 24.4383 14.1854 27.2445 14.1854C29.8716 14.1854 31.7828 12.875 31.7956 10.8551C31.7828 9.42329 30.8368 8.57315 28.8808 8.19602L26.9888 7.83807C26.1578 7.67188 25.8893 7.37784 25.8957 7.00071C25.8893 6.50213 26.471 6.19531 27.1933 6.19531C28.0179 6.19531 28.5932 6.63636 28.6827 7.25639L31.5527 7.17969Z" fill="#73848C"/>
|
||||
<path d="M38.8764 4.18182H37.1058V1.82955H33.9801V4.18182H32.6825V6.48295H33.9801V11.2578C33.9609 13.2457 35.2521 14.2429 37.4573 14.1406C38.2116 14.1023 38.7549 13.9489 39.0554 13.8594L38.5823 11.603C38.4481 11.6349 38.1349 11.6989 37.8984 11.6989C37.3934 11.6989 37.1058 11.4943 37.1058 10.9126V6.48295H38.8764V4.18182Z" fill="#73848C"/>
|
||||
<path d="M44.9552 14.1854C47.5312 14.1854 49.2251 12.9389 49.583 11.0085L46.713 10.9254C46.4701 11.5774 45.8309 11.929 45.0127 11.929C43.811 11.929 43.0696 11.13 43.0696 9.92827V9.84517H49.615V9.06534C49.615 5.83097 47.6463 4.05398 44.8593 4.05398C41.8934 4.05398 39.9886 6.08665 39.9886 9.12926C39.9886 12.2741 41.8679 14.1854 44.9552 14.1854ZM43.0696 8.02983C43.1143 7.05185 43.8877 6.31037 44.9232 6.31037C45.9524 6.31037 46.6938 7.02628 46.7066 8.02983H43.0696Z" fill="#73848C"/>
|
||||
<path d="M51.8059 14H53.2633V12.4915H53.4422C53.7746 13.0284 54.4138 14.2045 56.3059 14.2045C58.7604 14.2045 60.4735 12.2358 60.4735 9.11648C60.4735 6.02273 58.7604 4.05398 56.2803 4.05398C54.3627 4.05398 53.7746 5.23011 53.4422 5.74148H53.3144V0.909091H51.8059V14ZM53.2888 9.09091C53.2888 6.89205 54.2604 5.40909 56.1013 5.40909C58.019 5.40909 58.965 7.01989 58.965 9.09091C58.965 11.1875 57.9934 12.8494 56.1013 12.8494C54.286 12.8494 53.2888 11.3153 53.2888 9.09091Z" fill="#73848C"/>
|
||||
<path d="M62.781 14H64.2896V4.18182H62.781V14ZM63.5481 2.54545C64.1361 2.54545 64.6219 2.08523 64.6219 1.52273C64.6219 0.960227 64.1361 0.5 63.5481 0.5C62.96 0.5 62.4742 0.960227 62.4742 1.52273C62.4742 2.08523 62.96 2.54545 63.5481 2.54545Z" fill="#73848C"/>
|
||||
<path d="M68.561 8.09375C68.561 6.38068 69.6221 5.40909 71.0667 5.40909C72.4666 5.40909 73.3167 6.32315 73.3167 7.86364V14H74.8252V7.76136C74.8252 5.25568 73.4893 4.05398 71.5014 4.05398C70.0184 4.05398 69.098 4.71875 68.6377 5.71591H68.5099V4.18182H67.0525V14H68.561V8.09375Z" fill="#73848C"/>
|
||||
</svg>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div id="box2" class="menu-actions">
|
||||
<div class="button-wrap" style="position: relative;">
|
||||
<span class="label label--small">ctrl + s</span>
|
||||
<button class="save button-picture function">Save</button>
|
||||
</div>
|
||||
<div class="button-wrap" style="position: relative;">
|
||||
<span class="label label--small">ctrl + n</span>
|
||||
<button class="new button-picture function">New</button>
|
||||
</div>
|
||||
<div class="button-wrap" style="position: relative;">
|
||||
<span class="label label--small">ctrl + d</span>
|
||||
<button class="duplicate button-picture function">Duplicate & Edit</button>
|
||||
</div>
|
||||
<div class="button-wrap" style="position: relative;">
|
||||
<span class="label">ctrl + shift + r</span>
|
||||
<button class="raw button-picture function">Raw Text</button>
|
||||
</div>
|
||||
<div class="button-wrap" style="position: relative;">
|
||||
<span class="label">ctrl + shift + r</span>
|
||||
<button class="twitter button-picture function">Tweet It</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
User-agent: *
|
||||
Disallow: /*
|
||||
Allow: /?okparam=
|
||||
Allow: /$
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
/*
|
||||
|
||||
Orginal Style from ethanschoonover.com/solarized (c) Jeremy Hull <sourdrums@gmail.com>
|
||||
|
||||
*/
|
||||
|
||||
.hljs {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
padding: 0.5em;
|
||||
background: #002b36;
|
||||
color: #839496;
|
||||
}
|
||||
|
||||
.hljs-comment,
|
||||
.hljs-quote {
|
||||
color: #586e75;
|
||||
}
|
||||
|
||||
/* Solarized Green */
|
||||
.hljs-keyword,
|
||||
.hljs-selector-tag,
|
||||
.hljs-addition {
|
||||
color: #859900;
|
||||
}
|
||||
|
||||
/* Solarized Cyan */
|
||||
.hljs-number,
|
||||
.hljs-string,
|
||||
.hljs-meta .hljs-meta-string,
|
||||
.hljs-literal,
|
||||
.hljs-doctag,
|
||||
.hljs-regexp {
|
||||
color: #2aa198;
|
||||
}
|
||||
|
||||
/* Solarized Blue */
|
||||
.hljs-title,
|
||||
.hljs-section,
|
||||
.hljs-name,
|
||||
.hljs-selector-id,
|
||||
.hljs-selector-class {
|
||||
color: #268bd2;
|
||||
}
|
||||
|
||||
/* Solarized Yellow */
|
||||
.hljs-attribute,
|
||||
.hljs-attr,
|
||||
.hljs-variable,
|
||||
.hljs-template-variable,
|
||||
.hljs-class .hljs-title,
|
||||
.hljs-type {
|
||||
color: #b58900;
|
||||
}
|
||||
|
||||
/* Solarized Orange */
|
||||
.hljs-symbol,
|
||||
.hljs-bullet,
|
||||
.hljs-subst,
|
||||
.hljs-meta,
|
||||
.hljs-meta .hljs-keyword,
|
||||
.hljs-selector-attr,
|
||||
.hljs-selector-pseudo,
|
||||
.hljs-link {
|
||||
color: #cb4b16;
|
||||
}
|
||||
|
||||
/* Solarized Red */
|
||||
.hljs-built_in,
|
||||
.hljs-deletion {
|
||||
color: #dc322f;
|
||||
}
|
||||
|
||||
.hljs-formula {
|
||||
background: #073642;
|
||||
}
|
||||
|
||||
.hljs-emphasis {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.hljs-strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
69
stylesheets/pygment_trac.css
Normal file
69
stylesheets/pygment_trac.css
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
.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
stylesheets/styles.css
Normal file
255
stylesheets/styles.css
Normal file
|
|
@ -0,0 +1,255 @@
|
|||
@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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
mode: 'production',
|
||||
entry: path.resolve(__dirname, 'frontend/src/index.js'),
|
||||
output: {
|
||||
filename: 'bundle.js',
|
||||
path: path.resolve(__dirname, 'static/dist'),
|
||||
},
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue