Index: openacs-4/packages/search/tcl/search-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/tcl/search-procs.tcl,v diff -u -r1.24 -r1.25 --- openacs-4/packages/search/tcl/search-procs.tcl 23 Mar 2005 13:54:34 -0000 1.24 +++ openacs-4/packages/search/tcl/search-procs.tcl 29 Mar 2005 23:39:45 -0000 1.25 @@ -24,8 +24,8 @@ @author Jeff Davis (davis@xarg.net) } { - if {![empty_string_p $object_id] - && ![empty_string_p $event]} { + if {![empty_string_p $object_id] + && ![empty_string_p $event]} { package_exec_plsql \ -var_list [list \ [list object_id $object_id] \ @@ -39,7 +39,7 @@ ad_proc -public search::dequeue { -object_id -event_date - -event + -event } { Remove an object from the search queue @@ -49,7 +49,7 @@ @author Jeff Davis (davis@xarg.net) } { - if {![empty_string_p $object_id] + if {![empty_string_p $object_id] && ![empty_string_p $event_date] && ![empty_string_p $event]} { package_exec_plsql \ @@ -63,17 +63,34 @@ } +ad_proc -public -callback search::action { + -action + -object_id + -datasource + -object_type +} { + Do something with a search datasource Called by the indexer + after having created the datasource. + + @param action UPDATE INSERT DELETE + @param datasource name of the datasource array + + @return ignored + + @author Jeff Davis (davis@xarg.net) +} - + + ad_proc -private search::indexer {} { Search indexer loops over the existing entries in the search_observer_queue table and calls the appropriate driver functions to index, update, or delete the entry. @author Neophytos Demetriou - @author Jeff Davis + @author Jeff Davis (davis@xarg.net) } { set driver [ad_parameter -package_id [apm_package_id_from_key search] FtsEngineDriver] - set syndicate [ad_parameter -package_id [apm_package_id_from_key search] Syndicate -default 0] if {[empty_string_p $driver] || ! [acs_sc_binding_exists_p FtsEngineDriver $driver]} { @@ -97,10 +114,6 @@ array set datasource {mime {} storage_type {} keywords {}} if {[catch { array set datasource [acs_sc_call FtsContentProvider datasource [list $object_id] $object_type] - if {$syndicate} { - search::syndicate -datasource datasource - } - search::content_get txt $datasource(content) $datasource(mime) $datasource(storage_type) acs_sc_call FtsEngineDriver \ @@ -109,21 +122,36 @@ } errMsg]} { ns_log Error "search::indexer: error getting datasource for $object_id $object_type: $errMsg\n[ad_print_stack_trace]\n" } else { - search::dequeue -object_id $object_id -event_date $event_date -event $event + # call the action so other people who do indexey things have a hook + callback -catch search::action \ + -action $event \ + -object_id $object_id \ + -datasource datasource \ + -object_type $object_type + + # Remember seeing this object so we can avoid reindexing it later set seen($object_id) 1 + + search::dequeue -object_id $object_id -event_date $event_date -event $event } } - # Remember seeing this object so we can avoid reindexing it later } } DELETE { if {[catch { acs_sc_call FtsEngineDriver unindex [list $object_id] $driver - db_dml nuke_syn {delete from syndication where object_id = :object_id} } errMsg]} { - ns_log Error "search::indexer: error getting datasource for $object_id $object_type: $errMsg\n[ad_print_stack_trace]\n" + ns_log Error "search::indexer: error unindexing $object_id $object_type: $errMsg\n[ad_print_stack_trace]\n" } else { + # call the search action callbacks. + callback -catch search::action \ + -action $event \ + -object_id $object_id \ + -datasource NONE \ + -object_type $object_type + search::dequeue -object_id $object_id -event_date $event_date -event $event + } # unset seen since you could conceivably delete one but then subsequently @@ -147,7 +175,8 @@ } { @author Neophytos Demetriou - @param content + @param content + holds the filename if storage_type=file holds the text data if storage_type=text holds the lob_id if storage_type=lob @@ -218,52 +247,3 @@ } } - -ad_proc -private search::syndicate { - -datasource -} { - create or replace the record in the syndication table for - a given item id. - - called by the search::indexer. See photo-album-search-procs for an example of - what you need to provide to make something syndicable. - - JCD: to fix: should not just glue together XML this way, also assumes rss 2.0, no provision for - alternate formats, assumes content:encoded will be defined in the wrapper. - -} { - upvar $datasource d - - if {![info exists d(syndication)]} { - return - } - - array set syn { - category {} - author {} - guid {} - } - - array set syn $d(syndication) - - set object_id $d(object_id) - set url $syn(link) - set body $d(content) - - set published [lc_time_fmt $syn(pubDate) "%a, %d %b %Y %H:%M:%S GMT"] - - set rss_xml_frag " - $d(title) - $url - $syn(guid) - $syn(description) - $syn(author) - - $syn(category) - $published - " - - db_dml nuke {delete from syndication where object_id = :object_id} - db_dml ins {insert into syndication(object_id, rss_xml_frag, body, url) values (:object_id, :rss_xml_frag, :body, :url)} - -} Index: openacs-4/packages/search/tcl/syndicate-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/tcl/syndicate-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/tcl/syndicate-procs.tcl 29 Mar 2005 23:39:45 -0000 1.1 @@ -0,0 +1,59 @@ +ad_library { + Syndication callback and support routines. + + @author Jeff Davis (davis@xarg.net) + @cvs-id $Id: syndicate-procs.tcl,v 1.1 2005/03/29 23:39:45 jeffd Exp $ +} + +ad_proc -public -callback search::action -impl syndicate {} { + create or replace the record in the syndication table for + the given object_id + + See photo-album-search-procs for an example of what + you need to do in the FtsContentProvider datasource + proc to make something syndicable. + + JCD: to fix: should not just glue together XML this way, also assumes rss 2.0, no provision for + alternate formats, assumes content:encoded will be defined in the wrapper. +} { + if {![parameter::get -boolean -package_id [apm_package_id_from_key search] -parameter Syndicate -default 0]} { + return + } + if {[string equal $action DELETE]} { + db_dml nuke {delete from syndication where object_id = :object_id} + } else { + upvar $datasource d + + if {![info exists d(syndication)]} { + return + } + + array set syn { + category {} + author {} + guid {} + } + + array set syn $d(syndication) + + set object_id $d(object_id) + set url $syn(link) + set body $d(content) + + set published [lc_time_fmt $syn(pubDate) "%a, %d %b %Y %H:%M:%S GMT"] + + set rss_xml_frag " + $d(title) + $url + $syn(guid) + $syn(description) + $syn(author) + + $syn(category) + $published + " + + db_dml nuke {delete from syndication where object_id = :object_id} + db_dml insert {insert into syndication(object_id, rss_xml_frag, body, url) values (:object_id, :rss_xml_frag, :body, :url)} + } +}