summaryrefslogtreecommitdiff
path: root/internal/factgiver
diff options
from:
to:
context:
space:
mode:
authorGravatar Saya Andy <145215889+SayaAndy@users.noreply.github.com> 2025-10-20 19:01:05 +0700
committerGravatar GitHub <noreply@github.com> 2025-10-20 19:01:05 +0700
commitdf20c871060ad88254f18d4a04f714edf59156f0 (patch)
tree3161c1417a314ee13595fef6906969ac92172edf /internal/factgiver
parent3266aae61dbaaba45e32d64d7faddaaa671f8b52 (diff)
parent64397d4d27c14427ee8cb8d5a7618058d04f3737 (diff)
downloadweb-0.10.0.tar.gz
web-0.10.0.zip
v0.10.0 (#15)v0.10.0
- [feat: have toolbar on the top by default (only return to left if the screen is short on height)](https://github.com/SayaAndy/saya-today-web/commit/324c6df1ab878aa0c34f80c58f730e01aca1f4e9) - feat: switch font to Andika - [feat: add noise to plain color backgrounds](https://github.com/SayaAndy/saya-today-web/commit/36d7f332e6c318064ff0cd6849f69854c7ba0d79) - [feat: shorten toolbar in global map, paint map on the whole screen](https://github.com/SayaAndy/saya-today-web/commit/2cbbaaa40019e452b41c98720af8c23759351200) - [feat: redo language page with general page layout](https://github.com/SayaAndy/saya-today-web/commit/f6c60d0a963817189854f5b42bc58a76ddb90d53) - feat: move back button from header to toolbar - feat: switch masonry to use rem units - feat: fit masonry to center - feat: make inset shadows more apparent - feat: header font: less thick, non-italic and drops shadow - [fix: home page header getting too close to right border](https://github.com/SayaAndy/saya-today-web/commit/fdb8582f40168dbb0795358f1ea950a26f157b2d) - feat: paint shadow off home page header - fix: have toolbar buttons' href updated with language change - fix: add missing underline in contacts panel
Diffstat (limited to 'internal/factgiver')
-rw-r--r--internal/factgiver/factgiver.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/internal/factgiver/factgiver.go b/internal/factgiver/factgiver.go
index 6f77403..5b418ee 100644
--- a/internal/factgiver/factgiver.go
+++ b/internal/factgiver/factgiver.go
@@ -14,13 +14,13 @@ import (
type FactGiver struct {
b2Client *b2.B2Client
cache map[string][]string
- langs []string
+ langs []config.AvailableLanguageConfig
factsFileName string
nlRe *regexp.Regexp
randGen *rand.Rand
}
-func NewFactGiver(cfg *config.FactGiverConfig, langs []string) (*FactGiver, error) {
+func NewFactGiver(cfg *config.FactGiverConfig, langs []config.AvailableLanguageConfig) (*FactGiver, error) {
b2Client, err := b2.NewB2Client(&cfg.Storage.Config)
if err != nil {
return nil, fmt.Errorf("fail to init b2 client for a new fact giver: %s", err.Error())
@@ -52,15 +52,15 @@ func (g *FactGiver) Give(lang string) [3]string {
func (g *FactGiver) initCache() error {
for _, lang := range g.langs {
- localFacts := strings.Replace(g.factsFileName, "*", lang, 1)
+ localFacts := strings.Replace(g.factsFileName, "*", lang.Name, 1)
factsContentBytes, err := g.b2Client.ReadAll(localFacts)
if err != nil {
- return fmt.Errorf("fail to read '%s' facts file: %s", lang, err.Error())
+ return fmt.Errorf("fail to read '%s' facts file: %s", lang.Name, err.Error())
}
factsContent := string(factsContentBytes)
- g.cache[lang] = g.nlRe.Split(factsContent, -1)
- if g.cache[lang][len(g.cache[lang])-1] == "" {
- g.cache[lang] = g.cache[lang][:len(g.cache[lang])-1]
+ g.cache[lang.Name] = g.nlRe.Split(factsContent, -1)
+ if g.cache[lang.Name][len(g.cache[lang.Name])-1] == "" {
+ g.cache[lang.Name] = g.cache[lang.Name][:len(g.cache[lang.Name])-1]
}
}
return nil