diff --git a/bookwyrm/static/js/block_href.js b/bookwyrm/static/js/block_href.js new file mode 100644 index 00000000..1de6ca66 --- /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 8e1c46a3..0e653aeb 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 8ba868f5..5f8962b3 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 fb61e59e..d430598e 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 d85d2af3..7220d5d1 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 87dd0998..f3c8b5c0 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 19b6d13d..382978d4 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 %} -