Make bookmarklet available in footer of every page
This commit is contained in:
parent
fb2970af3b
commit
428c1e1508
|
@ -0,0 +1,8 @@
|
|||
from django.urls import reverse
|
||||
|
||||
|
||||
def bookmarklet_url(request):
|
||||
share_url = request.build_absolute_uri(reverse("share"))
|
||||
return {
|
||||
"bookmarklet_url": f"javascript:location.href='{share_url}?url='+encodeURIComponent(location.href)+';title='+encodeURIComponent(document.title)"
|
||||
}
|
|
@ -67,6 +67,7 @@ TEMPLATES = [
|
|||
"django.template.context_processors.request",
|
||||
"django.contrib.auth.context_processors.auth",
|
||||
"django.contrib.messages.context_processors.messages",
|
||||
"brutaldon.context_processors.bookmarklet_url",
|
||||
]
|
||||
},
|
||||
}
|
||||
|
|
|
@ -183,6 +183,7 @@
|
|||
<a class="level-item is-size-7" href="https://github.com/jfmcbrayer/brutaldon">
|
||||
Source
|
||||
</a>
|
||||
<span class="level-item is-size-7" >Bookmarklet: <a href="{{ bookmarklet_url }}">Share via brutaldon</a></span>
|
||||
</div>
|
||||
<div class="level-right">
|
||||
{% if preferences.theme.is_brutalist %}
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.conf import settings as django_settings
|
|||
from django.shortcuts import render, redirect
|
||||
from django.urls import reverse
|
||||
from django.views.decorators.cache import never_cache, cache_page
|
||||
from django.urls import reverse
|
||||
from django.core.files.uploadhandler import TemporaryFileUploadHandler
|
||||
from django.utils.translation import gettext as _
|
||||
from brutaldon.forms import (
|
||||
|
@ -191,11 +190,6 @@ 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",
|
||||
|
@ -800,13 +794,7 @@ def settings(request):
|
|||
return redirect(home)
|
||||
else:
|
||||
return render(
|
||||
request,
|
||||
"setup/settings.html",
|
||||
{
|
||||
"form": form,
|
||||
"account": account,
|
||||
"bookmarklet_url": bookmarklet_url(request),
|
||||
},
|
||||
request, "setup/settings.html", {"form": form, "account": account}
|
||||
)
|
||||
else:
|
||||
request.session["timezone"] = account.preferences.timezone
|
||||
|
@ -814,12 +802,7 @@ def settings(request):
|
|||
return render(
|
||||
request,
|
||||
"setup/settings.html",
|
||||
{
|
||||
"form": form,
|
||||
"account": account,
|
||||
"preferences": account.preferences,
|
||||
"bookmarklet_url": bookmarklet_url(request),
|
||||
},
|
||||
{"form": form, "account": account, "preferences": account.preferences},
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue