Index: openacs-4/packages/search/search.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/search/search.info,v
diff -u -N -r1.48 -r1.49
--- openacs-4/packages/search/search.info 21 Nov 2024 12:49:29 -0000 1.48
+++ openacs-4/packages/search/search.info 21 Nov 2024 14:51:39 -0000 1.49
@@ -9,7 +9,7 @@
f
t
-
+
OpenACS
Site wide search
2024-09-02
@@ -18,7 +18,7 @@
GPL version 2
3
-
+
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 -N -r1.61 -r1.62
--- openacs-4/packages/search/tcl/search-procs.tcl 21 Nov 2024 13:27:49 -0000 1.61
+++ openacs-4/packages/search/tcl/search-procs.tcl 21 Nov 2024 14:51:39 -0000 1.62
@@ -18,11 +18,11 @@
|| [acs_sc_binding_exists_p FtsContentProvider $object_type]}]
}
-ad_proc -public search::object_index {
+ad_proc -public search::object_datasource {
-object_id:required
- {-event "UPDATE"}
} {
- Indexes an object by invoking the proper datasource and callbacks.
+ Obtains the datasource for an object by invoking the proper
+ datasource and callbacks.
@return datasource as dict
} {
@@ -57,12 +57,30 @@
-impl $object_type]
}
+ return [array get d]
+}
+
+ad_proc -public search::object_index {
+ -object_id:required
+ {-event "UPDATE"}
+} {
+ Indexes an object by invoking the proper datasource and callbacks.
+
+ @return datasource as dict
+} {
+ array set d [search::object_datasource -object_id $object_id]
+ if {[array size d] == 0} {
+ return
+ }
+
search::content_get txt \
$d(content) \
$d(mime) \
$d(storage_type) \
$object_id
+ set driver [search::driver_name]
+
if {[callback::impl_exists -callback search::index -impl $driver]} {
callback -impl $driver search::index \
-object_id $object_id \
@@ -85,6 +103,8 @@
-impl $driver
}
+ set object_type [acs_object_type $object_id]
+
#
# Call the action so other people who do indexey things have a
# hook.
@@ -123,6 +143,26 @@
}
+ad_proc -public search::object_url {
+ -object_id:required
+} {
+ Retrieves the object URL by invoking the proper callbacks.
+
+ @return URL
+} {
+ set object_type [acs_object_type $object_id]
+
+ if {[callback::impl_exists -impl $object_type -callback search::url]} {
+ return [callback -impl $object_type search::url -object_id $object_id]
+ } else {
+ return [acs_sc::invoke \
+ -contract FtsContentProvider \
+ -operation url \
+ -call_args [list $object_id] \
+ -impl $object_type]
+ }
+}
+
ad_proc -public search::queue {
-object_id
-event
Index: openacs-4/packages/search/tcl/test/search-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/search/tcl/test/search-procs.tcl,v
diff -u -N -r1.5 -r1.6
--- openacs-4/packages/search/tcl/test/search-procs.tcl 21 Nov 2024 13:27:49 -0000 1.5
+++ openacs-4/packages/search/tcl/test/search-procs.tcl 21 Nov 2024 14:51:39 -0000 1.6
@@ -224,6 +224,8 @@
-cats {api smoke} \
-procs {
search::searchable_type_p
+ search::object_datasource
+ search::object_url
search::object_index
search::object_unindex
} \
@@ -254,12 +256,27 @@
order by object_type asc
}]] {
lassign $sample object_id object_type
- set datasource [search::object_index -object_id $object_id]
+ set datasource [search::object_datasource -object_id $object_id]
+
aa_true \
"Object '$object_id' of type '$object_type' will return a non null datasource" \
[llength $datasource]
+ set datasource [search::object_index -object_id $object_id]
+
+ aa_true \
+ "Object '$object_id' of type '$object_type' will return a non null datasource after index" \
+ [llength $datasource]
+
+ set url [search::object_url -object_id $object_id]
+
+ aa_false \
+ "Object '$object_id' produces a valid URL -> $url" \
+ [catch {
+ ns_parseurl $url
+ }]
+
aa_false "Unindexing does not bomb." [catch {
search::object_unindex -object_id $object_id
}]
Index: openacs-4/packages/search/www/search.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/search.tcl,v
diff -u -N -r1.43 -r1.44
--- openacs-4/packages/search/www/search.tcl 11 Sep 2024 06:15:54 -0000 1.43
+++ openacs-4/packages/search/www/search.tcl 21 Nov 2024 14:51:39 -0000 1.44
@@ -134,13 +134,7 @@
if { $t eq [_ search.Feeling_Lucky] && $result(count) > 0} {
set object_id [lindex $result(ids) 0]
- set object_type [acs_object_type $object_id]
- if {[callback::impl_exists -impl $object_type -callback search::url]} {
- set url [callback -impl $object_type search::url -object_id $object_id]
- } else {
- set url [acs_sc::invoke -contract FtsContentProvider -operation url \
- -call_args [list $object_id] -impl $object_type]
- }
+ set url [search::object_url -object_id $object_id]
ad_returnredirect $url
ad_script_abort
}
@@ -177,18 +171,16 @@
foreach object_id $result(ids) {
if {[catch {
- set object_type [acs_object_type $object_id]
- if {[callback::impl_exists -impl $object_type -callback search::datasource]} {
- array set datasource [lindex [callback -impl $object_type search::datasource -object_id $object_id] 0]
- set url_one [lindex [callback -impl $object_type search::url -object_id $object_id] 0]
- } else {
- #ns_log warning "SEARCH search/www/search.tcl callback::datasource::$object_type not found"
- array set datasource [acs_sc::invoke -contract FtsContentProvider -operation datasource \
- -call_args [list $object_id] -impl $object_type]
- set url_one [acs_sc::invoke -contract FtsContentProvider -operation url \
- -call_args [list $object_id] -impl $object_type]
- }
- search::content_get txt $datasource(content) $datasource(mime) $datasource(storage_type) $object_id
+ array set datasource [search::object_datasource -object_id $object_id]
+
+ set url_one [search::object_url -object_id $object_id]
+
+ search::content_get txt \
+ $datasource(content) \
+ $datasource(mime) \
+ $datasource(storage_type) \
+ $object_id
+
if {[callback::impl_exists -impl $driver -callback search::summary]} {
set title_summary [lindex [callback -impl $driver search::summary -query $q -text $datasource(title)] 0]
set txt_summary [lindex [callback -impl $driver search::summary -query $q -text $txt] 0]
@@ -199,7 +191,7 @@
-call_args [list $q $txt] -impl $driver]
}
} errmsg]} {
- ns_log error "search.tcl object_id $object_id object_type $object_type error $errmsg"
+ ns_log error "search.tcl object_id $object_id object_type [acs_object_type $object_id] error $errmsg"
} else {
template::multirow append searchresult $title_summary $txt_summary $url_one
}