mirror of
https://github.com/hrfee/jfa-go.git
synced 2025-01-01 14:00:12 +00:00
Compare commits
5 Commits
91b2b44768
...
cd2ea2e579
Author | SHA1 | Date | |
---|---|---|---|
cd2ea2e579 | |||
b66654787c | |||
882a3467db | |||
27ac0bf43e | |||
4485622354 |
32
config.go
32
config.go
@ -9,32 +9,6 @@ import (
|
|||||||
"gopkg.in/ini.v1"
|
"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 {
|
func (app *appContext) loadConfig() error {
|
||||||
var err error
|
var err error
|
||||||
app.config, err = ini.Load(app.configPath)
|
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()))
|
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() {
|
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" {
|
if key.Name() != "html_templates" {
|
||||||
key.SetValue(key.MustString(filepath.Join(app.dataPath, (key.Name() + ".json"))))
|
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"} {
|
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.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(""), "/")
|
app.URLBase = strings.TrimSuffix(app.config.Section("ui").Key("url_base").MustString(""), "/")
|
||||||
|
1
email.go
1
email.go
@ -60,7 +60,6 @@ func (sm *SMTP) send(address, fromName, fromAddr string, email *Email) error {
|
|||||||
ServerName: sm.server,
|
ServerName: sm.server,
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
fmt.Println(server)
|
|
||||||
// err = e.Send(server, sm.auth)
|
// err = e.Send(server, sm.auth)
|
||||||
if sm.sslTLS {
|
if sm.sslTLS {
|
||||||
err = e.SendWithTLS(server, sm.auth, tlsConfig)
|
err = e.SendWithTLS(server, sm.auth, tlsConfig)
|
||||||
|
13
lang.go
13
lang.go
@ -1,6 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "strings"
|
import (
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
type langMeta struct {
|
type langMeta struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
@ -19,6 +21,7 @@ func (ls *adminLangs) getOptions(chosen string) (string, []string) {
|
|||||||
i := 0
|
i := 0
|
||||||
for _, lang := range *ls {
|
for _, lang := range *ls {
|
||||||
opts[i] = lang.Meta.Name
|
opts[i] = lang.Meta.Name
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
return chosenLang, opts
|
return chosenLang, opts
|
||||||
}
|
}
|
||||||
@ -39,6 +42,7 @@ func (ls *formLangs) getOptions(chosen string) (string, []string) {
|
|||||||
i := 0
|
i := 0
|
||||||
for _, lang := range *ls {
|
for _, lang := range *ls {
|
||||||
opts[i] = lang.Meta.Name
|
opts[i] = lang.Meta.Name
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
return chosenLang, opts
|
return chosenLang, opts
|
||||||
}
|
}
|
||||||
@ -58,6 +62,7 @@ func (ls *emailLangs) getOptions(chosen string) (string, []string) {
|
|||||||
i := 0
|
i := 0
|
||||||
for _, lang := range *ls {
|
for _, lang := range *ls {
|
||||||
opts[i] = lang.Meta.Name
|
opts[i] = lang.Meta.Name
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
return chosenLang, opts
|
return chosenLang, opts
|
||||||
}
|
}
|
||||||
@ -73,7 +78,7 @@ type emailLang struct {
|
|||||||
|
|
||||||
type langSection map[string]string
|
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)
|
text := el.get(field)
|
||||||
for _, val := range vals {
|
for _, val := range vals {
|
||||||
text = strings.Replace(text, "{n}", val, 1)
|
text = strings.Replace(text, "{n}", val, 1)
|
||||||
@ -81,8 +86,8 @@ func (el *langSection) format(field string, vals ...string) string {
|
|||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
|
|
||||||
func (el *langSection) get(field string) string {
|
func (el langSection) get(field string) string {
|
||||||
t, ok := (*el)[field]
|
t, ok := el[field]
|
||||||
if !ok {
|
if !ok {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
3
main.go
3
main.go
@ -524,6 +524,9 @@ func start(asDaemon, firstCall bool) {
|
|||||||
app.info.Fatalf("Failed to load language files: %+v\n", err)
|
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.authJf, _ = mediabrowser.NewServer(serverType, server, "jfa-go", app.version, "auth", "auth", timeoutHandler, cacheTimeout)
|
||||||
|
|
||||||
app.loadStrftime()
|
app.loadStrftime()
|
||||||
|
@ -147,7 +147,7 @@ type setting struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type section struct {
|
type section struct {
|
||||||
Meta langMeta `json:"meta"`
|
Meta meta `json:"meta"`
|
||||||
Order []string `json:"order"`
|
Order []string `json:"order"`
|
||||||
Settings map[string]setting `json:"settings"`
|
Settings map[string]setting `json:"settings"`
|
||||||
}
|
}
|
||||||
|
@ -263,6 +263,11 @@ export class DOMInvite implements Invite {
|
|||||||
|
|
||||||
const toggle = (this._infoArea.querySelector("input.inv-toggle-details") as HTMLInputElement);
|
const toggle = (this._infoArea.querySelector("input.inv-toggle-details") as HTMLInputElement);
|
||||||
toggle.onchange = () => { this.expanded = !this.expanded; };
|
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._details = document.createElement('div') as HTMLDivElement;
|
||||||
this._container.appendChild(this._details);
|
this._container.appendChild(this._details);
|
||||||
|
Loading…
Reference in New Issue
Block a user