update: general formatting and cleanup
This commit is contained in:
58
lib/util.go
58
lib/util.go
@ -12,44 +12,44 @@ import (
|
||||
// python3 -c "import string; print(string.ascii_letters+string.digits+\" /,_-?!'\\\"\")"
|
||||
var valid string = `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 /,_-?!'"`
|
||||
|
||||
func IsStringValid(s string) bool{
|
||||
for _, c := range s {
|
||||
if !strings.Contains(valid, string(c)){
|
||||
fmt.Printf("%c\n", c)
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
func IsStringValid(s string) bool {
|
||||
for _, c := range s {
|
||||
if !strings.Contains(valid, string(c)) {
|
||||
fmt.Printf("%c\n", c)
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func RenderError(c *fiber.Ctx, code int) error{
|
||||
var msg string = "Server Error"
|
||||
c.Status(code)
|
||||
func RenderError(c *fiber.Ctx, code int) error {
|
||||
var msg string = "Server Error"
|
||||
c.Status(code)
|
||||
|
||||
switch code {
|
||||
case 404:
|
||||
msg = "Not Found"
|
||||
}
|
||||
switch code {
|
||||
case 404:
|
||||
msg = "Not Found"
|
||||
}
|
||||
|
||||
return c.Render("error", fiber.Map{
|
||||
"msg": msg,
|
||||
})
|
||||
return c.Render("error", fiber.Map{
|
||||
"msg": msg,
|
||||
})
|
||||
}
|
||||
|
||||
func TimeFromString(date string) (time.Time, error) {
|
||||
res, err := time.Parse("02/01/06", date)
|
||||
if err == nil {
|
||||
return res, nil
|
||||
}
|
||||
return time.Now(), nil
|
||||
res, err := time.Parse("02/01/06", date)
|
||||
if err == nil {
|
||||
return res, nil
|
||||
}
|
||||
return time.Now(), nil
|
||||
}
|
||||
|
||||
func ParseMarkdown(md string) string {
|
||||
ext := blackfriday.FencedCode
|
||||
ext |= blackfriday.BackslashLineBreak
|
||||
ext |= blackfriday.Strikethrough
|
||||
ext |= blackfriday.Tables
|
||||
ext |= blackfriday.NoEmptyLineBeforeBlock
|
||||
ext := blackfriday.FencedCode
|
||||
ext |= blackfriday.BackslashLineBreak
|
||||
ext |= blackfriday.Strikethrough
|
||||
ext |= blackfriday.Tables
|
||||
ext |= blackfriday.NoEmptyLineBeforeBlock
|
||||
|
||||
return string(blackfriday.Run([]byte(md), blackfriday.WithExtensions(ext)))
|
||||
return string(blackfriday.Run([]byte(md), blackfriday.WithExtensions(ext)))
|
||||
}
|
||||
|
Reference in New Issue
Block a user