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