pokepaste

package module
v0.0.0-...-617fd20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2021 License: BSD-3-Clause Imports: 16 Imported by: 0

README

PokePaste

PokePaste is a simple pastebin, with a clean interface, that supports
highlighting of the syntax created by Pokemon Showdown. This syntax has
become a standard, and is supported by multiple tools, yet no pastebin
(up until now) has had support for syntax-highlighting it.

PokePaste highlights mon names with their primary type, moves with their
type, items (where appropriate) with their associated type and more. It
also features an image preview for mons and items using art from the
Pokemon Global Link. The site is simple, standards-compliant and mobile-
friendly.

PokePaste is grateful to BrowserStack <https://www.browserstack.com> for
help testing PokePaste v3 across different browsers.

You can use PokePaste at <https://pokepast.es>.

PokePaste v3 was rewritten from the ground up in Go. Most of the
functionality required is in the standard library, with the exception of
the MySQL and Blowfish libraries.

A standalone tool is included to run PokePaste for development purposes;
use it something like this:

	$ go get github.com/felixphew/pokepaste/cmd/pokepaste
	$ POKEPASTE_DB=username:password@/dbname \
	> POKEPASTE_KEY='Super Secret Key' ~/go/bin/pokepaste

See <https://github.com/go-sql-driver/mysql#dsn-data-source-name> for
more information on the database connection parameters.

Licensing

PokePaste is licensed under the 3-clause BSD licence. In short, you can
do whatever you want with the code as long as you retain the copyright
notice (see LICENSE) and don't hold me liable.

Pokémon and Pokémon character names are trademarks of Nintendo.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Strict-Transport-Security", "max-age=31536000")
	w.Header().Set("Content-Security-Policy", "default-src 'none'; font-src 'self'; img-src 'self'; script-src 'self'; style-src 'self'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'")

	if m := path.FindStringSubmatch(r.URL.Path); m != nil {
		id, err := decodeID(m[1])
		if err != nil {
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}

		servePaste(w, id, m[2])
	} else if m := pathOld.FindStringSubmatch(r.URL.Path); m != nil {
		id, err := decodeOldID(m[1])
		if err != nil {
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}

		if id >= 1000 {
			http.Error(w, "Forbidden", http.StatusForbidden)
			return
		}

		servePaste(w, id, m[2])
	} else if r.URL.Path == "/create" {
		err := r.ParseForm()
		if err != nil {
			http.Error(w, err.Error(), http.StatusBadRequest)
			return
		}

		paste := r.Form.Get("paste")
		if len(paste) == 0 {
			http.Error(w, "No (or Invalid) Paste", http.StatusBadRequest)
			return
		}

		title := r.Form.Get("title")
		author := r.Form.Get("author")
		notes := r.Form.Get("notes")

		id, err := postPaste(&paste, &title, &author, &notes)
		if err != nil {
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}

		http.Redirect(w, r, "/"+encodeID(id), http.StatusSeeOther)
	} else {
		assets.ServeHTTP(w, r)
	}
})

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL