1
0
mirror of https://github.com/hrfee/jfa-go.git synced 2024-12-28 20:10:11 +00:00

Compare commits

...

5 Commits

9 changed files with 18 additions and 38 deletions

View File

@ -9,32 +9,6 @@ import (
"gopkg.in/ini.v1"
)
/*var DeCamel ini.NameMapper = func(raw string) string {
out := make([]rune, 0, len(raw))
upper := 0
for _, c := range raw {
if unicode.IsUpper(c) {
upper++
}
if upper == 2 {
out = append(out, '_')
upper = 0
}
out = append(out, unicode.ToLower(c))
}
return string(out)
}
func (app *appContext) loadDefaults() (err error) {
var cfb []byte
cfb, err = ioutil.ReadFile(app.configBase_path)
if err != nil {
return
}
json.Unmarshal(cfb, app.defaults)
return
}*/
func (app *appContext) loadConfig() error {
var err error
app.config, err = ini.Load(app.configPath)
@ -45,17 +19,11 @@ func (app *appContext) loadConfig() error {
app.config.Section("jellyfin").Key("public_server").SetValue(app.config.Section("jellyfin").Key("public_server").MustString(app.config.Section("jellyfin").Key("server").String()))
for _, key := range app.config.Section("files").Keys() {
// if key.MustString("") == "" && key.Name() != "custom_css" {
// key.SetValue(filepath.Join(app.data_path, (key.Name() + ".json")))
// }
if key.Name() != "html_templates" {
key.SetValue(key.MustString(filepath.Join(app.dataPath, (key.Name() + ".json"))))
}
}
for _, key := range []string{"user_configuration", "user_displayprefs", "user_profiles", "ombi_template", "invites", "emails", "user_template"} {
// if app.config.Section("files").Key(key).MustString("") == "" {
// key.SetValue(filepath.Join(app.data_path, (key.Name() + ".json")))
// }
app.config.Section("files").Key(key).SetValue(app.config.Section("files").Key(key).MustString(filepath.Join(app.dataPath, (key + ".json"))))
}
app.URLBase = strings.TrimSuffix(app.config.Section("ui").Key("url_base").MustString(""), "/")

View File

@ -60,7 +60,6 @@ func (sm *SMTP) send(address, fromName, fromAddr string, email *Email) error {
ServerName: sm.server,
}
var err error
fmt.Println(server)
// err = e.Send(server, sm.auth)
if sm.sslTLS {
err = e.SendWithTLS(server, sm.auth, tlsConfig)

13
lang.go
View File

@ -1,6 +1,8 @@
package main
import "strings"
import (
"strings"
)
type langMeta struct {
Name string `json:"name"`
@ -19,6 +21,7 @@ func (ls *adminLangs) getOptions(chosen string) (string, []string) {
i := 0
for _, lang := range *ls {
opts[i] = lang.Meta.Name
i++
}
return chosenLang, opts
}
@ -39,6 +42,7 @@ func (ls *formLangs) getOptions(chosen string) (string, []string) {
i := 0
for _, lang := range *ls {
opts[i] = lang.Meta.Name
i++
}
return chosenLang, opts
}
@ -58,6 +62,7 @@ func (ls *emailLangs) getOptions(chosen string) (string, []string) {
i := 0
for _, lang := range *ls {
opts[i] = lang.Meta.Name
i++
}
return chosenLang, opts
}
@ -73,7 +78,7 @@ type emailLang struct {
type langSection map[string]string
func (el *langSection) format(field string, vals ...string) string {
func (el langSection) format(field string, vals ...string) string {
text := el.get(field)
for _, val := range vals {
text = strings.Replace(text, "{n}", val, 1)
@ -81,8 +86,8 @@ func (el *langSection) format(field string, vals ...string) string {
return text
}
func (el *langSection) get(field string) string {
t, ok := (*el)[field]
func (el langSection) get(field string) string {
t, ok := el[field]
if !ok {
return ""
}

View File

@ -524,6 +524,9 @@ func start(asDaemon, firstCall bool) {
app.info.Fatalf("Failed to load language files: %+v\n", err)
}
// Since email depends on language, the email reload in loadConfig won't work first time.
app.email = NewEmailer(app)
app.authJf, _ = mediabrowser.NewServer(serverType, server, "jfa-go", app.version, "auth", "auth", timeoutHandler, cacheTimeout)
app.loadStrftime()

View File

@ -147,7 +147,7 @@ type setting struct {
}
type section struct {
Meta langMeta `json:"meta"`
Meta meta `json:"meta"`
Order []string `json:"order"`
Settings map[string]setting `json:"settings"`
}

View File

@ -263,6 +263,11 @@ export class DOMInvite implements Invite {
const toggle = (this._infoArea.querySelector("input.inv-toggle-details") as HTMLInputElement);
toggle.onchange = () => { this.expanded = !this.expanded; };
this._header.onclick = (event: Event) => {
if (event.target == this._header) {
this.expanded = !this.expanded;
}
};
this._details = document.createElement('div') as HTMLDivElement;
this._container.appendChild(this._details);