1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-04 18:19:54 +00:00

Hacky fix for capitalization

This commit is contained in:
osmarks 2024-06-16 15:34:47 +01:00
parent ceff8ad91b
commit dd40d7ea37
2 changed files with 12 additions and 1 deletions

View File

@ -43,6 +43,9 @@ var (
TelegramEnabled bool TelegramEnabled bool
TelegramBotToken string TelegramBotToken string
TelegramBotName string TelegramBotName string
ReplaceFrom []string
ReplaceTo []string
) )
// WikiDir is a full path to the wiki storage directory, which also must be a // WikiDir is a full path to the wiki storage directory, which also must be a
@ -59,6 +62,8 @@ type Config struct {
Authorization Authorization
CustomScripts `comment:"You can specify additional scripts to load on different kinds of pages, delimited by a comma ',' sign."` CustomScripts `comment:"You can specify additional scripts to load on different kinds of pages, delimited by a comma ',' sign."`
Telegram `comment:"You can enable Telegram authorization. Follow these instructions: https://core.telegram.org/widgets/login#setting-up-a-bot"` Telegram `comment:"You can enable Telegram authorization. Follow these instructions: https://core.telegram.org/widgets/login#setting-up-a-bot"`
ReplaceFrom []string
ReplaceTo []string
} }
// Hyphae is a section of Config which has fields related to special hyphae. // Hyphae is a section of Config which has fields related to special hyphae.
@ -191,6 +196,8 @@ func ReadConfigFile(path string) error {
TelegramBotToken = cfg.TelegramBotToken TelegramBotToken = cfg.TelegramBotToken
TelegramBotName = cfg.TelegramBotName TelegramBotName = cfg.TelegramBotName
TelegramEnabled = (TelegramBotToken != "") && (TelegramBotName != "") TelegramEnabled = (TelegramBotToken != "") && (TelegramBotName != "")
ReplaceFrom = cfg.ReplaceFrom
ReplaceTo = cfg.ReplaceTo
// This URL makes much more sense. If no URL is set or the protocol is forgotten, assume HTTP. // This URL makes much more sense. If no URL is set or the protocol is forgotten, assume HTTP.
if URL == "" { if URL == "" {

View File

@ -56,7 +56,11 @@ func RandomString(n int) (string, error) {
// BeautifulName makes the ugly name beautiful by replacing _ with spaces and using title case. // BeautifulName makes the ugly name beautiful by replacing _ with spaces and using title case.
func BeautifulName(uglyName string) string { func BeautifulName(uglyName string) string {
// Why not reuse // Why not reuse
return util.BeautifulName(uglyName) result := util.BeautifulName(uglyName)
for i, replace := range cfg.ReplaceFrom {
result = strings.ReplaceAll(result, replace, cfg.ReplaceTo[i])
}
return result
} }
// CanonicalName makes sure the `name` is canonical. A name is canonical if it is lowercase and all spaces are replaced with underscores. // CanonicalName makes sure the `name` is canonical. A name is canonical if it is lowercase and all spaces are replaced with underscores.