Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Improve handling of quote characters in search script. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
22781f7cbe531d50b666312263fc67c7 |
User & Date: | dan 2010-01-09 08:29:16.000 |
Context
2010-01-09
| ||
15:37 | Tweak the display of scoring on the search results page. (check-in: 3d2b460664 user: drh tags: trunk) | |
08:29 | Improve handling of quote characters in search script. (check-in: 22781f7cbe user: dan tags: trunk) | |
07:34 | Fix a couple of snippet related examples in fts3.html. (check-in: d8f53c98a9 user: dan tags: trunk) | |
Changes
Changes to search/search.tcl.
︙ | ︙ | |||
80 81 82 83 84 85 86 | lappend reslist "$key=$value" } join $reslist & } proc htmlize {str} { string map {< < > >} $str } | | | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | lappend reslist "$key=$value" } join $reslist & } proc htmlize {str} { string map {< < > >} $str } proc attrize {str} { string map {< < > > \x22 \x5c\x22} $str } #========================================================================= proc cgi_env_dump {} { set ret "<h1>Arguments</h1><table>" foreach {key value} [array get ::A] { |
︙ | ︙ | |||
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | # proc ttime {script} { set t [lindex [time [list uplevel $script]] 0] if {$t>1000000} { return [format "%.2f s" [expr {$t/1000000.0}]] } return [format "%.2f ms" [expr {$t/1000.0}]] } proc searchresults {} { if {![info exists ::A(q)]} return "" set ::TITLE "Results for: \"[htmlize $::A(q)]\"" # If the user has clicked the "Lucky" button and the query returns one or # more results, redirect the browser to the highest ranked result. If the # query returns zero results, fall through and display the "No results" # page as if the user had clicked "Search". # if {[info exists ::A(s)] && $::A(s) == "Lucky"} { set url [db one { | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | # proc ttime {script} { set t [lindex [time [list uplevel $script]] 0] if {$t>1000000} { return [format "%.2f s" [expr {$t/1000000.0}]] } return [format "%.2f ms" [expr {$t/1000.0}]] } proc rank {matchinfo args} { binary scan $matchinfo i* I set nPhrase [lindex $I 0] set nCol [lindex $I 1] set G [lrange $I 2 [expr {1+$nCol*$nPhrase}]] set L [lrange $I [expr {2+$nCol*$nPhrase}] end] foreach a $args { lappend log [expr {log10(100+$a)}] } set score 0.0 set i 0 foreach l $L g $G { if {$l > 0} { set div [lindex $log [expr $i%3]] set score [expr {$score + (double($l) / double($g)) / $div}] } incr i } return $score } proc erank {matchinfo args} { eval rank [list $matchinfo] $args } proc searchresults {} { if {![info exists ::A(q)]} return "" # Count the '"' characters in $::A(q). If there is an odd number of # occurences, add a " to the end of the query so that fts3 can parse # it without error. if {[regexp -all \x22 $::A(q)] % 2} { append ::A(q) \x22 } set ::TITLE "Results for: \"[htmlize $::A(q)]\"" #db func rank rank #db func erank erank # If the user has clicked the "Lucky" button and the query returns one or # more results, redirect the browser to the highest ranked result. If the # query returns zero results, fall through and display the "No results" # page as if the user had clicked "Search". # if {[info exists ::A(s)] && $::A(s) == "Lucky"} { set url [db one { |
︙ | ︙ |