mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-13 21:49:26 +02:00
Add option to display URL below title (#365)
* Add feature to display URL below title * updates pre-merging * Bookmark URL Tests & solving pending migration * cleanup after rebase * add test for updating setting --------- Co-authored-by: Bahadir Parmaksiz <bahadir.parmaksiz@tmconnected.com> Co-authored-by: Sascha Ißbrücker <sascha.issbruecker@gmail.com>
This commit is contained in:
@@ -90,6 +90,25 @@ class BookmarkListTagTest(TestCase, BookmarkFactoryMixin):
|
||||
<img src="/static/{bookmark.favicon_file}" alt="">
|
||||
''', html, count=count)
|
||||
|
||||
def assertBookmarkURLCount(self, html: str, bookmark: Bookmark, link_target: str = '_blank', count=0):
|
||||
self.assertInHTML(f'''
|
||||
<div class="url-path truncate">
|
||||
<a href="{ bookmark.url }" target="{ link_target }" rel="noopener"
|
||||
class="url-display text-sm">
|
||||
{ bookmark.url }
|
||||
</a>
|
||||
</div>
|
||||
''', html, count)
|
||||
|
||||
def assertBookmarkURLVisible(self, html: str, bookmark: Bookmark):
|
||||
self.assertBookmarkURLCount(html, bookmark, count=1)
|
||||
|
||||
|
||||
def assertBookmarkURLHidden(self, html: str, bookmark: Bookmark, link_target: str = '_blank'):
|
||||
self.assertBookmarkURLCount(html, bookmark, count=0)
|
||||
|
||||
|
||||
|
||||
def render_template(self, bookmarks: [Bookmark], template: Template, url: str = '/test') -> str:
|
||||
rf = RequestFactory()
|
||||
request = rf.get(url)
|
||||
@@ -252,3 +271,34 @@ class BookmarkListTagTest(TestCase, BookmarkFactoryMixin):
|
||||
html = self.render_default_template([bookmark])
|
||||
|
||||
self.assertFaviconHidden(html, bookmark)
|
||||
|
||||
def test_bookmark_url_should_be_hidden_by_default(self):
|
||||
profile = self.get_or_create_test_user().profile
|
||||
profile.save()
|
||||
|
||||
bookmark = self.setup_bookmark()
|
||||
html = self.render_default_template([bookmark])
|
||||
|
||||
self.assertBookmarkURLHidden(html,bookmark)
|
||||
|
||||
def test_show_bookmark_url_when_enabled(self):
|
||||
profile = self.get_or_create_test_user().profile
|
||||
profile.display_url = True
|
||||
profile.save()
|
||||
|
||||
bookmark = self.setup_bookmark()
|
||||
html = self.render_default_template([bookmark])
|
||||
|
||||
self.assertBookmarkURLVisible(html,bookmark)
|
||||
|
||||
def test_hide_bookmark_url_when_disabled(self):
|
||||
profile = self.get_or_create_test_user().profile
|
||||
profile.display_url = False
|
||||
profile.save()
|
||||
|
||||
bookmark = self.setup_bookmark()
|
||||
html = self.render_default_template([bookmark])
|
||||
|
||||
self.assertBookmarkURLHidden(html,bookmark)
|
||||
|
||||
|
||||
|
@@ -29,6 +29,7 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
||||
'enable_sharing': False,
|
||||
'enable_favicons': False,
|
||||
'tag_search': UserProfile.TAG_SEARCH_STRICT,
|
||||
'display_url': False,
|
||||
}
|
||||
|
||||
return {**form_data, **overrides}
|
||||
@@ -54,6 +55,7 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
||||
'enable_sharing': True,
|
||||
'enable_favicons': True,
|
||||
'tag_search': UserProfile.TAG_SEARCH_LAX,
|
||||
'display_url': True,
|
||||
}
|
||||
response = self.client.post(reverse('bookmarks:settings.general'), form_data)
|
||||
html = response.content.decode()
|
||||
@@ -68,6 +70,7 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
||||
self.assertEqual(self.user.profile.enable_sharing, form_data['enable_sharing'])
|
||||
self.assertEqual(self.user.profile.enable_favicons, form_data['enable_favicons'])
|
||||
self.assertEqual(self.user.profile.tag_search, form_data['tag_search'])
|
||||
self.assertEqual(self.user.profile.display_url, form_data['display_url'])
|
||||
self.assertInHTML('''
|
||||
<p class="form-input-hint">Profile updated</p>
|
||||
''', html)
|
||||
|
Reference in New Issue
Block a user