Documentation ¶
Index ¶
- Constants
- Variables
- func CheckIfStringContainsHTML(path string, templ *template.Template) error
- func CheckIfUserIsPartOfGroup(db *sql.DB, username string, group string) (bool, error)
- func ConvertInterfaceToHashmap(inInterface interface{}) (map[string]interface{}, error)
- func CreateDBHandler() (*sql.DB, error)
- func CreateDBHandlerWithDB(database string) (*sql.DB, error)
- func GenerateRandomStringURLSafe(n int) (string, error)
- func GenerateSlug(input string) string
- func GetSettingFromName(db *sql.DB, name string) (string, error)
- func GetSettings(db *sql.DB) (map[string]string, error)
- func GetUsernameFromRequest(r *http.Request) (string, error)
- func HandleError(err error)
- func InternalServerError(w http.ResponseWriter)
- func Markdown(arg string) template.HTML
- func ParseTemplates() *template.Template
- func RenderTemplate(r *http.Request, w http.ResponseWriter, tmpl string, data interface{})
- func UserIsAdmin(r *http.Request) bool
- type Configuration
- type FooterPage
- type Path
- type ToolbarPage
Constants ¶
const SettingsFileName = "settings.json"
SettingsFileName is the name of the settings file. Could be customized to anything you want but _should_ end in .json
Variables ¶
var ( // Store ... Store = sessions.NewCookieStore(key) )
Functions ¶
func CheckIfStringContainsHTML ¶
CheckIfStringContainsHTML checks if the string contains the .html suffix.
func CheckIfUserIsPartOfGroup ¶
CheckIfUserIsPartOfGroup checks if the user sent in is a part of the group sent in.
func ConvertInterfaceToHashmap ¶
ConvertInterfaceToHashmap converts an interface to a hashmap.
func CreateDBHandler ¶
CreateDBHandler returns a database handler to the database exactly as defined in the settings.json file.
func CreateDBHandlerWithDB ¶
CreateDBHandlerWithDB returns a database handler to the database as defined in the settings.json file without regards to the database_name config option. Is very useful for unit tests.
func GenerateRandomStringURLSafe ¶
GenerateRandomStringURLSafe returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateSlug ¶
GenerateSlug generates a slug from an input name.
func GetSettingFromName ¶
GetSettingFromName returns the setting value from the database by the setting name.
func GetSettings ¶
GetSettings returns all of the settings from the database as a hashmap.
func GetUsernameFromRequest ¶
GetUsernameFromRequest gets the username from the storage and returns it or an error.
func InternalServerError ¶
func InternalServerError(w http.ResponseWriter)
InternalServerError returns an internal server error.
func ParseTemplates ¶
ParseTemplates parses the HTML templates in the templates folder. Including any HTML templates in subdirectories.
func RenderTemplate ¶
func RenderTemplate(r *http.Request, w http.ResponseWriter, tmpl string, data interface{})
RenderTemplate renders the HTML file as sent in by the 'tmpl' variable and uses the 'data' interface as well as adds more data necessary for running the application.
func UserIsAdmin ¶
UserIsAdmin function checks if the user is an administrator and returns the result as a boolean.
Types ¶
type Configuration ¶
type Configuration struct { DatabaseUser string DatabasePassword string DatabaseHost string DatabasePort string DatabaseName string }
Configuration is the data stored in the settings.json file in a go struct.
type FooterPage ¶
type FooterPage struct {}
FooterPage contains the data used in the footer items
func GetFooterPages ¶
func GetFooterPages(db *sql.DB) ([]FooterPage, error)
GetFooterPages returns all of the footer pages from the database
type ToolbarPage ¶
ToolbarPage contains the data used in the toolbar items
func GetToolbarPages ¶
func GetToolbarPages(db *sql.DB) ([]ToolbarPage, error)
GetToolbarPages returns all of the toolbar pages from the database.