gnunet-gns-registrar

GNU Name System registrar
Log | Files | Refs | README

commit 5b0eaec6a47cdc27094d8b03ee75bf07bc5bfdcc
parent 7e3e8ebe886dd8ac6ea9de88d87f236498c688eb
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date:   Mon,  4 Dec 2023 22:29:59 +0100

UI improvements

Diffstat:
Mgns-registrar.conf | 1+
Mpkg/rest/gnsregistrar.go | 14+++++++++++---
Mweb/templates/landing.html | 13+++++++------
Mweb/templates/name.html | 19+++++++++++++++----
4 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/gns-registrar.conf b/gns-registrar.conf @@ -16,4 +16,5 @@ registrar_name = web/templates/name.html registration_failed = templates/registration_failed.html registration_duration = 1y root_zone_name = test +suffix_hint = gnunet.gns.alt registration_policy = fcfs diff --git a/pkg/rest/gnsregistrar.go b/pkg/rest/gnsregistrar.go @@ -83,6 +83,9 @@ type Registrar struct { // Name of our root zone RootZoneName string + // Suggested suffix for our zone + SuffixHint string + // Gnunet REST API basename GnunetUrl string @@ -110,7 +113,7 @@ func (t *Registrar) landingPage(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/html; charset=utf-8") fullData := map[string]interface{}{ - "registrarSuffix": t.RootZoneName, + "suffixHint": t.SuffixHint, } t.LandingTpl.Execute(w, fullData) return @@ -140,8 +143,10 @@ func (t *Registrar) registerName(w http.ResponseWriter, r *http.Request) { json.NewDecoder(resp.Body).Decode(&gnunetError) fmt.Println(gnunetError.Code) fmt.Println(err) + http.Redirect(w, r, "/name?label="+r.URL.Query().Get("label") + "&error=" + gnunetError.Description, http.StatusSeeOther) + return } - http.Redirect(w, r, "/name?label="+r.URL.Query().Get("label"), http.StatusSeeOther) + http.Redirect(w, r, "/name?label="+r.URL.Query().Get("label") + "&registered=true", http.StatusSeeOther) return } @@ -152,6 +157,7 @@ func (t *Registrar) namePage(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/html; charset=utf-8") var available = false var value = "" + var registered = r.URL.Query().Get("registered") == "true" // FIXME redirect back if label empty resp, err := http.Get(t.GnunetUrl + "/namestore/" + t.RootZoneName + "/" + r.URL.Query().Get("label")) if err != nil { @@ -181,8 +187,9 @@ func (t *Registrar) namePage(w http.ResponseWriter, r *http.Request) { "label": r.URL.Query().Get("label"), "available": available, "currentValue": value, - "registrarSuffix": t.RootZoneName, + "suffixHint": t.SuffixHint, "registrationPolicy": t.RegistrationPolicy, + "registrationSuccess": registered, } t.NameTpl.Execute(w, fullData) return @@ -263,6 +270,7 @@ func (t *Registrar) Initialize(cfgfile string) { } t.RelativeDelegationExpiration = t.Cfg.Section("gns-registrar").Key("relative_delegation_expiration").MustUint64(86400000) t.RegistrationPolicy = t.Cfg.Section("gns-registrar").Key("registration_policy").MustString("paid") + t.SuffixHint = t.Cfg.Section("gns-registrar").Key("suffix_hint").MustString("example.alt") t.RootZoneName = t.Cfg.Section("gns-registrar").Key("root_zone_name").MustString("master") t.GnunetUrl = t.Cfg.Section("gns-registrar").Key("gnunet_baseurl_private").MustString("http://localhost:7776") merchURL := t.Cfg.Section("gns-registrar").Key("merchant_baseurl_private").MustString("http://merchant.gnsregistrar/instances/myInstance") diff --git a/web/templates/landing.html b/web/templates/landing.html @@ -9,21 +9,22 @@ </head> <body> <div class="container pt-5"> - <h1>Lookup your domain name.</h1> - <form action="/name" method="get" class="text-center"> + <h1 class="text-center mb-5">.{{.suffixHint}} is TODOFIXMETHEACTUALKEY</h1> + <form action="/name" method="get"> + <label for="label" class="form-label">Check availability:</label> <div class="input-group mb-2 w-50"> - <input name="label" class="form-control form-control-lg text-end" maxlength="63" type="text" placeholder="Check if your name is still available!" aria-describedby="reg-suffix" required autofocus> - <span class="input-group-text" id="reg-suffix">.{{.registrarSuffix}}</span> + <input id="label" name="label" class="form-control form-control-lg text-end" maxlength="63" type="text" aria-describedby="reg-suffix" required autofocus> + <span class="input-group-text" id="reg-suffix">.{{.suffixHint}}</span> <input class="btn btn-primary" type="submit" value="Check!"> </div> </form> </div> <div class="container pt-5"> <div class="alert alert-light" role="alert"> - <h4 class="alert-heading">The .{{.registrarSuffix}} Zone!</h4> + <h4 class="alert-heading">The .{{.suffixHint}} Zone!</h4> <p>If you do not have our zone configured in your <i>Start Zones</i>, we suggest to do it as:</p> <hr> - <p class="mb-0">.{{.registrarSuffix}} = TODOFIXMETHEACTUALKEY</p> + <p class="mb-0">.{{.suffixHint}} = TODOFIXMETHEACTUALKEY</p> </div> </div> </body> diff --git a/web/templates/name.html b/web/templates/name.html @@ -8,12 +8,21 @@ <title>Name Overview</title> </head> <body> + {{if .registrationSuccess}} + <div class="container pt-5"> + <div class="alert alert-success" role="alert"> + <h4 class="alert-heading">Registration successful!</h4> + <hr> + <p class="mb-0">Your zone will be published shortly.</p> + </div> + </div> + {{end}} <div class="container pt-5"> {{if .available}} - <h1><i class="text-primary">{{.label}}</i>.<i class="text-secondary">{{.registrarSuffix}}</i> is still <span class="text-success">available<span>.</h1> + <h1 class="mb-5"><i class="text-primary">{{.label}}</i> is still <span class="text-success">available</span> for registration.</h1> <form action="/register" method="get" class="align-items-center"> <div class="input-group mb-2 w-75"> - <span class="input-group-text" id="reg-prefix">{{.label}}.{{.registrarSuffix}}: </span> + <span class="input-group-text" id="reg-prefix"><i class="text-primary">{{.label}}</i>.<i class="text-secondary">{{.suffixHint}}</i>: </span> <input type="hidden" name="label" value="{{.label}}"> <input name="zkey" class="form-control form-control-lg" maxlength="63" type="text" placeholder="Enter your zone key here!" required autofocus> {{if eq .registrationPolicy "fcfs"}} @@ -24,12 +33,14 @@ </div> </form> {{else}} - <h1><i class="text-primary">{{.label}}</i>.<i class="text-secondary">{{.registrarSuffix}}</i> is already <span class="text-danger">taken</span>!</h1> + <h1 class="mb-5"><i class="text-primary">{{.label}}</i> is already <span class="text-danger">taken</span>!</h1> <form action="/renew" method="get" class="align-items-center"> <div class="input-group mb-2 w-75"> - <span class="input-group-text" id="reg-prefix">{{.label}}.{{.registrarSuffix}}: </span> + <span class="input-group-text" id="reg-prefix"><i class="text-primary">{{.label}}</i>.<i class="text-secondary">{{.suffixHint}}</i>: </span> <input name="label" disabled="{{.modificationAllowed}}" class="form-control form-control-lg" maxlength="63" type="text" placeholder="Enter your zone key here!" value="{{.currentValue}}" required autofocus> + {{if .modificationAllowed}} <input class="btn btn-primary" disabled="{{.modificationAllowed}}" type="submit" value="Update"> + {{end}} </div> </form> <form action="/renew" method="get" class="align-items-center">