some fixes for attachments and edits and previews
This commit is contained in:
parent
86738e30b8
commit
db63bd3fc3
|
@ -9,8 +9,7 @@
|
|||
<details>
|
||||
<summary>more options</summary>
|
||||
<p>
|
||||
<label class=button id="donker">attach: <input type="file" multiple name="donk"><span>{{ .SavedFile }}</span></label>
|
||||
<input type="hidden" id="saveddonkxid" name="donkxid" value="{{ .SavedFile }}">
|
||||
<label class=button id="donker">attach: <input type="file" multiple name="donk"><span>{{ .SavedFile }}</span></label><input type="hidden" id="saveddonkxid" name="donkxid" value="{{ .SavedFile }}">
|
||||
<p id="donkdescriptor"><label for=donkdesc>description:</label><br>
|
||||
<input type="text" name="donkdesc" value="{{ .DonkDesc }}" autocomplete=off>
|
||||
{{ with .SavedPlace }}
|
||||
|
|
28
web.go
28
web.go
|
@ -1569,11 +1569,15 @@ func edithonkpage(w http.ResponseWriter, r *http.Request) {
|
|||
templinfo["Duration"] = tm.Duration
|
||||
}
|
||||
}
|
||||
templinfo["ServerMessage"] = "honk edit 2"
|
||||
templinfo["ServerMessage"] = "honk edit"
|
||||
templinfo["IsPreview"] = true
|
||||
templinfo["UpdateXID"] = honk.XID
|
||||
if len(honk.Donks) > 0 {
|
||||
templinfo["SavedFile"] = honk.Donks[0].XID
|
||||
var savedfiles []string
|
||||
for _, d := range honk.Donks {
|
||||
savedfiles = append(savedfiles, fmt.Sprintf("%s:%d", d.XID, d.FileID))
|
||||
}
|
||||
templinfo["SavedFile"] = strings.Join(savedfiles, ",")
|
||||
}
|
||||
err := readviews.Execute(w, "honkpage.html", templinfo)
|
||||
if err != nil {
|
||||
|
@ -1618,7 +1622,10 @@ func submitdonk(w http.ResponseWriter, r *http.Request) ([]*Donk, error) {
|
|||
return nil, nil
|
||||
}
|
||||
var donks []*Donk
|
||||
for _, hdr := range r.MultipartForm.File["donk"] {
|
||||
for i, hdr := range r.MultipartForm.File["donk"] {
|
||||
if i > 16 {
|
||||
break
|
||||
}
|
||||
donk, err := formtodonk(w, r, hdr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -1825,7 +1832,7 @@ func submithonk(w http.ResponseWriter, r *http.Request) *Honk {
|
|||
honk.Public = loudandproud(honk.Audience)
|
||||
honk.Convoy = convoy
|
||||
|
||||
donkxid := r.FormValue("donkxid")
|
||||
donkxid := strings.Join(r.Form["donkxid"], ",")
|
||||
if donkxid == "" {
|
||||
donks, err := submitdonk(w, r)
|
||||
if err != nil && err != http.ErrMissingFile {
|
||||
|
@ -1833,11 +1840,18 @@ func submithonk(w http.ResponseWriter, r *http.Request) *Honk {
|
|||
}
|
||||
if len(donks) > 0 {
|
||||
honk.Donks = append(honk.Donks, donks...)
|
||||
d := donks[0]
|
||||
donkxid = fmt.Sprintf("%s:%d", d.XID, d.FileID)
|
||||
var xids []string
|
||||
for _, d := range honk.Donks {
|
||||
xids = append(xids, fmt.Sprintf("%s:%d", d.XID, d.FileID))
|
||||
}
|
||||
donkxid = strings.Join(xids, ",")
|
||||
}
|
||||
} else {
|
||||
for _, xid := range r.Form["donkxid"] {
|
||||
xids := strings.Split(donkxid, ",")
|
||||
for i, xid := range xids {
|
||||
if i > 16 {
|
||||
break
|
||||
}
|
||||
p := strings.Split(xid, ":")
|
||||
xid = p[0]
|
||||
url := fmt.Sprintf("https://%s/d/%s", serverName, xid)
|
||||
|
|
Loading…
Reference in New Issue