Documentation
¶
Overview ¶
Package util provides constants, variables and functions related to Sriracha.
Index ¶
- Constants
- Variables
- func FormBool(r *http.Request, key string) bool
- func FormInt(r *http.Request, key string) int
- func FormInt64(r *http.Request, key string) int64
- func FormMultiString(r *http.Request, key string) []string
- func FormNegInt(r *http.Request, key string) int
- func FormRange[T constraints.Integer](r *http.Request, key string, min T, max T) T
- func FormString(r *http.Request, key string) string
- func FormatDuration(d time.Duration) string
- func FormatFileSize(size int64) string
- func FormatRawTimestamp(timestamp int64) string
- func FormatTimestamp(timestamp int64) template.HTML
- func MIMEToExt(mimeType string) string
- func ParseEmail(address string) string
- func ParseFloat(v string) float64
- func ParseInt(v string) int
- func ParseInt64(v string) int64
- func PathInt(r *http.Request, prefix string) int
- func PathString(r *http.Request, prefix string) string
- type Config
- type ImportConfig
- type UploadType
Constants ¶
View Source
const NewDirPermission = 0755
View Source
const NewFilePermission = 0644
Variables ¶
View Source
var ( AlphaNumericAndSymbols = regexp.MustCompile(`^[0-9A-Za-z_\-]+$`) FileNamePattern = regexp.MustCompile(`^[0-9A-Za-z_\-.]+$`) FilePathPattern = 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>`) )
Functions ¶
func FormatDuration ¶ added in v1.3.3
func FormatFileSize ¶
func FormatRawTimestamp ¶
func FormatTimestamp ¶
func ParseEmail ¶ added in v1.4.0
func ParseFloat ¶
func ParseInt64 ¶
Types ¶
type Config ¶
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.
MailAddress string // SMTP server Address:Port.
MailTLS bool // Whether TLS is used to connect to the server.
MailInsecure bool // Whether TLS certificate verification is skipped.
MailUsername string // SMTP server username.
MailPassword string // SMTP server password.
MailAuth string // SMTP server authentication mechanism. May be challenge / plain / none.
MailFrom string // "From" email address.
MailReplyTo string // "Reply-To" email address.
MailDomains string // Regular expression specifying allowed email address domains.
Mentions int // Duration (in minutes) mention notifications are batched together.
Notifications int // Duration (in minutes) non-mention notifications are batched together.
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.
Access map[string]string // Specifies which roles may perform each management or moderation action.
Import ImportConfig // Board import configuration.
ImportMode bool
ImportComplete bool
StartTime time.Time
// contains filtered or unexported fields
}
Config represents the server configuration.
func (*Config) UploadTypes ¶
func (c *Config) UploadTypes() []*UploadType
type ImportConfig ¶
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.
}
ImportConfig represents a board import configuration.
func (ImportConfig) Enabled ¶
func (c ImportConfig) Enabled() bool
type UploadType ¶
Click to show internal directories.
Click to hide internal directories.