Index: openacs-4/packages/xowiki/tcl/syndicate-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/syndicate-procs.tcl,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/xowiki/tcl/syndicate-procs.tcl 4 Mar 2007 21:32:40 -0000 1.5 +++ openacs-4/packages/xowiki/tcl/syndicate-procs.tcl 23 Mar 2007 11:36:06 -0000 1.6 @@ -2,9 +2,24 @@ # # RSS 2.0 support # + Class XMLSyndication -parameter {package_id} - Class RSS -parameter { - package_id + XMLSyndication instproc init {} { + my set xmlMap [list & "&" < "<" > ">" \" """ ' "'"] + } + + XMLSyndication instproc tag {{-atts } name value} { + my instvar xmlMap + set attsXML "" + if {[info exists atts]} { + foreach {attName attValue} $atts { + append attsXML " $attName='$attValue'" + } + } + return <$name$attsXML>[string map $xmlMap $value] + } + + Class RSS -superclass XMLSyndication -parameter { maxentries {name_filter ""} {days ""} @@ -26,21 +41,6 @@ } - RSS instproc init {} { - my set xmlMap [list & "&" < "<" > ">" \" """ ' "'"] - } - - RSS instproc tag {{-atts } name value} { - my instvar xmlMap - set attsXML "" - if {[info exists atts]} { - foreach {attName attValue} $atts { - append attsXML " $attName='$attValue'" - } - } - return <$name$attsXML>[string map $xmlMap $value] - } - RSS instproc css_link {} { my instvar css if {$css ne ""} { @@ -241,5 +241,68 @@ return $content } + Class Timeline -superclass XMLSyndication + Timeline instproc reverse list { + set result [list] + for {set i [expr {[llength $list] - 1}]} {$i >= 0} {incr i -1} { + lappend result [lindex $list $i] + } + return $result + } + + Timeline instproc render {} { + my instvar package_id + set folder_id [::$package_id folder_id] + + set last_user "" + set last_item "" + set last_clock "" + ::xo::OrderedComposite items -destroy_on_cleanup + db_foreach get_pages { + select ci.name, o.creation_user, cr.publish_date, cr.item_id, ci.parent_id, cr.title + from cr_items ci, cr_revisions cr, acs_objects o + where cr.item_id = ci.item_id and o.object_id = cr.revision_id + and ci.parent_id = :folder_id and creation_user is not null order by revision_id desc + } { + regexp {^([^.]+)[.][0-9]+(.*)$} $publish_date _ publish_date tz + set clock [clock scan $publish_date] + + if {$last_user == $creation_user && $last_item == $item_id && $last_clock ne ""} { + my log "--clockdiff = [expr {$last_clock - $clock }] $name" + if {($last_clock - $clock) < 7500 } { + my log "--clock ignore change due to cockdiff" + continue + } + } + set o [Object new] + foreach att {item_id creation_user item_id clock name publish_date parent_id title} { + $o set $att [set $att] + } + items add $o + foreach {last_user last_item last_clock} [list $creation_user $item_id $clock] break + } + + foreach i [my reverse [items children]] { + set key seen([$i set item_id]) + if {[info exists $key]} { + $i set operation modified + } else { + $i set operation created + set $key 1 + } + } + set result \n + foreach i [items children] { + set stamp [clock format [$i set clock] -format "%b %d %Y %X %Z" -gmt true] + set user [::xo::get_user_name [$i set creation_user]] + append result [my tag -atts [list \ + start $stamp \ + title [$i set title] \ + link [$package_id pretty_link [$i set name]]] \ + event "$user [$i set operation] [$i set title]"] \n + } + append result \n + return $result + } } \ No newline at end of file Index: openacs-4/packages/xowiki/tcl/xowiki-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-procs.tcl,v diff -u -N -r1.87 -r1.88 --- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 23 Mar 2007 08:18:10 -0000 1.87 +++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 23 Mar 2007 11:36:06 -0000 1.88 @@ -600,7 +600,8 @@ } if {$description eq "" && $revision_id > 0} { set description [db_string get_description_from_syndication \ - "select body from syndication where object_id = $revision_id"] + "select body from syndication where object_id = $revision_id" \ + -default ""] } return $description }