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 %} -