Class ::xolirc::Package (public)
::xo::PackageMgr ::xolirc::Package
Defined in
- Testcases:
-
No testcase defined.
Source code:
namespace eval ::xolirc {}
::nsf::object::alloc ::xo::PackageMgr ::xolirc::Package {set :__default_metaclass ::xotcl::Class
set :__default_superclass ::xotcl::Object
set :abstract_p f
set :auto_save false
array set :db_constraints {}
array set :db_slot {package_id ::xolirc::Package::slot::package_id}
set :default_package_parameter_page_info {}
set :default_package_parameters {}
set :id_column package_id
set :name_method {}
set :object_type ::xolirc::Package
set :object_type_key 00000000000001010000001000000000
set :package_key xolirc
set :pretty_name {IRC Logs displayer based on Xowiki}
set :pretty_plural {IRC Logs displayer based on Xowiki}
set :security_inherit_p t
set :site_wide_package_parameter_page_info {}
set :site_wide_package_parameters {}
set :site_wide_pages {}
set :sql_package_name ::xolirc::Package
set :supertype acs_object
set :table_name xolirc_package
set :with_table true}
::xolirc::Package proc create-page-from-log {{-overwrite 1} {-date ""}} {
set package_id [apm_package_ids_from_key -mounted -package_key xolirc]
::xolirc::Package initialize -package_id $package_id -init_url 0 -actual_query ""
if {$date ne ""} {
regsub -all -- "-" $date {} date
} else {
set date [parameter::get -package_id $package_id -parameter "date2process" -default [clock format [clock seconds] -format "%Y%m%d"]]
parameter::set_value -package_id $package_id -parameter "date2process" -value [clock format [clock seconds] -format "%Y%m%d"]
}
set text [$package_id get-html-from-log -date $date]
if { $text eq "" } {
ns_log Warning "xolirc: Nothing has been logged yet for the date [$package_id dash-date $date]"
return ""
}
set page [$package_id resolve_page_name "en:$date"]
if {$page eq ""} {
set page [::xowiki::Page new -title "Conversation log in #openacs on [$package_id dash-date $date]" -name "en:$date" -package_id $package_id -parent_id [$package_id folder_id] -destroy_on_cleanup -text [list $text]]
$page initialize_loaded_object
$page save_new
} elseif { $overwrite } {
$page set text [list $text]
$page save
}
set creation_date "[$package_id dash-date $date]"
db_dml update_date "update acs_objects set creation_date = :creation_date where object_id = [$page set revision_id]"
}
::xolirc::Package proc process-all-logs {{-overwrite 1}} {
set logs_path "/usr/local/eggdrop/html/"
foreach log [glob -nocomplain -directory $logs_path "openacs*_pg1.html"] {
regexp {.*openacs(\d{8})_pg1\.html} $log match date
ns_log notice "working on $date"
::xolirc::Package create-page-from-log -overwrite $overwrite -date $date
}
}
::xolirc::Package instproc query-actual-log {} {
}
::xolirc::Package instproc insert {} {
set __table_name [[self class] table_name]
set __id [[self class] id_column]
set :$__id ${:object_id}
:log "ID insert in $__table_name, id = $__id = [set :$__id]"
next
foreach {__slot_name __slot} [[self class] array get db_slot] {
if {[info exists :$__slot_name]} {
set $__slot_name [set :$__slot_name]
lappend __vars $__slot_name
lappend __atts [$__slot column_name]
}
}
::xo::dc dml insert_$__table_name "insert into $__table_name
([join $__atts ,]) values (:[join $__vars ,:])"
}
::xolirc::Package instproc initialize {} {
my set logs_path "/usr/local/eggdrop/html/"
}
::xolirc::Package instproc get-html-from-log {{-date ""}} {
my instvar logs_path
if {$date eq ""} {
set date [clock format [clock seconds] -format "%Y%m%d"]
}
set content ""
foreach log [lsort -dictionary [glob -nocomplain -directory $logs_path "openacs${date}*"]] {
set file [open $log]
set html [read $file] ; close $file
regexp "<body class=\"l2hLogPage\">(.*)<\/body>" $html body
set doc [dom parse -html $body]
set body [$doc documentElement]
set navtop [$body selectNodes "div/div/div\[@id='navtop'\]"]
$navtop delete
append content "[[$body selectNodes div/div\[@id='mainblock'\]] asHTML]"
$doc delete
}
return $content
}
::xolirc::Package instproc dash-date date {
return "[string range $date 0 3]-[string range $date 4 5]-[string range $date 6 7]"
}
::xolirc::Package instparametercmd package_id
::nsf::relation::set ::xolirc::Package superclass ::xowiki::Package
::nx::slotObj -container slot ::xolirc::Package
::nsf::object::alloc ::xo::db::Attribute ::xolirc::Package::slot::package_id {set :accessor public
set :column_name package_id
set :configurable true
set :convert false
set :create_acs_attribute false
set :create_table_attribute true
set :datatype integer
set :defaultmethods {}
set :disposition alias
set :domain ::xolirc::Package
set :incremental false
set :manager ::xolirc::Package::slot::package_id
set :max_n_values 1
set :methodname package_id
set :min_n_values 1
set :multiplicity 1..1
set :name package_id
set :per-object false
set :position 0
set :pretty_name ID
set :pretty_plural {}
set :references {}
set :required false
set :sqltype integer
set :trace none
: init}
XQL Not present:Generic, PostgreSQL, Oracle
[
hide source ]
| [
make this the default ]