Index: openacs.org-dev/packages/irc-logger/ChangeLog
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/irc-logger/ChangeLog,v
diff -u -r1.4 -r1.5
--- openacs.org-dev/packages/irc-logger/ChangeLog	13 Feb 2003 04:07:35 -0000	1.4
+++ openacs.org-dev/packages/irc-logger/ChangeLog	10 Mar 2003 21:46:14 -0000	1.5
@@ -1,3 +1,11 @@
+2003-03-10  Bart Teeuwisse  
+
+	* www/doc/index.adp (Module): 
+	- Add IRC logs in reverse order so that the newest log is at the top of the page.
+	- Add 'current' link to latest IRC log at the top of the page.
+	- Add 'current' link to irc-logger for links from other sites to the latest log.
+	- Update documentation.
+
 2003-02-12  Bart Teeuwisse  
 
 	* www/admin/update.tcl (Module): 
Index: openacs.org-dev/packages/irc-logger/irc-logger.info
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/irc-logger/irc-logger.info,v
diff -u -r1.2 -r1.3
--- openacs.org-dev/packages/irc-logger/irc-logger.info	11 Feb 2003 23:27:11 -0000	1.2
+++ openacs.org-dev/packages/irc-logger/irc-logger.info	10 Mar 2003 21:46:14 -0000	1.3
@@ -7,15 +7,15 @@
     f
     f
 
-    
+    
     
         oracle
         postgresql
     
         Bart Teeuwisse
         The IRC logger places the log files of logger (a Perl script by Dave Beckett) into ETP for integration with OpenACS.
-        2003-02-10
-        the Code Mill
+        2003-02-21
+        the Code Mill
         The IRC logger places the log files of <a href="http://cvs.ilrt.org/cvsweb/redland/logger/">logger</a> (a Perl script by Dave Beckett) into ETP for integration with OpenACS. Besides logger, this package also depends on <a href="http://www.tdom.org/">tDOM</a> (high performance XML data processing with easy and powerful Tcl scripting functionality).
 
         
@@ -34,6 +34,7 @@
             
             
             
+            
             
             
             
Index: openacs.org-dev/packages/irc-logger/tcl/irc-logger-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/irc-logger/tcl/irc-logger-procs-postgresql.xql,v
diff -u -r1.2 -r1.3
--- openacs.org-dev/packages/irc-logger/tcl/irc-logger-procs-postgresql.xql	4 Feb 2003 19:13:50 -0000	1.2
+++ openacs.org-dev/packages/irc-logger/tcl/irc-logger-procs-postgresql.xql	10 Mar 2003 21:45:46 -0000	1.3
@@ -6,12 +6,48 @@
     7.1
   
 
+  
+    
+      select etp__get_folder_id(:package_id)
+    
+  
+
+  
+    
+      select i1.item_id, i1.tree_sortkey, coalesce((
+      	select tree_sortkey 
+      	from cr_items i2 
+      	where i2.tree_sortkey > i1.tree_sortkey 
+      	and i2.parent_id = :parent_id 
+        and i2.name <> 'index'
+        and $i2_select_criteria
+      	order by i2.tree_sortkey limit 1), (
+      	select i2.tree_sortkey 
+      	from cr_items i2
+      	where i2.parent_id = :parent_id
+        and i2.name <> 'index'
+        and $i2_select_criteria
+      	order by i2.tree_sortkey limit 1)) as next_sortkey
+      from cr_items i1
+      where i1.parent_id = :parent_id 
+      and i1.name <> 'index'
+      and $i1_select_criteria
+      order by i1.tree_sortkey;
+    
+  
+
   
     
       select etp__create_page(:parent_package_id, :date, :date, :content_type)
     
   
 
+  
+    
+      select etp__create_extlink(:parent_package_id, :log_url, :link_label, :link_description);
+    
+  
+
   
     
       select u.user_id, p.first_names || ' ' || p.last_name as name 
Index: openacs.org-dev/packages/irc-logger/tcl/irc-logger-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/irc-logger/tcl/irc-logger-procs.tcl,v
diff -u -r1.3 -r1.4
--- openacs.org-dev/packages/irc-logger/tcl/irc-logger-procs.tcl	11 Feb 2003 23:23:23 -0000	1.3
+++ openacs.org-dev/packages/irc-logger/tcl/irc-logger-procs.tcl	10 Mar 2003 21:45:46 -0000	1.4
@@ -101,6 +101,60 @@
     return ""
 }
 
+ad_proc -public irc::logger::rotate_logs {
+    -package_id:required
+    {-all:boolean}
+} {
+
+    Rotate the ETP pages so that the ETP page with the new log is
+    listed first instead of last. Please be aware that changes to 
+    the sort order through of these logs through ETP might have 
+    undesired side effects to the order. This an artifact of ETP
+    and not of the IRC logger.
+
+    @creation-date 2003-02-18
+    @author Bart Teeuwisse (bart.teeuwisse@thecodemill.biz)
+
+    @param package_id The package_id of the ETP instance that is 
+    the parent of the ETP log pages.
+
+    @param -all Switch indicating wether all ETP instances should 
+    be rotated or only the ETP log pages. This flag is used when
+    the 'current' link has been created and needs to be rotated to 
+    the top of the page.
+
+    @return none
+
+    @error none
+} {
+
+    # Get the ID of the parent folder of the ETP log pages.
+
+    set parent_id [db_string get_parent_id {} -default {}]
+
+    # Rotate all ETP pages or just the logs?
+
+    if {$all_p} {
+	set i1_select_criteria "true"
+	set i2_select_criteria "true"
+    } else {
+	set i1_select_criteria [db_map i1_criteria]
+	set i2_select_criteria [db_map i2_criteria]
+    }
+
+    # Rotate the logs by assigning the tree_sortkey of the next ETP
+    # page to the current page. Assign the tree_sortkey of the first
+    # page to the last (=new) page.
+
+    db_foreach etp_logs {} {
+
+        # Assign the tree_sortkey of the next ETP page to the current
+        # page or the tree_sortkey of the first ETP to the last page.
+
+        db_dml shift {}
+    }
+}
+
 ad_proc -public irc::logger::update_log {
     -date:required
     -package_id:required
@@ -175,11 +229,45 @@
                             # Create a new ETP page for the log.
 
                             db_exec_plsql page_create {}
-                        }
+			    set log_live_revision_id [etp::get_live_revision_id $parent_package_id $date]
 
+			    # Rotate the logs so that the new log is
+			    # on top.
+
+			    irc::logger::rotate_logs -package_id $parent_package_id
+
+			    # Symlink 'current' to the latest log.
+
+			    set log_url "[site_node::get_url -node_id $parent_package_id]$date"
+			    if {![db_0or1row get_extlink {}]} {
+
+				# Create a 'current' symlink to the
+				# new log. As ETP symlinks don't
+				# support labels the link is created
+				# as an ETP extlink which do support
+				# labels and descriptions.
+
+				set link_label "current"
+				set link_description "Current $irc_channel_name conversation log"
+				db_exec_plsql create_extlink {}
+
+				# Rotate the symlink to the top of the list.
+
+				irc::logger::rotate_logs -package_id $parent_package_id -all
+
+			    } else {
+
+				# Point the 'current' symlink to the new log.
+
+				db_dml update_extlink {}
+
+			    }
+                        } else {
+			    set log_live_revision_id [etp::get_live_revision_id $parent_package_id $date]
+			}
+
                         # The update the existing ETP page for the log.
                         
-                        set log_live_revision_id [etp::get_live_revision_id $parent_package_id $date]
                         set log_description "Conversation log of $irc_channel_name of $date"
                         db_dml update_revision {}
 
Index: openacs.org-dev/packages/irc-logger/tcl/irc-logger-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/irc-logger/tcl/irc-logger-procs.xql,v
diff -u -r1.1 -r1.2
--- openacs.org-dev/packages/irc-logger/tcl/irc-logger-procs.xql	30 Jan 2003 00:14:44 -0000	1.1
+++ openacs.org-dev/packages/irc-logger/tcl/irc-logger-procs.xql	10 Mar 2003 21:45:46 -0000	1.2
@@ -1,6 +1,47 @@
 
 
 
+  
+    
+      (i1.content_type <> 'content_extlink' or
+	i1.content_type is null)
+    
+  
+
+  
+    
+      (i2.content_type <> 'content_extlink' or
+	i2.content_type is null)
+    
+  
+
+  
+    
+      update cr_items 
+      set tree_sortkey = :next_sortkey
+      where item_id = :item_id
+    
+  
+  
+  
+    
+      select extlink_id 
+      from cr_extlinks e, cr_items i, cr_folders f
+      where i.item_id = e.extlink_id
+      and i.parent_id = f.folder_id
+      and f.package_id = :parent_package_id
+      and e.label = 'current'
+    
+  
+
+  
+    
+      update cr_extlinks
+      set url = :log_url
+      where extlink_id = :extlink_id
+    
+  
+
   
     
       update cr_revisions 
Index: openacs.org-dev/packages/irc-logger/www/current.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/irc-logger/www/current.tcl,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs.org-dev/packages/irc-logger/www/current.tcl	10 Mar 2003 21:46:58 -0000	1.1
@@ -0,0 +1,22 @@
+ad_page_contract {
+
+    # Redirect to today's log. Unfortunately ETP didn't provide the
+    # means to create current link in the ETP folder. Had to resort to
+    # this somewhat round about link.
+
+    @author Bart Teeuwisse (bart.teeuwisse@thecodemill.biz)
+    @creation-date 2003-03-01
+    @cvs $Id: current.tcl,v 1.1 2003/03/10 21:46:58 bartt Exp $
+
+} {
+} 
+
+# The current log has the name of today's date in the GMT timezone.
+
+set gmt_today [clock format [clock seconds] -format %Y-%m-%d -gmt true]
+
+# Redirect to today's log without checking iXSf indeed it exists. It
+# could be that the logger died or that the ETP does not exists yet as
+# nothing has happened today on the channel.
+
+ns_returnredirect ../$gmt_today
Index: openacs.org-dev/packages/irc-logger/www/doc/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/irc-logger/www/doc/index.adp,v
diff -u -r1.2 -r1.3
--- openacs.org-dev/packages/irc-logger/www/doc/index.adp	4 Feb 2003 19:14:50 -0000	1.2
+++ openacs.org-dev/packages/irc-logger/www/doc/index.adp	10 Mar 2003 21:45:15 -0000	1.3
@@ -143,8 +143,19 @@
     Edit-This-Page that @package_name@ is mounted under.
 
   @package_name@ can be mounted more than once. Each instance
-    processing the logs of a different bot.
+    processing the logs of a different bot. New logs are added to the
+    top of the page, preceded by a link called 'current' which is a
+    symlink to the latest IRC log.
 
+  There is an additional 'current' link in @package_name@ for ease
+    of linking to the latest IRC log from other packages or from
+    external sites. This additional link is necessary because the
+    'current' link on the page listing the IRC logs can not be
+    referred to as /irc/log/current. Edit-This-Page does not redirect
+    the request for /irc/log/current to the latest log but produces a
+    '404 Page not found' error instead. Hence the additional 'current'
+    link at /irc/log/logger/current.
+
   @package_name@ will link to the user's profile and include the
     full name for users of the site who have entered their IRC nick as
     their OpenACS screen name.
Index: openacs.org-dev/packages/irc-logger/www/doc/license.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs.org-dev/packages/irc-logger/www/doc/license.tcl,v
diff -u -r1.3 -r1.4
--- openacs.org-dev/packages/irc-logger/www/doc/license.tcl	11 Feb 2003 23:21:13 -0000	1.3
+++ openacs.org-dev/packages/irc-logger/www/doc/license.tcl	10 Mar 2003 21:47:48 -0000	1.4
@@ -1,29 +1,29 @@
-ad_page_contract {
-
-    License information of the Authorize.net Gateway, an
-    implementation of the Payment Service Contract.
-
-    @author Bart Teeuwisse 
-    @creation-date May 2002
-    @cvs $Id$
-
-} {
-} -properties {
-    title:onevalue
-    context_bar:onevalue
-}
-
-# Authenticate the user
-
-set user_id [ad_maybe_redirect_for_registration]
-
-set package_name "IRC Logger"
-set title "$package_name License"
-
-# Set the context bar.
-
-set context_bar [ad_context_bar [list . $package_name] License]
-
-# Set signatory for at the bottom of the page
-
-set signatory "bart.teeuwisse@thecodemill.biz"
+ad_page_contract {
+
+    License information of the Authorize.net Gateway, an
+    implementation of the Payment Service Contract.
+
+    @author Bart Teeuwisse 
+    @creation-date May 2002
+    @cvs $Id$
+
+} {
+} -properties {
+    title:onevalue
+    context_bar:onevalue
+}
+
+# Authenticate the user
+
+set user_id [ad_maybe_redirect_for_registration]
+
+set package_name "IRC Logger"
+set title "$package_name License"
+
+# Set the context bar.
+
+set context_bar [ad_context_bar [list . $package_name] License]
+
+# Set signatory for at the bottom of the page
+
+set signatory "bart.teeuwisse@thecodemill.biz"