meta: Add a delete button

This commit is contained in:
Daan Sprenkels 2020-05-11 22:26:45 +02:00
parent b7ea5dfa4f
commit a4cec1e4b0
3 changed files with 13 additions and 12 deletions

View File

@ -26,11 +26,12 @@ created: unknown
created: {{.Paste.TimeCreated}}
{{end -}}
delete token: {{.CanDelete}}
{{if and (ne .Paste.State.String "deleted") .CanDeleteBool}}
```
curl --request "DELETE" "<a href="{{.RootURL}}/{{.Paste.Key}}{{.FileExt}}?deleteToken={{.Paste.DeleteToken}}">{{.RootURL}}/{{.Paste.Key}}{{.FileExt}}?deleteToken={{.Paste.DeleteToken}}"</a>
```
{{end}}
<form action="delete?deleteToken={{.Paste.DeleteToken}}" method="post">
<input type="submit" name="delete" value="Delete paste"
{{- if or (eq .Paste.State.String "deleted") (not .CanDeleteBool) -}}
disabled
{{- end -}}
>
</form>
</pre>
{{end}}

View File

@ -207,7 +207,7 @@ func templatesHtmlIndexHtmlTmpl() (*asset, error) {
return a, nil
}
var _templatesHtmlPastemetaHtmlTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\x54\x3d\x6f\xdb\x30\x10\xdd\xf9\x2b\x0e\x1c\xf2\x31\x48\xda\x13\x49\x05\xea\xb8\x40\x51\x0f\x85\xeb\x2c\x9d\x4c\x8b\xe7\x98\x36\x43\xb2\xe4\xa9\x89\x40\xf0\xbf\x17\x92\xfc\x91\xa2\x46\xe1\xa0\x4b\x17\x09\x3a\x3e\xbe\x7b\xef\x1d\xa9\x18\x25\xae\x95\x41\xe0\xa4\x48\x23\x4f\x89\x5d\xc7\x98\x7f\x15\x81\x30\xff\x82\x5d\x4a\x31\xe6\x9f\x94\xc6\xe9\x2b\xa5\x74\x0d\xcf\x48\x42\x0a\x12\x90\x81\x6f\xc3\x46\x2b\xb3\x63\x31\xa2\x91\x29\x31\x76\x22\xdb\xa0\x90\x99\x70\x0e\x8d\xec\x29\xcb\xd0\x78\xe5\x08\xa8\x73\x58\x71\xc2\x57\x2a\xb6\xe2\xa7\x18\xab\x1c\x82\x6f\x2a\x5e\x6c\x43\xd1\x58\xd7\x35\x5a\xb9\x95\x15\x5e\xe6\xdb\xc0\x41\xe2\x1a\x7d\x5d\x16\x23\xb4\x3e\xd7\x6b\x65\x65\x37\x34\x71\x1e\x41\xc9\x8a\xf7\x2c\x0b\x3b\x39\xf0\x4c\xac\x21\xa1\x0c\x7a\x0e\x8d\x16\x21\x54\x7c\xa3\xa4\x44\xc3\x6b\x56\xae\x5a\x22\x6b\xc0\x9a\x46\xab\x66\xf7\xc7\xd6\x9b\x3e\x8b\xb9\xb5\xf4\x38\x9f\xa5\x54\xfc\x25\x98\x5b\x5e\x4f\xac\xeb\xe0\x71\x3e\x03\xb2\x70\x34\x51\x16\x63\x8b\x1a\xca\xe0\x84\x39\xa7\xef\x1b\x09\x6a\x03\xef\x4d\x3a\x61\x6a\x56\x16\xce\x63\x3d\xd8\xa9\x59\x29\x60\xe3\x71\x5d\xf1\x0b\x85\xf0\xfa\x42\x60\x59\x88\x9a\x65\x59\xc6\x62\x54\x6b\x10\x46\xc2\x8d\x41\xd8\xa3\x7b\x49\xfd\xd3\x2b\xf3\x04\x5c\xa2\x46\x42\xc9\x6f\x21\x9f\x08\xf3\x30\x7c\x7d\xb4\x56\xa7\xc4\x5e\x14\x6d\x60\x5c\x07\xb2\x3b\x34\x77\xf0\x5e\xc5\x1f\xc6\xed\x8b\x7e\x77\x75\x84\x3d\x9c\x8a\xef\x30\x75\x01\xd7\xe0\x3b\x46\xd4\x01\x21\x3b\xef\xe0\x4a\xd3\x7d\x6b\x76\xc6\xbe\x98\xab\x27\xba\x1f\xcf\xdc\x00\xee\xcf\xef\x1d\x1c\x89\x17\x9d\xc3\x94\x58\xe8\xd3\x7a\x53\x1e\xd2\x4b\x69\x4c\xf6\x00\x55\xcf\x38\xf1\x28\x08\x65\xfe\x39\x7c\x47\x6f\x07\xc2\x66\x2c\xdd\xc1\xbe\xdf\x5b\x65\xc7\xb5\x53\xbf\x13\xc9\x40\x7f\x90\xf5\xbb\xfc\x18\x4f\x63\x1a\x6f\xca\x3f\x0c\x78\xb9\x5c\xb2\xa6\xf5\x1a\xb2\xcc\xe3\x8f\x16\x03\x01\x7f\x98\xce\xa6\x8b\x29\x07\xfe\x9f\x8f\x9a\x0f\xb3\xee\x1d\xec\xaf\xd4\xe1\xe7\xb1\x7f\xff\x0a\x00\x00\xff\xff\xde\xe1\x78\x84\xfc\x04\x00\x00")
var _templatesHtmlPastemetaHtmlTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\x94\xc1\x6e\xdb\x30\x0c\x86\xef\x7a\x0a\x42\x87\x36\x3d\x38\xbe\xb7\xb6\x07\x2c\xdd\x80\x61\x3d\x0c\x5d\x7b\xd9\x4d\xb1\x98\x5a\x8d\x22\x69\x12\xdd\xd6\x10\xf4\xee\x83\xec\x3a\xe9\xb6\x60\x4b\x2f\x01\x42\x51\x1f\xff\x9f\x22\x1d\xa3\xc4\x8d\x32\x08\x9c\x14\x69\xe4\x29\xb1\xf3\x18\x97\xdf\x44\x20\x5c\x7e\xc5\x21\xa5\x18\x97\x9f\x95\xc6\x4f\x2f\x94\xd2\x39\xec\x90\x84\x14\x24\xa0\x00\xdf\x87\x4e\x2b\xb3\x65\x31\xa2\x91\x29\x31\x76\x80\x75\x28\x64\x21\x9c\x43\x23\x33\xb2\x0a\xad\x57\x8e\x80\x06\x87\x35\x27\x7c\xa1\xf2\x51\x3c\x89\x29\xca\x21\xf8\xb6\xe6\xe5\x63\x28\x5b\xeb\x86\x56\x2b\xb7\xb6\xc2\xcb\xe5\x63\xe0\x20\x71\x83\xbe\xa9\xca\x29\xb5\x39\x56\x6b\x6d\xe5\x30\x16\x71\x1e\x41\xc9\x9a\x67\xca\x9d\x5d\xcd\x9c\x95\x35\x24\x94\x41\xcf\xa1\xd5\x22\x84\x9a\x77\x4a\x4a\x34\xbc\x61\xd5\xba\x27\xb2\x06\xac\x69\xb5\x6a\xb7\x7f\x5d\x5d\xe4\x5e\xdc\x5a\x4b\xf7\xb7\x37\x29\x95\xff\x68\xcc\x05\x6f\x56\xd6\x0d\x70\x7f\x7b\x03\x64\x61\x6f\xa2\x2a\xa7\x12\x0d\x54\xc1\x09\x73\x4c\xdf\x77\x12\xd4\x07\x9e\x4d\x3a\x61\x1a\x56\x95\xce\x63\x33\xda\x69\x58\x25\xa0\xf3\xb8\xa9\xf9\x89\x42\x78\x73\x62\x62\x55\x8a\x86\x15\x45\xc1\x62\x54\x1b\x10\x46\xc2\xc2\x20\xbc\x66\x67\x49\xf9\xd7\x2b\xf3\x00\x5c\xa2\x46\x42\xc9\x2f\x60\xb9\x12\xe6\x7a\xfc\xf7\xd1\x5a\x9d\x12\x7b\x56\xd4\xc1\x74\x0e\x64\xb7\x68\x2e\xe1\xbd\x8a\x3f\x4c\xd7\xef\xf2\xed\x7a\x9f\x76\x7d\x08\xbe\xc3\xd4\x09\xac\xd1\x77\x8c\xa8\x03\x42\x71\xdc\xc1\x99\xa6\xab\xde\x6c\x8d\x7d\x36\x67\x0f\x74\x35\xcd\xdc\x98\x9c\xe7\xf7\x12\xf6\xe0\xbb\xc1\x61\x4a\x2c\xe4\x6e\xbd\x09\x8f\xdd\x4b\x69\xea\xec\x9c\xaa\x76\xb8\xf2\x28\x08\xe5\xf2\x4b\xf8\x81\xde\x8e\xc0\x76\x0a\x5d\xc2\x6b\xbd\xb7\xca\xf6\x67\x87\x7a\x07\xc8\x88\x9f\x65\xfd\x2e\x3f\xc6\xc3\x33\xe5\xb5\xd8\x58\xbf\x03\xd1\x92\xb2\xa6\x7e\x7d\xcb\x53\x7a\x9e\x57\xbd\xb3\xb2\xe6\xce\x06\xca\xbb\xa2\x8c\xeb\xe7\x15\x0e\xfd\x7a\xa7\x88\x83\x11\x3b\x9c\xa1\x1c\x9e\x84\xee\xb1\xe6\x13\x07\x5c\x86\x72\x16\x63\x01\x6a\x03\xd6\xc3\x02\x7f\xfe\x6f\xc0\x16\xc6\xd2\x1f\x53\x76\x31\x59\x54\x41\xac\x35\xca\x11\x37\xfb\xce\xbb\x92\xdd\xed\x77\x66\xfe\x3a\xfc\x0a\x00\x00\xff\xff\x0b\x8d\xa7\x25\xd6\x04\x00\x00")
func templatesHtmlPastemetaHtmlTmplBytes() ([]byte, error) {
return bindataRead(
@ -222,7 +222,7 @@ func templatesHtmlPastemetaHtmlTmpl() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "templates/html/pasteMeta.html.tmpl", size: 1276, mode: os.FileMode(420), modTime: time.Unix(1587564030, 0)}
info := bindataFileInfo{name: "templates/html/pasteMeta.html.tmpl", size: 1238, mode: os.FileMode(420), modTime: time.Unix(1589228560, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}

View File

@ -193,7 +193,7 @@ func (rl *rushlink) viewPasteHandlerInnerMeta(w http.ResponseWriter, r *http.Req
return
}
func (rl *rushlink) viewCreateSuccess(w http.ResponseWriter, r *http.Request, p *db.Paste, fu *db.FileUpload) {
func (rl *rushlink) viewActionSuccess(w http.ResponseWriter, r *http.Request, p *db.Paste, fu *db.FileUpload) {
var fileExt string
if fu != nil {
fileExt = fu.Ext()
@ -255,7 +255,7 @@ func (rl *rushlink) newFileUploadPasteHandler(w http.ResponseWriter, r *http.Req
}); err != nil {
panic(err)
}
rl.viewCreateSuccess(w, r, paste, fu)
rl.viewActionSuccess(w, r, paste, fu)
}
func (rl *rushlink) newPasteHandlerURLEncoded(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
@ -295,7 +295,7 @@ func (rl *rushlink) newRedirectPasteHandler(w http.ResponseWriter, r *http.Reque
}); err != nil {
panic(err)
}
rl.viewCreateSuccess(w, r, paste, nil)
rl.viewActionSuccess(w, r, paste, nil)
}
// Delete a URL from the database
@ -336,7 +336,7 @@ func (rl *rushlink) deletePasteHandler(w http.ResponseWriter, r *http.Request) {
rl.renderError(w, r, errorCode, fmt.Sprintf("error: %v\n", err))
return
}
rl.viewCreateSuccess(w, r, paste, nil)
rl.viewActionSuccess(w, r, paste, nil)
}
// Add a new fileUpload redirect to the database