Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix the "search" box so that it accepts upper and lower case search terms (with case folding) and OR and NEAR search and phrase searches. Exclude some of the aggregate documents from indexing. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
26dedb8a9ab4751a399493e06395d896 |
User & Date: | drh 2012-05-30 14:25:11.216 |
Context
2012-05-31
| ||
08:00 | Adjust the search script to change an empty title into "No Title". (check-in: d53c90f145 user: drh tags: trunk) | |
2012-05-30
| ||
14:25 | Fix the "search" box so that it accepts upper and lower case search terms (with case folding) and OR and NEAR search and phrase searches. Exclude some of the aggregate documents from indexing. (check-in: 26dedb8a9a user: drh tags: trunk) | |
00:46 | Clarification of what counts as using a database connection for restrictions on SQLITE_THREADSAFE=2. (check-in: 84df66d24b user: drh tags: trunk) | |
Changes
Changes to main.mk.
︙ | ︙ | |||
41 42 43 44 45 46 47 | fast: base doc tclsh: $(TCLSQLITE3C) $(CC) -g -o tclsh -DSQLITE_ENABLE_FTS3 -DTCLSH=1 -DSQLITE_TCLMD5 $(TCLINC) $(TCLSQLITE3C) $(TCLFLAGS) tclsqlite3.fts3: $(TCLSQLITE3C) $(DOC)/search/searchc.c | | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | fast: base doc tclsh: $(TCLSQLITE3C) $(CC) -g -o tclsh -DSQLITE_ENABLE_FTS3 -DTCLSH=1 -DSQLITE_TCLMD5 $(TCLINC) $(TCLSQLITE3C) $(TCLFLAGS) tclsqlite3.fts3: $(TCLSQLITE3C) $(DOC)/search/searchc.c $(CC) -static -O2 -o tclsqlite3.fts3 -I. -DSQLITE_ENABLE_FTS3 $(TCLINC) $(DOC)/search/searchc.c $(TCLSQLITE3C) $(TCLFLAGS) sqlite3.h: tclsh $(SRC)/src/sqlite.h.in $(SRC)/manifest.uuid $(SRC)/VERSION ./tclsh $(SRC)/tool/mksqlite3h.tcl $(SRC) | \ sed 's/^SQLITE_API //' >sqlite3.h # Generate the directory into which generated documentation files will # be written. |
︙ | ︙ |
Changes to search/buildsearchdb.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | load ./parsehtml.so # Return a list of relative paths to documents that should be included # in the index. # proc document_list {} { set files [list] foreach f [glob *.html c3ref/*.html releaselog/*.html] { if {![string match *crossref* $f] && ![string match fileio.html $f] && ![string match btreemodule.html $f] } { lappend files $f } } return $files } proc readfile {zFile} { | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | load ./parsehtml.so # Return a list of relative paths to documents that should be included # in the index. # proc document_list {} { set files [list] foreach f [glob *.html c3ref/*.html releaselog/*.html] { if {![string match *crossref* $f] && ![string match fileio.html $f] && ![string match capi3ref.html $f] && ![string match changes.html $f] && ![string match btreemodule.html $f] } { lappend files $f } } return $files } proc readfile {zFile} { |
︙ | ︙ | |||
198 199 200 201 202 203 204 | set report } cd doc sqlite3 db search.db set ::tokenizer [db one {SELECT fts3_tokenizer('porter')}] rebuild_database | < | 200 201 202 203 204 205 206 | set report } cd doc sqlite3 db search.db set ::tokenizer [db one {SELECT fts3_tokenizer('porter')}] rebuild_database |
Changes to search/search.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #!/usr/bin/tclsqlite3.fts3 #========================================================================= # This proc is called to parse the arguments passed to this invocation of # the CGI program (via either the GET or POST method). It returns a # key/value list containing the arguments suitable for passing to [array # set]. For example, if the CGI is invoked via a GET request on the URI: # # http://www.sqlite.org/search?query=fts3+table&results=10 # # then the returned list value is: # # {query {fts3 table} results 10} # proc cgi_parse_args {} { | > > > > > > > > > > > > > > > > | > > > | < < < < < < < < < | | | > | | < > | < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #!/usr/bin/tclsqlite3.fts3 # Decode an HTTP %-encoded string # proc percent_decode {str} { # rewrite "+" back to space # protect \ and [ and ] by quoting with '\' set str [string map [list + { } "\\" "\\\\" \[ \\\[ \] \\\]] $str] # prepare to process all %-escapes regsub -all -- {%([A-Fa-f][A-Fa-f0-9])%([A-Fa-f89][A-Fa-f0-9])} \ $str {[encoding convertfrom utf-8 [binary decode hex \1\2]]} str regsub -all -- {%([0-7][A-Fa-f0-9])} $str {\\u00\1} str # process %-escapes return [subst -novar $str] } #========================================================================= # This proc is called to parse the arguments passed to this invocation of # the CGI program (via either the GET or POST method). It returns a # key/value list containing the arguments suitable for passing to [array # set]. For example, if the CGI is invoked via a GET request on the URI: # # http://www.sqlite.org/search?query=fts3+table&results=10 # # then the returned list value is: # # {query {fts3 table} results 10} # proc cgi_parse_args {} { global env A if {$env(REQUEST_METHOD) == "GET"} { foreach q [split $env(QUERY_STRING) &] { if {[regexp {([a-z0-9]*)=(.*)} $q all var value]} { set A($var) [percent_decode $value] } } } elseif {$env(REQUEST_METHOD) == "POST"} { set qstring [read stdin $env(CONTENT_LENGTH)] foreach q [split $qstring &] { if {[regexp {([a-z0-9]*)=(.*)} $q all var value]} { set A($var) [percent_decode $value] } } } else { error "Unrecognized method: $env(REQUEST_METHOD)" } } #========================================================================= # Redirect the web-browser to URL $url. This command does not return. # proc cgi_redirect {url} { |
︙ | ︙ | |||
178 179 180 181 182 183 184 | proc erank {matchinfo args} { eval rank [list $matchinfo] $args } proc searchresults {} { if {![info exists ::A(q)]} return "" | > | | 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | proc erank {matchinfo args} { eval rank [list $matchinfo] $args } proc searchresults {} { if {![info exists ::A(q)]} return "" #set ::A(q) [string map {' ''} $A(q)] #regsub -all {[^-/"A-Za-z0-9]} $::A(q) { } ::A(q) # 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)]\"" |
︙ | ︙ | |||
292 293 294 295 296 297 298 299 | append ret </center> } return $ret } proc main {} { sqlite3 db search.db | > < | | | 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | append ret </center> } return $ret } proc main {} { global A sqlite3 db search.db cgi_parse_args db transaction { set t [ttime { set doc "[searchform] [searchresults] [footer]" }] } append doc "<p>Page generated in $t." return $doc # return [cgi_env_dump] } #========================================================================= set ::HEADER { <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
︙ | ︙ |