Author: jvdrean
Date: 2008-02-26 18:51:11 +0100 (Tue, 26 Feb 2008)
New Revision: 7971

Modified:
   
xwiki-platform/xwiki-applications/trunk/watchlist/src/main/resources/XWiki/WatchListMessage
Log:
XPWATCHLIST-8 : Send diffs as part of the email in addition to sending modified 
pages

Modified: 
xwiki-platform/xwiki-applications/trunk/watchlist/src/main/resources/XWiki/WatchListMessage
===================================================================
--- 
xwiki-platform/xwiki-applications/trunk/watchlist/src/main/resources/XWiki/WatchListMessage
 2008-02-26 17:36:16 UTC (rev 7970)
+++ 
xwiki-platform/xwiki-applications/trunk/watchlist/src/main/resources/XWiki/WatchListMessage
 2008-02-26 17:51:11 UTC (rev 7971)
@@ -8,13 +8,13 @@
 <translation>0</translation>
 <parent></parent>
 <creator></creator>
-<author></author>
+<author>XWiki.Admin</author>
 <customClass></customClass>
-<contentAuthor></contentAuthor>
-<creationDate>1197307330000</creationDate>
-<date>1197307330000</date>
-<contentUpdateDate>1197307330000</contentUpdateDate>
-<version>1.1</version>
+<contentAuthor>XWiki.Admin</contentAuthor>
+<creationDate>1203938786000</creationDate>
+<date>1204021914000</date>
+<contentUpdateDate>1204021914000</contentUpdateDate>
+<version>2.1</version>
 <title></title>
 <template></template>
 <defaultTemplate></defaultTemplate>
@@ -70,29 +70,223 @@
 <number>0</number>
 <className>XWiki.Mail</className>
 <property>
-<html>&lt;b&gt;Hello $pseudo,&lt;/b&gt;&lt;br/&gt;
+<html>&lt;body style="background-color:#F7F7F7;"&gt;
+&lt;b&gt;Hello $pseudo,&lt;/b&gt;&lt;br/&gt;
 &lt;i&gt;This message is sent by XWiki. Here are the documents in your 
watchlist that have been created or updated since the last notification 
:&lt;/i&gt;&lt;br/&gt;
 &lt;br/&gt;
-&lt;table width="100%"&gt;
-&lt;tr style="background-color:#EFEFEF;font-weight:bold;"&gt;
-&lt;td&gt;Name&lt;/td&gt;&lt;td&gt;Space&lt;/td&gt;&lt;td&gt;Modified 
by&lt;/td&gt;&lt;td&gt;Comment&lt;/td&gt;&lt;td&gt;Modified on&lt;/td&gt;
+&lt;table width="100%" style="font-family:arial;font-size:14px;" 
cellpadding="4" cellspacing="0"&gt;
+&lt;tr style="background-color:$DEDEDE;font-weight:bold;"&gt;
+&lt;td&gt;Page&lt;/td&gt;&lt;td&gt;Informations&lt;/td&gt;
 &lt;/tr&gt;
+&lt;tr&gt;&lt;td colspan="2"&gt;&lt;/td&gt;&lt;/tr&gt;
+## ------------------------------------------
+## Loop over the modified documents
+## ------------------------------------------
 #foreach ($udocname in $documents)
+#set ($identifiedModification = false)
 #set ($udoc = $xwiki.getDocument($udocname))
 #if ($velocityCount % 2 == 0)
-  #set ($color = "#E5F0FE")
+  #set ($color = "#FFF")
 #else
   #set ($color = "#FFF")
 #end
+## ------------------------------------------
+## 1st line : doc name, last author, etc
+## ------------------------------------------
 &lt;tr style="background-color:${color};"&gt;
-&lt;td&gt;&lt;a 
href="${udoc.getExternalURL()}"&gt;$udoc.getDisplayTitle()&lt;/a&gt;&lt;/td&gt;
-&lt;td&gt;$udoc.web&lt;/td&gt;
-&lt;td&gt;$xwiki.getLocalUserName($udoc.author, true)&lt;/td&gt;
-&lt;td&gt;$udoc.getComment()&lt;/td&gt;
-&lt;td&gt;$xwiki.formatDate($udoc.date)&lt;/td&gt;
+&lt;td style="border-top:1px solid #999999;border-left:1px solid 
#999999;border-bottom:1px solid #999999;font-weight:bold;"&gt;&lt;a 
href="${udoc.getExternalURL()}"&gt;$udoc.getDisplayTitle()&lt;/a&gt;&lt;br/&gt;&lt;span
 style="font-size:10px;"&gt;${udoc.fullName}&lt;/span&gt;&lt;/td&gt;
+&lt;td style="border-top:1px solid #999999;border-right:1px solid #999999;"&gt;
+modified by $xwiki.getLocalUserName($udoc.author, false) on 
$xwiki.formatDate($udoc.date) #if (!$udoc.getComment().equals("")), comment : 
$udoc.getComment() #end
+&lt;/td&gt;
 &lt;/tr&gt;
+#set ($rev1 = "")
+#foreach ($rev in $udoc.getRecentRevisions(2))
+  #set ($rev1 = $rev)
 #end
-&lt;/table&gt;</html>
+#set ($rev2 = $udoc.getVersion())
+#set($origdoc = $xwiki.getDocument($udoc, $rev1))
+#set($newdoc = $udoc)
+## ------------------------------------------
+## 2nd line : differences
+## ------------------------------------------
+&lt;tr style="background-color:${color};"&gt;
+&lt;td style="background-color:#F7F7F7;"&gt;&lt;/td&gt;
+&lt;td style="border-bottom:1px solid #999999;border-right:1px solid 
#999999;border-left:1px solid #999999;"&gt;
+## ------------------------------------------
+## Content
+## ------------------------------------------
+##
+#macro(displayhtmldiff $html)
+##set ($html = $html.replaceAll('\&lt;span 
class="diffremoveword"\&gt;(.*)\&lt;/span\&gt;', '\&lt;span 
style="font-style:bold;color:red;"\&gt;\&lt;strike\&gt;$1\&lt;/strike\&gt;\&lt;/span\&gt;'))
+#set ($html = $html.replaceAll('class="diffremoveword"', 
'style="text-decoration: line-through;color:red;"'))
+#set ($html = $html.replaceAll('class="diffaddword"', 
'style="font-weight:bold;color:green;"'))
+$html
+#end
+#if($origdoc.get("XWiki.ArticleClass"))
+  ##
+  ## blog article
+  ##
+  #set($ok = $origdoc.use("XWiki.ArticleClass"))
+  #set($origcontent = $!origdoc.getValue("content").trim())
+  #if(!$origcontent)
+    #set($text1 = "")
+  #else
+    #set($text1 = $origcontent)
+  #end
+  #set($ok = $newdoc.use("XWiki.ArticleClass"))
+  #set($newcontent = $!newdoc.getValue("content").trim())
+  #if(!$newcontent)
+    #set($text2 = "")
+  #else
+    #set($text2 = $newcontent)
+  #end
+  #set ($htmlDiff = $xwiki.diff.getDifferencesAsHTML($text1, $text2 ,false))
+  ## !$text1.equals($text2) was failing
+  #if(!$htmlDiff.replaceAll('\&lt;div class="diff"\&gt;\&lt;/div\&gt;', 
"").trim().equals(""))
+    #set ($identifiedModification = true)
+    &lt;table class="changes-table" width="100%" 
style="border-color:#CDCDCD;font-family:arial;font-size:12px;text-align:left;"&gt;
+      &lt;tr class="changes-table-title"&gt;
+        &lt;th style="border-bottom:1px solid #000000;"&gt;Content&lt;/th&gt;
+      &lt;/tr&gt;
+      &lt;tr&gt;
+        &lt;td&gt;
+          $htmlDiff
+        &lt;/td&gt;
+      &lt;/tr&gt;
+    &lt;/table&gt;
+  #end
+#else
+  ##
+  ## Wiki page
+  ##
+  #set($origcontent = $!origdoc.content.trim())
+  #if(!$origcontent)
+    #set($text1 = "")
+  #else
+    #set($text1 = $origcontent)
+  #end
+  #set($newcontent = $!newdoc.content.trim())
+  #if(!$newcontent)
+    #set($text2 = "")
+  #else
+    #set($text2 = $newcontent)
+  #end
+  #set ($htmlDiff = $xwiki.diff.getDifferencesAsHTML($text1, $text2 
,false).replaceAll('\&lt;div class="diff"\&gt;\&lt;/div\&gt;', "").trim())
+  ## !$text1.equals($text2) was failing
+  #if(!$htmlDiff.equals(""))
+    #set ($identifiedModification = true)
+    &lt;table class="changes-table" width="100%" 
style="border-color:#CDCDCD;font-family:arial;font-size:12px;text-align:left;"&gt;
+      &lt;tr class="changes-table-title"&gt;
+        &lt;th style="border-bottom:1px solid #000000;"&gt;Content&lt;/th&gt;
+      &lt;/tr&gt;
+      &lt;tr&gt;
+        &lt;td&gt;
+          #displayhtmldiff($htmlDiff)
+        &lt;/td&gt;
+      &lt;/tr&gt;
+    &lt;/table&gt;
+  #end
+#end
+## ------------------------------------------
+## Comments
+## ------------------------------------------
+#set($commentchanges = 0)
+#foreach($objdiffs in $newdoc.getObjectDiff($origdoc, $newdoc))
+  #set($commentchangetitledone = 0)
+  #foreach($objdiff in $objdiffs)
+    #if($objdiff.getClassName().equals("XWiki.XWikiComments"))
+      #if($commentchangetitledone==0)
+        #set($commentchanges = 1 + $commentchanges)
+        #set($commentchangetitledone = 1)
+      #end
+    #end
+  #end
+#end
+#if($commentchanges&gt;0)
+#set ($identifiedModification = true)
+&lt;table class="changes-table" width="100%" 
style="border-color:#CDCDCD;font-family:arial;font-size:12px;text-align:left;"&gt;
+&lt;tr class="changes-table-title" style="border-bottom:1px solid #000000;"&gt;
+&lt;th style="border-bottom:1px solid #000000;"&gt;Comment&lt;/th&gt;
+&lt;/tr&gt;
+#foreach($objdiffs in $newdoc.getObjectDiff($origdoc, $newdoc))
+  #set ($wascomment = false)
+  #set ($author = "")
+  #set ($date = "")
+  #set ($comment = "")
+  #foreach($objdiff in $objdiffs)
+    #if($objdiff.getClassName().equals("XWiki.XWikiComments"))
+      #set ($wascomment = true)
+      #set($propname = $objdiff.getPropName())
+      #if($propname=="author")
+        #set($author = $objdiff.getNewValue().toString())
+        #if($author!="")
+          #set ($author = 
$xwiki.renderText($xwiki.getLocalUserName($author),$newdoc))
+        #end
+      #elseif ($propname=="date")
+        #set($date = $objdiff.getNewValue().toString())
+      #elseif ($propname=="comment")
+        #set($comment = $objdiff.getNewValue().toString())
+      #end
+    #else
+      #set($wascomment = false)
+    #end
+  #end
+  #if ($comment!="")
+    &lt;tr&gt;
+      &lt;td&gt;
+         Added by $author on $date : &lt;br/&gt;
+         &lt;br/&gt;
+         $comment
+      &lt;/td&gt;
+    &lt;/tr&gt;
+  #end
+#end
+&lt;/table&gt;
+#end
+## ------------------------------------------
+## Attachments
+## ------------------------------------------
+#set($attachChanges = $newdoc.getAttachmentDiff($origdoc, $newdoc))
+#if ($attachChanges &amp;&amp; $attachChanges.size() &gt; 0)
+#set ($identifiedModification = true)
+  &lt;table class="changes-table" width="100%" 
style="border-color:#CDCDCD;font-family:arial;font-size:12px;text-align:left;"&gt;
+    &lt;tr class="changes-table-title"&gt;
+      &lt;th style="border-bottom:1px solid #000000;"&gt;Attachment&lt;/th&gt;
+    &lt;/tr&gt;
+    #foreach($attachChange in $attachChanges)
+      &lt;tr&gt;
+        &lt;td&gt;
+          #if(!$attachChange.origVersion)
+            Attachment added : &lt;a 
href="$newdoc.getAttachmentRevisionURL($attachChange.fileName,$attachChange.newVersion)"&gt;$attachChange.fileName&lt;/a&gt;
+          #elseif(!$attachChange.newVersion)
+            Attachment deleted : $attachChange.fileName
+          #else
+            Attachment updated from version &lt;a 
href="$newdoc.getAttachmentRevisionURL($attachChange.fileName,$attachChange.origVersion)"&gt;$attachChange.origVersion&lt;/a&gt;
+            to version &lt;a 
href="$newdoc.getAttachmentRevisionURL($attachChange.fileName,$attachChange.newVersion)"&gt;$attachChange.newVersion&lt;/a&gt;
+          #end
+        &lt;/td&gt;
+      &lt;/tr&gt;
+    #end
+  &lt;/table&gt;
+#end
+##
+## / Differences
+##
+#if (!$identifiedModification)
+Modifications on page objects or class
+#end
+&lt;/td&gt;
+&lt;/tr&gt;
+##
+## Spacer
+##
+&lt;tr&gt;
+  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
+  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
+&lt;/tr&gt;
+#end
+&lt;/table&gt;
+&lt;/body&gt;</html>
 </property>
 <property>
 <language>en</language>
@@ -109,5 +303,38 @@
 #end</text>
 </property>
 </object>
+<object>
+<class>
+<name>XWiki.TagClass</name>
+<customClass></customClass>
+<customMapping></customMapping>
+<defaultViewSheet></defaultViewSheet>
+<defaultEditSheet></defaultEditSheet>
+<defaultWeb></defaultWeb>
+<nameField></nameField>
+<validationScript></validationScript>
+<tags>
+<cache>0</cache>
+<displayType>input</displayType>
+<multiSelect>1</multiSelect>
+<name>tags</name>
+<number>1</number>
+<prettyName>Tags</prettyName>
+<relationalStorage>1</relationalStorage>
+<separator> </separator>
+<separators> ,|</separators>
+<size>30</size>
+<unmodifiable>0</unmodifiable>
+<values></values>
+<classType>com.xpn.xwiki.objects.classes.StaticListClass</classType>
+</tags>
+</class>
+<name>XWiki.WatchListMessage</name>
+<number>0</number>
+<className>XWiki.TagClass</className>
+<property>
+<tags/>
+</property>
+</object>
 <content>
 </content></xwikidoc>
\ No newline at end of file

_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to