taldir

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

commit db7f57e6f535fbf5a26b0fc777b2f3cf3e914164
parent d96fc0f4795716c34d61148d9f67a318385e01f7
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date:   Sat, 11 Jan 2025 13:33:49 +0100

Footer in separate template file

Diffstat:
Mpkg/rest/taldir.go | 13+++++++++----
Aweb/templates/footer.html | 4++++
Mweb/templates/landing.html | 5+----
Mweb/templates/landing_email.html | 1+
Mweb/templates/landing_phone.html | 1+
Mweb/templates/lookup_result.html | 1+
Mweb/templates/validation_landing.html | 1+
7 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/pkg/rest/taldir.go b/pkg/rest/taldir.go @@ -618,6 +618,7 @@ func (t *Taldir) validationPage(w http.ResponseWriter, r *http.Request) { encodedPng := base64.StdEncoding.EncodeToString(png) fullData := map[string]interface{}{ + "version": t.Version, "QRCode": template.URL("data:image/png;base64," + encodedPng), "WalletLink": template.URL(walletLink), } @@ -625,6 +626,7 @@ func (t *Taldir) validationPage(w http.ResponseWriter, r *http.Request) { } else { expectedSolution := util.GenerateSolution(validation.TargetUri, validation.Challenge) fullData := map[string]interface{}{ + "version": t.Version, "error": r.URL.Query().Get("error"), "target_uri": template.URL(validation.TargetUri), "address": template.URL(address), @@ -689,6 +691,7 @@ func (t *Taldir) methodLookupResultPage(w http.ResponseWriter, r *http.Request) found = true } fullData := map[string]interface{}{ + "version": t.Version, "available": !found, "method": val.Name, "address": r.URL.Query().Get("address"), @@ -713,6 +716,7 @@ func (t *Taldir) methodLandingPage(w http.ResponseWriter, r *http.Request) { return } fullData := map[string]interface{}{ + "version": t.Version, "error": r.URL.Query().Get("error"), } err := val.LandingPageTpl.Execute(w, fullData) @@ -775,6 +779,7 @@ func (t *Taldir) Initialize(cfgfile string, version string) { fmt.Println("Production mode enabled") } + 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") t.Validators = make(map[string]Validator) @@ -788,7 +793,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) + vlandingPageTpl, err := template.ParseFiles(vlandingPageTplFile, footerTplFile) if err != nil { log.Printf("`%s` template not found, disabling validator `%s`.\n", vlandingPageTplFile, vname) continue @@ -859,19 +864,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) + t.ValidationTpl, err = template.ParseFiles(validationLandingTplFile, 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) + t.LandingPageTpl, err = template.ParseFiles(landingTplFile, 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) + t.LookupResultPageTpl, err = template.ParseFiles(lookupResultTplFile, footerTplFile) if err != nil { log.Fatal(err) os.Exit(1) diff --git a/web/templates/footer.html b/web/templates/footer.html @@ -0,0 +1,4 @@ +<footer class="fs-6 text-sm-end mt-4 me-2"> + <span>Version: {{.version}}</span><br/> + <span>Source: <a href="https://git.taler.net/taldir.git">Browse Git Repository</a></span> +</footer> diff --git a/web/templates/landing.html b/web/templates/landing.html @@ -33,9 +33,6 @@ </div> {{end}} </div> + {{ template "footer.html" . }} </body> - <footer class="fs-6 text-sm-end mt-4 me-2"> - <span>Version: {{.version}}</span><br/> - <span>Source: <a href="https://git.taler.net/taldir.git">Browse Git Repository</a></span> - </footer> </html> diff --git a/web/templates/landing_email.html b/web/templates/landing_email.html @@ -41,5 +41,6 @@ </div> </form> </div> + {{ template "footer.html" . }} </body> </html> diff --git a/web/templates/landing_phone.html b/web/templates/landing_phone.html @@ -40,5 +40,6 @@ </div> </form> </div> + {{ template "footer.html" . }} </body> </html> diff --git a/web/templates/lookup_result.html b/web/templates/lookup_result.html @@ -73,6 +73,7 @@ </div> {{end}} </div> + {{ template "footer.html" . }} </body> <script> var form = document.getElementById('regform'); diff --git a/web/templates/validation_landing.html b/web/templates/validation_landing.html @@ -50,6 +50,7 @@ </div> </div> {{end}} + {{ template "footer.html" . }} </body> <script> var form = document.getElementById('regform');