mirror of
https://codeberg.org/pluja/kycnot.me
synced 2025-04-16 13:43:19 -04:00
parse special characters for cactus id
This commit is contained in:
parent
71f9a8cfff
commit
88e97900c2
@ -263,7 +263,7 @@ initComments({
|
||||
defaultHomeserverUrl: "https://matrix.cactus.chat:8448",
|
||||
serverName: "cactus.chat",
|
||||
siteName: "kycnot.me",
|
||||
commentSectionId: "{{.Service.Name}}",
|
||||
commentSectionId: "{{toId .Service.Name}}",
|
||||
guestPostingEnabled: false
|
||||
})
|
||||
</script>
|
@ -7,6 +7,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -138,6 +139,22 @@ func (s *Server) RegisterViews() {
|
||||
"safe": func(s string) template.HTML {
|
||||
return template.HTML(s)
|
||||
},
|
||||
"toId": func(s string) string {
|
||||
reg, err := regexp.Compile("[^a-zA-Z0-9]+")
|
||||
if err != nil {
|
||||
log.Debug().Err(err).Msg("toId error")
|
||||
return strings.Replace(strings.ToLower(s), " ", "-", -1)
|
||||
}
|
||||
processedString := reg.ReplaceAllString(s, "-")
|
||||
regReplace, err := regexp.Compile("-+")
|
||||
if err != nil {
|
||||
log.Debug().Err(err).Msg("toId error")
|
||||
return strings.Replace(strings.ToLower(s), " ", "-", -1)
|
||||
}
|
||||
processedString = regReplace.ReplaceAllString(processedString, "-")
|
||||
|
||||
return strings.ToLower(processedString)
|
||||
},
|
||||
"randomElem": func(vs []string) string {
|
||||
if len(vs) == 0 {
|
||||
return ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user