global

package
v0.0.0-...-09e72e1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package global provides constants, defaults and helper methods to mouthful.

Index

Constants

View Source
const DefaultAuthorLengthLimit = 50

DefaultAuthorLengthLimit default author length limit

View Source
const DefaultBindAddress = "0.0.0.0"

DefaultBindAddress is the default value for api service bind address

View Source
const DefaultCleanupPeriod = int64(86400)

DefaultCleanupPeriod default cleanup period time

View Source
const DefaultCommentLengthLimit = 0

DefaultCommentLengthLimit default comment length limit

View Source
const DefaultDynamoDbCommentTableName = "mouthful_comment"

DefaultDynamoDbCommentTableName default suffix for dynamodb comment

View Source
const DefaultDynamoDbThreadTableName = "mouthful_thread"

DefaultDynamoDbThreadTableName default suffix for dynamodb thread

View Source
const DefaultPort = 8080

DefaultPort is the default value for api port

View Source
const DefaultSessionName = "mouthful-session"

DefaultSessionName default sesion name for api

View Source
const StaticPath = "./static"

StaticPath is the default location for our static files

Variables

View Source
var ErrBadRequest = errors.New("Bad request")

ErrBadRequest -> 400 basically

View Source
var ErrCommentNotFound = errors.New("Comment not found")

ErrCommentNotFound indicates that the comment does not exist

View Source
var ErrCouldNotFindBundleFile = errors.New("Can't find bundle file")

ErrCouldNotFindBundleFile indicates that we could not find the required bundle file

View Source
var ErrCouldNotOverrideBundlePath = errors.New("Can't override bundle file path")

ErrCouldNotOverrideBundlePath indicates that we could not find override the path in bundle

View Source
var ErrInternalServerError = errors.New("Internal server error")

ErrInternalServerError -> 500 basically

View Source
var ErrThreadNotFound = errors.New("Thread not found")

ErrThreadNotFound indicates that no thread was found

View Source
var ErrUnauthorized = errors.New("Unauthorized")

ErrUnauthorized -> 401 basically

View Source
var ErrWrongReplyTo = errors.New("Can't reply to this comment")

ErrWrongReplyTo indicates that the comments replyTo comment Id is invalid

Functions

func FindAdminPanelChunkFilename

func FindAdminPanelChunkFilename(root string) (string, error)

FindAdminPanelChunkFilename returns the name of the route-panel chunk file, as it contains a hash.

func GetUUID

func GetUUID() uuid.UUID

GetUUID returns a new random UUID

func NanoToTime

func NanoToTime(t int64) time.Time

NanoToTime takes in a nano unix time and converts it to time.Time object

func OverrideScriptPathInBundle

func OverrideScriptPathInBundle(prefix, filepath string) error

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

func OverrideScriptRootInAdminHTML(prefix, filepath string) error

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

func ParseAndSaniziteMarkdown(input string) string

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

func ParseUUIDFromString(uid string) (*uuid.UUID, error)

ParseUUIDFromString tries to parse a string as uuid, if fails returns an error. Otherwise a pointer to uuid.UUID

func RewriteAdminPanelScripts

func RewriteAdminPanelScripts(path string) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL