Index: openacs-4/packages/xowiki/tcl/xowiki-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-procs.tcl,v diff -u -r1.472.2.5 -r1.472.2.6 --- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 13 Nov 2013 10:53:58 -0000 1.472.2.5 +++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 16 Nov 2013 13:57:43 -0000 1.472.2.6 @@ -2029,7 +2029,7 @@ set word($tag) 1 } #my log [list html $html keywords [array names work]] - return [list html $html keywords [array names work]] + return [list mime text/html html $html keywords [array names work] text ""] } Page instproc record_last_visited {-user_id} { @@ -2303,14 +2303,32 @@ if {[my exists item_id]} { my instvar text mime_type package_id item_id revision_id set storage_area_key [::xo::db_string get_storage_key \ - "select storage_area_key from cr_items where item_id=$item_id"] + "select storage_area_key from cr_items where item_id=:item_id"] my set full_file_name [cr_fs_path $storage_area_key]/$text #my log "--F setting FILE=[my set full_file_name]" } } return [my set full_file_name] } + File instproc search_render {} { + # array set "" {mime text/html text "" html "" keywords ""} + set mime [my set mime_type] + if {$mime eq "text/plain"} { + set result [next] + } else { + if {[info commands "::search::convert::binary_to_text"] ne ""} { + set txt [search::convert::binary_to_text -filename [my full_file_name] -mime_type $mime] + set result [list text $txt mime text/plain] + } else { + set result [list text "" mime text/plain] + } + } + + #ns_log notice "search_render returns $result" + return $result + } + File instproc html_content {{-add_sections_to_folder_tree 0} -owner} { set parent_id [my parent_id] set fileName [my full_file_name] Index: openacs-4/packages/xowiki/tcl/xowiki-sc-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-sc-procs.tcl,v diff -u -r1.37 -r1.37.2.1 --- openacs-4/packages/xowiki/tcl/xowiki-sc-procs.tcl 13 Sep 2012 16:05:29 -0000 1.37 +++ openacs-4/packages/xowiki/tcl/xowiki-sc-procs.tcl 16 Nov 2013 13:57:44 -0000 1.37.2.1 @@ -13,46 +13,63 @@ returns a datasource for the search package } { - #ns_log notice "--sc datasource called with revision_id = $revision_id" - + #ns_log notice "--sc ::xowiki::datasource called with revision_id = $revision_id" + set page [::xowiki::Package instantiate_page_from_id -revision_id $revision_id -user_id 0] + + #ns_log notice "--sc ::xowiki::datasource $page [$page set publish_status]" - #ns_log notice "--sc package=[[$page package_id] serialize]" - ns_log notice "--sc $page [$page set publish_status]" - if {[$page set publish_status] eq "production"} { # no data source for for pages under construction #ns_log notice "--sc page under construction, no datasource" - return [list object_id $revision_id title "" \ - content "" keywords "" \ - storage_type text mime text/html] + return [list object_id $revision_id title "" \ + content "" keywords "" \ + storage_type text mime text/html] } #ns_log notice "--sc setting absolute links for page = $page [$page set name]" - array set "" [$page search_render] + set d [dict merge \ + {mime text/html text "" html "" keywords ""} \ + [$page search_render]] - if {![info exists (title)]} { - set (title) [$page title] + if {![dict exists $d title]} { + dict set d title [$page title] } - set text [ad_html_text_convert -from text/html -to text/plain -- $(html)] - #set text [ad_text_to_html $(html)]; #this could be used for entity encoded html text in rss entries - - set found [string first {[1]} $text] - #$page log "--sc search=$found,html=$(html),text=$text" - if {$found > -1} { - append description {} - } else { - set description [string map [list "&" "&" < "<" > ">"] $text] + switch [dict get $d mime] { + text/html { + set content [dict get $d html] + set text [ad_html_text_convert -from text/html -to text/plain -- [dict get $d html]] + #set text [ad_text_to_html [dict get $d html]]; #this could be used for entity encoded html text in rss entries + + # If the html contains links (which are rendered by ad_html_text as [1], [2], ...) + # then we have to use CDATA in the description + # + if {[string first {[1]} $text] > -1} { + append description {} + } else { + set description [ns_quotehtml $text] + } + } + text/plain { + set content [dict get $d text] + set description $content + } + default { + ns_log error "can't handle results of search_render of type '[dict get $d mime]'" + set content "" + set description "" + } } - #::xowiki::notification::do_notifications -page $page -html $(html) -text $text - #ns_log notice "--sc INDEXING $revision_id -> $text keywords $(keywords)" - #$page set unresolved_references 0 - $page instvar item_id + #ns_log notice "--sc INDEXING $revision_id -> $text keywords [dict get $d keywords]" + + # # cleanup old stuff. This might run into an error, when search is not # configured, and therefore txt does not exist. TODO: we should look for a better # solution, where syndication does not depend on search.... + # + $page instvar item_id catch { db_dml delete_old_revisions { delete from txt where object_id in \ @@ -64,15 +81,17 @@ set pubDate [::xo::db::tcl_date [$page set publish_date] tz] set link [$page detail_link] - set result [list object_id $revision_id title $(title) \ - content $(html) keywords $(keywords) \ - storage_type text mime text/html \ - syndication [list link [string map [list & "&"] $link] \ - description $description \ - author [$page set creator] \ - category "" \ - guid "$item_id" \ - pubDate $pubDate] \ + set result [list object_id $revision_id title [dict get $d title] \ + content $content \ + keywords [dict get $d keywords] \ + storage_type text mime [dict get $d mime] \ + syndication [list \ + link [string map [list & "&"] $link] \ + description $description \ + author [$page set creator] \ + category "" \ + guid "$item_id" \ + pubDate $pubDate] \ ] if {[catch {::xo::at_cleanup} errorMsg]} { ns_log notice "cleanup in ::xowiki::datasource returned $errorMsg"