From 5857148ec933b378567fb906d536ee29d659143c Mon Sep 17 00:00:00 2001 From: Ryan Stafford Date: Sun, 3 Sep 2023 13:11:53 -0400 Subject: [PATCH] create post url parameters for bookmarklets --- routes.go | 11 +++++++++++ state.go | 3 +++ templates/create_post.html | 7 ++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/routes.go b/routes.go index 19aa8b6..a653ad0 100644 --- a/routes.go +++ b/routes.go @@ -648,6 +648,17 @@ func GetCreatePost(w http.ResponseWriter, r *http.Request, ps httprouter.Params) Render(w, "index.html", state) return } + m, _ := url.ParseQuery(r.URL.RawQuery) + + if len(m["url"]) > 0 { + state.SubmitURL = m["url"][0] + } + if len(m["title"]) > 0 { + state.SubmitTitle = m["title"][0] + } + if len(m["body"]) > 0 { + state.SubmitBody = m["body"][0] + } state.GetSite() state.GetCommunity("") state.Op = "create_post" diff --git a/state.go b/state.go index cac206a..1b1d804 100644 --- a/state.go +++ b/state.go @@ -105,6 +105,9 @@ type State struct { ShowNSFW bool HideInstanceNames bool HideThumbnails bool + SubmitURL string + SubmitTitle string + SubmitBody string } func (s State) UserBlocked() bool { diff --git a/templates/create_post.html b/templates/create_post.html index 86302df..b9a7d09 100644 --- a/templates/create_post.html +++ b/templates/create_post.html @@ -3,17 +3,18 @@
- +
- +