Implement SEO optimizations and improve error handling and branch detection

This commit is contained in:
Moritz Marquardt 2021-03-19 20:30:08 +01:00
parent c4bae34b71
commit 8ead10c82e
No known key found for this signature in database
GPG key ID: D5788327BEE388B6
2 changed files with 111 additions and 71 deletions

20
main.go
View file

@ -20,7 +20,6 @@ import (
"fmt"
"net"
"os"
"strings"
"time"
_ "embed"
@ -67,14 +66,6 @@ var IndexPages = []string{
"index.html",
}
// ReservedUsernames specifies the usernames that are reserved by Gitea and thus may not be used as owner names.
// The contents are taken from https://github.com/go-gitea/gitea/blob/master/models/user.go#L783; reserved names with
// dots are removed as they are forbidden for Codeberg Pages anyways.
var ReservedUsernames = createLookupMapFromWords(`
admin api assets attachments avatars captcha commits debug error explore ghost help install issues less login metrics milestones new notifications org plugins pulls raw repo search stars template user
`)
// main sets up and starts the web server.
func main() {
// Make sure MainDomain has a trailing dot, and GiteaRoot has no trailing slash
@ -122,14 +113,3 @@ func envOr(env string, or string) string {
}
return or
}
func createLookupMapFromWords(input string) map[string]struct{} {
var res = map[string]struct{}{}
input = strings.NewReplacer("\t", " ", "\n", " ", "\r", " ").Replace(input)
for _, word := range strings.Split(input, " ") {
if len(word) > 0 {
res[word] = struct{}{}
}
}
return res
}