preview button now that there's more things that can go wrong
Ted Unangst tedu@tedunangst.com
Sun, 16 Jun 2019 14:11:23 -0400
3 files changed,
19 insertions(+),
4 deletions(-)
M
docs/changelog.txt
→
docs/changelog.txt
@@ -2,6 +2,8 @@ changelog
-- v +++ Preview before honking. + + Misc UI touchups. + Read only support for qonks.
M
honk.go
→
honk.go
@@ -946,6 +946,7 @@ d.XID = name
d.Name = name d.Media = media d.URL = url + d.Local = true honk.Donks = append(honk.Donks, &d) } herd := herdofemus(honk.Noise)@@ -962,6 +963,20 @@ aud := strings.Join(honk.Audience, " ")
whofore := 2 if !honk.Public { whofore = 3 + } + if r.FormValue("preview") == "preview" { + honks := []*Honk{ &honk } + reverbolate(honks) + templinfo := getInfo(r) + templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r) + templinfo["Honks"] = honks + templinfo["Noise"] = r.FormValue("noise") + templinfo["ServerMessage"] = "honk preview" + err := readviews.Execute(w, "honkpage.html", templinfo) + if err != nil { + log.Print(err) + } + return } res, err := stmtSaveHonk.Exec(userinfo.UserID, what, honk.Honker, xid, rid, dt.Format(dbtimeformat), "", aud, noise, convoy, whofore, "html", honk.Precis, honk.Oonker)
M
views/honkform.html
→
views/honkform.html
@@ -7,9 +7,10 @@ <input type="hidden" name="CSRF" value="{{ .HonkCSRF }}">
<p> <label id="donker">attach: <input onchange="updatedonker();" type="file" name="donk"><span></span></label> <p> -<textarea name="noise" id="honknoise"></textarea> +<textarea name="noise" id="honknoise">{{ .Noise }}</textarea> <p> <input type="submit" value="it's gonna be honked"> +<input type="submit" name="preview" value="preview"> </form> <script> function showhonkform(rid, hname) {@@ -20,9 +21,6 @@ var honknoise = document.getElementById("honknoise")
if (rid) { ridinput.value = rid honknoise.value = "@" + hname + " " - } else { - ridinput.value = "" - honknoise.value = "" } document.getElementById("infobox").scrollIntoView() }