Sharing bookmarklet works

This commit is contained in:
Jason McBrayer 2019-11-07 19:44:09 -05:00
parent da1de5ea32
commit 2da4fd0de2
2 changed files with 24 additions and 2 deletions

View File

@ -166,6 +166,12 @@
value="Save" class="button is-primary" >
</div>
</form>
<h2 class="subtitle">Bookmarklet</h2>
<p>
<a href="{{ bookmarklet_url }}">Share via brutaldon</a>
</p>
<h2 class="subtitle">Filters and More</h2>
<p><a href="{% url "list_filters" %}">List filters</a></p>
<p><a href="{% url "follow_requests" %}">Follow requests</a></p>

View File

@ -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),
},
)