From 310e7947ff3e17aeddfb21e5968537f60593e5b7 Mon Sep 17 00:00:00 2001 From: Sebastian Dietrich Date: Sun, 27 Aug 2023 17:42:59 +0200 Subject: [PATCH 1/3] Revert to using genshi.builder.tag because the code is not yet compatible with trac.util.html.tag genshi.builder.tag converts attribute names like 'data_base_url' to 'data-base-url' which makes them accessible by jQuery's .data() API. trac.util.html.tag does not do that. fixes regression in fa7cdff4500f3a2a215645d3cd5470833dfca624 --- code_comments/subscription.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code_comments/subscription.py b/code_comments/subscription.py index cbe14dc..913c2db 100644 --- a/code_comments/subscription.py +++ b/code_comments/subscription.py @@ -6,11 +6,11 @@ from trac.admin import IAdminCommandProvider from trac.attachment import Attachment, IAttachmentChangeListener from trac.core import Component, implements -from trac.util.html import html as tag from trac.versioncontrol import ( RepositoryManager, NoSuchChangeset, IRepositoryChangeListener) from trac.web.api import HTTPNotFound, IRequestHandler, ITemplateStreamFilter +from genshi.builder import tag # Note that trac.util.html.html is NOT a drop-in replacement. (see #85) from genshi.filters import Transformer from code_comments.api import ICodeCommentChangeListener From 77a3a8d343c091d2c0ddd6ef971a1e568efe484e Mon Sep 17 00:00:00 2001 From: Sebastian Dietrich Date: Sun, 8 Jun 2025 15:57:47 +0200 Subject: [PATCH 2/3] Allow Backbone.View to access dynamically generated elements This will be necessary to be able to dynamically create the subscription button. --- code_comments/htdocs/code-comments.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code_comments/htdocs/code-comments.js b/code_comments/htdocs/code-comments.js index fe1cda6..53bca3e 100644 --- a/code_comments/htdocs/code-comments.js +++ b/code_comments/htdocs/code-comments.js @@ -328,7 +328,7 @@ var underscore = _.noConflict(); }); window.SubscriptionView = Backbone.View.extend({ - el: $('button#subscribe'), + el: 'button#subscribe', initialize: function(){ _.bindAll(this, "render"); From 2934e2c8f7758db3945fd4a3f29d7bf7fa61cae7 Mon Sep 17 00:00:00 2001 From: Sebastian Dietrich Date: Thu, 3 Oct 2024 23:27:13 +0200 Subject: [PATCH 3/3] Avoid ITemplateStreamFilter when adding the subscription button The button is now created using javascript. --- code_comments/htdocs/code-comments.js | 44 +++++++++++++++++++++++++++ code_comments/subscription.py | 30 ++---------------- 2 files changed, 46 insertions(+), 28 deletions(-) diff --git a/code_comments/htdocs/code-comments.js b/code_comments/htdocs/code-comments.js index 53bca3e..40586ba 100644 --- a/code_comments/htdocs/code-comments.js +++ b/code_comments/htdocs/code-comments.js @@ -1,5 +1,48 @@ var underscore = _.noConflict(); +function addSubscriptionButton() { + if (jQuery('h1').length == 0) { + return; + } + + var rev = new URLSearchParams(window.location.search).get('rev') || ''; + + var button = jQuery( + '