Coder Social home page Coder Social logo

paste's Introduction

paste is a simple web app for writing & sharing code. It's my own take on conventional pastebin sites like pastebin.com or hastebin.

Anyone can use paste! The official/public instance can be accessed using the endpoints listed below, but you can also host your own if you like!

1) In a Web Browser

Just go to https://pastes.dev!

2) From the Command Line

You can submit content most easily using curl.

# Upload the contents of a file
> curl -T example.txt https://api.pastes.dev/post

# Upload the contents of a file and specify the language
> curl -T example.yml -H "Content-Type: text/yaml" https://api.pastes.dev/post

# Pipe in some output from any command
> echo "Hello world" | curl -T - https://api.pastes.dev/post
If curl isn't installed on your system, you can also post using netcat.
# Pipe in some output from any command
> echo "Hello world" | nc nc.pastes.dev 1337

# Upload the contents of a file
> cat example.txt | nc nc.pastes.dev 1337
If you don't want to do so much typing, you can create a shorter alias.
# Add this to the end of `~/.bashrc` and run 'source ~/.bashrc'
paste() {
  curl -T $1 https://api.pastes.dev/post
}

then...

# Upload the contents of a file
> paste example.txt

# Pipe in some output from any command
> echo "Hello!" | paste -
3) From Code

Send GET/POST/PUT requests to https://api.pastes.dev/. More info below.


About

The frontend (this repository) is written using the React framework. The backend data storage is handled by a separate web service called bytebin.

The user-interface is based on the Monaco Editor, the engine behind the popular Visual Studio Code text editor. It's quite simple; it supports syntax highlighting, automatic indentation, many supported languages, themes, zooming in/out, linking to specific lines or sections, and more!

pastes.dev

I host a public instance at https://pastes.dev. Please feel free to use it to share code/configs/whatever!

Please note that the following (very-non-legally worded) terms of service apply.
If you come across any content which is illegal or infringes on copyright, please get in touch and let me know so I can remove it.

Uploaded content is retained for 90 days then deleted.

pastes.dev API

  • To read content, send a HTTP GET request to https://api.pastes.dev/<key>.
    • Replace <key> with the id of the paste.
    • The content is returned in the response body.
    • The Content-Type header is text/<language>, where language is the id of the language the paste was saved with.
  • To upload content, send a HTTP POST request to https://api.pastes.dev/post.
    • Include the content in the request body.
    • Specify the language with the Content-Type: text/<language> header, and please provide a User-Agent header too.
    • The paste "key" is returned in the Location header, or in the response body as a JSON object in the format {"key": "<key>"}.

The API is powered by the bytebin service, so more information about how it works can be found there.


Host your own

It's quite simple to host your own version.

git clone https://github.com/lucko/paste
cd paste
yarn install

# Outputs html/css/js files to /build
yarn build

# Start a webserver for testing/development
yarn start

You can then follow the create-react-app deployment documentation for how to host the build output. I personally recommend deploying to the cloud using a service like Netlify instead of hosting on your own webserver.

If you really want to self-host (including the bytebin data storage part), I suggest using Docker:

git clone https://github.com/lucko/paste
docker compose up -d

You should then (hopefully!) be able to access the application at http://localhost:8080/.

paste's People

Contributors

benwoo1110 avatar lucko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

paste's Issues

Multi-arch docker image support

Since there is a raise in ARM based server usage, it would be awesome to have MultiArch enabled for docker
to host paste in ARM based servers

502 Bad Gateway on /data/post

I have used the Docker method for the repo and the site it self works but not the /data/post path. It says 502 Bad Gateway. I use a custom Port. (1020)

paste cannot run in docker environment

amd64 on debian12

root@dev:/home/soft/paste# docker logs -f de0
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf differs from the packaged version
/docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2023/09/09 15:52:37 [notice] 1#1: using the "epoll" event method
2023/09/09 15:52:37 [notice] 1#1: nginx/1.25.2
2023/09/09 15:52:37 [notice] 1#1: built by gcc 12.2.1 20220924 (Alpine 12.2.1_git20220924-r10) 
2023/09/09 15:52:37 [notice] 1#1: OS: Linux 6.1.0-10-cloud-amd64
2023/09/09 15:52:37 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2023/09/09 15:52:37 [notice] 1#1: start worker processes
2023/09/09 15:52:37 [notice] 1#1: start worker process 29
2023/09/09 15:52:37 [notice] 1#1: start worker process 30
2023/09/09 15:52:37 [notice] 1#1: start worker process 31
2023/09/09 15:52:37 [notice] 1#1: start worker process 32
2023/09/09 15:52:37 [notice] 1#1: start worker process 33
2023/09/09 15:52:37 [notice] 1#1: start worker process 34
2023/09/09 15:52:37 [notice] 1#1: start worker process 35
2023/09/09 15:52:37 [notice] 1#1: start worker process 36
2023/09/09 15:52:37 [notice] 1#1: start worker process 37
2023/09/09 15:52:37 [notice] 1#1: start worker process 38
2023/09/09 15:52:37 [notice] 1#1: start worker process 39
2023/09/09 15:52:37 [notice] 1#1: start worker process 40
2023/09/09 15:52:37 [notice] 1#1: start worker process 41
2023/09/09 15:52:37 [notice] 1#1: start worker process 42
2023/09/09 15:52:37 [notice] 1#1: start worker process 43
2023/09/09 15:52:37 [notice] 1#1: start worker process 44

Disable automatic ligatures display for specific language highlightings

The paste service currently seems to apply ligatures to text, meaning displaying text like -> as โ†’ (Not accurate ligature... probably).
The text itself remains the same, it's only visual.

However, this may still cause confusion if someone f.e. shares a configuration file, or an error and the text displayed does not represent the text actually used visually.

Ligatures shoudl honestly only be utilized in the [code] languages, which is what I would like to propose now.
All other categories do not really have a need for ligatures to be used and may only cause general confusion for the people who read the paste, as it wouldn't represent what is actually used.

Automatic selection of language based on query parameters

This can be seen as an addition to #9

My suggestion is, to allow the language to be (pre-)selected based on a query parameter defined in the URL.
This would allow people to share a link, where the code highlighting is already set, only requiring a paste of the info and subsequently save.

For example:
Providing https://pastes.dev/?lang=yaml would automatically select YAML as the language for the paste.

Log formatting option

A language option to display the text as (MC Console) logs would be nice.
It would allow to more easily identify warnings and errors if there's a bunch of lines shared.

Page Not Found error on Netlify

After I saved the paste, the link to it is copied, but when I open it, I get an error.

Page Not Found Looks like you've followed a broken link or entered a URL that doesn't exist on this site.
image

Hocon support

Support for Hocon syntax highlighting would be amazing

Netcat / easier command line pasting

Love using pastes.dev, but would love to see the ability from e.g. https://termbin.com/ to netcat content to pastes.dev.
I guess an alternative to this would be sending an HTTP request to the pastes.dev API which I guess I could create an alias for, but something like netcat is a lot easier.

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.