No registered users in community rubick
in last 10 minutes
in last 10 minutes
Script to import greenspun's forums to OpenACS forums
This is a little script I wrote to import forums from Greenspun's old forum package to the OpenACS forums.
# to do: set forum_id # set up second dvfile # do not use Safari or another browser that times out set dvfile1 [open "/home/path/forum_dump.html" r] set dvcontent1 [read $dvfile1] close $dvfile1 ns_write "<html>Start" set lines [split $dvcontent1 "|"] set position 0 foreach line $lines { if {$position == 0} { set message_id $line } elseif {$position == 1} { set message $line } elseif {$position == 2} { set posting_date $line } elseif {$position == 3} { set subject $line } elseif {$position == 4} { set topic $line } elseif {$position == 5} { set creator_name $line } elseif {$position == 6} { set creator_email $line } elseif {$position == 7} { # use the message_id from before, create list of last items, then use # message_id for next item if {![regexp {(.*)<br>(.*)} $line match refers_to next_message_id]} { # we're done set message_id $line ns_write "last one, hopefully" } set new_message_id [db_nextval acs_object_id_seq] set message_map($message_id) $new_message_id lappend items [list $new_message_id $refers_to $subject $message $creator_name] set message_id $next_message_id set position 0 } ns_write "." incr position } # this is hardcoded to the Forum ID set forum_id 6823 # this is hardcoded to the user ID of the person you want the forum postings to be under. set user_id 2539 ns_write "<P>" foreach item $items { ns_write "<hr>Line: $item<BR>" set message_id [lindex $item 0] set refers_to [lindex $item 1] set subject [lindex $item 2] set message [lindex $item 3] set creator_name [lindex $item 4] if {[string equal $refers_to "no referal"] || [string equal $refers_to "no"] } { set refers_to "" forum::message::new \ -forum_id $forum_id \ -message_id $message_id \ -parent_id $refers_to \ -subject $subject \ -content "$message --$creator_name (posting from archive)" \ -html_p "f" \ -user_id $user_id } else { lappend need_parents $item } } foreach item $need_parents { ns_write "<hr>Parent Line: $item<BR>" set message_id [lindex $item 0] set refers_to [lindex $item 1] set subject [lindex $item 2] set message [lindex $item 3] set creator_name [lindex $item 4] if {[string equal $refers_to "no referal"] || [string equal $refers_to "no"] } { set refers_to "" } else { set refers_to $message_map($refers_to) } forum::message::new \ -forum_id $forum_id \ -message_id $message_id \ -parent_id $refers_to \ -subject $subject \ -content "$message --$creator_name (posting from archive)" \ -html_p "f" \ -user_id $user_id } # ns_write "$lines" ns_write "Done.</html>"