From 2da4fd0de23caecfe710e1c8407841e816be4a50 Mon Sep 17 00:00:00 2001 From: Jason McBrayer Date: Thu, 7 Nov 2019 19:44:09 -0500 Subject: [PATCH] Sharing bookmarklet works --- brutaldon/templates/setup/settings.html | 6 ++++++ brutaldon/views.py | 20 ++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/brutaldon/templates/setup/settings.html b/brutaldon/templates/setup/settings.html index 2e09f20..9d626a1 100644 --- a/brutaldon/templates/setup/settings.html +++ b/brutaldon/templates/setup/settings.html @@ -166,6 +166,12 @@ value="Save" class="button is-primary" > + +

Bookmarklet

+

+ Share via brutaldon +

+

Filters and More

List filters

Follow requests

diff --git a/brutaldon/views.py b/brutaldon/views.py index 227191f..4ef1d2a 100644 --- a/brutaldon/views.py +++ b/brutaldon/views.py @@ -191,6 +191,11 @@ def min_visibility(visibility1, visibility2): ] +def bookmarklet_url(request): + share_url = request.build_absolute_uri(reverse("share")) + return f"javascript:location.href='{share_url}?url='+encodeURIComponent(location.href)+';title='+encodeURIComponent(document.title)" + + def timeline( request, timeline="home", @@ -792,7 +797,13 @@ def settings(request): return redirect(home) else: return render( - request, "setup/settings.html", {"form": form, "account": account} + request, + "setup/settings.html", + { + "form": form, + "account": account, + "bookmarklet_url": bookmarklet_url(request), + }, ) else: request.session["timezone"] = account.preferences.timezone @@ -800,7 +811,12 @@ def settings(request): return render( request, "setup/settings.html", - {"form": form, "account": account, "preferences": account.preferences}, + { + "form": form, + "account": account, + "preferences": account.preferences, + "bookmarklet_url": bookmarklet_url(request), + }, )