taldir

Directory service to resolve wallet mailboxes by messenger addresses
Log | Files | Refs | Submodules | README | LICENSE

commit a2adca06e7ceb3db876bc7ec7ac9ee8d731ff297
parent db7f57e6f535fbf5a26b0fc777b2f3cf3e914164
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date:   Tue, 14 Jan 2025 13:50:28 +0100

minor facelift wip

Diffstat:
Mgo.mod | 4++--
Mlocales/de-DE/taldir.yml | 2+-
Mlocales/en-US/taldir.yml | 2+-
Mpkg/rest/taldir.go | 39++++++++++++++++++++-------------------
Mweb/templates/landing.html | 2+-
Mweb/templates/landing_email.html | 12+++++-------
Mweb/templates/landing_phone.html | 11++++-------
Mweb/templates/lookup_result.html | 13+++++--------
8 files changed, 39 insertions(+), 46 deletions(-)

diff --git a/go.mod b/go.mod @@ -3,8 +3,10 @@ module taler.net/taldir go 1.18 require ( + github.com/gertd/go-pluralize v0.2.1 github.com/gorilla/mux v1.8.0 github.com/jarcoal/httpmock v1.2.0 + github.com/kataras/i18n v0.0.8 github.com/schanzen/taler-go v1.0.6 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e gnunet v0.1.27 @@ -16,7 +18,6 @@ require ( require ( github.com/BurntSushi/toml v1.2.1 // indirect github.com/bfix/gospel v1.2.15 // indirect - github.com/gertd/go-pluralize v0.2.1 // indirect github.com/jackc/chunkreader/v2 v2.0.1 // indirect github.com/jackc/pgconn v1.11.0 // indirect github.com/jackc/pgio v1.0.0 // indirect @@ -27,7 +28,6 @@ require ( github.com/jackc/pgx/v4 v4.15.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect - github.com/kataras/i18n v0.0.8 // indirect golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898 // indirect golang.org/x/net v0.9.0 // indirect golang.org/x/text v0.9.0 // indirect diff --git a/locales/de-DE/taldir.yml b/locales/de-DE/taldir.yml @@ -1,6 +1,6 @@ phone: "Telefonnummer" email: "E-Mail" error: "Es ist ein Fehler aufgetreten!" -title: "TalDir Alias Registration und Suche" +title: "Alias Registration und Suche" selectAliasToLookupOrLink: "Bitte wähle einen Alias-Typ den Du suchen oder mit einer Bezahlsystemaddresse verlinken möchtest." lookupOrRegister: "Suchen oder Verlinken" diff --git a/locales/en-US/taldir.yml b/locales/en-US/taldir.yml @@ -1,6 +1,6 @@ phone: "Phone" email: "E-mail" error: "An error occured!" -title: "TalDir Alias Registration and Lookup" +title: "Alias Registration and Lookup" selectAliasToLookupOrLink: "Select a type of alias that you want to look up or link to a Payment System Address." lookupOrRegister: "Look up or register" diff --git a/pkg/rest/taldir.go b/pkg/rest/taldir.go @@ -779,6 +779,7 @@ func (t *Taldir) Initialize(cfgfile string, version string) { fmt.Println("Production mode enabled") } + navTplFile := t.Cfg.Section("taldir").Key("navigation").MustString("web/templates/nav.html") footerTplFile := t.Cfg.Section("taldir").Key("footer").MustString("web/templates/footer.html") t.Version = version t.BaseUrl = t.Cfg.Section("taldir").Key("base_url").MustString("http://localhost:11000") @@ -793,7 +794,7 @@ func (t *Taldir) Initialize(cfgfile string, version string) { } vname := strings.TrimPrefix(sec.Name(), "taldir-validator-") vlandingPageTplFile := sec.Key("registration_page").MustString("web/templates/landing_" + vname + ".html") - vlandingPageTpl, err := template.ParseFiles(vlandingPageTplFile, footerTplFile) + vlandingPageTpl, err := template.ParseFiles(vlandingPageTplFile, navTplFile, footerTplFile) if err != nil { log.Printf("`%s` template not found, disabling validator `%s`.\n", vlandingPageTplFile, vname) continue @@ -864,19 +865,19 @@ func (t *Taldir) Initialize(cfgfile string, version string) { } }() validationLandingTplFile := t.Cfg.Section("taldir").Key("validation_landing").MustString("web/templates/validation_landing.html") - t.ValidationTpl, err = template.ParseFiles(validationLandingTplFile, footerTplFile) + t.ValidationTpl, err = template.ParseFiles(validationLandingTplFile, navTplFile, footerTplFile) if err != nil { log.Fatal(err) os.Exit(1) } landingTplFile := t.Cfg.Section("taldir").Key("landing_page").MustString("web/templates/landing.html") - t.LandingPageTpl, err = template.ParseFiles(landingTplFile, footerTplFile) + t.LandingPageTpl, err = template.ParseFiles(landingTplFile, navTplFile, footerTplFile) if err != nil { log.Fatal(err) os.Exit(1) } lookupResultTplFile := t.Cfg.Section("taldir").Key("lookup_result_page").MustString("web/templates/lookup_result.html") - t.LookupResultPageTpl, err = template.ParseFiles(lookupResultTplFile, footerTplFile) + t.LookupResultPageTpl, err = template.ParseFiles(lookupResultTplFile, navTplFile, footerTplFile) if err != nil { log.Fatal(err) os.Exit(1) @@ -885,20 +886,20 @@ func (t *Taldir) Initialize(cfgfile string, version string) { if "" == t.Salt { t.Salt = t.Cfg.Section("taldir").Key("salt").MustString("ChangeMe") } - merchURL := t.Cfg.Section("taldir").Key("merchant_base_url").MustString("http://merchant.taldir/") - merchToken := t.Cfg.Section("taldir").Key("merchant_token").MustString("secretAccessToken") - t.Merchant = merchant.NewMerchant(merchURL, merchToken) - merchConfig, err := t.Merchant.GetConfig() - if nil != err { - log.Fatal("Failed to get merchant config") - os.Exit(1) - } - registrationCost, _ := talerutil.ParseAmount(t.MonthlyFee) - currencySpec, currencySupported := merchConfig.Currencies[registrationCost.Currency] - for !currencySupported { - log.Fatalf("Currency `%s' not supported by merchant!\n", registrationCost.Currency) - os.Exit(1) - } - t.CurrencySpec = currencySpec + //merchURL := t.Cfg.Section("taldir").Key("merchant_base_url").MustString("http://merchant.taldir/") + //merchToken := t.Cfg.Section("taldir").Key("merchant_token").MustString("secretAccessToken") + //t.Merchant = merchant.NewMerchant(merchURL, merchToken) + //merchConfig, err := t.Merchant.GetConfig() + //if nil != err { + // log.Fatal("Failed to get merchant config") + // os.Exit(1) + //} + //registrationCost, _ := talerutil.ParseAmount(t.MonthlyFee) + //currencySpec, currencySupported := merchConfig.Currencies[registrationCost.Currency] + //for !currencySupported { + // log.Fatalf("Currency `%s' not supported by merchant!\n", registrationCost.Currency) + // os.Exit(1) + //} + //t.CurrencySpec = currencySpec t.setupHandlers() } diff --git a/web/templates/landing.html b/web/templates/landing.html @@ -7,7 +7,7 @@ <link href="/css/bootstrap.min.css" rel="stylesheet"> <title>{{ call .tr "title" }}</title> </head> - <body> + {{ template "nav.html" . }} <div class="container pt-5"> <h1 class="text-center mb-5">{{ call .tr "title" }}</h1> {{if .error}} diff --git a/web/templates/landing_email.html b/web/templates/landing_email.html @@ -8,6 +8,7 @@ <title>TalDir Alias Registration and Lookup</title> </head> <body> + {{ template "nav.html" . }} <div class="container pt-5"> <h1 class="text-center mb-5">TalDir Alias Registration and Lookup</h1> {{if .error}} @@ -29,16 +30,13 @@ <div class="row"> <div class="col-lg-6 offset-lg-3 text-center"> <div class="input-group mb-3"> - <span class="input-group-text" id="inputGroup-sizing-default">Email</span> - <input type="text" name="address" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default"> + <input type="text" name="address" class="form-control" placeholder="jdoe@example.com" aria-label="Default" aria-describedby="inputGroup-sizing-default" data-sb-validations="required,email"> + <div class="invalid-feedback text-white" data-sb-feedback="emailAddressBelow:required">Email Address is required.</div> + <div class="invalid-feedback text-white" data-sb-feedback="emailAddressBelow:email">Email Address is not valid.</div> + <input class="input-group-text btn btn-primary" type="submit" value="Lookup"> </div> </div> </div> - <div class="row"> - <div class="col-lg-6 offset-lg-3 text-center"> - <input class="btn btn-primary" type="submit" value="Lookup"> - </div> - </div> </form> </div> {{ template "footer.html" . }} diff --git a/web/templates/landing_phone.html b/web/templates/landing_phone.html @@ -8,6 +8,7 @@ <title>TalDir Alias Registration and Lookup</title> </head> <body> + {{ template "nav.html" . }} <div class="container pt-5"> <h1 class="text-center mb-5">TalDir Alias Registration and Lookup</h1> {{if .error}} @@ -28,16 +29,12 @@ <div class="row"> <div class="col-lg-6 offset-lg-3 text-center"> <div class="input-group mb-3"> - <span class="input-group-text" id="inputGroup-sizing-default">Phone number: (+)</span> - <input type="text" name="address" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default"> + <span class="input-group-text" id="inputGroup-sizing-default">+</span> + <input type="text" name="address" class="form-control" aria-label="Default" placeholder="49123456789" aria-describedby="inputGroup-sizing-default"> + <input class="input-group-text btn btn-primary" type="submit" value="Lookup"> </div> </div> </div> - <div class="row"> - <div class="col-lg-6 offset-lg-3 text-center"> - <input class="btn btn-primary" type="submit" value="Lookup"> - </div> - </div> </form> </div> {{ template "footer.html" . }} diff --git a/web/templates/lookup_result.html b/web/templates/lookup_result.html @@ -8,6 +8,7 @@ <title>TalDir Alias Registration and Lookup</title> </head> <body> + {{ template "nav.html" . }} <div class="container pt-5"> <h1 class="text-center mb-5">TalDir Alias Registration and Lookup</h1> {{if .error}} @@ -41,16 +42,12 @@ <div class="row"> <div class="col-lg-6 offset-lg-3 text-center"> <div class="input-group mb-3"> - <span class="input-group-text" id="inputGroup-sizing-default">Payment System Address</span> - <input id="uriInput" name="target_uri" type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default"> + <span class="input-group-text" id="inputGroup-sizing-default">{{.address}}: </span> + <input id="uriInput" name="target_uri" type="text" class="form-control" placeholder="Payment System Address" aria-label="Default" aria-describedby="inputGroup-sizing-default"> + <input class="input-group-text btn btn-primary" type="submit" value="Link"> </div> </div> </div> - <div class="row"> - <div class="col-lg-6 offset-lg-3 text-center"> - <input class="btn btn-primary" type="submit" value="Link"> - </div> - </div> </form> {{else}} <div class="container pt-5"> @@ -65,7 +62,7 @@ <div class="row"> <div class="col-lg-6 offset-lg-3 text-center"> <div class="input-group mb-3"> - <span class="input-group-text" id="inputGroup-sizing-default">Payment System Address</span> + <span class="input-group-text" id="inputGroup-sizing-default">{{.address}}: </span> <input disabled="disabled" name="target_uri" type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" value="{{.result}}"> </div> </div>