%PDF- %PDF-
Direktori : /home/waritko/jetty-distribution-9.4.21.v20190926/webapps/ROOT/templates/notification/ |
Current File : //home/waritko/jetty-distribution-9.4.21.v20190926/webapps/ROOT/templates/notification/macros.vm |
#** * Default displayer for a notification * *# #macro(displayNotificationEvent $compositeEvent) ### ### Icons ### #set ($eventDescriptor = $services.eventstream.getDescriptorForEventType($compositeEvent.type, $xcontext.isMainWiki())) #if ($eventDescriptor) #set ($mainIcon = $eventDescriptor.applicationIcon) #set ($smallIcon = $eventDescriptor.eventTypeIcon) #else #set ($mainIcon = 'bell') #set ($smallIcon = '') #end #if ($eventDescriptor.applicationId == 'org.xwiki.platform') #set ($mainIcon = $smallIcon) #set ($smallIcon = '') #end ### ### Content ### #define($content) #set ($document = $xwiki.getDocument($compositeEvent.document)) <div class="notification-page"> ## Here, we have 2 choices: ## 1 - Render the title with "plain/1.0" syntax, and use $escapetool.xml() to make sure we don't inject HTML tags ## 2 - Render the title with HTML syntax ($document.displayTitle), and don't use $escapetool.xml() (because it ## would be useless to render HTML tags only to remove them with escape tools afterwards). ## ## I've played with both, and I have chosen solution 2 for the following reasons: ## ## * in the title of a document, you cannot add HTML tags or nasty content (HTML macro is not rendered, so HTML ## tags are escaped), so we don't need to use escape tools. ## ## * In a page named "SOME - EXAMPLE", the white spaces are represented as ` ` when rendered with ## the HTML renderer meanwhile they are trimmed when rendered with the plain text renderer. ## ## * It's consistent with the way the title is displayed in the page itself (using html, see: `titlevars.vm`). <a href="$!escapetool.xml($document.getURL())">$document.displayTitle</a> #if ("$!request.currentWiki" != '' && $request.currentWiki != $compositeEvent.document.wikiReference.name) <span class="text-muted">($services.wiki.getById($compositeEvent.document.wikiReference.name).prettyName)</span> #end </div> <div class="notification-description"> #if ($compositeEvent.users.size() == 1) $services.localization.render("notifications.events.${compositeEvent.type}.description.by.1user", ["#displayNotificationEventUsers($compositeEvent.users, true, false)"]) #else <div> $services.localization.render("notifications.events.${compositeEvent.type}.description.by.users", [$compositeEvent.users.size()]) </div> <div> #displayNotificationEventUsers($compositeEvent.users, true, true) </div> #end <div><small class="text-muted">$escapetool.xml($services.date.displayTimeAgo($compositeEvent.dates.get(0)))</small></div> </div> #end ### ### Details ### #define($details) #displayNotificationEventDetails($compositeEvent) #end ### ### Display ### #displayNotificationEventSkeleton($mainIcon, $smallIcon, $content, $details) #end #** * Display a skeleton for a notification * @param $mainIcon the name of the main icon * @param $smallIcon the name of the small icon * @param $content the content of the notification * @param $details (optional) the "details" part at the botton *# #macro(displayNotificationEventSkeleton $mainIcon $smallIcon $content $details) #set ($details = $details.toString()) <div class="clearfix row"> <div class="col-xs-3 notification-icon"> <div class="img-thumbnail"> $services.icon.renderHTML($mainIcon) </div> #if ("$!smallIcon" != '') <div class="img-thumbnail img-circle small"> $services.icon.renderHTML($smallIcon) </div> #end </div> <div class="col-xs-9 notification-content"> $content #if ($stringtool.isNotBlank($details)) <button class="btn btn-xs toggle-notification-event-details" type="submit"> <span class="fa fa-ellipsis-h"></span> </button> #end </div> #if ($stringtool.isNotBlank($details)) $details #end </div> #end #** * Default displayer for the notification details * @param $compositeEvent the event *# #macro(displayNotificationEventDetails $compositeEvent) #set ($basicTypes = ['update', 'create']) #set ($compositeEventType = $compositeEvent.type) #define($rows) #foreach($event in $compositeEvent.events) ## Display the event only on some conditions. ## See: https://jira.xwiki.org/browse/XWIKI-14846 #if (!$basicTypes.contains($event.type) or $event.type == $compositeEventType) ## Diff URL #set ($diffUrl = $xwiki.getURL($event.document, 'view', "viewer=changes&rev2=${event.documentVersion}")) <tr> #set ($description = $services.localization.render("notifications.events.${event.type}.description")) #if ("$!description" == '') #set ($description = $event.type) #end #set ($eventDescriptor = $services.eventstream.getDescriptorForEventType($compositeEvent.type, $xcontext.isMainWiki())) <td>#displayNotificationEventUser($event.user)</td> <td class="description">$services.icon.renderHTML($eventDescriptor.eventTypeIcon) $escapetool.xml($description)</td> <td class="text-right text-muted">#if($diffUrl!='')<a href="$escapetool.xml($diffUrl)">#end$escapetool.xml($xwiki.formatDate($event.date))#if($diffUrl!='')</a>#end</td> </tr> #end #end #end #displayNotificationEventDetailsSkeletons($events.size(), $rows) #end #** * Display a skeleton for the notification details. * @param $number the number of events in the details list * @param $rows the details rows to display inside the table *# #macro(displayNotificationEventDetailsSkeletons $number $rows) <div class="col-xs-12 clearfix"> <table class="notification-event-details"> $rows </table> </div> #end #** * Display a line with a user (its name and a small avatar) * @param $user the reference of the user to display *# #macro(displayNotificationEventUser $user $onlyAvatar) #set ($userDoc = $xwiki.getDocument($user)) #getUserAvatarURL($userDoc.documentReference, $avatarURL, 40) #set ($userName = $xwiki.getUserName($user)) <span class="notification-event-user"><img src="$avatarURL.url" alt="$escapetool.xml($userDoc.pageReference.name)"/>#if(!$onlyAvatar) <a href="$userDoc.getURL()">$userName</a>#end</span>## #end #** * Display a line with the name of all users * @param $users the users to display * @param $link (since 9.5) either or not an HTML link to the user must be generated (default: true) *# #macro(displayNotificationEventUsers $users $link $onlyAvatars)## ## The indent is bad to not introduce space charaters in the results #if("$!link" == '')#set ($link = true)#end #foreach ($user in $users)## #if ($link) #set ($onlyAvatars = $users.size() > 1 || $onlyAvatars) #displayNotificationEventUser($user, $onlyAvatars)## #else $xwiki.getPlainUserName($user)## #end #end## #end## #** * Display a notification for a message sent through the Message Stream. * TODO: find a way to move it to the "message stream" module * @since 10.5RC1 * @since 9.11.6 *# #macro(displayMessageNotification $compositeEvent $translationKey $icon) #define($content) #set ($messageEvent = $event.events[0]) <p>$services.localization.render($translationKey, ["#displayNotificationEventUser($messageEvent.user, false)"])</p> <blockquote> $messageEvent.body </blockquote> <div><small class="text-muted">$escapetool.xml($services.date.displayTimeAgo($compositeEvent.dates.get(0)))</small></div> #end #displayNotificationEventSkeleton($icon, 'comment', $content, '') #end