Index: openacs-4/packages/notes/tcl/notes-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/notes/tcl/notes-procs.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/notes/tcl/notes-procs.tcl 3 Sep 2001 17:53:24 -0000 1.1 +++ openacs-4/packages/notes/tcl/notes-procs.tcl 15 Sep 2001 21:31:50 -0000 1.2 @@ -9,7 +9,7 @@ n.body as content, 'text/plain' as mime, '' as keywords, - 'text' as storage + 'text' as storage_type from notes n where note_id = :object_id } -column_array datasource @@ -35,3 +35,10 @@ return $url } + + + + + + + Index: openacs-4/packages/openfts-driver/tcl/openfts-driver-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/openfts-driver/tcl/openfts-driver-procs.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/openfts-driver/tcl/openfts-driver-procs.tcl 1 Sep 2001 20:33:52 -0000 1.1 +++ openacs-4/packages/openfts-driver/tcl/openfts-driver-procs.tcl 15 Sep 2001 21:31:50 -0000 1.2 @@ -2,6 +2,9 @@ query offset limit + user_id + df + dt } { @author Neophytos Demetriou } { @@ -10,7 +13,6 @@ set result(ids) "" set result(stopwords) "" - array set self [Search::OpenFTS::new ofts] if ![array size self] { error "Search failed." @@ -42,22 +44,45 @@ } set txttbl [split $opt(txttid) .] + + set date_range_condition "" + if { $df != "" } { + append date_range_condition "'$df' <= last_modified and" + } + if { $dt != "" } { + append date_range_condition "'$dt' >= last_modified and" + } + + set permission_check_enabled_p [ad_parameter -package_id [apm_package_id_from_key openfts-driver] permission_check_enabled_p] + set permission_check_condition "" + if { $permission_check_enabled_p } { + append permission_check_condition "and acs_permission__permission_p( $opt(txttid), $user_id, 'read') = 't'" + } + set sql_count " select count(*) from [lindex $txttbl 0]$tables - where $condition" + where + $date_range_condition + $condition + $permission_check_condition" set sql_sort " - select $opt(txttid) as id$out + select $opt(txttid) as object_id$out from [lindex $txttbl 0]$tables - where $condition + where + $date_range_condition + $condition + $permission_check_condition $order limit $limit offset $offset" set result(stopwords) $opt(rejected) set result(count) [db_exec_plsql sql_count $sql_count] - db_foreach sql_sort $sql_sort {lappend result(ids) $id} + if { $result(count) > 0} { + db_foreach sql_sort $sql_sort {lappend result(ids) $object_id} + } return [array get result] } @@ -113,7 +138,7 @@ } { openfts_driver__unindex $tid - openfts_driver__index $tid $txt $title + openfts_driver__index $tid $txt $title $keywords return } Index: openacs-4/packages/openfts-driver/www/doc/INSTALL =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/openfts-driver/www/doc/INSTALL,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/openfts-driver/www/doc/INSTALL 4 Sep 2001 15:39:51 -0000 1.2 +++ openacs-4/packages/openfts-driver/www/doc/INSTALL 15 Sep 2001 21:31:50 -0000 1.3 @@ -1,13 +1,13 @@ -Last updated: September 1st, 2001 +Last updated: September 12, 2001 Maintainer: Neophytos Demetriou (k2pts@cytanet.com.cy) - Make sure you have installed all headers (for example, spi.h) using "gmake install-all-headers" during the PostgreSQL installation. If you have not installed intarray, please do so now. intarray is under the contrib directory of the PostgreSQL source code. -- Download Search-OpenFTS-tcl-0.1.tar.gz from http://openfts.sourceforge.net/ - and save it to /tmp/Search-OpenFTS-tcl-0.1.tar.gz +- Download Search-OpenFTS-tcl-0.2.tar.gz from http://openfts.sourceforge.net/ + and save it to /tmp/Search-OpenFTS-tcl-0.2.tar.gz - Log in as the root user: @@ -16,13 +16,13 @@ - Untar the archive file: cd /usr/local/src - tar -xzvf /tmp/Search-OpenFTS-tcl-0.1.tar.gz + tar -xzvf /tmp/Search-OpenFTS-tcl-0.2.tar.gz - Install the OpenFTS AOLServer module: - chown -R nsadmin.web Search-OpenFTS-tcl-0.1/ - cd Search-OpenFTS-tcl-0.1/ + chown -R nsadmin.web Search-OpenFTS-tcl-0.2/ + cd Search-OpenFTS-tcl-0.2/ ./configure --with-aolserver-src=AOLSERVER_SRC_DIR make cd aolserver Index: openacs-4/packages/search/search.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/search.info,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/search/search.info 2 Sep 2001 18:11:39 -0000 1.1 +++ openacs-4/packages/search/search.info 15 Sep 2001 21:31:50 -0000 1.2 @@ -1,5 +1,5 @@ - + Search @@ -18,18 +18,33 @@ - - + + + + + + + + + + + + + + + + - - - + + + + Index: openacs-4/packages/search/sql/postgresql/search-sc-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/postgresql/search-sc-create.sql,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/search/sql/postgresql/search-sc-create.sql 2 Sep 2001 18:11:39 -0000 1.1 +++ openacs-4/packages/search/sql/postgresql/search-sc-create.sql 15 Sep 2001 21:31:50 -0000 1.2 @@ -10,7 +10,7 @@ select acs_sc_msg_type__new ( 'FtsEngineDriver.Search.InputType', - 'query:string,offset:integer,limit:integer' + 'query:string,offset:integer,limit:integer,user_id:integer,df:timestamp,dt:timestamp' ); select acs_sc_msg_type__new ( 'FtsEngineDriver.Search.OutputType', @@ -144,7 +144,7 @@ ); select acs_sc_msg_type__new ( 'FtsContentProvider.Datasource.OutputType', - 'object_id:integer,title:string,content:string,mime:string,storage:string' + 'object_id:integer,title:string,content:string,mime:string,storage_type:string' ); select acs_sc_operation__new ( 'FtsContentProvider', -- contract_name @@ -180,3 +180,5 @@ + + Index: openacs-4/packages/search/sql/postgresql/search-tables-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/sql/postgresql/search-tables-create.sql,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/search/sql/postgresql/search-tables-create.sql 13 Sep 2001 04:59:26 -0000 1.3 +++ openacs-4/packages/search/sql/postgresql/search-tables-create.sql 15 Sep 2001 21:31:50 -0000 1.4 @@ -1,11 +1,7 @@ create table search_observer_queue ( - object_id integer - constraint search_observer_queue_object_id_fk - references acs_objects(object_id) on delete cascade, + object_id integer, date timestamp default now(), event varchar(6) constraint search_observer_queue_event_ck - check (event in ('INSERT','DELETE','UPDATE')) - - -- constraint search_observer_queue_oid_date_un unique(object_id,date) + check (event in ('INSERT','DELETE','UPDATE')) ); 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.1 -r1.2 --- openacs-4/packages/search/tcl/search-procs.tcl 2 Sep 2001 18:11:39 -0000 1.1 +++ openacs-4/packages/search/tcl/search-procs.tcl 15 Sep 2001 21:31:50 -0000 1.2 @@ -14,7 +14,7 @@ INSERT { set object_type [db_exec_plsql get_object_type "select acs_object_util__get_object_type($object_id)"] array set datasource [acs_sc_call FtsContentProvider datasource [list $object_id] $object_type] - set txt [search_content_filter $datasource(content) $datasource(mime) $datasource(storage)] + search_content_get txt $datasource(content) $datasource(mime) $datasource(storage_type) acs_sc_call FtsEngineDriver index [list $datasource(object_id) $txt $datasource(title) $datasource(keywords)] $driver } DELETE { @@ -23,10 +23,8 @@ UPDATE { set object_type [db_exec_plsql get_object_type "select acs_object_util__get_object_type($object_id)"] array set datasource [acs_sc_call FtsContentProvider datasource [list $object_id] $object_type] - set txt [search_content_filter $datasource(content) $datasource(mime) $datasource(storage)] - if { $txt != "" } { - acs_sc_call FtsEngineDriver update_index [list $datasource(object_id) $txt $datasource(title) $datasource(keywords)] $driver - } + search_content_get txt $datasource(content) $datasource(mime) $datasource(storage_type) + acs_sc_call FtsEngineDriver update_index [list $datasource(object_id) $txt $datasource(title) $datasource(keywords)] $driver } } @@ -41,61 +39,63 @@ } - -ad_proc search_content_filter { +ad_proc search_content_get { + _txt content mime - storage + storage_type } { @author Neophytos Demetriou + + @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 } { - switch $mime { - {text/plain} { - return $content + upvar $_txt txt + + switch $storage_type { + text { + set data $content } - {text/html} { - return $content + file { + set data [db_blob_get data "select $content, 'file' as storage_type"] } + lob { + set data [db_blob_get data "select $content, 'lob' as storage_type"] + } } - return + + search_content_filter txt data $mime + } -ad_proc search_content_get { - content + +ad_proc search_content_filter { + _txt + _data mime - storage } { @author Neophytos Demetriou - - @param content - holds the filename if storage=file - holds the text data if storage=text - holds the lob_id if storage=lob } { - switch $storage { - text { - return $content + upvar $_txt txt + upvar $_data data + + switch $mime { + {text/plain} { + set txt $data } - file { - if {[file exists $content]} { - set ofp [open $content r] - set txt [read $ofp] - close $ofp - } else { - error "file: $content doesn't exist" - } - return [DoubleApos $txt] + {text/html} { + set txt $data } - lob { - return $txt - } } - return } + + ad_proc search_choice_bar { items links values {default ""} } { @author Neophytos Demetriou } { Index: openacs-4/packages/search/www/advanced-search.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/advanced-search.adp,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/www/advanced-search.adp 15 Sep 2001 21:31:50 -0000 1.1 @@ -0,0 +1,26 @@ + + +

@title@

+@context_bar@ +
+ + +
+ + + +
+Date Range + +
Index: openacs-4/packages/search/www/advanced-search.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/advanced-search.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/search/www/advanced-search.tcl 15 Sep 2001 21:31:50 -0000 1.1 @@ -0,0 +1,18 @@ +ad_page_contract { + @author Neophytos Demetriou +} { + {q ""} + {num 0} +} + +set package_id [ad_conn package_id] + +if { $num == 0 } { + set num [ad_parameter -package_id $package_id LimitDefault] +} + +set title "Advanced Search" +set context_bar [ad_context_bar $title] + + +ad_return_template \ No newline at end of file Index: openacs-4/packages/search/www/search-results-top.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/search/www/Attic/search-results-top.adp,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/search/www/search-results-top.adp 2 Sep 2001 18:11:39 -0000 1.1 +++ openacs-4/packages/search/www/search-results-top.adp 15 Sep 2001 21:31:50 -0000 1.2 @@ -2,53 +2,46 @@ @title@ - +

@title@

@context_bar@ +
- - - - + + + Advanced Search +
+ + + +
+ + + Tip: In most browsers you can just hit the return key instead of clicking on the search button.

- - - - - - -
-
- - - - -
-
- - - The "AND" operator is unnecessary -- we include all search terms by default. - [details] - - -
- - - "@stopwords@" is a very common word and was not included in your search. - [details] - - -
- - - The following words are very common and were not included in your search: @stopwords@. - [details] - - -
+ + + The "AND" operator is unnecessary -- we include all search terms by default. + [details]
+
+
+ + + "@stopwords@" is a very common word and was not included in your search. + [details]
+
+
+ + + The following words are very common and were not included in your search: @stopwords@. + [details]
+
+
+ + -

Your search - @query@ - did not match any documents. + Your search - @query@ - did not match any documents.
No pages were found containing "@query@".

Suggestions:
    @@ -61,7 +54,6 @@
-
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.2 -r1.3 --- openacs-4/packages/search/www/search.tcl 3 Sep 2001 07:14:40 -0000 1.2 +++ openacs-4/packages/search/www/search.tcl 15 Sep 2001 21:31:50 -0000 1.3 @@ -4,7 +4,11 @@ @cvs-id $Id$ } { q:notnull,trim - {offset 0} + {t:trim ""} + {offset:integer 0} + {num:integer 0} + {dfs:trim ""} + {dts:trim ""} } -errors { q:notnull {You must specify some keywords.} } @@ -15,7 +19,7 @@ set template_one_file "$this_dir/search-results-one" set template_bottom_file "$this_dir/search-results-bottom" - +set user_id [ad_conn user_id] set package_id [ad_conn package_id] set driver [ad_parameter -package_id $package_id FtsEngineDriver] array set info [acs_sc_call FtsEngineDriver info [list] $driver] @@ -25,33 +29,60 @@ ns_write "FtsEngineDriver not available!" return } +if { $num <= 0} { + set limit [ad_parameter -package_id $package_id LimitDefault] +} else { + set limit $num +} -set limit [ad_parameter -package_id $package_id LimitDefault] +set df "" +set dt "" +if { $dfs == "all" } { set dfs "" } +array set symbol2interval [ad_parameter -package_id $package_id Symbol2Interval] +if { $dfs != "" } { set df [db_exec_plsql get_df "select now() + '$symbol2interval($dfs)'::interval"] } +if { $dts != "" } { set dt [db_exec_plsql get_dt "select now() + '$symbol2interval($dts)'::interval"] } + + + + + + set title "Search Results" set context_bar [ad_context_bar {Search Results}] set q [string tolower $q] +set urlencoded_query [ad_urlencode $q] if { $offset < 0 } { set offset 0 } set t0 [clock clicks -milliseconds] -array set result [acs_sc_call FtsEngineDriver search [list $q $offset $limit] $driver] +array set result [acs_sc_call FtsEngineDriver search [list $q $offset $limit $user_id $df $dt] $driver] set tend [clock clicks -milliseconds] -set elapsed [format "%.02f" [expr double(abs($tend - $t0)) / 1000.0]] -if { $offset >= $result(count) } { set offset [expr ($result(count) / $limit) * $limit] } +if { $t == "Feeling Lucky" } { + set object_id [lindex $result(ids) 0] + set object_type [db_exec_plsql get_object_type "select acs_object_util__get_object_type($object_id)"] + set url [acs_sc_call FtsContentProvider url [list $object_id] $object_type] + ad_returnredirect $url + return +} +set elapsed [format "%.02f" [expr double(abs($tend - $t0)) / 1000.0]] +if { $offset >= $result(count) } { set offset [expr ($result(count) / $limit) * $limit] } set low [expr $offset + 1] set high [expr $offset + $limit] if { $high > $result(count) } { set high $result(count) } - - if { $info(automatic_and_queries_p) && ([lsearch -exact $q and] > 0) } { set and_queries_notice_p 1 } else { set and_queries_notice_p 0 } +set url_advanced_search "" +append url_advanced_search "advanced-search?q=${urlencoded_query}" +if { $num > 0 } { append url_advanced_search "&num=${num}" } + set template_top [template::adp_parse $template_top_file [list \ + t $t \ title $title \ context_bar $context_bar \ query $q \ @@ -62,17 +93,17 @@ low $low \ high $high \ count $result(count) \ - elapsed $elapsed]] + elapsed $elapsed \ + url_advanced_search $url_advanced_search]] ns_write $template_top - for { set __i [expr 0] } { $__i < [expr $high - $low +1] } { incr __i } { + for { set __i 0 } { $__i < [expr $high - $low +1] } { incr __i } { set object_id [lindex $result(ids) $__i] set object_type [db_exec_plsql get_object_type "select acs_object_util__get_object_type($object_id)"] array set datasource [acs_sc_call FtsContentProvider datasource [list $object_id] $object_type] - - set txt [search_content_filter $datasource(content) $datasource(mime) $datasource(storage)] + search_content_get txt $datasource(content) $datasource(mime) $datasource(storage_type) set title_summary [acs_sc_call FtsEngineDriver summary [list $q $datasource(title)] $driver] set txt_summary [acs_sc_call FtsEngineDriver summary [list $q $txt] $driver] set url [acs_sc_call FtsContentProvider url [list $object_id] $object_type] @@ -87,21 +118,37 @@ } - set urlencoded_query [ad_urlencode $q] set from_result_page 1 set current_result_page [expr ($low / $limit) + 1] - set to_result_page [expr ($result(count) / $limit) + 1] + set to_result_page [expr ceil(double($result(count)) / double($limit))] + set url_previous "" + set url_next "" + append url_previous "search?q=${urlencoded_query}" + append url_next "search?q=${urlencoded_query}" + if { [expr $current_result_page - 1] > $from_result_page } { + append url_previous "&offset=[expr ($current_result_page - 2) * $limit]" + } + if { $current_result_page < $to_result_page } { + append url_next "&offset=[expr $current_result_page * $limit]" + } + if { $num > 0 } { + append url_previous "&num=$num" + append url_next "&num=$num" + } + + set items [list] set links [list] set values [list] for { set __i $from_result_page } { $__i <= $to_result_page} { incr __i } { + set link "" + append link "search?q=${urlencoded_query}" + if { $__i > 1 } { append link "&offset=[expr ($__i - 1) * $limit]" } + if { $num > 0 } { append link "&num=$num" } + lappend items $__i - if { $__i == 1 } { - lappend links "search?q=${urlencoded_query}" - } else { - lappend links "search?q=${urlencoded_query}&offset=[expr ($__i - 1) * $limit]" - } + lappend links $link lappend values $__i } @@ -120,9 +167,9 @@ from_result_page $from_result_page \ current_result_page $current_result_page \ to_result_page $to_result_page \ - offset_previous [expr $offset - $limit] \ + url_previous $url_previous \ choice_bar [search_choice_bar $items $links $values $current_result_page] \ - offset_next [expr $offset + $limit] \ + url_next $url_next \ stw $stw\ ]]