Documentation ¶
Index ¶
- func EncodeID(id string) string
- func GetMdExtensionsAndRenderer() (bf.Extensions, *bfchroma.Renderer)
- func HashValue(val, secret string) string
- type BlockedUser
- type Comment
- type CommentConverter
- type CommentConverterFunc
- type CommentFormatter
- type DeleteMode
- type Edit
- type Locator
- type PostInfo
- type User
- type VotedIPInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeID ¶
EncodeID hashes id to sha1. The function intentionally left outside of User struct because in some cases we need hashing for parts of id, in some others hashing for non-User values.
func GetMdExtensionsAndRenderer ¶ added in v1.12.0
func GetMdExtensionsAndRenderer() (bf.Extensions, *bfchroma.Renderer)
GetMdExtensionsAndRenderer returns blackfriday extensions and renderer used for rendering markdown within store module.
Types ¶
type BlockedUser ¶
type BlockedUser struct { ID string `json:"id"` Name string `json:"name"` Until time.Time `json:"time"` }
BlockedUser holds id and ts for blocked user
type Comment ¶
type Comment struct { ID string `json:"id" bson:"_id"` ParentID string `json:"pid"` Text string `json:"text"` Orig string `json:"orig,omitempty"` // important: never render this as HTML! It's not sanitized. User User `json:"user"` Locator Locator `json:"locator"` Score int `json:"score"` Votes map[string]bool `json:"votes,omitempty"` VotedIPs map[string]VotedIPInfo `json:"voted_ips,omitempty"` // voted ips (hashes) with TS Vote int `json:"vote"` // vote for the current user, -1/1/0. Controversy float64 `json:"controversy,omitempty"` Timestamp time.Time `json:"time" bson:"time"` Edit *Edit `json:"edit,omitempty" bson:"edit,omitempty"` // pointer to have empty default in json response Pin bool `json:"pin,omitempty" bson:"pin,omitempty"` Deleted bool `json:"delete,omitempty" bson:"delete"` Imported bool `json:"imported,omitempty" bson:"imported"` PostTitle string `json:"title,omitempty" bson:"title"` }
Comment represents a single comment with optional reference to its parent
func (*Comment) PrepareUntrusted ¶
func (c *Comment) PrepareUntrusted()
PrepareUntrusted pre-processes a comment received from untrusted source by clearing all autogen fields and reset everything users not supposed to provide
func (*Comment) Sanitize ¶
func (c *Comment) Sanitize()
Sanitize clean dangerous html/js from the comment. Comment.Orig which is used to store the original comment text is not sanitized as we expect to never render it as HTML and render Comment.Text instead
func (*Comment) SanitizeAsURL ¶
SanitizeAsURL drops dangerous code from a url. It wraps input with href to trigger bluemonday sanitizer and cleans href after sanitizing done
func (*Comment) SanitizeText ¶ added in v1.9.0
SanitizeText used to sanitize any input string
func (*Comment) SetDeleted ¶
func (c *Comment) SetDeleted(mode DeleteMode)
SetDeleted clears comment info, reset to deleted state. hard flag will clear all user info as well
type CommentConverter ¶
CommentConverter defines interface to convert some parts of commentHTML Passed at creation time and does client-defined conversions, like image proxy link change
type CommentConverterFunc ¶
CommentConverterFunc functional struct implementing CommentConverter
func (CommentConverterFunc) Convert ¶
func (f CommentConverterFunc) Convert(text string) string
Convert calls func for given text
type CommentFormatter ¶
type CommentFormatter struct {
// contains filtered or unexported fields
}
CommentFormatter implements all generic formatting ops on comment
func NewCommentFormatter ¶
func NewCommentFormatter(converters ...CommentConverter) *CommentFormatter
NewCommentFormatter makes CommentFormatter
func (*CommentFormatter) Format ¶
func (f *CommentFormatter) Format(c Comment) Comment
Format comment fields
func (*CommentFormatter) FormatText ¶
func (f *CommentFormatter) FormatText(txt string) (res string)
FormatText converts text with markdown processor, applies external converters and shortens links
type DeleteMode ¶
type DeleteMode int
DeleteMode defines how much comment info will be erased
const ( SoftDelete DeleteMode = 0 HardDelete DeleteMode = 1 )
DeleteMode enum
type PostInfo ¶
type PostInfo struct { URL string `json:"url"` Count int `json:"count"` ReadOnly bool `json:"read_only,omitempty" bson:"read_only,omitempty"` FirstTS time.Time `json:"first_time,omitempty" bson:"first_time,omitempty"` LastTS time.Time `json:"last_time,omitempty" bson:"last_time,omitempty"` }
PostInfo holds summary for given post url
type User ¶
type User struct { Name string `json:"name"` ID string `json:"id"` Picture string `json:"picture"` IP string `json:"ip,omitempty"` Admin bool `json:"admin"` Blocked bool `json:"block,omitempty"` Verified bool `json:"verified,omitempty"` EmailSubscription bool `json:"email_subscription,omitempty"` SiteID string `json:"site_id,omitempty"` PaidSub bool `json:"paid_sub,omitempty"` }
User holds user-related info
type VotedIPInfo ¶
VotedIPInfo keeps timestamp and voting value (direction). Used as VotedIPs value
Directories ¶
Path | Synopsis |
---|---|
Package admin defines and implements store for admin-level data like secret key, list of admins and so on
|
Package admin defines and implements store for admin-level data like secret key, list of admins and so on |
Package image handles storing, resizing and retrieval of images Provides Store with Save and Load implementations on top of local file system and bolt db.
|
Package image handles storing, resizing and retrieval of images Provides Store with Save and Load implementations on top of local file system and bolt db. |
Package service wraps engine interfaces with common logic unrelated to any particular engine implementation.
|
Package service wraps engine interfaces with common logic unrelated to any particular engine implementation. |