diff --git a/bookwyrm/static/js/block_href.js b/bookwyrm/static/js/block_href.js new file mode 100644 index 000000000..1de6ca665 --- /dev/null +++ b/bookwyrm/static/js/block_href.js @@ -0,0 +1,22 @@ +/* exported BlockHref */ +/* globals BookWyrm */ + +let BlockHref = new class { + constructor() { + document.querySelectorAll('[data-href]') + .forEach(t => t.addEventListener('click', this.followLink.bind(this))); + } + + /** + * Follow a fake link + * + * @param {Event} event + * @return {undefined} + */ + followLink(event) { + const url = event.currentTarget.dataset.href; + + window.location.href = url; + } +}(); + diff --git a/bookwyrm/templates/notifications/items/add.html b/bookwyrm/templates/notifications/items/add.html index 8e1c46a30..0e653aeb8 100644 --- a/bookwyrm/templates/notifications/items/add.html +++ b/bookwyrm/templates/notifications/items/add.html @@ -3,6 +3,14 @@ {% load i18n %} {% load utilities %} +{% block primary_link %}{% spaceless %} +{% if notification.related_list_item.approved %} + {{ notification.related_list_item.book_list.local_path }} +{% else %} + {% url 'list-curate' notification.related_list_item.book_list.id %} +{% endif %} +{% endspaceless %}{% endblock %} + {% block icon %} {% endblock %} diff --git a/bookwyrm/templates/notifications/items/boost.html b/bookwyrm/templates/notifications/items/boost.html index 8ba868f5f..5f8962b38 100644 --- a/bookwyrm/templates/notifications/items/boost.html +++ b/bookwyrm/templates/notifications/items/boost.html @@ -3,6 +3,10 @@ {% load i18n %} {% load utilities %} +{% block primary_link %}{% spaceless %} + {{ notification.related_status.local_path }} +{% endspaceless %}{% endblock %} + {% block icon %} {% endblock %} diff --git a/bookwyrm/templates/notifications/items/fav.html b/bookwyrm/templates/notifications/items/fav.html index fb61e59ef..d430598e9 100644 --- a/bookwyrm/templates/notifications/items/fav.html +++ b/bookwyrm/templates/notifications/items/fav.html @@ -3,6 +3,10 @@ {% load i18n %} {% load utilities %} +{% block primary_link %}{% spaceless %} + {{ notification.related_status.local_path }} +{% endspaceless %}{% endblock %} + {% block icon %} {% endblock %} diff --git a/bookwyrm/templates/notifications/items/follow.html b/bookwyrm/templates/notifications/items/follow.html index d85d2af3a..7220d5d17 100644 --- a/bookwyrm/templates/notifications/items/follow.html +++ b/bookwyrm/templates/notifications/items/follow.html @@ -3,6 +3,10 @@ {% load i18n %} {% load utilities %} +{% block primary_link %}{% spaceless %} + {{ notification.related_user.local_path }} +{% endspaceless %}{% endblock %} + {% block icon %} {% endblock %} diff --git a/bookwyrm/templates/notifications/items/import.html b/bookwyrm/templates/notifications/items/import.html index 87dd09983..f3c8b5c09 100644 --- a/bookwyrm/templates/notifications/items/import.html +++ b/bookwyrm/templates/notifications/items/import.html @@ -1,7 +1,10 @@ {% extends 'notifications/items/item_layout.html' %} - {% load i18n %} +{% block primary_link %}{% spaceless %} +{% url 'import-status' notification.related_import.id %} +{% endspaceless %}{% endblock %} + {% block icon %} {% endblock %} diff --git a/bookwyrm/templates/notifications/items/item_layout.html b/bookwyrm/templates/notifications/items/item_layout.html index 19b6d13dd..382978d47 100644 --- a/bookwyrm/templates/notifications/items/item_layout.html +++ b/bookwyrm/templates/notifications/items/item_layout.html @@ -1,7 +1,7 @@ {% load humanize %} {% load bookwyrm_tags %} {% related_status notification as related_status %} -
+
{% block icon %}{% endblock %} diff --git a/bookwyrm/templates/notifications/items/mention.html b/bookwyrm/templates/notifications/items/mention.html index 003f4e29e..cda77163e 100644 --- a/bookwyrm/templates/notifications/items/mention.html +++ b/bookwyrm/templates/notifications/items/mention.html @@ -3,6 +3,9 @@ {% load i18n %} {% load utilities %} +{% block primary_link %}{% spaceless %} + {{ notification.related_status.local_path }} +{% endspaceless %}{% endblock %} {% block icon %} diff --git a/bookwyrm/templates/notifications/items/reply.html b/bookwyrm/templates/notifications/items/reply.html index 125e4dec2..883bbbb5b 100644 --- a/bookwyrm/templates/notifications/items/reply.html +++ b/bookwyrm/templates/notifications/items/reply.html @@ -3,6 +3,9 @@ {% load i18n %} {% load utilities %} +{% block primary_link %}{% spaceless %} + {{ notification.related_status.local_path }} +{% endspaceless %}{% endblock %} {% block icon %} diff --git a/bookwyrm/templates/notifications/items/report.html b/bookwyrm/templates/notifications/items/report.html index 9e56d352d..f537b5255 100644 --- a/bookwyrm/templates/notifications/items/report.html +++ b/bookwyrm/templates/notifications/items/report.html @@ -2,6 +2,10 @@ {% load i18n %} +{% block primary_link %}{% spaceless %} + {% url 'settings-report' notification.related_report.id %} +{% endspaceless %}{% endblock %} + {% block icon %} {% endblock %} diff --git a/bookwyrm/templates/notifications/notifications_page.html b/bookwyrm/templates/notifications/notifications_page.html index 8d1cf6ad5..dc6acbdb3 100644 --- a/bookwyrm/templates/notifications/notifications_page.html +++ b/bookwyrm/templates/notifications/notifications_page.html @@ -1,5 +1,6 @@ {% extends 'layout.html' %} {% load i18n %} +{% load static %} {% block title %}{% trans "Notifications" %}{% endblock %} @@ -45,3 +46,7 @@ {% endif %}
{% endblock %} + +{% block scripts %} + +{% endblock %}