Documentation
¶
Index ¶
- Constants
- Variables
- func Connect(uri string) error
- func EscapeHTML(content string) string
- func FilterSpam(doc *Document, highlighted *string) error
- func GenerateName() string
- func GenerateSafeName() (string, error)
- func Highlight(content string, language string) (string, bool, error)
- func IsConnected() bool
- func LoadBlacklistFile(filename string) error
- func LoadWordsFile(filename string) error
- func ParseExpiration(expiration string) (time.Time, error)
- func ParseSyntax(language string) string
- func SetLogLevel(level logging.Level)
- func Slice2map(s []string) map[string]bool
- func Store(document *Document) error
- func StripHTML(content string) string
- func SyntaxExists(language string) bool
- type Document
Constants ¶
const MaxFilesize = 1024 * 1024 // 1MB
Variables ¶
var FilterEnable = map[string]bool{}
var Log = logging.MustGetLogger("example")
Log refers to the main logger instance used by the qbin application.
var PrismServer = "/tmp/prism-server.sock"
PrismServer defines the TCP address or unix socket path (containing a /) to prism-server.
Functions ¶
func Connect ¶
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 ¶
EscapeHTML removes all special HTML characters (namely, &<>") in a string and replaces them with their entities (e.g. &).
func FilterSpam ¶
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 ¶
GenerateSafeName generates a slug (like GenerateName()) that doesn't exist in the database yet.
func Highlight ¶
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 LoadWordsFile ¶
LoadWordsFile imports the word definition file used for names.
func ParseExpiration ¶
ParseExpiration creates a time.Time object from an expiration string, taking the units m, h, d, w into account.
func ParseSyntax ¶
ParseSyntax applies aliases and some other transformations to a syntax name supplied by the user to make it more intuitive.
func SetLogLevel ¶
SetLogLevel changes how much information is printed to Stdout.
func Slice2map ¶
getLanguages reads the existing languages from the prism-server for use with SyntaxExists.
func StripHTML ¶
StripHTML strips all HTML tags and replaces the entities from escapeHTML backwards.
func SyntaxExists ¶
SyntaxExists checks if a given syntax definition exists in Prism.js.