Fix expires label
This commit is contained in:
@@ -78,8 +78,8 @@ func TestFormatRoundTrips(t *testing.T) {
|
|||||||
if got, err := ParseDuration(FormatDuration(d)); err != nil || got != d {
|
if got, err := ParseDuration(FormatDuration(d)); err != nil || got != d {
|
||||||
t.Errorf("FormatDuration(%s) = %q, which parses back to %s (%v)", d, FormatDuration(d), got, err)
|
t.Errorf("FormatDuration(%s) = %q, which parses back to %s (%v)", d, FormatDuration(d), got, err)
|
||||||
}
|
}
|
||||||
// FormatLifetime reaches the upload form as the expiry placeholder, so
|
// FormatLifetime is shown next to the field a caller types into, so
|
||||||
// what it prints has to be something a caller could type back.
|
// what it prints has to be something ParseDuration would accept.
|
||||||
if got, err := ParseDuration(FormatLifetime(d)); err != nil || got != d {
|
if got, err := ParseDuration(FormatLifetime(d)); err != nil || got != d {
|
||||||
t.Errorf("FormatLifetime(%s) = %q, which parses back to %s (%v)", d, FormatLifetime(d), got, err)
|
t.Errorf("FormatLifetime(%s) = %q, which parses back to %s (%v)", d, FormatLifetime(d), got, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,10 +48,14 @@ type indexPage struct {
|
|||||||
MaxSize string
|
MaxSize string
|
||||||
MaxExpiry string
|
MaxExpiry string
|
||||||
DefaultExpiry string
|
DefaultExpiry string
|
||||||
AbsBase string
|
// ExpiryHint is the same lifetime as DefaultExpiry, worded for the form's
|
||||||
AllowVanity bool
|
// "Expires in" field rather than for a row in the limits list: what the
|
||||||
MaxSizeBytes int64 // 0 when unlimited; the script checks against it
|
// field wants is "never", what the list wants is "unlimited".
|
||||||
Stale bool // a login whose token no longer exists
|
ExpiryHint string
|
||||||
|
AbsBase string
|
||||||
|
AllowVanity bool
|
||||||
|
MaxSizeBytes int64 // 0 when unlimited; the script checks against it
|
||||||
|
Stale bool // a login whose token no longer exists
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) {
|
func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -71,6 +75,7 @@ func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) {
|
|||||||
MaxSize: config.FormatSize(lim.MaxSize),
|
MaxSize: config.FormatSize(lim.MaxSize),
|
||||||
MaxExpiry: config.FormatLifetime(lim.MaxExpiry),
|
MaxExpiry: config.FormatLifetime(lim.MaxExpiry),
|
||||||
DefaultExpiry: config.FormatLifetime(lim.DefaultExpiry),
|
DefaultExpiry: config.FormatLifetime(lim.DefaultExpiry),
|
||||||
|
ExpiryHint: config.FormatDuration(lim.DefaultExpiry),
|
||||||
AbsBase: s.absBase(r),
|
AbsBase: s.absBase(r),
|
||||||
AllowVanity: lim.AllowVanity,
|
AllowVanity: lim.AllowVanity,
|
||||||
MaxSizeBytes: lim.MaxSize,
|
MaxSizeBytes: lim.MaxSize,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<label class="field">
|
<label class="field">
|
||||||
<span>Expires in</span>
|
<span>Expires in</span>
|
||||||
<input type="text" name="expiry" id="expiry" placeholder="{{.DefaultExpiry}}" autocomplete="off">
|
<input type="text" name="expiry" id="expiry" placeholder="{{.ExpiryHint}}" autocomplete="off">
|
||||||
</label>
|
</label>
|
||||||
<label class="field">
|
<label class="field">
|
||||||
<span>Custom name <em>({{if .AllowVanity}}optional{{else}}needs a token{{end}})</em></span>
|
<span>Custom name <em>({{if .AllowVanity}}optional{{else}}needs a token{{end}})</em></span>
|
||||||
|
|||||||
Reference in New Issue
Block a user