<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[3370] CalendarServer/trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.macosforge.org/projects/calendarserver/changeset/3370">3370</a></dd>
<dt>Author</dt> <dd>sagen@apple.com</dd>
<dt>Date</dt> <dd>2008-11-11 14:37:11 -0800 (Tue, 11 Nov 2008)</dd>
</dl>

<h3>Log Message</h3>
<pre>Email date icons and templates now have an official home within /usr/share/caldavd; changing code to match</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunklocalesEnglishlprojcalendarserverstrings">CalendarServer/trunk/locales/English.lproj/calendarserver.strings</a></li>
<li><a href="#CalendarServertrunktwistedcaldavconfigpy">CalendarServer/trunk/twistedcaldav/config.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavlocalizationpy">CalendarServer/trunk/twistedcaldav/localization.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavmailpy">CalendarServer/trunk/twistedcaldav/mail.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavtestdatalocalespigLC_MESSAGEScalendarservermo">CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.mo</a></li>
<li><a href="#CalendarServertrunktwistedcaldavtestdatalocalespigLC_MESSAGEScalendarserverpo">CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.po</a></li>
<li><a href="#CalendarServertrunktwistedcaldavtesttest_localizationpy">CalendarServer/trunk/twistedcaldav/test/test_localization.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavtesttest_mailpy">CalendarServer/trunk/twistedcaldav/test/test_mail.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunklocalesEnglishlprojcalendarserverstrings"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/locales/English.lproj/calendarserver.strings (3369 => 3370)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/locales/English.lproj/calendarserver.strings        2008-11-11 21:38:42 UTC (rev 3369)
+++ CalendarServer/trunk/locales/English.lproj/calendarserver.strings        2008-11-11 22:37:11 UTC (rev 3370)
</span><span class="lines">@@ -62,29 +62,29 @@
</span><span class="cx"> 
</span><span class="cx"> &quot;December&quot; = &quot;December&quot;;
</span><span class="cx"> 
</span><del>-&quot;Jan&quot; = &quot;Jan&quot;;
</del><ins>+&quot;JAN&quot; = &quot;JAN&quot;;
</ins><span class="cx"> 
</span><del>-&quot;Feb&quot; = &quot;Feb&quot;;
</del><ins>+&quot;FEB&quot; = &quot;FEB&quot;;
</ins><span class="cx"> 
</span><del>-&quot;Mar&quot; = &quot;Mar&quot;;
</del><ins>+&quot;MAR&quot; = &quot;MAR&quot;;
</ins><span class="cx"> 
</span><del>-&quot;Apr&quot; = &quot;Apr&quot;;
</del><ins>+&quot;APR&quot; = &quot;APR&quot;;
</ins><span class="cx"> 
</span><del>-&quot;May&quot; = &quot;May&quot;;
</del><ins>+&quot;MAY&quot; = &quot;MAY&quot;;
</ins><span class="cx"> 
</span><del>-&quot;Jun&quot; = &quot;Jun&quot;;
</del><ins>+&quot;JUN&quot; = &quot;JUN&quot;;
</ins><span class="cx"> 
</span><del>-&quot;Jul&quot; = &quot;Jul&quot;;
</del><ins>+&quot;JUL&quot; = &quot;JUL&quot;;
</ins><span class="cx"> 
</span><del>-&quot;Aug&quot; = &quot;Aug&quot;;
</del><ins>+&quot;AUG&quot; = &quot;AUG&quot;;
</ins><span class="cx"> 
</span><del>-&quot;Sep&quot; = &quot;Sep&quot;;
</del><ins>+&quot;SEP&quot; = &quot;SEP&quot;;
</ins><span class="cx"> 
</span><del>-&quot;Oct&quot; = &quot;Oct&quot;;
</del><ins>+&quot;OCT&quot; = &quot;OCT&quot;;
</ins><span class="cx"> 
</span><del>-&quot;Nov&quot; = &quot;Nov&quot;;
</del><ins>+&quot;NOV&quot; = &quot;NOV&quot;;
</ins><span class="cx"> 
</span><del>-&quot;Dec&quot; = &quot;Dec&quot;;
</del><ins>+&quot;DEC&quot; = &quot;DEC&quot;;
</ins><span class="cx"> 
</span><span class="cx"> &quot;Event canceled&quot; = &quot;Event canceled&quot;;
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavconfigpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/config.py (3369 => 3370)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/config.py        2008-11-11 21:38:42 UTC (rev 3369)
+++ CalendarServer/trunk/twistedcaldav/config.py        2008-11-11 22:37:11 UTC (rev 3370)
</span><span class="lines">@@ -270,8 +270,8 @@
</span><span class="cx">                 &quot;Password&quot;      : &quot;&quot;,    # For account receving mail
</span><span class="cx">             },
</span><span class="cx">             &quot;AddressPatterns&quot;   : [],    # Reg-ex patterns to match iMIP-able calendar user addresses
</span><del>-            &quot;MailTemplatesDirectory&quot;: &quot;/usr/share/caldavd/templates&quot;, # Directory containing HTML templates for email invitations (invite.html, cancel.html)
-            &quot;MailIconsDirectory&quot;: &quot;/usr/share/caldavd/images/mail&quot;, # Directory containing language-specific subdirectories containing date-specific icons for email invitations (cal-icon-mm-dd.png)
</del><ins>+            &quot;MailTemplatesDirectory&quot;: &quot;/usr/share/caldavd/share/email_templates&quot;, # Directory containing HTML templates for email invitations (invite.html, cancel.html)
+            &quot;MailIconsDirectory&quot;: &quot;/usr/share/caldavd/share/date_icons&quot;, # Directory containing language-specific subdirectories containing date-specific icons for email invitations
</ins><span class="cx">             &quot;InvitationDaysToLive&quot; : 90, # How many days invitations are valid
</span><span class="cx">         },
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavlocalizationpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/localization.py (3369 => 3370)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/localization.py        2008-11-11 21:38:42 UTC (rev 3369)
+++ CalendarServer/trunk/twistedcaldav/localization.py        2008-11-11 22:37:11 UTC (rev 3370)
</span><span class="lines">@@ -130,6 +130,9 @@
</span><span class="cx">         # Don't swallow exceptions
</span><span class="cx">         return False
</span><span class="cx"> 
</span><ins>+    def monthAbbreviation(self, monthNumber):
+        return self.translation.ugettext(monthsAbbrev[monthNumber])
+
</ins><span class="cx">     def date(self, component):
</span><span class="cx">         dtStart = component.propertyNativeValue(&quot;DTSTART&quot;)
</span><span class="cx">         return self.dtDate(dtStart)
</span><span class="lines">@@ -317,16 +320,16 @@
</span><span class="cx"> 
</span><span class="cx"> monthsAbbrev = [
</span><span class="cx">     &quot;datetime.month is 1-based&quot;,
</span><del>-    _(&quot;Jan&quot;),
-    _(&quot;Feb&quot;),
-    _(&quot;Mar&quot;),
-    _(&quot;Apr&quot;),
-    _(&quot;May&quot;),
-    _(&quot;Jun&quot;),
-    _(&quot;Jul&quot;),
-    _(&quot;Aug&quot;),
-    _(&quot;Sep&quot;),
-    _(&quot;Oct&quot;),
-    _(&quot;Nov&quot;),
-    _(&quot;Dec&quot;),
</del><ins>+    _(&quot;JAN&quot;),
+    _(&quot;FEB&quot;),
+    _(&quot;MAR&quot;),
+    _(&quot;APR&quot;),
+    _(&quot;MAY&quot;),
+    _(&quot;JUN&quot;),
+    _(&quot;JUL&quot;),
+    _(&quot;AUG&quot;),
+    _(&quot;SEP&quot;),
+    _(&quot;OCT&quot;),
+    _(&quot;NOV&quot;),
+    _(&quot;DEC&quot;),
</ins><span class="cx"> ]
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavmailpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/mail.py (3369 => 3370)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/mail.py        2008-11-11 21:38:42 UTC (rev 3369)
+++ CalendarServer/trunk/twistedcaldav/mail.py        2008-11-11 22:37:11 UTC (rev 3370)
</span><span class="lines">@@ -772,19 +772,26 @@
</span><span class="cx">         deferred.addErrback(_failure, msgId, fromAddr, toAddr)
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    def getIconPath(self, details, language='en'):
+        month = int(details['month'])
+        day = int(details['day'])
+        iconDir = config.Scheduling.iMIP.MailIconsDirectory.rstrip(&quot;/&quot;)
+        with translationTo(language) as trans:
+            monthName = trans.monthAbbreviation(month)
+        iconName = &quot;%02d.png&quot; % (day,)
+        iconPath = os.path.join(iconDir, monthName, iconName)
+        if not os.path.exists(iconPath):
+            # Try the generic (numeric) version
+            iconPath = os.path.join(iconDir, &quot;%02d&quot; % (month,), iconName)
+        return iconPath
+
+
</ins><span class="cx">     def generateEmail(self, newInvitation, calendar, orgEmail, orgCN,
</span><span class="cx">         attendees, fromAddress, replyToAddress, toAddress, language='en'):
</span><span class="cx"> 
</span><span class="cx">         details = self.getEventDetails(calendar, language=language)
</span><ins>+        iconPath = self.getIconPath(details, language=language)
</ins><span class="cx"> 
</span><del>-        iconDir = config.Scheduling.iMIP.MailIconsDirectory.rstrip(&quot;/&quot;)
-        iconName = &quot;cal-icon-%02d-%02d.png&quot; % (details['month'],
-            details['day'])
-        iconPath = os.path.join(iconDir, language, iconName)
-        if not os.path.exists(iconPath):
-            # Try the generic (numeric) version
-            iconPath = os.path.join(iconDir, 'generic', iconName)
-
</del><span class="cx">         with translationTo(language):
</span><span class="cx">             msg = MIMEMultipart()
</span><span class="cx">             msg[&quot;From&quot;] = fromAddress
</span><span class="lines">@@ -886,7 +893,7 @@
</span><span class="cx">             else:
</span><span class="cx">                 details['htmlOrganizer'] = orgCN
</span><span class="cx"> 
</span><del>-            details['iconName'] = iconName
</del><ins>+            details['iconName'] = iconName = &quot;calicon.png&quot;
</ins><span class="cx"> 
</span><span class="cx">             templateDir = config.Scheduling.iMIP.MailTemplatesDirectory.rstrip(&quot;/&quot;)
</span><span class="cx">             templateName = &quot;cancel.html&quot; if canceled else &quot;invite.html&quot;
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavtestdatalocalespigLC_MESSAGEScalendarservermo"></a>
<div class="binary"><h4>Modified: CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.mo</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavtestdatalocalespigLC_MESSAGEScalendarserverpo"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.po (3369 => 3370)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.po        2008-11-11 21:38:42 UTC (rev 3369)
+++ CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.po        2008-11-11 22:37:11 UTC (rev 3370)
</span><span class="lines">@@ -144,8 +144,8 @@
</span><span class="cx"> msgstr &quot;Ecemberday&quot;
</span><span class="cx"> 
</span><span class="cx"> #: localization.py:273
</span><del>-msgid &quot;Jan&quot;
-msgstr &quot;&quot;
</del><ins>+msgid &quot;JAN&quot;
+msgstr &quot;ANJAY&quot;
</ins><span class="cx"> 
</span><span class="cx"> #: localization.py:274
</span><span class="cx"> msgid &quot;Feb&quot;
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavtesttest_localizationpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/test/test_localization.py (3369 => 3370)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/test/test_localization.py        2008-11-11 21:38:42 UTC (rev 3369)
+++ CalendarServer/trunk/twistedcaldav/test/test_localization.py        2008-11-11 22:37:11 UTC (rev 3370)
</span><span class="lines">@@ -109,6 +109,8 @@
</span><span class="cx">             self.assertEquals(t.time(comp),
</span><span class="cx">                 (u'11:05 AM PDT to 6:15 PM EDT', u'4 hours 10 minutes'))
</span><span class="cx"> 
</span><ins>+            self.assertEquals(t.monthAbbreviation(1), &quot;JAN&quot;)
+
</ins><span class="cx">         with translationTo('pig', localeDir=localeDir) as t:
</span><span class="cx"> 
</span><span class="cx">             comp = data[0][1]
</span><span class="lines">@@ -135,3 +137,5 @@
</span><span class="cx">             comp = data[5][1]
</span><span class="cx">             self.assertEquals(t.time(comp),
</span><span class="cx">                 (u'11:05 PDT otay 18:15 EDT', u'4 ourshay 10 inutesmay'))
</span><ins>+
+            self.assertEquals(t.monthAbbreviation(1), &quot;ANJAY&quot;)
</ins></span></pre></div>
<a id="CalendarServertrunktwistedcaldavtesttest_mailpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/test/test_mail.py (3369 => 3370)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/test/test_mail.py        2008-11-11 21:38:42 UTC (rev 3369)
+++ CalendarServer/trunk/twistedcaldav/test/test_mail.py        2008-11-11 22:37:11 UTC (rev 3370)
</span><span class="lines">@@ -30,6 +30,14 @@
</span><span class="cx">         self.handler = MailHandler(dataRoot=&quot;:memory:&quot;)
</span><span class="cx">         self.dataDir = os.path.join(os.path.dirname(__file__), &quot;data&quot;, &quot;mail&quot;)
</span><span class="cx"> 
</span><ins>+    def test_iconPath(self):
+        iconPath = self.handler.getIconPath({'day':'1', 'month':'1'}, language='en')
+        iconDir = &quot;/usr/share/caldavd/share/date_icons&quot;
+        if os.path.exists(&quot;%s/JAN/01.png&quot; % (iconDir,)):
+            self.assertEquals(iconPath, &quot;%s/JAN/01.png&quot; % (iconDir,))
+        else:
+            self.assertEquals(iconPath, &quot;%s/01/01.png&quot; % (iconDir,))
+
</ins><span class="cx">     def test_checkDSNFailure(self):
</span><span class="cx"> 
</span><span class="cx">         data = {
</span></span></pre>
</div>
</div>

</body>
</html>