The AnnouncerPlugin is meant to provide an extensible,

user-customizable notification system that can be used
to completely replace Trac's default notifications.

WWW: http://trac-hacks.org/wiki/AnnouncertPlugin

PR:		ports/150484
Submitted by:	Eygene Ryabinkin <rea-fbsd at codelabs.ru>
This commit is contained in:
Philip M. Gollucci 2010-10-12 06:21:13 +00:00
parent 569b879858
commit 6c3241dda1
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=262873
6 changed files with 150 additions and 0 deletions

View file

@ -1665,6 +1665,7 @@
SUBDIR += trac-accountmanager
SUBDIR += trac-addcomment
SUBDIR += trac-advancedticketworkflow
SUBDIR += trac-announcer
SUBDIR += trac-autocomplete
SUBDIR += trac-batchmodify
SUBDIR += trac-bzr

View file

@ -0,0 +1,46 @@
# New ports collection makefile for: trac-autocomplete
# Date created: December 23, 2009
# Whom: Eygene Ryabinkin <rea-fbsd@codelabs.ru>
#
# $FreeBSD$
#
PORTNAME= announcer
PORTVERSION= 1.0
CATEGORIES= www python
MASTER_SITES= http://dist.codelabs.ru/fbsd/
PKGNAMEPREFIX= trac-
DISTNAME= announcerplugin-r${REL}
MAINTAINER= rea-fbsd@codelabs.ru
COMMENT= A plugin for making user-customizable notifications
BUILD_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}Babel>=0.9:${PORTSDIR}/devel/py-babel
RUN_DEPENDS+= trac>=0.11:${PORTSDIR}/www/trac
USE_PYTHON= 2.5+
USE_ZIP= yes
USE_PYDISTUTILS= yes
PYDISTUTILS_PKGNAME= AnnouncerPlugin
PYDISTUTILS_NOEGGINFO= yes
WRKSRC= ${WRKDIR}/announcerplugin/trunk
REL= 8411
EGG_VER= 0.12_p2.dev
PLIST_SUB+= PORTVERSION=${PORTVERSION:S/.a/_a/} \
PYTHONVERSION=${_PYTHON_VERSION}
PLIST_FILES+= %%PYTHON_SITELIBDIR%%/AnnouncerPlugin-${EGG_VER}-py%%PYTHONVERSION%%.egg
# We must fix file permissions -- ZIP file have 0000 for every file.
# Directory permissions are fine (they aren't stored inside ZIP
# file), but we set them too -- just in case.
post-extract:
@${FIND} ${WRKSRC} -type f | ${XARGS} ${CHMOD} 644
@${FIND} ${WRKSRC} -type d | ${XARGS} ${CHMOD} 755
# Build phase: create locale stuff
build: configure
cd ${WRKSRC} && ${PYTHON_CMD} setup.py compile_catalog
.include <bsd.port.mk>

View file

@ -0,0 +1,3 @@
MD5 (announcerplugin-r8411.zip) = 9bce5288566802a5a85c85868876c19c
SHA256 (announcerplugin-r8411.zip) = d67bc92713733205babf0c3437910c7dc72424d73597913199808df14efefb27
SIZE (announcerplugin-r8411.zip) = 121238

View file

@ -0,0 +1,15 @@
--- announcer/util/mail.py.orig 2010-09-10 21:05:17.000000000 +0400
+++ announcer/util/mail.py 2010-09-10 21:07:34.000000000 +0400
@@ -48,7 +48,11 @@
def set_header(message, key, value, charset=None):
if not charset:
charset = message.get_charset() or 'ascii'
- value = Header(value, charset, MAXHEADERLEN-(len(key)+2))
+ # Don't encode pure ASCII headers.
+ try:
+ value = Header(value, 'ascii', MAXHEADERLEN-(len(key)+2))
+ except:
+ value = Header(value, charset, MAXHEADERLEN-(len(key)+2))
if message.has_key(key):
message.replace_header(key, value)
else:

View file

@ -0,0 +1,80 @@
--- ./announcer/formatters/ticket.py.orig 2010-09-10 19:37:52.000000000 +0400
+++ ./announcer/formatters/ticket.py 2010-09-10 21:03:38.000000000 +0400
@@ -36,7 +36,7 @@
from genshi.template import NewTextTemplate, MarkupTemplate
from genshi.template import TemplateLoader
-from trac.config import Option, IntOption, ListOption
+from trac.config import Option, IntOption, ListOption, BoolOption
from trac.core import *
from trac.mimeview import Context
from trac.test import Mock, MockPerm
@@ -72,6 +72,11 @@
'owner, reporter, milestone, priority, severity',
doc="""Comma seperated list of fields to appear in tickets.
Use * to include all headers.""")
+
+ ticket_link_with_comment = BoolOption('announcer',
+ 'ticket_link_with_comment',
+ 'false',
+ """Include last change anchor to the ticket URL.""")
def styles(self, transport, realm):
if realm == "ticket":
@@ -89,6 +94,38 @@
elif style == "text/html":
return self._format_html(event)
+ def _ticket_link(self, ticket):
+ ticket_link = self.env.abs_href('ticket', ticket.id)
+ if self.ticket_link_with_comment == False:
+ return ticket_link
+
+ cnum = self._ticket_last_comment(ticket)
+ if cnum != None:
+ ticket_link += "#comment:%s" % str(cnum)
+
+ return ticket_link
+
+ def _ticket_last_comment(self, ticket):
+ cnum = -1
+
+ for entry in ticket.get_changelog():
+ (time, author, field, oldvalue, newvalue, permanent) = entry
+ if field != "comment":
+ continue
+
+ try:
+ n = int(oldvalue)
+ except:
+ continue
+
+ if cnum < n:
+ cnum = n
+
+ if cnum == -1:
+ return None
+ else:
+ return cnum
+
def _format_plaintext(self, event):
ticket = event.target
short_changes = {}
@@ -109,7 +146,7 @@
comment = event.comment,
fields = self._header_fields(ticket),
category = event.category,
- ticket_link = self.env.abs_href('ticket', ticket.id),
+ ticket_link = self._ticket_link(ticket),
project_name = self.env.project_name,
project_desc = self.env.project_description,
project_link = self.env.project_url or self.env.abs_href(),
@@ -189,7 +226,7 @@
fields = self._header_fields(ticket),
comment = temp,
category = event.category,
- ticket_link = self.env.abs_href('ticket', ticket.id),
+ ticket_link = self._ticket_link(ticket),
project_name = self.env.project_name,
project_desc = self.env.project_description,
project_link = self.env.project_url or self.env.abs_href(),

View file

@ -0,0 +1,5 @@
The AnnouncerPlugin is meant to provide an extensible,
user-customizable notification system that can be used
to completely replace Trac's default notifications.
WWW: http://trac-hacks.org/wiki/AnnouncertPlugin