diff --git a/bookmarks/templates/bookmarks/archive.html b/bookmarks/templates/bookmarks/archive.html index bd8d1c1..407089b 100644 --- a/bookmarks/templates/bookmarks/archive.html +++ b/bookmarks/templates/bookmarks/archive.html @@ -5,42 +5,42 @@ {% block content %} - {% include 'bookmarks/bulk_edit/state.html' %} + {% include 'bookmarks/bulk_edit/state.html' %} -
+
- {# Bookmark list #} -
-
-

Archived bookmarks

-
- {% bookmark_search filters tags mode='archived' %} - {% include 'bookmarks/bulk_edit/toggle.html' %} -
+ {# Bookmark list #} +
+
+

Archived bookmarks

+
+ {% bookmark_search filters tags mode='archived' %} + {% include 'bookmarks/bulk_edit/toggle.html' %} +
-
- {% csrf_token %} - {% include 'bookmarks/bulk_edit/bar.html' with mode='archive' %} + + {% csrf_token %} + {% include 'bookmarks/bulk_edit/bar.html' with mode='archive' %} - {% if empty %} - {% include 'bookmarks/empty_bookmarks.html' %} - {% else %} - {% bookmark_list bookmarks return_url link_target %} - {% endif %} -
-
+ {% if empty %} + {% include 'bookmarks/empty_bookmarks.html' %} + {% else %} + {% bookmark_list bookmarks return_url link_target %} + {% endif %} + +
- {# Tag list #} -
-
-

Tags

-
- {% tag_cloud tags selected_tags %} -
-
+ {# Tag list #} +
+
+

Tags

+
+ {% tag_cloud tags selected_tags %} +
+
- - - + + + {% endblock %} diff --git a/bookmarks/templates/bookmarks/bookmark_list.html b/bookmarks/templates/bookmarks/bookmark_list.html index 68aded0..5cbae67 100644 --- a/bookmarks/templates/bookmarks/bookmark_list.html +++ b/bookmarks/templates/bookmarks/bookmark_list.html @@ -1,91 +1,98 @@ {% load shared %} {% load pagination %} - - -
+
{% pagination bookmarks %} -
+
+{% endhtmlmin %} diff --git a/bookmarks/templates/bookmarks/bookmarklet.js b/bookmarks/templates/bookmarks/bookmarklet.js index abd8339..175415e 100644 --- a/bookmarks/templates/bookmarks/bookmarklet.js +++ b/bookmarks/templates/bookmarks/bookmarklet.js @@ -1,9 +1,9 @@ -(function() { - var bookmarkUrl = window.location; - var applicationUrl = '{{ application_url }}'; +(function () { + var bookmarkUrl = window.location; + var applicationUrl = '{{ application_url }}'; - applicationUrl += '?url=' + encodeURIComponent(bookmarkUrl); - applicationUrl += '&auto_close'; + applicationUrl += '?url=' + encodeURIComponent(bookmarkUrl); + applicationUrl += '&auto_close'; - window.open(applicationUrl); + window.open(applicationUrl); })(); diff --git a/bookmarks/templates/bookmarks/bulk_edit/bar.html b/bookmarks/templates/bookmarks/bulk_edit/bar.html index bc473fe..933c30e 100644 --- a/bookmarks/templates/bookmarks/bulk_edit/bar.html +++ b/bookmarks/templates/bookmarks/bulk_edit/bar.html @@ -1,31 +1,34 @@ +{% load shared %} +{% htmlmin %}
-
- - {% if mode == 'archive' %} - - {% else %} - - {% endif %} - - - - - - - -
+
+ + {% if mode == 'archive' %} + + {% else %} + + {% endif %} + + + + + + + +
+{% endhtmlmin %} diff --git a/bookmarks/templates/bookmarks/bulk_edit/toggle.html b/bookmarks/templates/bookmarks/bulk_edit/toggle.html index 9c006d3..af3b391 100644 --- a/bookmarks/templates/bookmarks/bulk_edit/toggle.html +++ b/bookmarks/templates/bookmarks/bulk_edit/toggle.html @@ -2,7 +2,8 @@ - + diff --git a/bookmarks/templates/bookmarks/close.html b/bookmarks/templates/bookmarks/close.html index f560857..dd18e6c 100644 --- a/bookmarks/templates/bookmarks/close.html +++ b/bookmarks/templates/bookmarks/close.html @@ -1,9 +1,9 @@ {% extends "bookmarks/layout.html" %} {% block content %} - -

You can now close this window.

+ +

You can now close this window.

{% endblock %} diff --git a/bookmarks/templates/bookmarks/edit.html b/bookmarks/templates/bookmarks/edit.html index bb61f81..bedb77a 100644 --- a/bookmarks/templates/bookmarks/edit.html +++ b/bookmarks/templates/bookmarks/edit.html @@ -2,14 +2,15 @@ {% load bookmarks %} {% block content %} -
-
-
-

Edit bookmark

-
-
- {% bookmark_form form return_url bookmark_id %} -
-
-
+
+
+
+

Edit bookmark

+
+
+ {% bookmark_form form return_url bookmark_id %} +
+
+
{% endblock %} diff --git a/bookmarks/templates/bookmarks/empty_bookmarks.html b/bookmarks/templates/bookmarks/empty_bookmarks.html index 0018889..b6217d9 100644 --- a/bookmarks/templates/bookmarks/empty_bookmarks.html +++ b/bookmarks/templates/bookmarks/empty_bookmarks.html @@ -1,8 +1,9 @@
-

You have no bookmarks yet

-

- You can get started by adding bookmarks, - importing your existing bookmarks or configuring the - browser extension or the bookmarklet. -

+

You have no bookmarks yet

+

+ You can get started by adding bookmarks, + importing your existing bookmarks or configuring the + browser extension or the bookmarklet. +

diff --git a/bookmarks/templates/bookmarks/form.html b/bookmarks/templates/bookmarks/form.html index a193752..8c44136 100644 --- a/bookmarks/templates/bookmarks/form.html +++ b/bookmarks/templates/bookmarks/form.html @@ -2,205 +2,205 @@ {% load static %}
- {% csrf_token %} - {{ form.website_title }} - {{ form.website_description }} - {{ form.auto_close|attr:"type:hidden" }} -
- - {{ form.url|add_class:"form-input"|attr:"autofocus"|attr:"placeholder: " }} - {% if form.url.errors %} -
- {{ form.url.errors }} -
- {% endif %} -
- This URL is already bookmarked. You can edit it or you can overwrite the existing bookmark - by saving this form. -
-
-
- - {{ form.tag_string|add_class:"form-input"|attr:"autocomplete:off" }} -
- Enter any number of tags separated by space and without the hash (#). If a tag does not - exist it will be - automatically created. -
- {{ form.tag_string.errors }} -
-
- -
- {{ form.title|add_class:"form-input"|attr:"autocomplete:off" }} - - - - - - - -
-
- Optional, leave empty to use title from website. -
- {{ form.title.errors }} -
-
- -
- {{ form.description|add_class:"form-input"|attr:"rows:2" }} - - - - - - - -
-
- Optional, leave empty to use description from website. -
- {{ form.description.errors }} -
-
- + {% csrf_token %} + {{ form.website_title }} + {{ form.website_description }} + {{ form.auto_close|attr:"type:hidden" }} +
+ + {{ form.url|add_class:"form-input"|attr:"autofocus"|attr:"placeholder: " }} + {% if form.url.errors %}
- Unread bookmarks can be filtered for, and marked as read after you had a chance to look at them. -
-
- {% if request.user.profile.enable_sharing %} -
- -
- Share this bookmark with other users. -
+ {{ form.url.errors }}
{% endif %} -
-
- {% if auto_close %} - - {% else %} - - {% endif %} - Nevermind +
+ This URL is already bookmarked. You can edit it or you can overwrite the existing bookmark + by saving this form.
+
+
+ + {{ form.tag_string|add_class:"form-input"|attr:"autocomplete:off" }} +
+ Enter any number of tags separated by space and without the hash (#). If a tag does not + exist it will be + automatically created. +
+ {{ form.tag_string.errors }} +
+
+ +
+ {{ form.title|add_class:"form-input"|attr:"autocomplete:off" }} + + + + + + + +
+
+ Optional, leave empty to use title from website. +
+ {{ form.title.errors }} +
+
+ +
+ {{ form.description|add_class:"form-input"|attr:"rows:2" }} + + + + + + + +
+
+ Optional, leave empty to use description from website. +
+ {{ form.description.errors }} +
+
+ +
+ Unread bookmarks can be filtered for, and marked as read after you had a chance to look at them. +
+
+ {% if request.user.profile.enable_sharing %} +
+ +
+ Share this bookmark with other users. +
+
+ {% endif %} +
+
+ {% if auto_close %} + + {% else %} + + {% endif %} + Nevermind +
- {# Replace tag input with auto-complete component #} - - + + - + setupEditAutoValueButton(titleInput); + setupEditAutoValueButton(descriptionInput); + })(); +
diff --git a/bookmarks/templates/bookmarks/index.html b/bookmarks/templates/bookmarks/index.html index 248f2e7..3f69df1 100644 --- a/bookmarks/templates/bookmarks/index.html +++ b/bookmarks/templates/bookmarks/index.html @@ -5,42 +5,42 @@ {% block content %} - {% include 'bookmarks/bulk_edit/state.html' %} + {% include 'bookmarks/bulk_edit/state.html' %} -
+
- {# Bookmark list #} -
-
-

Bookmarks

-
- {% bookmark_search filters tags %} - {% include 'bookmarks/bulk_edit/toggle.html' %} -
+ {# Bookmark list #} +
+
+

Bookmarks

+
+ {% bookmark_search filters tags %} + {% include 'bookmarks/bulk_edit/toggle.html' %} +
-
- {% csrf_token %} - {% include 'bookmarks/bulk_edit/bar.html' with mode='default' %} + + {% csrf_token %} + {% include 'bookmarks/bulk_edit/bar.html' with mode='default' %} - {% if empty %} - {% include 'bookmarks/empty_bookmarks.html' %} - {% else %} - {% bookmark_list bookmarks return_url link_target %} - {% endif %} -
-
+ {% if empty %} + {% include 'bookmarks/empty_bookmarks.html' %} + {% else %} + {% bookmark_list bookmarks return_url link_target %} + {% endif %} + +
- {# Tag list #} -
-
-

Tags

-
- {% tag_cloud tags selected_tags %} -
-
+ {# Tag list #} +
+
+

Tags

+
+ {% tag_cloud tags selected_tags %} +
+
- - - + + + {% endblock %} diff --git a/bookmarks/templates/bookmarks/layout.html b/bookmarks/templates/bookmarks/layout.html index f2be882..90fbb78 100644 --- a/bookmarks/templates/bookmarks/layout.html +++ b/bookmarks/templates/bookmarks/layout.html @@ -5,61 +5,61 @@ {# Use data attributes as storage for access in static scripts #} - - - - - - - - linkding - {# Include SASS styles, files are resolved from bookmarks/styles #} - {# Include specific theme variant based on user profile setting #} - {% if request.user.profile.theme == 'light' %} - - {% elif request.user.profile.theme == 'dark' %} - - {% else %} - {# Use auto theme as fallback #} - - - {% endif %} + + + + + + + + linkding + {# Include SASS styles, files are resolved from bookmarks/styles #} + {# Include specific theme variant based on user profile setting #} + {% if request.user.profile.theme == 'light' %} + + {% elif request.user.profile.theme == 'dark' %} + + {% else %} + {# Use auto theme as fallback #} + + + {% endif %}
- {% if has_toasts %} + {% if has_toasts %}
{% csrf_token %} {% for toast in toast_messages %} -
- {{ toast.message }} - -
+
+ {{ toast.message }} + +
{% endfor %}
+ {% endif %} +
- {% block content %} - {% endblock %} + {% block content %} + {% endblock %}
diff --git a/bookmarks/templates/bookmarks/nav_menu.html b/bookmarks/templates/bookmarks/nav_menu.html index b7dfe85..88d895d 100644 --- a/bookmarks/templates/bookmarks/nav_menu.html +++ b/bookmarks/templates/bookmarks/nav_menu.html @@ -1,93 +1,101 @@ +{% load shared %} +{% htmlmin %} {# Basic menu list #}
- Add bookmark - - Settings - Logout + Add bookmark + + Settings + Logout
{# Menu drop-down for smaller devices #}
- - - - + + + + + +
+{% endhtmlmin %} diff --git a/bookmarks/templates/bookmarks/new.html b/bookmarks/templates/bookmarks/new.html index 62d0144..1166e1b 100644 --- a/bookmarks/templates/bookmarks/new.html +++ b/bookmarks/templates/bookmarks/new.html @@ -2,14 +2,14 @@ {% load bookmarks %} {% block content %} -
-
-
-

New bookmark

-
-
- {% bookmark_form form return_url auto_close=auto_close %} -
-
-
+
+
+
+

New bookmark

+
+
+ {% bookmark_form form return_url auto_close=auto_close %} +
+
+
{% endblock %} diff --git a/bookmarks/templates/bookmarks/pagination.html b/bookmarks/templates/bookmarks/pagination.html index c7b94f1..59f853e 100644 --- a/bookmarks/templates/bookmarks/pagination.html +++ b/bookmarks/templates/bookmarks/pagination.html @@ -1,35 +1,35 @@ {% load shared %} \ No newline at end of file diff --git a/bookmarks/templates/bookmarks/search.html b/bookmarks/templates/bookmarks/search.html index a4b35a2..1d49def 100644 --- a/bookmarks/templates/bookmarks/search.html +++ b/bookmarks/templates/bookmarks/search.html @@ -1,43 +1,43 @@ {# Replace search input with auto-complete component #} \ No newline at end of file diff --git a/bookmarks/templates/bookmarks/shared.html b/bookmarks/templates/bookmarks/shared.html index 3fa0d4c..ebcffd4 100644 --- a/bookmarks/templates/bookmarks/shared.html +++ b/bookmarks/templates/bookmarks/shared.html @@ -5,44 +5,44 @@ {% block content %} -
+
- {# Bookmark list #} -
-
-

Shared bookmarks

-
- {% bookmark_search filters tags mode='shared' %} -
+ {# Bookmark list #} +
+
+

Shared bookmarks

+
+ {% bookmark_search filters tags mode='shared' %} +
-
- {% csrf_token %} + + {% csrf_token %} - {% if empty %} - {% include 'bookmarks/empty_bookmarks.html' %} - {% else %} - {% bookmark_list bookmarks return_url link_target %} - {% endif %} -
-
+ {% if empty %} + {% include 'bookmarks/empty_bookmarks.html' %} + {% else %} + {% bookmark_list bookmarks return_url link_target %} + {% endif %} + +
- {# Filters #} -
-
-

User

-
-
- {% user_select filters users %} -
-
-
-

Tags

-
- {% tag_cloud tags selected_tags %} -
-
+ {# Filters #} +
+
+

User

+
+
+ {% user_select filters users %} +
+
+
+

Tags

+
+ {% tag_cloud tags selected_tags %} +
+
- - + + {% endblock %} diff --git a/bookmarks/templates/bookmarks/tag_cloud.html b/bookmarks/templates/bookmarks/tag_cloud.html index 579d2b5..921f0a9 100644 --- a/bookmarks/templates/bookmarks/tag_cloud.html +++ b/bookmarks/templates/bookmarks/tag_cloud.html @@ -1,35 +1,37 @@ {% load shared %} - -
+{% htmlmin %} +
{% if has_selected_tags %} -

- {% for tag in selected_tags %} - - -{{ tag.name }} - - {% endfor %} -

+

+ {% for tag in selected_tags %} + + -{{ tag.name }} + + {% endfor %} +

{% endif %}
- {% for group in groups %} -

- {% for tag in group.tags %} - {# Highlight first char of first tag in group #} - {% if forloop.counter == 1 %} - - {{ tag.name|first_char }}{{ tag.name|remaining_chars:1 }} - - {% else %} - {# Render remaining tags normally #} - - {{ tag.name }} - - {% endif %} - {% endfor %} -

- {% endfor %} + {% for group in groups %} +

+ {% for tag in group.tags %} + {# Highlight first char of first tag in group #} + {% if forloop.counter == 1 %} + + {{ tag.name|first_char }}{{ tag.name|remaining_chars:1 }} + + {% else %} + {# Render remaining tags normally #} + + {{ tag.name }} + + {% endif %} + {% endfor %} +

+ {% endfor %}
-
+
+{% endhtmlmin %} diff --git a/bookmarks/templatetags/shared.py b/bookmarks/templatetags/shared.py index 9e136db..e8b3857 100644 --- a/bookmarks/templatetags/shared.py +++ b/bookmarks/templatetags/shared.py @@ -1,3 +1,5 @@ +import re + from django import template from bookmarks import utils @@ -48,6 +50,7 @@ def remove_from_query_param(context, **kwargs): return query.urlencode() + @register.simple_tag(takes_context=True) def replace_query_param(context, **kwargs): query = context.request.GET.copy() @@ -87,3 +90,22 @@ def humanize_relative_date(value): if value in (None, ''): return '' return utils.humanize_relative_date(value) + + +@register.tag +def htmlmin(parser, token): + nodelist = parser.parse(('endhtmlmin',)) + parser.delete_first_token() + return HtmlMinNode(nodelist) + + +class HtmlMinNode(template.Node): + def __init__(self, nodelist): + self.nodelist = nodelist + + def render(self, context): + output = self.nodelist.render(context) + + output = re.sub(r'\s+', ' ', output) + + return output