Mailing List Archive

How change Trac to send custom html emails?
Hi!

I have written a few simple custom plugins for Trac that all meet my simple
needs up until this point. However, now I'm reaching a limit of sorts...

I understand that Trac 1.4.2 uses Jinja2 templates and that I can edit
those templates in order to alter the contents of the outgoing email.
However, I find the templates hard to read and hard to maintain; given that
I do not know (nor have the time to deeply learn) Jinja2 templates.

My situation...

I have a python cron job that runs weekly and collects ticket information
from a few Trac projects. It uses a static html header and static html
footer; both in their own files. This allows me to both easily improve the
header/footer over timeor swap them out for something else entirely.

What I'm looking for...

I'd like to make use of my static header/footer files and change the email
notifications coming out of Trac from plain text to html. I'd also like to
modify the contents of the outgoing email in order to simplify the contents
so that when a ticket is modified a very simplistic email is sent.

I imagine that it is best to create a custom python plugin. If so, what
interface(s) would be best for me to implement and what should I do to turn
off the Jinja2 email template? If not, what might be a better solution?

Any and all thoughts to help me build a custom (simple) email would be very
much appreciated!

Kindly,
Aikido Guy

PS I've been using Trac for quite a few years and think it is great! A job
well done in my view! Thank you!

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/33571d43-6dcc-4677-99a0-73418c7cd234n%40googlegroups.com.
Re: How change Trac to send custom html emails? [ In reply to ]
On Monday, May 17, 2021 at 12:52:18 PM UTC-7 aiki...@gmail.com wrote:

> Hi!
>
> I have written a few simple custom plugins for Trac that all meet my
> simple needs up until this point. However, now I'm reaching a limit of
> sorts...
>
> I understand that Trac 1.4.2 uses Jinja2 templates and that I can edit
> those templates in order to alter the contents of the outgoing email.
> However, I find the templates hard to read and hard to maintain; given that
> I do not know (nor have the time to deeply learn) Jinja2 templates.
>
> My situation...
>
> I have a python cron job that runs weekly and collects ticket information
> from a few Trac projects. It uses a static html header and static html
> footer; both in their own files. This allows me to both easily improve the
> header/footer over timeor swap them out for something else entirely.
>
> What I'm looking for...
>
> I'd like to make use of my static header/footer files and change the email
> notifications coming out of Trac from plain text to html. I'd also like to
> modify the contents of the outgoing email in order to simplify the contents
> so that when a ticket is modified a very simplistic email is sent.
>
> I imagine that it is best to create a custom python plugin. If so, what
> interface(s) would be best for me to implement and what should I do to turn
> off the Jinja2 email template? If not, what might be a better solution?
>
> Any and all thoughts to help me build a custom (simple) email would be
> very much appreciated!
>
> Kindly,
> Aikido Guy
>
> PS I've been using Trac for quite a few years and think it is great! A job
> well done in my view! Thank you!
>

You could use this plugin:
https://trac-hacks.org/wiki/TracHtmlNotificationPlugin

But if you want to modify the template you'll need to copy the template to
the environment templates dir and modify it:
https://trac-hacks.org/browser/trachtmlnotificationplugin/0.12/trachtmlnotification/templates/jinja2/htmlnotification_ticket.html
https://trac-hacks.org/wiki/TracHtmlNotificationPlugin

The include tag may be useful:
https://jinja.palletsprojects.com/en/3.0.x/templates/#include

Ryan

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/53ce36e2-a3cf-4295-9039-b81694fc650bn%40googlegroups.com.
Re: How change Trac to send custom html emails? [ In reply to ]
Interesting! I will definitely look into this! Thanks!

On Monday, May 17, 2021 at 3:57:48 PM UTC-4 RjOllos wrote:

> On Monday, May 17, 2021 at 12:52:18 PM UTC-7 aiki...@gmail.com wrote:
>
>> Hi!
>>
>> I have written a few simple custom plugins for Trac that all meet my
>> simple needs up until this point. However, now I'm reaching a limit of
>> sorts...
>>
>> I understand that Trac 1.4.2 uses Jinja2 templates and that I can edit
>> those templates in order to alter the contents of the outgoing email.
>> However, I find the templates hard to read and hard to maintain; given that
>> I do not know (nor have the time to deeply learn) Jinja2 templates.
>>
>> My situation...
>>
>> I have a python cron job that runs weekly and collects ticket information
>> from a few Trac projects. It uses a static html header and static html
>> footer; both in their own files. This allows me to both easily improve the
>> header/footer over timeor swap them out for something else entirely.
>>
>> What I'm looking for...
>>
>> I'd like to make use of my static header/footer files and change the
>> email notifications coming out of Trac from plain text to html. I'd also
>> like to modify the contents of the outgoing email in order to simplify the
>> contents so that when a ticket is modified a very simplistic email is sent.
>>
>> I imagine that it is best to create a custom python plugin. If so, what
>> interface(s) would be best for me to implement and what should I do to turn
>> off the Jinja2 email template? If not, what might be a better solution?
>>
>> Any and all thoughts to help me build a custom (simple) email would be
>> very much appreciated!
>>
>> Kindly,
>> Aikido Guy
>>
>> PS I've been using Trac for quite a few years and think it is great! A
>> job well done in my view! Thank you!
>>
>
> You could use this plugin:
> https://trac-hacks.org/wiki/TracHtmlNotificationPlugin
>
> But if you want to modify the template you'll need to copy the template to
> the environment templates dir and modify it:
>
> https://trac-hacks.org/browser/trachtmlnotificationplugin/0.12/trachtmlnotification/templates/jinja2/htmlnotification_ticket.html
> https://trac-hacks.org/wiki/TracHtmlNotificationPlugin
>
> The include tag may be useful:
> https://jinja.palletsprojects.com/en/3.0.x/templates/#include
>
> Ryan
>

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/de5eeff6-6cef-412f-9aba-54cd2fb43ffan%40googlegroups.com.
Re: How change Trac to send custom html emails? [ In reply to ]
On Monday, May 17, 2021 at 4:46:30 PM UTC-4 Aikido Guy wrote:

> On Monday, May 17, 2021 at 3:57:48 PM UTC-4 RjOllos wrote:
>
>> On Monday, May 17, 2021 at 12:52:18 PM UTC-7 Aikido Guy wrote:
>>
>>>
>>> What I'm looking for...
>>>
>>> I'd like to make use of my static header/footer files and change the
>>> email notifications coming out of Trac from plain text to html. I'd also
>>> like to modify the contents of the outgoing email in order to simplify the
>>> contents so that when a ticket is modified a very simplistic email is sent.
>>>
>>> PS I've been using Trac for quite a few years and think it is great! A
>>> job well done in my view! Thank you!
>>>
>>
>> You could use this plugin:
>> https://trac-hacks.org/wiki/TracHtmlNotificationPlugin
>>
>> Ryan
>>
>
Any idea if someone will put TracHtmlNotificationPlugin on pypi? I did a
search of pypi but (sadly) did not find one...
- https://pypi.org/search/?q=TracHtmlNotification

Kindly,
Aikido Guy

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/0ec388a0-8f81-425e-bdca-bc8f50ca0f43n%40googlegroups.com.
Re: How change Trac to send custom html emails? [ In reply to ]
On Tuesday, May 18, 2021 at 1:36:31 PM UTC-7 aiki...@gmail.com wrote:

> On Monday, May 17, 2021 at 4:46:30 PM UTC-4 Aikido Guy wrote:
>
>> On Monday, May 17, 2021 at 3:57:48 PM UTC-4 RjOllos wrote:
>>
> On Monday, May 17, 2021 at 12:52:18 PM UTC-7 Aikido Guy wrote:
>>>
>>
>>>> What I'm looking for...
>>>>
>>>> I'd like to make use of my static header/footer files and change the
>>>> email notifications coming out of Trac from plain text to html. I'd also
>>>> like to modify the contents of the outgoing email in order to simplify the
>>>> contents so that when a ticket is modified a very simplistic email is sent.
>>>>
>>>> PS I've been using Trac for quite a few years and think it is great! A
>>>> job well done in my view! Thank you!
>>>>
>>> You could use this plugin:
>>> https://trac-hacks.org/wiki/TracHtmlNotificationPlugin
>>>
>>> Ryan
>>>
>>
> Any idea if someone will put TracHtmlNotificationPlugin on pypi? I did a
> search of pypi but (sadly) did not find one...
> - https://pypi.org/search/?q=TracHtmlNotification
>
> Kindly,
> Aikido Guy
>

Do you just wish to "pip install" it? You can pip install directly from SVN:
https://trac.edgewall.org/wiki/TracInstall#Usingpip

Ryan

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/a444f06e-6e0e-4c94-800d-deb6878b0834n%40googlegroups.com.
Re: How change Trac to send custom html emails? [ In reply to ]
On Tuesday, May 18, 2021 at 4:59:44 PM UTC-4 RjOllos wrote:

> On Tuesday, May 18, 2021 at 1:36:31 PM UTC-7 Aikido Guy wrote:
>
>> On Monday, May 17, 2021 at 4:46:30 PM UTC-4 Aikido Guy wrote:
>>
>>> On Monday, May 17, 2021 at 3:57:48 PM UTC-4 RjOllos wrote:
>>>
>> On Monday, May 17, 2021 at 12:52:18 PM UTC-7 Aikido Guy wrote:
>>>>
>>>
>>>>> What I'm looking for...
>>>>>
>>>>> I'd like to make use of my static header/footer files and change the
>>>>> email notifications coming out of Trac from plain text to html. I'd also
>>>>> like to modify the contents of the outgoing email in order to simplify the
>>>>> contents so that when a ticket is modified a very simplistic email is sent.
>>>>>
>>>>> PS I've been using Trac for quite a few years and think it is great! A
>>>>> job well done in my view! Thank you!
>>>>>
>>>> You could use this plugin:
>>>> https://trac-hacks.org/wiki/TracHtmlNotificationPlugin
>>>>
>>>> Ryan
>>>>
>>>
>> Any idea if someone will put TracHtmlNotificationPlugin on pypi? I did a
>> search of pypi but (sadly) did not find one...
>> - https://pypi.org/search/?q=TracHtmlNotification
>>
>> Kindly,
>> Aikido Guy
>>
>
> Do you just wish to "pip install" it? You can pip install directly from
> SVN:
> https://trac.edgewall.org/wiki/TracInstall#Usingpip
>
> Ryan
>

Was hoping for pypi because I download to an external hard drive and then
carry it over to my air gapped computer to install...

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/3bf3bf1f-9804-4c87-8f4a-0c0f0afb204dn%40googlegroups.com.
Re: How change Trac to send custom html emails? [ In reply to ]
On Tuesday, May 18, 2021 at 4:45:40 PM UTC-7 aiki...@gmail.com wrote:

> On Tuesday, May 18, 2021 at 4:59:44 PM UTC-4 RjOllos wrote:
>
>> On Tuesday, May 18, 2021 at 1:36:31 PM UTC-7 Aikido Guy wrote:
>>
>>> On Monday, May 17, 2021 at 4:46:30 PM UTC-4 Aikido Guy wrote:
>>>
>>>> On Monday, May 17, 2021 at 3:57:48 PM UTC-4 RjOllos wrote:
>>>>
>>> On Monday, May 17, 2021 at 12:52:18 PM UTC-7 Aikido Guy wrote:
>>>>>
>>>>
>>>>>> What I'm looking for...
>>>>>>
>>>>>> I'd like to make use of my static header/footer files and change the
>>>>>> email notifications coming out of Trac from plain text to html. I'd also
>>>>>> like to modify the contents of the outgoing email in order to simplify the
>>>>>> contents so that when a ticket is modified a very simplistic email is sent.
>>>>>>
>>>>>> PS I've been using Trac for quite a few years and think it is great!
>>>>>> A job well done in my view! Thank you!
>>>>>>
>>>>> You could use this plugin:
>>>>> https://trac-hacks.org/wiki/TracHtmlNotificationPlugin
>>>>>
>>>>> Ryan
>>>>>
>>>>
>>> Any idea if someone will put TracHtmlNotificationPlugin on pypi? I did a
>>> search of pypi but (sadly) did not find one...
>>> - https://pypi.org/search/?q=TracHtmlNotification
>>>
>>> Kindly,
>>> Aikido Guy
>>>
>>
>> Do you just wish to "pip install" it? You can pip install directly from
>> SVN:
>> https://trac.edgewall.org/wiki/TracInstall#Usingpip
>>
>> Ryan
>>
>
> Was hoping for pypi because I download to an external hard drive and then
> carry it over to my air gapped computer to install...
>

Jun hasn't been publishing his plugins to PyPI. As a workaround:

$ svn co <repos URL and path> <local path>
$ cd <local path>
$ python setup.py bdist_wheel

Wheel will be in dist/ directory.


--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/38736b8f-a748-40f5-b2aa-32ff53ad953bn%40googlegroups.com.
Re: How change Trac to send custom html emails? [ In reply to ]
On Tuesday, May 18, 2021 at 7:51:53 PM UTC-4 RjOllos wrote:

> On Tuesday, May 18, 2021 at 4:45:40 PM UTC-7 Aikido Guy wrote:
>
>> On Tuesday, May 18, 2021 at 4:59:44 PM UTC-4 RjOllos wrote:
>>
>>> On Tuesday, May 18, 2021 at 1:36:31 PM UTC-7 Aikido Guy wrote:
>>>
>>>> On Monday, May 17, 2021 at 4:46:30 PM UTC-4 Aikido Guy wrote:
>>>>
>>>>> On Monday, May 17, 2021 at 3:57:48 PM UTC-4 RjOllos wrote:
>>>>>
>>>> On Monday, May 17, 2021 at 12:52:18 PM UTC-7 Aikido Guy wrote:
>>>>>>
>>>>>
>>>>>>> What I'm looking for...
>>>>>>>
>>>>>>> I'd like to make use of my static header/footer files and change the
>>>>>>> email notifications coming out of Trac from plain text to html. I'd also
>>>>>>> like to modify the contents of the outgoing email in order to simplify the
>>>>>>> contents so that when a ticket is modified a very simplistic email is sent.
>>>>>>>
>>>>>>> PS I've been using Trac for quite a few years and think it is great!
>>>>>>> A job well done in my view! Thank you!
>>>>>>>
>>>>>> You could use this plugin:
>>>>>> https://trac-hacks.org/wiki/TracHtmlNotificationPlugin
>>>>>>
>>>>>> Ryan
>>>>>>
>>>>>
>>>> Any idea if someone will put TracHtmlNotificationPlugin on pypi? I did
>>>> a search of pypi but (sadly) did not find one...
>>>> - https://pypi.org/search/?q=TracHtmlNotification
>>>>
>>>> Kindly,
>>>> Aikido Guy
>>>>
>>>
>>> Do you just wish to "pip install" it? You can pip install directly from
>>> SVN:
>>> https://trac.edgewall.org/wiki/TracInstall#Usingpip
>>>
>>> Ryan
>>>
>>
>> Was hoping for pypi because I download to an external hard drive and then
>> carry it over to my air gapped computer to install...
>>
>
> Jun hasn't been publishing his plugins to PyPI. As a workaround:
>
> $ svn co <repos URL and path> <local path>
> $ cd <local path>
> $ python setup.py bdist_wheel
>
> Wheel will be in dist/ directory.
>

I now have *TracHtmlNotificationPlugin-0.12.0.2-py2-none-any.whl *in
hand... will try it out! Much appreciated

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/48b9b66d-2b3e-4ad8-a30b-86e24735605dn%40googlegroups.com.
Re: How change Trac to send custom html emails? [ In reply to ]
On Tuesday, May 18, 2021 at 8:21:34 PM UTC-4 Aikido Guy wrote:

> On Tuesday, May 18, 2021 at 7:51:53 PM UTC-4 RjOllos wrote:
>
>> On Tuesday, May 18, 2021 at 4:45:40 PM UTC-7 Aikido Guy wrote:
>>
>>> On Tuesday, May 18, 2021 at 4:59:44 PM UTC-4 RjOllos wrote:
>>>
>>>> On Tuesday, May 18, 2021 at 1:36:31 PM UTC-7 Aikido Guy wrote:
>>>>
>>>>> On Monday, May 17, 2021 at 4:46:30 PM UTC-4 Aikido Guy wrote:
>>>>>
>>>>>> On Monday, May 17, 2021 at 3:57:48 PM UTC-4 RjOllos wrote:
>>>>>>
>>>>> On Monday, May 17, 2021 at 12:52:18 PM UTC-7 Aikido Guy wrote:
>>>>>>>
>>>>>>
>>>>>>>> What I'm looking for...
>>>>>>>>
>>>>>>>> I'd like to make use of my static header/footer files and change
>>>>>>>> the email notifications coming out of Trac from plain text to html. I'd
>>>>>>>> also like to modify the contents of the outgoing email in order to simplify
>>>>>>>> the contents so that when a ticket is modified a very simplistic email is
>>>>>>>> sent.
>>>>>>>>
>>>>>>>> PS I've been using Trac for quite a few years and think it is
>>>>>>>> great! A job well done in my view! Thank you!
>>>>>>>>
>>>>>>> You could use this plugin:
>>>>>>> https://trac-hacks.org/wiki/TracHtmlNotificationPlugin
>>>>>>>
>>>>>>> Ryan
>>>>>>>
>>>>>>
>>>>> Any idea if someone will put TracHtmlNotificationPlugin on pypi? I did
>>>>> a search of pypi but (sadly) did not find one...
>>>>> - https://pypi.org/search/?q=TracHtmlNotification
>>>>>
>>>>> Kindly,
>>>>> Aikido Guy
>>>>>
>>>>
>>>> Do you just wish to "pip install" it? You can pip install directly from
>>>> SVN:
>>>> https://trac.edgewall.org/wiki/TracInstall#Usingpip
>>>>
>>>> Ryan
>>>>
>>>
>>> Was hoping for pypi because I download to an external hard drive and
>>> then carry it over to my air gapped computer to install...
>>>
>>
>> Jun hasn't been publishing his plugins to PyPI. As a workaround:
>>
>> $ svn co <repos URL and path> <local path>
>> $ cd <local path>
>> $ python setup.py bdist_wheel
>>
>> Wheel will be in dist/ directory.
>>
>
> I now have *TracHtmlNotificationPlugin-0.12.0.2-py2-none-any.whl *in
> hand... will try it out! Much appreciated
>

I just realized that my situation is not exactly as I described... oops!

I need to have a *Content-Type:multipart/alternative *with one part plain
text and one part html... where the html part is
*Content-Type:multipart/related*.

With the TracHtmlNotificationPlugin will I have control over the
Content-Type?
- Or would it be better to read the source code and modify for my needs?

Perhaps my original thought of creating a plugin is the simplest and most
direct approach in this case... I just need the plugin listening/triggering
on the right things (based on the notifications)... I can see I'll probably
have to dig into code...

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/886134ca-7748-45ba-a65c-d78e67a8a4ben%40googlegroups.com.