Documentation ¶
Overview ¶
Package global provides constants, defaults and helper methods to mouthful.
Index ¶
- Constants
- Variables
- func FindAdminPanelChunkFilename(root string) (string, error)
- func GetUUID() uuid.UUID
- func NanoToTime(t int64) time.Time
- func OverrideScriptPathInBundle(prefix, filepath string) error
- func OverrideScriptRootInAdminHTML(prefix, filepath string) error
- func ParseAndSaniziteMarkdown(input string) string
- func ParseUUIDFromString(uid string) (*uuid.UUID, error)
- func RewriteAdminPanelScripts(path string) error
- type CleanupType
Constants ¶
const DefaultAuthorLengthLimit = 50
DefaultAuthorLengthLimit default author length limit
const DefaultBindAddress = "0.0.0.0"
DefaultBindAddress is the default value for api service bind address
const DefaultCleanupPeriod = int64(86400)
DefaultCleanupPeriod default cleanup period time
const DefaultCommentLengthLimit = 0
DefaultCommentLengthLimit default comment length limit
const DefaultDynamoDbCommentTableName = "mouthful_comment"
DefaultDynamoDbCommentTableName default suffix for dynamodb comment
const DefaultDynamoDbThreadTableName = "mouthful_thread"
DefaultDynamoDbThreadTableName default suffix for dynamodb thread
const DefaultPort = 8080
DefaultPort is the default value for api port
const DefaultSessionName = "mouthful-session"
DefaultSessionName default sesion name for api
const StaticPath = "./static"
StaticPath is the default location for our static files
Variables ¶
var ErrBadRequest = errors.New("Bad request")
ErrBadRequest -> 400 basically
var ErrCommentNotFound = errors.New("Comment not found")
ErrCommentNotFound indicates that the comment does not exist
var ErrCouldNotFindBundleFile = errors.New("Can't find bundle file")
ErrCouldNotFindBundleFile indicates that we could not find the required bundle file
var ErrCouldNotOverrideBundlePath = errors.New("Can't override bundle file path")
ErrCouldNotOverrideBundlePath indicates that we could not find override the path in bundle
var ErrInternalServerError = errors.New("Internal server error")
ErrInternalServerError -> 500 basically
var ErrThreadNotFound = errors.New("Thread not found")
ErrThreadNotFound indicates that no thread was found
ErrUnauthorized -> 401 basically
var ErrWrongReplyTo = errors.New("Can't reply to this comment")
ErrWrongReplyTo indicates that the comments replyTo comment Id is invalid
Functions ¶
func FindAdminPanelChunkFilename ¶
FindAdminPanelChunkFilename returns the name of the route-panel chunk file, as it contains a hash.
func NanoToTime ¶
NanoToTime takes in a nano unix time and converts it to time.Time object
func OverrideScriptPathInBundle ¶
OverrideScriptPathInBundle changes the root path in the bundle file. This is needed because preact by default bakes in an absolute src, like src="/". This results in issues with hosting the mouthful instance under a path that's different than /, such as "/mouthful". To fix it, on running mouthful this function is run and overrides the src with prefix + src.
func OverrideScriptRootInAdminHTML ¶
OverrideScriptRootInAdminHTML changes the src elements in the index.html of the admin panel inside the static dir. This is needed because preact by default bakes in an absolute src, like src="/". This results in issues with hosting the mouthful instance under a path that's different than /, such as "/mouthful". To fix it, on running mouthful this function is run and overrides the src with prefix + src.
func ParseAndSaniziteMarkdown ¶
ParseAndSaniziteMarkdown takes in a markdown string, parses it and sanitizes it with blue monday. The returned html string should be safe for consumption.
func ParseUUIDFromString ¶
ParseUUIDFromString tries to parse a string as uuid, if fails returns an error. Otherwise a pointer to uuid.UUID
func RewriteAdminPanelScripts ¶
RewriteAdminPanelScripts performs all the steps needed for rewriting the admin panel paths if your mouthful instance is not running under "/".
Types ¶
type CleanupType ¶
type CleanupType int
CleanupType represents all the different types of cleanup we can perform
const ( // Unconfirmed cleans up unconfirmed comments Unconfirmed CleanupType = 0 // Deleted cleans up deleted comments Deleted CleanupType = 1 )
func (CleanupType) String ¶
func (i CleanupType) String() string