diff --git a/brutaldon/context_processors.py b/brutaldon/context_processors.py
new file mode 100644
index 0000000..105ccb6
--- /dev/null
+++ b/brutaldon/context_processors.py
@@ -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)"
+ }
diff --git a/brutaldon/settings.py b/brutaldon/settings.py
index e54279d..97ba350 100644
--- a/brutaldon/settings.py
+++ b/brutaldon/settings.py
@@ -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",
]
},
}
diff --git a/brutaldon/templates/base.html b/brutaldon/templates/base.html
index 4d7116a..eeb41bb 100644
--- a/brutaldon/templates/base.html
+++ b/brutaldon/templates/base.html
@@ -183,6 +183,7 @@
Source
+ Bookmarklet: Share via brutaldon
{% if preferences.theme.is_brutalist %}
diff --git a/brutaldon/views.py b/brutaldon/views.py
index 7a441d6..a7ebfc5 100644
--- a/brutaldon/views.py
+++ b/brutaldon/views.py
@@ -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},
)