From 686fff945e0b4697aa74da404ce90534bb7b121d Mon Sep 17 00:00:00 2001 From: Jonas Kohl Date: Thu, 26 Dec 2024 20:12:34 +0100 Subject: Add async email and topic subscribing --- .../templates/bootstrap-3/view_topic.twig | 40 ++++++++++++++++++---- src/application/templates/modern/view_topic.twig | 34 +++++++++++++++++- src/application/templates/old/view_topic.twig | 29 +++++++++++++++- 3 files changed, 95 insertions(+), 8 deletions(-) (limited to 'src/application/templates') diff --git a/src/application/templates/bootstrap-3/view_topic.twig b/src/application/templates/bootstrap-3/view_topic.twig index 383dd41..7009afc 100644 --- a/src/application/templates/bootstrap-3/view_topic.twig +++ b/src/application/templates/bootstrap-3/view_topic.twig @@ -30,6 +30,12 @@ or currentUser.hasPermission(permission("DELETE_OTHER_TOPIC")) ) %} +{% set canSubscribe = currentUser is not null %} + +{% set isSubscribed = + currentUser is not null + and ctx.subscription is not null %} + {% set title = ctx.topic.title %} {% extends "base.twig" %} @@ -178,30 +184,40 @@ {{ ctx.topic.title }}
{% if canEdit and not ctx.topic.isLocked %} - + {% endif %} {% if canReply %} - + + {% endif %} + {% if canSubscribe %} +
+ + {% if isSubscribed %} + + {% else %} + + {% endif %} +
{% endif %} {% if canEdit %} {% if ctx.topic.isLocked %}
- +
{% else %}
- +
{% endif %} {% endif %} {% if canDelete %}
- +
{% endif %}
@@ -209,7 +225,14 @@ {{ __("Started by %user% on %date%", { "user": (ctx.topicAuthor is not null) ? ('' ~ ctx.topicAuthor.displayName|e("html") ~ '') : __("(deleted)"), "date": '' ~ ctx.topic.creationDate.format("c")|e("html") ~ '', - }) }} + }) }} • {{ ___( + "%n% person is watching this topic", + "%n% people are watching this topic", + ctx.subscription_count, + { + n: ctx.subscription_count, + }, + ) }} {% if canEdit %} {% else %} diff --git a/src/application/templates/modern/view_topic.twig b/src/application/templates/modern/view_topic.twig index 733ce1b..c064b1c 100644 --- a/src/application/templates/modern/view_topic.twig +++ b/src/application/templates/modern/view_topic.twig @@ -30,6 +30,12 @@ or currentUser.hasPermission(permission("DELETE_OTHER_TOPIC")) ) %} +{% set canSubscribe = currentUser is not null %} + +{% set isSubscribed = + currentUser is not null + and ctx.subscription is not null %} + {% set title = ctx.topic.title %} {% extends "base.twig" %} @@ -189,6 +195,20 @@ {% endif %} + {% if canSubscribe %} +
+ + {% if isSubscribed %} + + {% else %} + + {% endif %} +
+ {% endif %} {% if canEdit %} {% if ctx.topic.isLocked %}
@@ -221,7 +241,14 @@ {{ __("Started by %user% on %date%", { "user": (ctx.topicAuthor is not null) ? ('' ~ ctx.topicAuthor.displayName|e("html") ~ '') : __("(deleted)"), "date": '' ~ ctx.topic.creationDate.format("c")|e("html") ~ '', - }) }} + }) }} • {{ ___( + "%n% person is watching this topic", + "%n% people are watching this topic", + ctx.subscription_count, + { + n: ctx.subscription_count, + }, + ) }} {% if canEdit %} @@ -348,6 +375,11 @@ document.addEventListener("DOMContentLoaded", function() { }) }} + {% if not isSubscribed %} +
+ +
+ {% endif %}
+ {%- else -%} + + {%- endif -%} + + {%- endif -%} {%- if canDelete -%}
{# #}{# @@ -87,7 +103,14 @@ {{ __("Started by %user% on %date%", { "user": (ctx.topicAuthor is not null) ? ('' ~ ctx.topicAuthor.displayName|e("html") ~ '') : __("(deleted)"), "date": '' ~ ctx.topic.creationDate.format("c")|e("html") ~ '', - }) }} + }) }} • {{ ___( + "%n% person is watching this topic", + "%n% people are watching this topic", + ctx.subscription_count, + { + n: ctx.subscription_count, + }, + ) }} {% if canEdit %} @@ -216,6 +239,10 @@ $(function() { }) }}


+ {% if not isSubscribed %} +
+
+ {% endif %}
{% else %} -- cgit v1.2.3