...

Package util

Overview ▾

Package util provides constants, variables and functions related to sriracha.

Constants

const NewDirPermission = 0755
const NewFilePermission = 0640

Variables

var (
    AlphaNumericAndSymbols = regexp.MustCompile(`^[0-9A-Za-z_-]+$`)

    QuotePattern = regexp.MustCompile(`^>(.*)$`)

    RefLinkPattern   = regexp.MustCompile(`>>([0-9]+)`)
    BoardLinkPattern = regexp.MustCompile(`>>>\/([0-9A-Za-z_-]+)?\/?`)

    URLPattern     = regexp.MustCompile(`(?i)(((f|ht)tp(s)?:\/\/)[-a-zA-Zа-яА-Я()0-9@%\!_+.,~#?&;:|\'\/=]+)`)
    FixURLPattern1 = regexp.MustCompile(`(?i)\(\<a href\=\"(.*)\)"\ target\=\"\_blank\">(.*)\)\<\/a>`)
    FixURLPattern2 = regexp.MustCompile(`(?i)\<a href\=\"(.*)\."\ target\=\"\_blank\">(.*)\.\<\/a>`)
    FixURLPattern3 = regexp.MustCompile(`(?i)\<a href\=\"(.*)\,"\ target\=\"\_blank\">(.*)\,\<\/a>`)
)

func FormBool

func FormBool(r *http.Request, key string) bool

func FormInt

func FormInt(r *http.Request, key string) int

func FormInt64

func FormInt64(r *http.Request, key string) int64

func FormMultiString

func FormMultiString(r *http.Request, key string) []string

func FormNegInt

func FormNegInt(r *http.Request, key string) int

func FormRange

func FormRange[T constraints.Integer](r *http.Request, key string, min T, max T) T

func FormString

func FormString(r *http.Request, key string) string

func FormatFileSize

func FormatFileSize(size int64) string

func FormatRawTimestamp

func FormatRawTimestamp(timestamp int64) string

func FormatTimestamp

func FormatTimestamp(timestamp int64) template.HTML

func MIMEToExt

func MIMEToExt(mimeType string) string

func ParseFloat

func ParseFloat(v string) float64

func ParseInt

func ParseInt(v string) int

func ParseInt64

func ParseInt64(v string) int64

func PathInt

func PathInt(r *http.Request, prefix string) int

func PathString

func PathString(r *http.Request, prefix string) string

type Config

Config represents the server configuration.

type Config struct {
    Locale string // Default locale. See locale directory for available languages.
    Root   string // Directory where board files are written to.
    Serve  string // Address:Port to listen for HTTP connections on.
    Header string // Client IP address header.

    SaltData string // Long random string of text used when one-way hashing data. Must not change once set.
    SaltPass string // Long random string of text used when two-way hashing data. Must not change once set.
    SaltTrip string // Long random string of text used when generating secure tripcodes. Must not change once set.

    Address  string // Address:Port to connect to the database.
    Username string // Database username.
    Password string // Database password.
    DBName   string // Database name.
    DBURL    string // Database connection URL.

    Template string // Custom template directory.

    Identifiers bool // Whether staff may browse posts by IP hashes and boards may display identifier hashes.

    Uploads []string // Supported upload file types.

    Import ImportConfig // Board import configuration.

    ImportMode     bool
    ImportComplete bool
    StartTime      time.Time
    // contains filtered or unexported fields
}

func (*Config) UploadTypes

func (c *Config) UploadTypes() []*UploadType

type ImportConfig

ImportConfig represents a board import configuration.

type ImportConfig struct {
    Address  string // Address:Port to connect to the database.
    Username string // Database username.
    Password string // Database password.
    DBName   string // Database name.

    Posts    string // Posts table.
    Keywords string // Keywords table.
}

func (ImportConfig) Enabled

func (c ImportConfig) Enabled() bool

type UploadType

type UploadType struct {
    Ext   string
    MIME  string
    Thumb string
}