Help us shape the future of Go! Take the 2026 Go Developer Survey

qbin

package module
v0.0.0-...-522c81c Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2018 License: MIT Imports: 22 Imported by: 0

README

qbin

A minimalist pastebin service. Includes a nice and easy Netcat and POST API, and can render Markdown.

Backend Repository

Contains API and webserver code. To the main repository


» Documentation and more information
» Public Version - see qbin in action

Documentation

Index

Constants

View Source
const MaxFilesize = 1024 * 1024 // 1MB

Variables

View Source
var FilterEnable = map[string]bool{}
View Source
var Log = logging.MustGetLogger("example")

Log refers to the main logger instance used by the qbin application.

View Source
var PrismServer = "/tmp/prism-server.sock"

PrismServer defines the TCP address or unix socket path (containing a /) to prism-server.

Functions

func Connect

func Connect(uri string) error

Connect tries to establish a connection to a MySQL/MariaDB database under the given URI and initializes the qbin tables if they don't exist yet.

func EscapeHTML

func EscapeHTML(content string) string

EscapeHTML removes all special HTML characters (namely, &<>") in a string and replaces them with their entities (e.g. &amp;).

func FilterSpam

func FilterSpam(doc *Document, highlighted *string) error

FilterSpam ->Filter content with different Filters to categories spam

func GenerateName

func GenerateName() string

GenerateName generates a slug in the format "cornflake-peddling-bp0q". Note that this function will return an empty string if an error occurs along the way!

func GenerateSafeName

func GenerateSafeName() (string, error)

GenerateSafeName generates a slug (like GenerateName()) that doesn't exist in the database yet.

func Highlight

func Highlight(content string, language string) (string, bool, error)

Highlight performs syntax highlighting on a string using Prism.js running under node.js.

func IsConnected

func IsConnected() bool

IsConnected returns true if the database has already been initialized.

func LoadBlacklistFile

func LoadBlacklistFile(filename string) error

func LoadWordsFile

func LoadWordsFile(filename string) error

LoadWordsFile imports the word definition file used for names.

func ParseExpiration

func ParseExpiration(expiration string) (time.Time, error)

ParseExpiration creates a time.Time object from an expiration string, taking the units m, h, d, w into account.

func ParseSyntax

func ParseSyntax(language string) string

ParseSyntax applies aliases and some other transformations to a syntax name supplied by the user to make it more intuitive.

func SetLogLevel

func SetLogLevel(level logging.Level)

SetLogLevel changes how much information is printed to Stdout.

func Slice2map

func Slice2map(s []string) map[string]bool

getLanguages reads the existing languages from the prism-server for use with SyntaxExists.

func Store

func Store(document *Document) error

Store a document object in the database.

func StripHTML

func StripHTML(content string) string

StripHTML strips all HTML tags and replaces the entities from escapeHTML backwards.

func SyntaxExists

func SyntaxExists(language string) bool

SyntaxExists checks if a given syntax definition exists in Prism.js.

Types

type Document

type Document struct {
	// ID is set on Store()
	ID      string
	Content string
	Syntax  string
	// Upload is set on Store()
	Upload     time.Time
	Expiration time.Time
	Views      int
	Custom     string
}

Document specifies the content and metadata of a piece of code that is hosted on qbin.

func Request

func Request(id string, raw bool) (Document, error)

Request a document from the database by its ID.

Directories

Path Synopsis
cmd
qbin command

Jump to

Keyboard shortcuts

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