mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-13 13:39:27 +02:00
Add support for context path (#313)
* Add support for context path add an optional environment variable: LD_CONTEXT_PATH * Fix for pull request code review comments Co-authored-by: s2marine <s2marine@gmail.com>
This commit is contained in:
@@ -44,7 +44,7 @@
|
||||
{% endif %}
|
||||
<div class="navbar container grid-lg">
|
||||
<section class="navbar-section">
|
||||
<a href="/" class="navbar-brand text-bold">
|
||||
<a href="{% url 'bookmarks:index' %}" class="navbar-brand text-bold">
|
||||
<img class="logo" src="{% static 'logo.png' %}" alt="Application logo">
|
||||
<h1>linkding</h1>
|
||||
</a>
|
||||
|
53
bookmarks/tests/test_context_path.py
Normal file
53
bookmarks/tests/test_context_path.py
Normal file
@@ -0,0 +1,53 @@
|
||||
import importlib
|
||||
|
||||
from django.test import TestCase, override_settings
|
||||
from django.urls import reverse
|
||||
|
||||
|
||||
class MockUrlConf:
|
||||
def __init__(self, module):
|
||||
self.urlpatterns = module.urlpatterns
|
||||
|
||||
|
||||
class ContextPathTestCase(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.siteroot_urls = importlib.import_module('siteroot.urls')
|
||||
|
||||
@override_settings(LD_CONTEXT_PATH=None)
|
||||
def tearDown(self):
|
||||
importlib.reload(self.siteroot_urls)
|
||||
|
||||
@override_settings(LD_CONTEXT_PATH='linkding/')
|
||||
def test_route_with_context_path(self):
|
||||
module = importlib.reload(self.siteroot_urls)
|
||||
# pass mock config instead of actual module to prevent caching the
|
||||
# url config in django.urls.reverse
|
||||
urlconf = MockUrlConf(module)
|
||||
test_cases = [
|
||||
('bookmarks:index', '/linkding/bookmarks'),
|
||||
('bookmarks:bookmark-list', '/linkding/api/bookmarks/'),
|
||||
('login', '/linkding/login/'),
|
||||
('admin:bookmarks_bookmark_changelist', '/linkding/admin/bookmarks/bookmark/'),
|
||||
]
|
||||
|
||||
for url_name, expected_url in test_cases:
|
||||
url = reverse(url_name, urlconf=urlconf)
|
||||
self.assertEqual(expected_url, url)
|
||||
|
||||
@override_settings(LD_CONTEXT_PATH='')
|
||||
def test_route_without_context_path(self):
|
||||
module = importlib.reload(self.siteroot_urls)
|
||||
# pass mock config instead of actual module to prevent caching the
|
||||
# url config in django.urls.reverse
|
||||
urlconf = MockUrlConf(module)
|
||||
test_cases = [
|
||||
('bookmarks:index', '/bookmarks'),
|
||||
('bookmarks:bookmark-list', '/api/bookmarks/'),
|
||||
('login', '/login/'),
|
||||
('admin:bookmarks_bookmark_changelist', '/admin/bookmarks/bookmark/'),
|
||||
]
|
||||
|
||||
for url_name, expected_url in test_cases:
|
||||
url = reverse(url_name, urlconf=urlconf)
|
||||
self.assertEqual(expected_url, url)
|
@@ -73,7 +73,7 @@ def get_ttl_hash(seconds=3600):
|
||||
|
||||
@login_required
|
||||
def integrations(request):
|
||||
application_url = request.build_absolute_uri("/bookmarks/new")
|
||||
application_url = request.build_absolute_uri(reverse('bookmarks:new'))
|
||||
api_token = Token.objects.get_or_create(user=request.user)[0]
|
||||
feed_token = FeedToken.objects.get_or_create(user=request.user)[0]
|
||||
all_feed_url = request.build_absolute_uri(reverse('bookmarks:feeds.all', args=[feed_token.key]))
|
||||
|
Reference in New Issue
Block a user