~sotirisp/kindleto

02c131b3a261af2349e091e0e71b0cfda55cc043 — Sotiris Papatheodorou 2 months ago ea85837
Remove trailing slashes from paths

They refer to single pages, not directories.
3 files changed, 12 insertions(+), 12 deletions(-)

M handlers.go
M kindleto.go
M templates/template_strings.go
M handlers.go => handlers.go +2 -2
@@ 151,14 151,14 @@ func manageClientCertificates(w http.ResponseWriter, r *http.Request) {
			log.Printf("manageClientCertificates: failed to delete certificate for scope '%s': %v", scope, err)
			http.Error(w, "Internal Server Error", 500)
		}
		http.Redirect(w, r, "/settings/certificates/", http.StatusFound)
		http.Redirect(w, r, "/settings/certificates", http.StatusFound)
	} else if r.Method == http.MethodPost && r.FormValue("delete") == "expired" {
		err = certificates.DeleteExpiredClientCerts()
		if err != nil {
			log.Printf("manageClientCertificates: failed to delete expired certificates: %v", err)
			http.Error(w, "Internal Server Error", 500)
		}
		http.Redirect(w, r, "/settings/certificates/", http.StatusFound)
		http.Redirect(w, r, "/settings/certificates", http.StatusFound)
	} else {
		if util.LogLevel > 0 {
			log.Println("manageClientCertificates: invalid request")

M kindleto.go => kindleto.go +4 -4
@@ 72,11 72,11 @@ func main() {

	mux := http.NewServeMux()
	mux.HandleFunc("/", proxy)
	mux.HandleFunc("/certificate/", clientCertificateRequired)
	mux.HandleFunc("/settings/certificates/", manageClientCertificates)
	mux.HandleFunc("/certificate", clientCertificateRequired)
	mux.HandleFunc("/settings/certificates", manageClientCertificates)
	mux.HandleFunc("/kindleto.css", css)
	mux.HandleFunc("/about/", about)
	mux.HandleFunc("/help/", help)
	mux.HandleFunc("/about", about)
	mux.HandleFunc("/help", help)

	if util.LogLevel > 0 {
		log.Printf("main: starting HTTP server on 127.0.0.1:%s", optPort)

M templates/template_strings.go => templates/template_strings.go +6 -6
@@ 10,7 10,7 @@ const Certificates string = `{{template "header" .}}
{{end}}
<h1>Manage Client Certificates</h1>
{{if gt .ExpiredCerts 0}}
<form action="/settings/certificates/" method="POST">
<form action="/settings/certificates" method="POST">
<input type="hidden" name="delete" value="expired">
<input type="submit" value="Delete {{.ExpiredCerts}} expired certificate{{if gt .ExpiredCerts 1}}s{{end}}">
</form>


@@ 22,7 22,7 @@ const Certificates string = `{{template "header" .}}
Valid from: {{.NotBefore}}<br/>
Valid until: {{.NotAfter}}<br/>
{{if .Expired}}Expired!{{end}}</p>
<form action="/settings/certificates/" method="POST">
<form action="/settings/certificates" method="POST">
<input type="hidden" name="delete" value="single">
<input type="hidden" name="scope" value="{{.Scope}}">
<input type="submit" value="DELETE">


@@ 42,8 42,8 @@ const Footer string = `{{define "footer"}}
<a href="#header">Top</a>
<span style="float:right;">
{{if .URL}}<a href="/?source=1&url={{.URL}}">Page source</a>{{end}}
<a href="/help/">Help</a>
<a href="/about/">About</a>
<a href="/help">Help</a>
<a href="/about">About</a>
</span>
</div>
</div>


@@ 60,7 60,7 @@ const GeminiCertificate string = `{{template "header" .}}
<p class="url-asking-for-client-cert">{{.URL}}</p>
<p>We can create a temporary/transient TLS client certificate to send to the server. This will temporarily uniquely identify you to this server, effectively creating a user session. This identity will not be available to other sites, and will expire after the specified duration, {{.Count}} hours by default.</p>
<p>Optionally, you may enter a name that will be used for the certificate's CommonName field. This name will be sent to the server and is typically used as a username. If you leave the certificate name empty, Kindleto will generate a random value. If in doubt, leave the name empty.</p>
<form action="/certificate/" method="POST">
<form action="/certificate" method="POST">
<label for="client-cert-name-input">Certificate CommonName (optional)</label>
<input type="text" id="client-cert-name-input" name="name">
<br/>


@@ 120,7 120,7 @@ const Header string = `{{define "header"}}
{{if .ParentURL}}<a href="/?url={{.ParentURL}}">Parent</a>{{end}}
<a href="#footer">Bottom</a>
<span style="float:right;">
{{if .ManageCerts}}<a href="/settings/certificates/">Certificates</a>{{end}}
{{if .ManageCerts}}<a href="/settings/certificates">Certificates</a>{{end}}
</span>
</div>
<form action="/" method="POST">