Index: openacs-4/packages/xowiki/tcl/xowiki-portlet-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/Attic/xowiki-portlet-procs.tcl,v
diff -u -r1.13 -r1.14
--- openacs-4/packages/xowiki/tcl/xowiki-portlet-procs.tcl 8 Jan 2007 00:11:34 -0000 1.13
+++ openacs-4/packages/xowiki/tcl/xowiki-portlet-procs.tcl 9 Jan 2007 11:05:57 -0000 1.14
@@ -2,7 +2,7 @@
namespace eval ::xowiki::portlet {
Class create ::xowiki::Portlet \
-superclass ::xo::Context \
- -parameter {{name ""} {title ""} {__decoration "portlet"}}
+ -parameter {{name ""} {title ""} {__decoration "portlet"} {id}}
::xowiki::Portlet instproc locale_clause {package_id locale} {
set default_locale [$package_id default_locale]
@@ -40,11 +40,18 @@
#
Class ::xowiki::portlet::decoration=portlet -instproc render {} {
my instvar package_id name title
+ set class [namespace tail [my info class]]
+ set id [expr {[my exists id] ? "id='[my id]'" : ""}]
set link [expr {[string match "*:*" $name] ? [$package_id pretty_link $name] : ""}]
- return "
\
+ return "
"
}
+ Class ::xowiki::portlet::decoration=plain -instproc render {} {
+ set class [namespace tail [my info class]]
+ set id [expr {[my exists id] ? "id='[my id]'" : ""}]
+ return "
[next]
"
+ }
}
namespace eval ::xowiki::portlet {
@@ -80,7 +87,7 @@
foreach {att value} $pl {
::xo::cc set_parameter $att $value
}
- return "NO"
+ return ""
}
}
@@ -456,54 +463,78 @@
-superclass ::xowiki::Portlet \
-parameter {{__decoration plain}}
+ # TODO make display style -decoration
+
presence instproc render {} {
my initialize -parameter {
{-interval "10 minutes"}
{-max_users:integer 40}
+ {-show_anonymous "summary"}
{-page}
}
my get_parameters
- set sql "select user_id,time from xowiki_last_visited \
- where package_id = $package_id "
+ set summary 0
+ if {[::xo::cc user_id] == 0} {
+ switch -- $show_anonymous {
+ nothing {return ""}
+ all {set summary 0}
+ default {set summary 1}
+ }
+ }
+ if {$summary} {
+ set sql "select count(distinct user_id) from xowiki_last_visited "
+ set order_clause ""
+ } else {
+ set sql "select user_id,time from xowiki_last_visited "
+ set limit_clause "limit $max_users"
+ set order_clause "order by time desc $limit_clause"
+ }
+ append sql "\
+ where package_id = $package_id \
+ and time > now() - '$interval'::interval "
+ set when "
in last $interval"
+
if {[info exists page] && $page eq "this"} {
my instvar __including_page
append sql "and page_id = [$__including_page item_id] "
- set limit_clause "limit $max_users"
- set what "last on page [$__including_page title]"
+ set what " on page [$__including_page title]"
} else {
append sql "and time > now() - '$interval'::interval "
set limit_clause ""
- set what "currently in community [$package_id instance_name]"
-
+ set what " in community [$package_id instance_name]"
}
- append sql "order by time desc $limit_clause"
-
set count 0
set output ""
- db_foreach get_visitors $sql {
- if {[info exists seen($user_id)]} continue
- set seen($user_id) $time
- if {[incr count]>$max_users} {
- set count $max_users
- break
- }
- if {[::xo::cc user_id]>0} {
+ if {$summary} {
+ my log "--presence $sql"
+ set count [db_string presence_count_users $sql]
+ } else {
+ db_foreach get_visitors $sql {
+ if {[info exists seen($user_id)]} continue
+ set seen($user_id) $time
+ if {[incr count]>$max_users} {
+ set count $max_users
+ break
+ }
+
regexp {^([^.]+)[.]} $time _ time
set pretty_time [util::age_pretty -timestamp_ansi $time \
- -sysdate_ansi [clock_to_ansi [clock seconds]] \
- -mode_3_fmt "%d %b %Y, at %X"]
+ -sysdate_ansi [clock_to_ansi [clock seconds]] \
+ -mode_3_fmt "%d %b %Y, at %X"]
set name [::xo::get_user_name $user_id]
append output "
$name | $pretty_time |
\n"
}
+ if {$output ne ""} {set output "
\n"}
}
- if {$output ne ""} {set output "
\n"}
- set users [expr {$count == 0 ? "No users" : "$count users"}]
- return "
$users $what
$output"
+ set users [expr {$count == 0 ? "No users" :
+ $count == 1 ? "1 registered user" :
+ "$count registered users"}]
+ return "
$users$what$when
$output"
}
}
@@ -546,7 +577,7 @@
foreach o [$pages children] {
$o instvar page_order title page_id name title
- my log "o: $page_order"
+ #my log "o: $page_order"
set displayed_page_order $page_order
for {set i 0} {$i < $remove_levels} {incr i} {
regsub {^[^.]+[.]} $displayed_page_order "" displayed_page_order
@@ -591,7 +622,7 @@
}
set navigation(count) $node_cnt
- my log "--COUNT=$node_cnt"
+ #my log "--COUNT=$node_cnt"
return $js
}
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 -r1.69 -r1.70
--- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 7 Jan 2007 21:52:38 -0000 1.69
+++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 9 Jan 2007 11:05:58 -0000 1.70
@@ -641,7 +641,7 @@
-title {$page set title $value}
}
}
- if {[$page exists __decoration] && [$page set __decoration] ne "plain"} {
+ if {[$page exists __decoration] && [$page set __decoration] ne "none"} {
$page mixin add ::xowiki::portlet::decoration=[$page set __decoration]
}
if {[catch {set html [$page render]} errorMsg]} {
Index: openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl,v
diff -u -r1.29 -r1.30
--- openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 5 Jan 2007 12:11:02 -0000 1.29
+++ openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 9 Jan 2007 11:05:58 -0000 1.30
@@ -44,16 +44,7 @@
set top_portlets ""
set vp [$package_id get_parameter "top_portlet" ""]
if {$vp ne ""} {
- set vp_name [lindex $vp 0]
- if {[my isclass ::xowiki::portlet::$vp_name]} {
- set p [::xowiki::portlet::$vp_name new \
- -package_id $package_id \
- -name $vp_name \
- -actual_query [::xo::cc actual_query] \
- -destroy_on_cleanup ]
- $p set __caller_parameters [lrange $vp 1 end]
- set top_portlets [$p render]
- }
+ set top_portlets [my include_portlet $vp]
}
if {[$package_id get_parameter "with_user_tracking" 1]} {
Index: openacs-4/packages/xowiki/www/resources/xowiki.css
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/www/resources/xowiki.css,v
diff -u -r1.12 -r1.13
--- openacs-4/packages/xowiki/www/resources/xowiki.css 9 Jan 2007 08:56:40 -0000 1.12
+++ openacs-4/packages/xowiki/www/resources/xowiki.css 9 Jan 2007 11:05:58 -0000 1.13
@@ -101,10 +101,10 @@
a:visited.rss {color: #FFF}
a:link.rss {color: #FFF}
-#presence {float:right; right: 1em; clear: right; font-size: 75%; padding: 5px;
+div.presence {float:right; right: 1em; clear: right; font-size: 75%; padding: 5px;
border:dotted; border-width:1px;background: #f8f8f8
}
-#presence h1 {font-size: 11px; margin-bottom: 0px}
+div.presence h1 {font-size: 90%; margin-bottom: 0px}
.code {
font-family: "Courier", monospace;