From 1b7f57999d1f48e8f99fd925949937f13c14011e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20I=C3=9Fbr=C3=BCcker?= Date: Sat, 6 Jul 2019 17:17:14 +0200 Subject: [PATCH] Improve URL handling Extract bookmark list tag --- .../templates/bookmarks/bookmark_list.html | 40 ++++++++++++++++++ bookmarks/templates/bookmarks/index.html | 42 ++----------------- bookmarks/templates/bookmarks/layout.html | 8 ++-- bookmarks/templates/settings/index.html | 2 +- bookmarks/templatetags/bookmarks.py | 8 ++++ bookmarks/urls.py | 4 +- bookmarks/views/settings.py | 2 +- 7 files changed, 59 insertions(+), 47 deletions(-) create mode 100644 bookmarks/templates/bookmarks/bookmark_list.html diff --git a/bookmarks/templates/bookmarks/bookmark_list.html b/bookmarks/templates/bookmarks/bookmark_list.html new file mode 100644 index 0000000..d8d93d9 --- /dev/null +++ b/bookmarks/templates/bookmarks/bookmark_list.html @@ -0,0 +1,40 @@ + + diff --git a/bookmarks/templates/bookmarks/index.html b/bookmarks/templates/bookmarks/index.html index 29c2f09..e0a8f10 100644 --- a/bookmarks/templates/bookmarks/index.html +++ b/bookmarks/templates/bookmarks/index.html @@ -19,46 +19,10 @@ - - + {% if bookmarks.paginator.num_pages > 0 %} + {% bookmark_list bookmarks %} + {% endif %} {# Tag list #} diff --git a/bookmarks/templates/bookmarks/layout.html b/bookmarks/templates/bookmarks/layout.html index 2c16ce3..de7c99a 100644 --- a/bookmarks/templates/bookmarks/layout.html +++ b/bookmarks/templates/bookmarks/layout.html @@ -5,7 +5,7 @@ - linkdings + linkding {# Include SASS styles, files are resolved from bookmarks/styles #} @@ -22,9 +22,9 @@ {% if request.user.is_authenticated %} {% endif %} diff --git a/bookmarks/templates/settings/index.html b/bookmarks/templates/settings/index.html index f30bf70..6ff427c 100644 --- a/bookmarks/templates/settings/index.html +++ b/bookmarks/templates/settings/index.html @@ -10,7 +10,7 @@

Import bookmarks and tags in the Netscape HTML format. This will execute a sync where new bookmarks are added and existing ones are updated.

-
+ {% csrf_token %}
diff --git a/bookmarks/templatetags/bookmarks.py b/bookmarks/templatetags/bookmarks.py index 29c55a5..78233c9 100644 --- a/bookmarks/templatetags/bookmarks.py +++ b/bookmarks/templatetags/bookmarks.py @@ -1,6 +1,7 @@ from typing import List from django import template +from django.core.paginator import Page from bookmarks.models import BookmarkForm, Tag @@ -45,3 +46,10 @@ def tag_cloud(context, tags: List[Tag]): return { 'groups': groups, } + + +@register.inclusion_tag('bookmarks/bookmark_list.html', name='bookmark_list', takes_context=True) +def bookmark_list(context, bookmarks: Page): + return { + 'bookmarks': bookmarks, + } diff --git a/bookmarks/urls.py b/bookmarks/urls.py index 16f825a..7244a18 100644 --- a/bookmarks/urls.py +++ b/bookmarks/urls.py @@ -16,8 +16,8 @@ urlpatterns = [ path('bookmarks//remove', views.bookmarks.remove, name='remove'), path('bookmarklet', views.bookmarks.bookmarklet, name='bookmarklet'), # Settings - path('settings', views.settings.index, name='settings_index'), - path('settings/import', views.settings.bookmark_import, name='settings_import'), + path('settings', views.settings.index, name='settings.index'), + path('settings/import', views.settings.bookmark_import, name='settings.import'), # API path('api/website_metadata', views.api.website_metadata, name='api.website_metadata'), ] diff --git a/bookmarks/views/settings.py b/bookmarks/views/settings.py index 5a166ed..e7bbf3d 100644 --- a/bookmarks/views/settings.py +++ b/bookmarks/views/settings.py @@ -26,7 +26,7 @@ def bookmark_import(request): messages.error(request, 'An error occurred during bookmark import.', 'bookmark_import') pass - return HttpResponseRedirect(reverse('bookmarks:settings_index')) + return HttpResponseRedirect(reverse('bookmarks:settings.index')) def _find_message_with_tag(messages, tag):