From 360c3fcc1183737f62b3a86ca6722d7d01fbd34f Mon Sep 17 00:00:00 2001 From: Justin Hawkins Date: Fri, 27 May 2022 22:07:25 +0930 Subject: [PATCH] Improve UX for the bookmarklet, if the user clicks instead of dragging, provide a prompt --- web/templates/bookmarklet.html | 13 +++++++++++++ web/web.go | 8 +++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/web/templates/bookmarklet.html b/web/templates/bookmarklet.html index 73c23d1..f58ff61 100644 --- a/web/templates/bookmarklet.html +++ b/web/templates/bookmarklet.html @@ -1,7 +1,20 @@
+ {{ if .clicked }} + +

Drag the bookmarklet link below to your bookmarks bar, or right click + it, copy the link and add it to your bookmarks manually.

+ +

Then whenever you are on a webpage you would like to bookmark, just + click the bookmarklet.

+ + Bookmarklet + + + {{ else }} {{ template "add_url_form.html" .}} + {{ end }}
\ No newline at end of file diff --git a/web/web.go b/web/web.go index 55d00d8..4a151c4 100644 --- a/web/web.go +++ b/web/web.go @@ -220,8 +220,14 @@ func Create(bmm *db.BookmarkManager, cmm *db.ConfigManager) *Server { r.GET("/bookmarklet", func(c *gin.Context) { url := c.Query("url") - log.Printf(url) + meta := gin.H{"page": "bookmarklet_click", "config": config, "url": url} + + // check if they just clicked it from the actual app + if strings.Index(url, config.BaseURL) == 0 { + meta["clicked"] = true + } + c.HTML(http.StatusOK, "_layout.html", meta, )