xowiki::Page instproc www-diff (public)

 <instance of xowiki::Page[i]> www-diff

Defined in packages/xowiki/tcl/xowiki-www-procs.tcl

This web-callable method produces a "diff" of two pages based on the current page and the revision_id provided as query parameter by "compare_revision_id". We can choose here between the more fancy "::util::html_diff" and a plain text diff. The latter is used, when the query variable "plain_text_diff" is provided, or when the fancy diff raises an exception.

Partial Call Graph (max 5 caller/called nodes):
%3 ad_html_text_convert ad_html_text_convert (public) ad_try ad_try (public) util::html_diff util::html_diff (public) xo::get_user_name xo::get_user_name xowiki::text_diff_in_html xowiki::text_diff_in_html (private) xowiki::Page instproc www-diff xowiki::Page instproc www-diff xowiki::Page instproc www-diff->ad_html_text_convert xowiki::Page instproc www-diff->ad_try xowiki::Page instproc www-diff->util::html_diff xowiki::Page instproc www-diff->xo::get_user_name xowiki::Page instproc www-diff->xowiki::text_diff_in_html

Testcases:
No testcase defined.
Source code:

set compare_id [:query_parameter compare_revision_id:int32 0]
if {$compare_id == 0} {
  return ""
}
::xo::Page requireCSS urn:ad:css:xowiki-[::xowiki::CSS toolkit]

set my_page [::xowiki::Package instantiate_page_from_id -revision_id ${:revision_id}]

ad_try {
  set html1 [$my_page render]
} on error {errorMsg} {
  set html1 "Error rendering ${:revision_id}$errorMsg"
}
set user1 [::xo::get_user_name [$my_page set creation_user]]
set time1 [$my_page set creation_date]
set revision_id1 [$my_page set revision_id]
regexp {^([^.]+)[.]} $time1 _ time1

set other_page [::xowiki::Package instantiate_page_from_id -revision_id $compare_id]
$other_page volatile
#$other_page absolute_links 1

ad_try {
  set html2 [$other_page render]
} on error {errorMsg} {
  set html2 "Error rendering $compare_id: $errorMsg"
}
set user2 [::xo::get_user_name [$other_page set creation_user]]
set time2 [$other_page set creation_date]
set revision_id2 [$other_page set revision_id]
regexp {^([^.]+)[.]} $time2 _ time2

set title "Differences for ${:name}"
set context [list $title]

if {![:exists_query_parameter plain_text_diff]} {
  #
  # try util::html diff if it is available and works
  #
  ad_try {
    set content [::util::html_diff -old $html2 -new $html1 -show_old_p t]
  } on error {errMsg} {
    ns_log notice "::util::html_diff failed on comparing page ${:name}, revisions_id ${:revision_id} and $compare_id"
  }
}

if {![info exists content]} {
  #
  # If the fist attempt failed, or the plain text based diff was
  # desired, fall back to proven plain text based diff
  #
  set text1 [ad_html_text_convert -from text/html -to text/plain -- $html1]
  set text2 [ad_html_text_convert -from text/html -to text/plain -- $html2]
  set content [::xowiki::text_diff_in_html $text2 $text1]
}

::xo::Page set_property doc title $title
array set property_doc [::xo::Page get_property doc]
::xo::Page header_stuff

${:package_id} return_page -adp /packages/xowiki/www/diff -variables {
  content title context
  time1 time2 user1 user2 revision_id1 revision_id2 property_doc
}
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: