Index: openacs-4/packages/xowiki/tcl/notification-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/notification-procs.tcl,v diff -u -r1.21 -r1.22 --- openacs-4/packages/xowiki/tcl/notification-procs.tcl 15 Jun 2015 19:21:06 -0000 1.21 +++ openacs-4/packages/xowiki/tcl/notification-procs.tcl 7 Aug 2017 23:48:30 -0000 1.22 @@ -100,24 +100,51 @@ if {![info exists page]} { set page [::xowiki::Package instantiate_page_from_id -revision_id $revision_id] $page volatile + } else { + set revision_id [$page set revision_id] } + + #ns_log notice "--n notification proc called for page [$page name] (revision_id $revision_id) in state [$page publish_status]" if {[$page set publish_status] eq "production"} { - # don't do notification for pages under construction - #ns_log notice "--n xowiki::notification NO NOTIFCATION due to production state" + # + # Don't do notification for pages under construction. + # + ns_log notice "--n xowiki::notification NO notification due to production state" return } - + set pretty_link [$page pretty_link] $page absolute_links 1 - if {![info exists html]} {set html [$page render]} - if {![info exists text]} {set text [ad_html_text_convert -from text/html -to text/plain -- $html]} + if {![info exists html]} { + set html [$page notification_render] + } + + if {$html eq ""} { + # + # The notification renderer returned empty. Nothing to do. + # + #ns_log notice "--n notification renderer returned emtpy for page [$page name] (revision_id $revision_id). Nothing to do" + return + } - #ns_log notice "--n xowiki::notification::do_notifications called for item_id [$page set revision_id] publish_status=[$page set publish_status] XXX" - $page instvar package_id - set link [$page pretty_link -absolute 1] - append html "

For more details, see [ns_quotehtml [$page set title]]

" - append text "\nFor more details, see $link ...
\n" + # + # Turn relative URLs into absolute URLs in the HTML text such that + # links in notification still work. The function supports as well + # non-wiki links. Here we are able to provide an accurate + # pretty_link as base-url. + # + set html [ad_html_qualify_links -path [file dirname $pretty_link] $html] + + if {![info exists text]} { + set text [ad_html_text_convert -from text/html -to text/plain -- $html] + } + #ns_log notice "--n xowiki do_notifications called for revision_id $revision_id publish_status=[$page set publish_status]" + set details [$page notification_detail_link] + append html [dict get $details html] + append text [dict get $details text] + + $page instvar package_id set state [expr {[$page set last_modified] eq [$page set creation_date] ? "New" : "Updated"}] set instance_name [::$package_id instance_name] @@ -128,7 +155,7 @@ -type_id [notification::type::get_type_id -short_name xowiki_notif] \ -object_id [$page set package_id] \ -response_id [$page set revision_id] \ - -notif_subject "\[$instance_name\] [$page set title] ($state)" \ + -notif_subject [$page notification_subject -instance_name $instance_name -state $state] \ -notif_text $text \ -notif_html $html \ -notif_user $notif_user_id @@ -151,7 +178,7 @@ -type_id [notification::type::get_type_id -short_name xowiki_notif] \ -object_id $cat($level) \ -response_id [$page set revision_id] \ - -notif_subject "\[$instance_name\] $label($level): [$page set title] ($state)" \ + -notif_subject [$page notification_subject -instance_name $instance_name -category_label $label($level) -state $state] \ -notif_text $text \ -notif_html $html \ -notif_user $notif_user_id