From 6ee7cbcf24a3000c66845e1b0037768761c1eebe Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Mon, 10 Jun 2019 22:28:09 -0400 Subject: [PATCH] xzone to start importing external content --- honk.go | 30 ++++++++++++++++++++++++++++++ views/header.html | 4 ++++ views/style.css | 8 +++++++- views/xzone.html | 11 +++++++++++ 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 views/xzone.html diff --git a/honk.go b/honk.go index cd9a729..e8bf09b 100644 --- a/honk.go +++ b/honk.go @@ -25,6 +25,7 @@ import ( "log" notrand "math/rand" "net/http" + "net/url" "os" "sort" "strconv" @@ -378,6 +379,32 @@ func inbox(w http.ResponseWriter, r *http.Request) { } } +func ximport(w http.ResponseWriter, r *http.Request) { + xid := r.FormValue("xid") + j, err := GetJunk(xid) + if err != nil { + log.Printf("error getting external object: %s", err) + return + } + u := login.GetUserInfo(r) + user, _ := butwhatabout(u.Username) + xonk := xonkxonk(user, j, originate(xid)) + convoy := "" + if xonk != nil { + convoy = xonk.Convoy + savexonk(user, xonk) + } + http.Redirect(w, r, "/t?c="+url.QueryEscape(convoy), http.StatusSeeOther) +} + +func xzone(w http.ResponseWriter, r *http.Request) { + templinfo := getInfo(r) + templinfo["XCSRF"] = login.GetCSRF("ximport", r) + err := readviews.Execute(w, r.URL.Path[1:]+".html", templinfo) + if err != nil { + log.Print(err) + } +} func outbox(w http.ResponseWriter, r *http.Request) { name := mux.Vars(r)["name"] user, err := butwhatabout(name) @@ -1275,6 +1302,7 @@ func serve() { "views/account.html", "views/about.html", "views/login.html", + "views/xzone.html", "views/header.html", ) if !debug { @@ -1321,11 +1349,13 @@ func serve() { loggedin.HandleFunc("/chpass", dochpass) loggedin.HandleFunc("/atme", homepage) loggedin.HandleFunc("/zonkzone", zonkzone) + loggedin.HandleFunc("/xzone", xzone) loggedin.Handle("/honk", login.CSRFWrap("honkhonk", http.HandlerFunc(savehonk))) loggedin.Handle("/bonk", login.CSRFWrap("honkhonk", http.HandlerFunc(savebonk))) loggedin.Handle("/zonkit", login.CSRFWrap("honkhonk", http.HandlerFunc(zonkit))) loggedin.Handle("/zonkzonk", login.CSRFWrap("zonkzonk", http.HandlerFunc(zonkzonk))) loggedin.Handle("/saveuser", login.CSRFWrap("saveuser", http.HandlerFunc(saveuser))) + loggedin.Handle("/ximport", login.CSRFWrap("ximport", http.HandlerFunc(ximport))) loggedin.HandleFunc("/honkers", showhonkers) loggedin.HandleFunc("/h/{name:[[:alnum:]]+}", showhonker) loggedin.HandleFunc("/c/{name:[[:alnum:]]+}", showcombo) diff --git a/views/header.html b/views/header.html index a471496..544940c 100644 --- a/views/header.html +++ b/views/header.html @@ -17,8 +17,12 @@ {{ .UserInfo.Username }} honkers combos +
+more +xzone zonkzone account +
{{ else }} about {{ if .ShowRSS }} diff --git a/views/style.css b/views/style.css index 8c1a238..26a9232 100644 --- a/views/style.css +++ b/views/style.css @@ -44,6 +44,12 @@ body > header { body > header span { margin-right: 2em; } +header details { + display: inline; +} +header details[open] summary { + display: none; +} main { max-width: 1200px; margin: auto; @@ -162,7 +168,7 @@ button a { } .inlineform select { } -details summary { +.honk details summary { color: #aab; } .limited details summary { diff --git a/views/xzone.html b/views/xzone.html new file mode 100644 index 0000000..ddb86f1 --- /dev/null +++ b/views/xzone.html @@ -0,0 +1,11 @@ +{{ template "header.html" . }} +
+
+
+ +

import +

- xid +

+

+
+