Documentation
¶
Index ¶
- Constants
- Variables
- func CheckCaptcha(task *CaptchaTask, input string) bool
- func DetectLanguageWithTimeout(text string, log *slog.Logger) string
- func E(err error) slog.Attr
- func InitL10n(assets *assets.Bin, userLocale string)
- func InsertOrUpdateAuthor(db Data, newAuthor *Author) (id int64, err error)
- func InsertOrUpdatePost(db Data, post *EntryTable) (id int64, err error)
- func Main()
- func MkBasicData(ctx *Context, pageNo, offset int, conf Config) tmplMap
- func MkFlashes(ctx *Context) template.HTML
- func PublishComment(db Data, postID, commenterID int64, body string) (string, error)
- func PublishCommentAndCommenter(db Data, postID int64, commenter *Commenter, rawBody string) (string, error)
- func RightCaptchaReply(w http.ResponseWriter, redir string, log *slog.Logger) error
- func WrongCaptchaReply(w http.ResponseWriter, req *http.Request, status string, task *CaptchaTask, ...) error
- type Author
- type BcryptHelper
- type CaptchaTask
- type Comment
- type CommentTable
- type CommentWithPostTitle
- type Commenter
- type CommenterTable
- type Config
- type Context
- type CryptoHelper
- type Data
- type DbData
- type Deck
- type Entry
- type EntryLink
- type EntryTable
- type Interface
- type LangDetector
- type Notifications
- type Server
- type Tag
- type TagMap
- type XeroxLangDetector
Constants ¶
View Source
const ( MaxFileSize = 50 * 1024 * 1024 // bytes PostsPerPage = 5 NumFeedItems = 3 NumRecentPosts = 10 )
Variables ¶
View Source
var (
L10n i18n.TranslateFunc
)
Functions ¶
func CheckCaptcha ¶
func CheckCaptcha(task *CaptchaTask, input string) bool
func InitL10n ¶
Loads translation files and inits L10n func that retrieves the translations. l10nDir is a name of a directory with translations. userLocale specifies a locale preferred by the user (a preference or accept header or language cookie).
func InsertOrUpdateAuthor ¶
func InsertOrUpdatePost ¶
func InsertOrUpdatePost(db Data, post *EntryTable) (id int64, err error)
func MkBasicData ¶
func PublishComment ¶
func RightCaptchaReply ¶
func WrongCaptchaReply ¶
func WrongCaptchaReply(w http.ResponseWriter, req *http.Request, status string, task *CaptchaTask, log *slog.Logger) error
Types ¶
type BcryptHelper ¶
type BcryptHelper struct{}
func (BcryptHelper) Decrypt ¶
func (h BcryptHelper) Decrypt(hash, passwd []byte) error
type CaptchaTask ¶
type Comment ¶
type Comment struct {
Commenter
CommentTable
}
type CommentTable ¶
type CommentTable struct {
CommenterID int64 `gorm:"column:commenter_id"`
PostID int64 `gorm:"column:post_id"`
Body template.HTML `sql:"-"`
RawBody string `gorm:"column:body"`
Time string `sql:"-"`
Timestamp int64 `gorm:"column:timestamp"`
CommentID int64 `gorm:"column:id; primary_key:yes"`
}
func (CommentTable) TableName ¶
func (t CommentTable) TableName() string
type CommentWithPostTitle ¶
type CommenterTable ¶
func (CommenterTable) TableName ¶
func (t CommenterTable) TableName() string
type Config ¶
type Config struct {
Server
Notifications
Interface
}
type Context ¶
type CryptoHelper ¶
type Deck ¶
type Deck struct {
// contains filtered or unexported fields
}
func (*Deck) GetTask ¶
func (d *Deck) GetTask(id string) *CaptchaTask
func (*Deck) NextTask ¶
func (d *Deck) NextTask() *CaptchaTask
func (*Deck) SetNextTask ¶
type Entry ¶
type Entry struct {
EntryTable
Author string `gorm:"column:disp_name"`
Tags []*Tag `sql:"-"`
Comments []*Comment `sql:"-"`
}
func (Entry) HasComments ¶
func (Entry) NumCommentsStr ¶
type EntryLink ¶
type EntryLink struct {
Title string `gorm:"column:title"`
URL string `gorm:"column:url"`
Hidden bool `gorm:"column:hidden"`
}
Note: URL mapping is required, gorm won't be able to map to all-caps URL without it. Others are only for consistency.
type EntryTable ¶
type EntryTable struct {
EntryLink
ID int64
AuthorID int64 `gorm:"column:author_id"`
Date string `sql:"-"`
UnixDate int64 `gorm:"column:date"`
Body template.HTML `sql:"-"`
RawBody string `gorm:"column:body"`
}
func (EntryTable) TableName ¶
func (e EntryTable) TableName() string
type Notifications ¶
type Server ¶
type Server struct {
DBConn string `yaml:"db_conn"`
StaticDir string `yaml:"static_dir"`
Favicon string
Port string
TLSPort string `yaml:"tls_port"`
TLSCert string `yaml:"tls_cert"`
TLSKey string `yaml:"tls_key"`
CookieSecret string `yaml:"cookie_secret"`
Log string
LogSQL bool `yaml:"log_sql"`
UploadsRoot string `yaml:"uploads_root"`
}
type TagMap ¶
type XeroxLangDetector ¶
type XeroxLangDetector struct{}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.