save attached images past preview
This commit is contained in:
parent
e15d81638b
commit
2ef8cc8a80
|
@ -2,6 +2,8 @@ changelog
|
|||
|
||||
-- next
|
||||
|
||||
+ Attached images are not lost when previewing.
|
||||
|
||||
- Remove sensitivity to spicy peppers.
|
||||
|
||||
+ Keep reply to setting during preview.
|
||||
|
|
19
honk.go
19
honk.go
|
@ -1014,6 +1014,8 @@ func savehonk(w http.ResponseWriter, r *http.Request) {
|
|||
honk.Noise = noise
|
||||
honk.Convoy = convoy
|
||||
|
||||
donkxid := r.FormValue("donkxid")
|
||||
if donkxid == "" {
|
||||
file, filehdr, err := r.FormFile("donk")
|
||||
if err == nil {
|
||||
var buf bytes.Buffer
|
||||
|
@ -1067,6 +1069,22 @@ func savehonk(w http.ResponseWriter, r *http.Request) {
|
|||
d.URL = url
|
||||
d.Local = true
|
||||
honk.Donks = append(honk.Donks, &d)
|
||||
donkxid = d.XID
|
||||
}
|
||||
} else {
|
||||
xid := donkxid
|
||||
url := fmt.Sprintf("https://%s/d/%s", serverName, xid)
|
||||
var donk Donk
|
||||
row := stmtFindFile.QueryRow(url)
|
||||
err := row.Scan(&donk.FileID)
|
||||
if err == nil {
|
||||
donk.XID = xid
|
||||
donk.Local = true
|
||||
donk.URL = url
|
||||
honk.Donks = append(honk.Donks, &donk)
|
||||
} else {
|
||||
log.Printf("can't find file: %s", xid)
|
||||
}
|
||||
}
|
||||
herd := herdofemus(honk.Noise)
|
||||
for _, e := range herd {
|
||||
|
@ -1091,6 +1109,7 @@ func savehonk(w http.ResponseWriter, r *http.Request) {
|
|||
templinfo["Honks"] = honks
|
||||
templinfo["InReplyTo"] = r.FormValue("rid")
|
||||
templinfo["Noise"] = r.FormValue("noise")
|
||||
templinfo["SavedFile"] = donkxid
|
||||
templinfo["ServerMessage"] = "honk preview"
|
||||
err := readviews.Execute(w, "honkpage.html", templinfo)
|
||||
if err != nil {
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
in reply to: <input type="text" name="rid" id="ridinput" value="{{ .InReplyTo }}" autocomplete=off>
|
||||
<input type="hidden" name="CSRF" value="{{ .HonkCSRF }}">
|
||||
<p>
|
||||
<label id="donker">attach: <input onchange="updatedonker();" type="file" name="donk"><span></span></label>
|
||||
<label id="donker">attach: {{ if .SavedFile }} {{ .SavedFile }} {{ else }} <input onchange="updatedonker();" type="file" name="donk"><span></span> {{ end }}</label>
|
||||
<input type="hidden" name="donkxid" value="{{ .SavedFile }}">
|
||||
<p>
|
||||
<textarea name="noise" id="honknoise">{{ .Noise }}</textarea>
|
||||
<p>
|
||||
|
|
Loading…
Reference in New Issue